Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_ecn.c
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | SYSCTL_INT(_net_inet_tcp_ecn, OID_AUTO, enable, | ||||
CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(tcp_do_ecn), 0, | CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(tcp_do_ecn), 0, | ||||
"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, | SYSCTL_INT(_net_inet_tcp_ecn, OID_AUTO, maxretries, | ||||
CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(tcp_ecn_maxretries), 0, | CTLFLAG_VNET | CTLFLAG_RW, &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_option) = 0; | |||||
SYSCTL_INT(_net_inet_tcp_ecn, OID_AUTO, option, | |||||
CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(tcp_ecn_option), 0, | |||||
"Use AccECN TCP option"); | |||||
/* | /* | ||||
* Process incoming SYN,ACK packet | * Process incoming SYN,ACK packet | ||||
*/ | */ | ||||
void | void | ||||
tcp_ecn_input_syn_sent(struct tcpcb *tp, uint16_t thflags, int iptos) | tcp_ecn_input_syn_sent(struct tcpcb *tp, uint16_t thflags, int iptos) | ||||
{ | { | ||||
if (V_tcp_do_ecn == 0) | if (V_tcp_do_ecn == 0) | ||||
return; | return; | ||||
if ((V_tcp_do_ecn == 1) || | if ((V_tcp_do_ecn == 1) || | ||||
(V_tcp_do_ecn == 2)) { | (V_tcp_do_ecn == 2)) { | ||||
/* RFC3168 ECN handling */ | /* RFC3168 ECN handling */ | ||||
if ((thflags & (TH_CWR | TH_ECE)) == (0 | TH_ECE)) { | if ((thflags & (TH_CWR | TH_ECE)) == (0 | TH_ECE)) { | ||||
tp->t_flags2 |= TF2_ECN_PERMIT; | tp->t_flags2 |= TF2_ECN_PERMIT; | ||||
tp->t_flags2 &= ~TF2_ACE_PERMIT; | tp->t_flags2 &= ~TF2_ACE_PERMIT; | ||||
▲ Show 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | |||||
int | int | ||||
tcp_ecn_input_segment(struct tcpcb *tp, uint16_t thflags, int tlen, int pkts, int iptos) | tcp_ecn_input_segment(struct tcpcb *tp, uint16_t thflags, int tlen, int pkts, int iptos) | ||||
{ | { | ||||
int delta_cep = 0; | int delta_cep = 0; | ||||
if (tp->t_flags2 & (TF2_ECN_PERMIT | TF2_ACE_PERMIT)) { | if (tp->t_flags2 & (TF2_ECN_PERMIT | TF2_ACE_PERMIT)) { | ||||
switch (iptos & IPTOS_ECN_MASK) { | switch (iptos & IPTOS_ECN_MASK) { | ||||
case IPTOS_ECN_CE: | case IPTOS_ECN_CE: | ||||
tp->t_flags2 |= TF2_ACO_CE; | |||||
tp->t_ae.rceb += tlen; | |||||
TCPSTAT_INC(tcps_ecn_ce); | TCPSTAT_INC(tcps_ecn_ce); | ||||
tp->t_rcep++; | |||||
break; | break; | ||||
case IPTOS_ECN_ECT0: | case IPTOS_ECN_ECT0: | ||||
tp->t_flags2 |= TF2_ACO_E0; | |||||
tp->t_ae.re0b += tlen; | |||||
TCPSTAT_INC(tcps_ecn_ect0); | TCPSTAT_INC(tcps_ecn_ect0); | ||||
break; | break; | ||||
case IPTOS_ECN_ECT1: | case IPTOS_ECN_ECT1: | ||||
tp->t_flags2 |= TF2_ACO_E1; | |||||
tp->t_ae.re1b += tlen; | |||||
TCPSTAT_INC(tcps_ecn_ect1); | TCPSTAT_INC(tcps_ecn_ect1); | ||||
break; | break; | ||||
} | } | ||||
if (tp->t_flags2 & TF2_ACE_PERMIT) { | if (tp->t_flags2 & TF2_ACE_PERMIT) { | ||||
if ((iptos & IPTOS_ECN_MASK) == IPTOS_ECN_CE) | |||||
tp->t_rcep += 1; | |||||
if (tp->t_flags2 & TF2_ECN_PERMIT) { | if (tp->t_flags2 & TF2_ECN_PERMIT) { | ||||
delta_cep = (tcp_ecn_get_ace(thflags) + 8 - | delta_cep = (tcp_ecn_get_ace(thflags) + 8 - | ||||
(tp->t_scep & 7)) & 7; | (tp->t_scep & 7)) & 7; | ||||
if (delta_cep < pkts) | if (delta_cep < pkts) | ||||
delta_cep = pkts - | delta_cep = pkts - | ||||
((pkts - delta_cep) & 7); | ((pkts - delta_cep) & 7); | ||||
tp->t_scep += delta_cep; | tp->t_scep += delta_cep; | ||||
} else { | } else { | ||||
▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | if (tp->t_flags2 & TF2_ACE_PERMIT) { | ||||
if (newdata && | if (newdata && | ||||
(tp->t_flags2 & TF2_ECN_SND_CWR)) { | (tp->t_flags2 & TF2_ECN_SND_CWR)) { | ||||
*thflags |= TH_CWR; | *thflags |= TH_CWR; | ||||
tp->t_flags2 &= ~TF2_ECN_SND_CWR; | tp->t_flags2 &= ~TF2_ECN_SND_CWR; | ||||
} | } | ||||
if (tp->t_flags2 & TF2_ECN_SND_ECE) | if (tp->t_flags2 & TF2_ECN_SND_ECE) | ||||
*thflags |= TH_ECE; | *thflags |= TH_ECE; | ||||
} | } | ||||
return ipecn; | return ipecn; | ||||
} | } | ||||
/* | /* | ||||
* Set up the ECN related tcpcb fields from | * Set up the ECN related tcpcb fields from | ||||
* a syncache entry | * a syncache entry | ||||
*/ | */ | ||||
void | void | ||||
▲ Show 20 Lines • Show All 145 Lines • Show Last 20 Lines |