Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_input.c
Show First 20 Lines • Show All 542 Lines • ▼ Show 20 Lines | if (tp->ccv->flags & CCF_ACKNOW) { | ||||
tp->t_flags |= TF_ACKNOW; | tp->t_flags |= TF_ACKNOW; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
void inline | void inline | ||||
cc_ecnpkt_handler(struct tcpcb *tp, struct tcphdr *th, uint8_t iptos) | cc_ecnpkt_handler(struct tcpcb *tp, struct tcphdr *th, uint8_t iptos) | ||||
{ | { | ||||
cc_ecnpkt_handler_flags(tp, th->th_flags, iptos); | cc_ecnpkt_handler_flags(tp, tcp_get_flags(th), iptos); | ||||
} | } | ||||
/* | /* | ||||
* TCP input handling is split into multiple parts: | * TCP input handling is split into multiple parts: | ||||
* tcp6_input is a thin wrapper around tcp_input for the extended | * tcp6_input is a thin wrapper around tcp_input for the extended | ||||
* ip6_protox[] call format in ip6_input | * ip6_protox[] call format in ip6_input | ||||
* tcp_input handles primary segment validation, inpcb lookup and | * tcp_input handles primary segment validation, inpcb lookup and | ||||
* SYN processing on listen sockets | * SYN processing on listen sockets | ||||
▲ Show 20 Lines • Show All 234 Lines • ▼ Show 20 Lines | #ifdef INET | ||||
ip = mtod(m, struct ip *); | ip = mtod(m, struct ip *); | ||||
th = (struct tcphdr *)((caddr_t)ip + off0); | th = (struct tcphdr *)((caddr_t)ip + off0); | ||||
} | } | ||||
} | } | ||||
#endif | #endif | ||||
optlen = off - sizeof (struct tcphdr); | optlen = off - sizeof (struct tcphdr); | ||||
optp = (u_char *)(th + 1); | optp = (u_char *)(th + 1); | ||||
} | } | ||||
thflags = th->th_flags; | thflags = tcp_get_flags(th); | ||||
/* | /* | ||||
* Convert TCP protocol specific fields to host format. | * Convert TCP protocol specific fields to host format. | ||||
*/ | */ | ||||
tcp_fields_to_host(th); | tcp_fields_to_host(th); | ||||
/* | /* | ||||
* Delay dropping TCP, IP headers, IPv6 ext headers, and TCP options. | * Delay dropping TCP, IP headers, IPv6 ext headers, and TCP options. | ||||
▲ Show 20 Lines • Show All 721 Lines • ▼ Show 20 Lines | #ifdef TCPDEBUG | ||||
/* | /* | ||||
* The size of tcp_saveipgen must be the size of the max ip header, | * The size of tcp_saveipgen must be the size of the max ip header, | ||||
* now IPv6. | * now IPv6. | ||||
*/ | */ | ||||
u_char tcp_saveipgen[IP6_HDR_LEN]; | u_char tcp_saveipgen[IP6_HDR_LEN]; | ||||
struct tcphdr tcp_savetcp; | struct tcphdr tcp_savetcp; | ||||
short ostate = 0; | short ostate = 0; | ||||
#endif | #endif | ||||
thflags = th->th_flags; | thflags = tcp_get_flags(th); | ||||
inc = &tp->t_inpcb->inp_inc; | inc = &tp->t_inpcb->inp_inc; | ||||
tp->sackhint.last_sack_ack = 0; | tp->sackhint.last_sack_ack = 0; | ||||
sack_changed = 0; | sack_changed = 0; | ||||
nsegs = max(1, m->m_pkthdr.lro_nsegs); | nsegs = max(1, m->m_pkthdr.lro_nsegs); | ||||
NET_EPOCH_ASSERT(); | NET_EPOCH_ASSERT(); | ||||
INP_WLOCK_ASSERT(tp->t_inpcb); | INP_WLOCK_ASSERT(tp->t_inpcb); | ||||
KASSERT(tp->t_state > TCPS_LISTEN, ("%s: TCPS_LISTEN", | KASSERT(tp->t_state > TCPS_LISTEN, ("%s: TCPS_LISTEN", | ||||
▲ Show 20 Lines • Show All 1,622 Lines • ▼ Show 20 Lines | if (th->th_seq == tp->rcv_nxt && | ||||
((tp->t_flags2 & TF2_FBYTES_COMPLETE) == 0) && | ((tp->t_flags2 & TF2_FBYTES_COMPLETE) == 0) && | ||||
(tp->t_fbyte_in == 0)) { | (tp->t_fbyte_in == 0)) { | ||||
tp->t_fbyte_in = ticks; | tp->t_fbyte_in = ticks; | ||||
if (tp->t_fbyte_in == 0) | if (tp->t_fbyte_in == 0) | ||||
tp->t_fbyte_in = 1; | tp->t_fbyte_in = 1; | ||||
if (tp->t_fbyte_out && tp->t_fbyte_in) | if (tp->t_fbyte_out && tp->t_fbyte_in) | ||||
tp->t_flags2 |= TF2_FBYTES_COMPLETE; | tp->t_flags2 |= TF2_FBYTES_COMPLETE; | ||||
} | } | ||||
thflags = th->th_flags & TH_FIN; | thflags = tcp_get_flags(th) & TH_FIN; | ||||
TCPSTAT_INC(tcps_rcvpack); | TCPSTAT_INC(tcps_rcvpack); | ||||
TCPSTAT_ADD(tcps_rcvbyte, tlen); | TCPSTAT_ADD(tcps_rcvbyte, tlen); | ||||
SOCKBUF_LOCK(&so->so_rcv); | SOCKBUF_LOCK(&so->so_rcv); | ||||
if (so->so_rcv.sb_state & SBS_CANTRCVMORE) | if (so->so_rcv.sb_state & SBS_CANTRCVMORE) | ||||
m_freem(m); | m_freem(m); | ||||
else | else | ||||
sbappendstream_locked(&so->so_rcv, m, 0); | sbappendstream_locked(&so->so_rcv, m, 0); | ||||
tp->t_flags |= TF_WAKESOR; | tp->t_flags |= TF_WAKESOR; | ||||
▲ Show 20 Lines • Show All 208 Lines • ▼ Show 20 Lines | #ifdef INET6 | ||||
struct ip6_hdr *ip6; | struct ip6_hdr *ip6; | ||||
#endif | #endif | ||||
if (tp != NULL) { | if (tp != NULL) { | ||||
INP_LOCK_ASSERT(tp->t_inpcb); | INP_LOCK_ASSERT(tp->t_inpcb); | ||||
} | } | ||||
/* Don't bother if destination was broadcast/multicast. */ | /* Don't bother if destination was broadcast/multicast. */ | ||||
if ((th->th_flags & TH_RST) || m->m_flags & (M_BCAST|M_MCAST)) | if ((tcp_get_flags(th) & TH_RST) || m->m_flags & (M_BCAST|M_MCAST)) | ||||
goto drop; | goto drop; | ||||
#ifdef INET6 | #ifdef INET6 | ||||
if (mtod(m, struct ip *)->ip_v == 6) { | if (mtod(m, struct ip *)->ip_v == 6) { | ||||
ip6 = mtod(m, struct ip6_hdr *); | ip6 = mtod(m, struct ip6_hdr *); | ||||
if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst) || | if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst) || | ||||
IN6_IS_ADDR_MULTICAST(&ip6->ip6_src)) | IN6_IS_ADDR_MULTICAST(&ip6->ip6_src)) | ||||
goto drop; | goto drop; | ||||
/* IPv6 anycast check is done at tcp6_input() */ | /* IPv6 anycast check is done at tcp6_input() */ | ||||
Show All 13 Lines | #ifdef INET | ||||
} | } | ||||
#endif | #endif | ||||
/* Perform bandwidth limiting. */ | /* Perform bandwidth limiting. */ | ||||
if (badport_bandlim(rstreason) < 0) | if (badport_bandlim(rstreason) < 0) | ||||
goto drop; | goto drop; | ||||
/* tcp_respond consumes the mbuf chain. */ | /* tcp_respond consumes the mbuf chain. */ | ||||
if (th->th_flags & TH_ACK) { | if (tcp_get_flags(th) & TH_ACK) { | ||||
tcp_respond(tp, mtod(m, void *), th, m, (tcp_seq)0, | tcp_respond(tp, mtod(m, void *), th, m, (tcp_seq)0, | ||||
th->th_ack, TH_RST); | th->th_ack, TH_RST); | ||||
} else { | } else { | ||||
if (th->th_flags & TH_SYN) | if (tcp_get_flags(th) & TH_SYN) | ||||
tlen++; | tlen++; | ||||
if (th->th_flags & TH_FIN) | if (tcp_get_flags(th) & TH_FIN) | ||||
tlen++; | tlen++; | ||||
tcp_respond(tp, mtod(m, void *), th, m, th->th_seq+tlen, | tcp_respond(tp, mtod(m, void *), th, m, th->th_seq+tlen, | ||||
(tcp_seq)0, TH_RST|TH_ACK); | (tcp_seq)0, TH_RST|TH_ACK); | ||||
} | } | ||||
return; | return; | ||||
drop: | drop: | ||||
m_freem(m); | m_freem(m); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 657 Lines • Show Last 20 Lines |