Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_stacks/rack.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 15,998 Lines • ▼ Show 20 Lines | if (udp) { | ||||
if (rack->r_is_v6) | if (rack->r_is_v6) | ||||
ulen = hdrlen + len - sizeof(struct ip6_hdr); | ulen = hdrlen + len - sizeof(struct ip6_hdr); | ||||
else | else | ||||
ulen = hdrlen + len - sizeof(struct ip); | ulen = hdrlen + len - sizeof(struct ip); | ||||
udp->uh_ulen = htons(ulen); | udp->uh_ulen = htons(ulen); | ||||
} | } | ||||
m->m_pkthdr.rcvif = (struct ifnet *)0; | m->m_pkthdr.rcvif = (struct ifnet *)0; | ||||
if (TCPS_HAVERCVDSYN(tp->t_state) && | if (TCPS_HAVERCVDSYN(tp->t_state) && | ||||
(tp->t_flags2 & TF2_ECN_PERMIT)) { | (tp->t_flags2 & (TF2_ECN_PERMIT | TF2_ACE_PERMIT))) { | ||||
int ect = tcp_ecn_output_established(tp, &flags, len); | int ect = tcp_ecn_output_established(tp, &flags, len); | ||||
if ((tp->t_state == TCPS_SYN_RECEIVED) && | if ((tp->t_state == TCPS_SYN_RECEIVED) && | ||||
(tp->t_flags2 & TF2_ECN_SND_ECE)) | (tp->t_flags2 & TF2_ECN_SND_ECE)) | ||||
tp->t_flags2 &= ~TF2_ECN_SND_ECE; | tp->t_flags2 &= ~TF2_ECN_SND_ECE; | ||||
#ifdef INET6 | #ifdef INET6 | ||||
if (rack->r_is_v6) { | if (rack->r_is_v6) { | ||||
ip6->ip6_flow &= ~htonl(IPTOS_ECN_MASK << 20); | ip6->ip6_flow &= ~htonl(IPTOS_ECN_MASK << 20); | ||||
ip6->ip6_flow |= htonl(ect << 20); | ip6->ip6_flow |= htonl(ect << 20); | ||||
▲ Show 20 Lines • Show All 429 Lines • ▼ Show 20 Lines | if ((tso == 0) && (len > segsiz)) | ||||
len = segsiz; | len = segsiz; | ||||
if ((len == 0) || | if ((len == 0) || | ||||
(len <= MHLEN - hdrlen - max_linkhdr)) { | (len <= MHLEN - hdrlen - max_linkhdr)) { | ||||
goto failed; | goto failed; | ||||
} | } | ||||
sb_offset = tp->snd_max - tp->snd_una; | sb_offset = tp->snd_max - tp->snd_una; | ||||
th->th_seq = htonl(tp->snd_max); | th->th_seq = htonl(tp->snd_max); | ||||
th->th_ack = htonl(tp->rcv_nxt); | th->th_ack = htonl(tp->rcv_nxt); | ||||
tcp_set_flags(th, flags); | |||||
th->th_win = htons((u_short)(rack->r_ctl.fsb.recwin >> tp->rcv_scale)); | th->th_win = htons((u_short)(rack->r_ctl.fsb.recwin >> tp->rcv_scale)); | ||||
if (th->th_win == 0) { | if (th->th_win == 0) { | ||||
tp->t_sndzerowin++; | tp->t_sndzerowin++; | ||||
tp->t_flags |= TF_RXWIN0SENT; | tp->t_flags |= TF_RXWIN0SENT; | ||||
} else | } else | ||||
tp->t_flags &= ~TF_RXWIN0SENT; | tp->t_flags &= ~TF_RXWIN0SENT; | ||||
tp->snd_up = tp->snd_una; /* drag it along, its deprecated */ | tp->snd_up = tp->snd_una; /* drag it along, its deprecated */ | ||||
KMOD_TCPSTAT_INC(tcps_sndpack); | KMOD_TCPSTAT_INC(tcps_sndpack); | ||||
Show All 29 Lines | if (udp) { | ||||
if (rack->r_is_v6) | if (rack->r_is_v6) | ||||
ulen = hdrlen + len - sizeof(struct ip6_hdr); | ulen = hdrlen + len - sizeof(struct ip6_hdr); | ||||
else | else | ||||
ulen = hdrlen + len - sizeof(struct ip); | ulen = hdrlen + len - sizeof(struct ip); | ||||
udp->uh_ulen = htons(ulen); | udp->uh_ulen = htons(ulen); | ||||
} | } | ||||
m->m_pkthdr.rcvif = (struct ifnet *)0; | m->m_pkthdr.rcvif = (struct ifnet *)0; | ||||
if (TCPS_HAVERCVDSYN(tp->t_state) && | if (TCPS_HAVERCVDSYN(tp->t_state) && | ||||
(tp->t_flags2 & TF2_ECN_PERMIT)) { | (tp->t_flags2 & (TF2_ECN_PERMIT | TF2_ACE_PERMIT))) { | ||||
int ect = tcp_ecn_output_established(tp, &flags, len); | int ect = tcp_ecn_output_established(tp, &flags, len); | ||||
if ((tp->t_state == TCPS_SYN_RECEIVED) && | if ((tp->t_state == TCPS_SYN_RECEIVED) && | ||||
(tp->t_flags2 & TF2_ECN_SND_ECE)) | (tp->t_flags2 & TF2_ECN_SND_ECE)) | ||||
tp->t_flags2 &= ~TF2_ECN_SND_ECE; | tp->t_flags2 &= ~TF2_ECN_SND_ECE; | ||||
#ifdef INET6 | #ifdef INET6 | ||||
if (rack->r_is_v6) { | if (rack->r_is_v6) { | ||||
ip6->ip6_flow &= ~htonl(IPTOS_ECN_MASK << 20); | ip6->ip6_flow &= ~htonl(IPTOS_ECN_MASK << 20); | ||||
ip6->ip6_flow |= htonl(ect << 20); | ip6->ip6_flow |= htonl(ect << 20); | ||||
} | } | ||||
else | else | ||||
#endif | #endif | ||||
{ | { | ||||
ip->ip_tos &= ~IPTOS_ECN_MASK; | ip->ip_tos &= ~IPTOS_ECN_MASK; | ||||
ip->ip_tos |= ect; | ip->ip_tos |= ect; | ||||
} | } | ||||
} | } | ||||
tcp_set_flags(th, flags); | |||||
m->m_pkthdr.len = hdrlen + len; /* in6_cksum() need this */ | m->m_pkthdr.len = hdrlen + len; /* in6_cksum() need this */ | ||||
#ifdef INET6 | #ifdef INET6 | ||||
if (rack->r_is_v6) { | if (rack->r_is_v6) { | ||||
if (tp->t_port) { | if (tp->t_port) { | ||||
m->m_pkthdr.csum_flags = CSUM_UDP_IPV6; | m->m_pkthdr.csum_flags = CSUM_UDP_IPV6; | ||||
m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum); | m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum); | ||||
udp->uh_sum = in6_cksum_pseudo(ip6, ulen, IPPROTO_UDP, 0); | udp->uh_sum = in6_cksum_pseudo(ip6, ulen, IPPROTO_UDP, 0); | ||||
th->th_sum = htons(0); | th->th_sum = htons(0); | ||||
▲ Show 20 Lines • Show All 2,026 Lines • ▼ Show 20 Lines | #endif | ||||
* are on a retransmit, we may resend those bits a number of times | * are on a retransmit, we may resend those bits a number of times | ||||
* as per RFC 3168. | * as per RFC 3168. | ||||
*/ | */ | ||||
if (tp->t_state == TCPS_SYN_SENT && V_tcp_do_ecn) { | if (tp->t_state == TCPS_SYN_SENT && V_tcp_do_ecn) { | ||||
flags |= tcp_ecn_output_syn_sent(tp); | flags |= tcp_ecn_output_syn_sent(tp); | ||||
} | } | ||||
/* Also handle parallel SYN for ECN */ | /* Also handle parallel SYN for ECN */ | ||||
if (TCPS_HAVERCVDSYN(tp->t_state) && | if (TCPS_HAVERCVDSYN(tp->t_state) && | ||||
(tp->t_flags2 & TF2_ECN_PERMIT)) { | (tp->t_flags2 & (TF2_ECN_PERMIT | TF2_ACE_PERMIT))) { | ||||
int ect = tcp_ecn_output_established(tp, &flags, len); | int ect = tcp_ecn_output_established(tp, &flags, len); | ||||
if ((tp->t_state == TCPS_SYN_RECEIVED) && | if ((tp->t_state == TCPS_SYN_RECEIVED) && | ||||
(tp->t_flags2 & TF2_ECN_SND_ECE)) | (tp->t_flags2 & TF2_ECN_SND_ECE)) | ||||
tp->t_flags2 &= ~TF2_ECN_SND_ECE; | tp->t_flags2 &= ~TF2_ECN_SND_ECE; | ||||
#ifdef INET6 | #ifdef INET6 | ||||
if (isipv6) { | if (isipv6) { | ||||
ip6->ip6_flow &= ~htonl(IPTOS_ECN_MASK << 20); | ip6->ip6_flow &= ~htonl(IPTOS_ECN_MASK << 20); | ||||
ip6->ip6_flow |= htonl(ect << 20); | ip6->ip6_flow |= htonl(ect << 20); | ||||
▲ Show 20 Lines • Show All 1,986 Lines • ▼ Show 20 Lines | if ((tp->t_flags & TF_REQ_TSTMP) && (tp->t_flags & TF_RCVD_TSTMP)) | ||||
ti->tcpi_options |= TCPI_OPT_TIMESTAMPS; | ti->tcpi_options |= TCPI_OPT_TIMESTAMPS; | ||||
if (tp->t_flags & TF_SACK_PERMIT) | if (tp->t_flags & TF_SACK_PERMIT) | ||||
ti->tcpi_options |= TCPI_OPT_SACK; | ti->tcpi_options |= TCPI_OPT_SACK; | ||||
if ((tp->t_flags & TF_REQ_SCALE) && (tp->t_flags & TF_RCVD_SCALE)) { | if ((tp->t_flags & TF_REQ_SCALE) && (tp->t_flags & TF_RCVD_SCALE)) { | ||||
ti->tcpi_options |= TCPI_OPT_WSCALE; | ti->tcpi_options |= TCPI_OPT_WSCALE; | ||||
ti->tcpi_snd_wscale = tp->snd_scale; | ti->tcpi_snd_wscale = tp->snd_scale; | ||||
ti->tcpi_rcv_wscale = tp->rcv_scale; | ti->tcpi_rcv_wscale = tp->rcv_scale; | ||||
} | } | ||||
if (tp->t_flags2 & TF2_ECN_PERMIT) | if (tp->t_flags2 & (TF2_ECN_PERMIT | TF2_ACE_PERMIT)) | ||||
ti->tcpi_options |= TCPI_OPT_ECN; | ti->tcpi_options |= TCPI_OPT_ECN; | ||||
if (tp->t_flags & TF_FASTOPEN) | if (tp->t_flags & TF_FASTOPEN) | ||||
ti->tcpi_options |= TCPI_OPT_TFO; | ti->tcpi_options |= TCPI_OPT_TFO; | ||||
/* still kept in ticks is t_rcvtime */ | /* still kept in ticks is t_rcvtime */ | ||||
ti->tcpi_last_data_recv = ((uint32_t)ticks - tp->t_rcvtime) * tick; | ti->tcpi_last_data_recv = ((uint32_t)ticks - tp->t_rcvtime) * tick; | ||||
/* Since we hold everything in precise useconds this is easy */ | /* Since we hold everything in precise useconds this is easy */ | ||||
ti->tcpi_rtt = tp->t_srtt; | ti->tcpi_rtt = tp->t_srtt; | ||||
ti->tcpi_rttvar = tp->t_rttvar; | ti->tcpi_rttvar = tp->t_rttvar; | ||||
▲ Show 20 Lines • Show All 420 Lines • Show Last 20 Lines |