Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_input.c
Show First 20 Lines • Show All 204 Lines • ▼ Show 20 Lines | SYSCTL_INT(_net_inet_tcp, OID_AUTO, abc_l_var, CTLFLAG_VNET | CTLFLAG_RW, | ||||
&VNET_NAME(tcp_abc_l_var), 2, | &VNET_NAME(tcp_abc_l_var), 2, | ||||
"Cap the max cwnd increment during slow-start to this number of segments"); | "Cap the max cwnd increment during slow-start to this number of segments"); | ||||
static SYSCTL_NODE(_net_inet_tcp, OID_AUTO, ecn, | static SYSCTL_NODE(_net_inet_tcp, OID_AUTO, ecn, | ||||
CTLFLAG_RW | CTLFLAG_MPSAFE, 0, | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, | ||||
"TCP ECN"); | "TCP ECN"); | ||||
VNET_DEFINE(int, tcp_do_ecn) = 2; | VNET_DEFINE(int, tcp_do_ecn) = 2; | ||||
SYSCTL_INT(_net_inet_tcp_ecn, OID_AUTO, enable, CTLFLAG_VNET | CTLFLAG_RW, | static int sysctl_net_inet_tcp_ecn_enable_check(SYSCTL_HANDLER_ARGS); | ||||
&VNET_NAME(tcp_do_ecn), 0, | SYSCTL_PROC(_net_inet_tcp_ecn, OID_AUTO, enable, | ||||
CTLFLAG_VNET | CTLFLAG_RW | CTLTYPE_UINT | CTLFLAG_NEEDGIANT, | |||||
&VNET_NAME(tcp_do_ecn), 0, &sysctl_net_inet_tcp_ecn_enable_check, "IU", | |||||
"TCP ECN support"); | "TCP ECN support"); | ||||
VNET_DEFINE(int, tcp_ecn_maxretries) = 1; | VNET_DEFINE(int, tcp_ecn_maxretries) = 1; | ||||
SYSCTL_INT(_net_inet_tcp_ecn, OID_AUTO, maxretries, CTLFLAG_VNET | CTLFLAG_RW, | SYSCTL_INT(_net_inet_tcp_ecn, OID_AUTO, maxretries, CTLFLAG_VNET | CTLFLAG_RW, | ||||
&VNET_NAME(tcp_ecn_maxretries), 0, | &VNET_NAME(tcp_ecn_maxretries), 0, | ||||
"Max retries before giving up on ECN"); | "Max retries before giving up on ECN"); | ||||
VNET_DEFINE(int, tcp_ecn_generalized) = 0; | |||||
static int sysctl_net_inet_tcp_ecn_generalized_check(SYSCTL_HANDLER_ARGS); | |||||
SYSCTL_PROC(_net_inet_tcp_ecn, OID_AUTO, generalized, | |||||
CTLFLAG_VNET | CTLFLAG_RW | CTLTYPE_UINT | CTLFLAG_NEEDGIANT, | |||||
&VNET_NAME(tcp_ecn_generalized), 0, &sysctl_net_inet_tcp_ecn_generalized_check, "IU", | |||||
"Send all packets as ECT"); | |||||
VNET_DEFINE(int, tcp_insecure_syn) = 0; | VNET_DEFINE(int, tcp_insecure_syn) = 0; | ||||
SYSCTL_INT(_net_inet_tcp, OID_AUTO, insecure_syn, CTLFLAG_VNET | CTLFLAG_RW, | SYSCTL_INT(_net_inet_tcp, OID_AUTO, insecure_syn, CTLFLAG_VNET | CTLFLAG_RW, | ||||
&VNET_NAME(tcp_insecure_syn), 0, | &VNET_NAME(tcp_insecure_syn), 0, | ||||
"Follow RFC793 instead of RFC5961 criteria for accepting SYN packets"); | "Follow RFC793 instead of RFC5961 criteria for accepting SYN packets"); | ||||
VNET_DEFINE(int, tcp_insecure_rst) = 0; | VNET_DEFINE(int, tcp_insecure_rst) = 0; | ||||
SYSCTL_INT(_net_inet_tcp, OID_AUTO, insecure_rst, CTLFLAG_VNET | CTLFLAG_RW, | SYSCTL_INT(_net_inet_tcp, OID_AUTO, insecure_rst, CTLFLAG_VNET | CTLFLAG_RW, | ||||
&VNET_NAME(tcp_insecure_rst), 0, | &VNET_NAME(tcp_insecure_rst), 0, | ||||
▲ Show 20 Lines • Show All 1,433 Lines • ▼ Show 20 Lines | #endif | ||||
*/ | */ | ||||
if (tp->t_state == TCPS_SYN_SENT && (thflags & TH_SYN)) { | if (tp->t_state == TCPS_SYN_SENT && (thflags & TH_SYN)) { | ||||
/* Handle parallel SYN for ECN */ | /* Handle parallel SYN for ECN */ | ||||
if (!(thflags & TH_ACK) && | if (!(thflags & TH_ACK) && | ||||
((thflags & (TH_CWR | TH_ECE)) == (TH_CWR | TH_ECE)) && | ((thflags & (TH_CWR | TH_ECE)) == (TH_CWR | TH_ECE)) && | ||||
((V_tcp_do_ecn == 1) || (V_tcp_do_ecn == 2))) { | ((V_tcp_do_ecn == 1) || (V_tcp_do_ecn == 2))) { | ||||
tp->t_flags2 |= TF2_ECN_PERMIT; | tp->t_flags2 |= TF2_ECN_PERMIT; | ||||
tp->t_flags2 |= TF2_ECN_SND_ECE; | tp->t_flags2 |= TF2_ECN_SND_ECE; | ||||
if (V_tcp_ecn_generalized) | |||||
tp->t_flags2 |= TF2_ECN_PLUSPLUS; | |||||
TCPSTAT_INC(tcps_ecn_shs); | TCPSTAT_INC(tcps_ecn_shs); | ||||
} | } | ||||
if ((to.to_flags & TOF_SCALE) && | if ((to.to_flags & TOF_SCALE) && | ||||
(tp->t_flags & TF_REQ_SCALE) && | (tp->t_flags & TF_REQ_SCALE) && | ||||
!(tp->t_flags & TF_NOOPT)) { | !(tp->t_flags & TF_NOOPT)) { | ||||
tp->t_flags |= TF_RCVD_SCALE; | tp->t_flags |= TF_RCVD_SCALE; | ||||
tp->snd_scale = to.to_wscale; | tp->snd_scale = to.to_wscale; | ||||
} else | } else | ||||
▲ Show 20 Lines • Show All 394 Lines • ▼ Show 20 Lines | #endif | ||||
tcp_timer_activate(tp, TT_DELACK, | tcp_timer_activate(tp, TT_DELACK, | ||||
tcp_delacktime); | tcp_delacktime); | ||||
else | else | ||||
tp->t_flags |= TF_ACKNOW; | tp->t_flags |= TF_ACKNOW; | ||||
if (((thflags & (TH_CWR | TH_ECE)) == TH_ECE) && | if (((thflags & (TH_CWR | TH_ECE)) == TH_ECE) && | ||||
(V_tcp_do_ecn == 1)) { | (V_tcp_do_ecn == 1)) { | ||||
tp->t_flags2 |= TF2_ECN_PERMIT; | tp->t_flags2 |= TF2_ECN_PERMIT; | ||||
if (V_tcp_ecn_generalized) | |||||
tp->t_flags2 |= TF2_ECN_PLUSPLUS; | |||||
TCPSTAT_INC(tcps_ecn_shs); | TCPSTAT_INC(tcps_ecn_shs); | ||||
} | } | ||||
/* | /* | ||||
* Received <SYN,ACK> in SYN_SENT[*] state. | * Received <SYN,ACK> in SYN_SENT[*] state. | ||||
* Transitions: | * Transitions: | ||||
* SYN_SENT --> ESTABLISHED | * SYN_SENT --> ESTABLISHED | ||||
* SYN_SENT* --> FIN_WAIT_1 | * SYN_SENT* --> FIN_WAIT_1 | ||||
▲ Show 20 Lines • Show All 2,008 Lines • ▼ Show 20 Lines | else { | ||||
/* Per RFC5681 Section 3.1 */ | /* Per RFC5681 Section 3.1 */ | ||||
if (maxseg > 2190) | if (maxseg > 2190) | ||||
return (2 * maxseg); | return (2 * maxseg); | ||||
else if (maxseg > 1095) | else if (maxseg > 1095) | ||||
return (3 * maxseg); | return (3 * maxseg); | ||||
else | else | ||||
return (4 * maxseg); | return (4 * maxseg); | ||||
} | } | ||||
} | |||||
static int | |||||
sysctl_net_inet_tcp_ecn_enable_check(SYSCTL_HANDLER_ARGS) | |||||
{ | |||||
uint32_t new; | |||||
int error; | |||||
new = V_tcp_do_ecn; | |||||
error = sysctl_handle_int(oidp, &new, 0, req); | |||||
if (error == 0 && req->newptr != NULL) { | |||||
if (new > 2) | |||||
error = EINVAL; | |||||
else { | |||||
V_tcp_do_ecn = new; | |||||
if (new == 0) | |||||
V_tcp_ecn_generalized = new; | |||||
} | |||||
} | |||||
return (error); | |||||
} | |||||
static int | |||||
sysctl_net_inet_tcp_ecn_generalized_check(SYSCTL_HANDLER_ARGS) | |||||
{ | |||||
uint32_t new; | |||||
int error; | |||||
new = V_tcp_ecn_generalized; | |||||
error = sysctl_handle_int(oidp, &new, 0, req); | |||||
if (error == 0 && req->newptr != NULL) { | |||||
if (new > 1) | |||||
error = EINVAL; | |||||
else | |||||
if (!V_tcp_do_ecn && new == 1) | |||||
error = EINVAL; | |||||
else | |||||
V_tcp_ecn_generalized = new; | |||||
} | |||||
return (error); | |||||
} | } |