Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netinet/tcp_stacks/fastpath.c
Show First 20 Lines • Show All 491 Lines • ▼ Show 20 Lines | if ((thflags & TH_ACK) && | ||||
SEQ_GT(th->th_ack, tp->snd_max))) { | SEQ_GT(th->th_ack, tp->snd_max))) { | ||||
rstreason = BANDLIM_RST_OPENPORT; | rstreason = BANDLIM_RST_OPENPORT; | ||||
goto dropwithreset; | goto dropwithreset; | ||||
} | } | ||||
break; | break; | ||||
/* | /* | ||||
* If the state is SYN_SENT: | * If the state is SYN_SENT: | ||||
* if seg contains an ACK, but not for our SYN, drop the input. | |||||
* if seg contains a RST, then drop the connection. | * if seg contains a RST, then drop the connection. | ||||
* if seg does not contain SYN, then drop it. | * if seg does not contain SYN, then drop it. | ||||
* Otherwise this is an acceptable SYN segment | * Otherwise this is an acceptable SYN segment | ||||
* initialize tp->rcv_nxt and tp->irs | * initialize tp->rcv_nxt and tp->irs | ||||
* if seg contains ack then advance tp->snd_una | * if seg contains ack then advance tp->snd_una | ||||
* if seg contains an ECE and ECN support is enabled, the stream | * if seg contains an ECE and ECN support is enabled, the stream | ||||
* is ECN capable. | * is ECN capable. | ||||
* if SYN has been acked change to ESTABLISHED else SYN_RCVD state | * if SYN has been acked change to ESTABLISHED else SYN_RCVD state | ||||
* arrange for segment to be acked (eventually) | * arrange for segment to be acked (eventually) | ||||
* continue processing rest of data/controls, beginning with URG | * continue processing rest of data/controls, beginning with URG | ||||
*/ | */ | ||||
case TCPS_SYN_SENT: | case TCPS_SYN_SENT: | ||||
if ((thflags & TH_ACK) && | |||||
(SEQ_LEQ(th->th_ack, tp->iss) || | |||||
SEQ_GT(th->th_ack, tp->snd_max))) { | |||||
rstreason = BANDLIM_UNLIMITED; | |||||
goto dropwithreset; | |||||
} | |||||
if ((thflags & (TH_ACK|TH_RST)) == (TH_ACK|TH_RST)) { | if ((thflags & (TH_ACK|TH_RST)) == (TH_ACK|TH_RST)) { | ||||
TCP_PROBE5(connect__refused, NULL, tp, m, tp, th); | TCP_PROBE5(connect__refused, NULL, tp, m, tp, th); | ||||
tp = tcp_drop(tp, ECONNREFUSED); | tp = tcp_drop(tp, ECONNREFUSED); | ||||
} | } | ||||
if (thflags & TH_RST) | if (thflags & TH_RST) | ||||
goto drop; | goto drop; | ||||
if (!(thflags & TH_SYN)) | if (!(thflags & TH_SYN)) | ||||
goto drop; | goto drop; | ||||
▲ Show 20 Lines • Show All 1,243 Lines • ▼ Show 20 Lines | if ((thflags & TH_SYN) && (thflags & TH_FIN) && V_drop_synfin) { | ||||
} | } | ||||
if (ti_locked == TI_RLOCKED) { | if (ti_locked == TI_RLOCKED) { | ||||
INP_INFO_RUNLOCK(&V_tcbinfo); | INP_INFO_RUNLOCK(&V_tcbinfo); | ||||
} | } | ||||
INP_WUNLOCK(tp->t_inpcb); | INP_WUNLOCK(tp->t_inpcb); | ||||
m_freem(m); | m_freem(m); | ||||
return; | return; | ||||
} | } | ||||
/* | |||||
* If a segment with the ACK-bit set arrives in the SYN-SENT state | |||||
* check SEQ.ACK first. | |||||
*/ | |||||
if ((tp->t_state == TCPS_SYN_SENT) && (thflags & TH_ACK) && | |||||
(SEQ_LEQ(th->th_ack, tp->iss) || SEQ_GT(th->th_ack, tp->snd_max))) { | |||||
tcp_dropwithreset(m, th, tp, tlen, BANDLIM_UNLIMITED); | |||||
if (ti_locked == TI_RLOCKED) { | |||||
INP_INFO_RUNLOCK(&V_tcbinfo); | |||||
} | |||||
INP_WUNLOCK(tp->t_inpcb); | |||||
return; | |||||
} | |||||
tp->sackhint.last_sack_ack = 0; | tp->sackhint.last_sack_ack = 0; | ||||
/* | /* | ||||
* Segment received on connection. | * Segment received on connection. | ||||
* Reset idle time and keep-alive timer. | * Reset idle time and keep-alive timer. | ||||
* XXX: This should be done after segment | * XXX: This should be done after segment | ||||
* validation to ignore broken/spoofed segs. | * validation to ignore broken/spoofed segs. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 442 Lines • ▼ Show 20 Lines | if ((s = tcp_log_addrs(inc, th, NULL, NULL))) { | ||||
"sysctl setting)\n", s, __func__); | "sysctl setting)\n", s, __func__); | ||||
free(s, M_TCPLOG); | free(s, M_TCPLOG); | ||||
} | } | ||||
if (ti_locked == TI_RLOCKED) { | if (ti_locked == TI_RLOCKED) { | ||||
INP_INFO_RUNLOCK(&V_tcbinfo); | INP_INFO_RUNLOCK(&V_tcbinfo); | ||||
} | } | ||||
INP_WUNLOCK(tp->t_inpcb); | INP_WUNLOCK(tp->t_inpcb); | ||||
m_freem(m); | m_freem(m); | ||||
return; | |||||
} | |||||
/* | |||||
* If a segment with the ACK-bit set arrives in the SYN-SENT state | |||||
* check SEQ.ACK first. | |||||
*/ | |||||
if ((tp->t_state == TCPS_SYN_SENT) && (thflags & TH_ACK) && | |||||
(SEQ_LEQ(th->th_ack, tp->iss) || SEQ_GT(th->th_ack, tp->snd_max))) { | |||||
tcp_dropwithreset(m, th, tp, tlen, BANDLIM_UNLIMITED); | |||||
if (ti_locked == TI_RLOCKED) { | |||||
INP_INFO_RUNLOCK(&V_tcbinfo); | |||||
} | |||||
INP_WUNLOCK(tp->t_inpcb); | |||||
return; | return; | ||||
} | } | ||||
tp->sackhint.last_sack_ack = 0; | tp->sackhint.last_sack_ack = 0; | ||||
/* | /* | ||||
* Segment received on connection. | * Segment received on connection. | ||||
* Reset idle time and keep-alive timer. | * Reset idle time and keep-alive timer. | ||||
* XXX: This should be done after segment | * XXX: This should be done after segment | ||||
* validation to ignore broken/spoofed segs. | * validation to ignore broken/spoofed segs. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 191 Lines • Show Last 20 Lines |