Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_input.c
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
#include "opt_inet.h" | #include "opt_inet.h" | ||||
#include "opt_inet6.h" | #include "opt_inet6.h" | ||||
#include "opt_ipsec.h" | #include "opt_ipsec.h" | ||||
#include "opt_tcpdebug.h" | #include "opt_tcpdebug.h" | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#ifdef TCP_HHOOK | |||||
#include <sys/hhook.h> | #include <sys/hhook.h> | ||||
#endif | |||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/mbuf.h> | #include <sys/mbuf.h> | ||||
#include <sys/proc.h> /* for proc0 declaration */ | #include <sys/proc.h> /* for proc0 declaration */ | ||||
#include <sys/protosw.h> | #include <sys/protosw.h> | ||||
#include <sys/sdt.h> | #include <sys/sdt.h> | ||||
#include <sys/signalvar.h> | #include <sys/signalvar.h> | ||||
#include <sys/socket.h> | #include <sys/socket.h> | ||||
#include <sys/socketvar.h> | #include <sys/socketvar.h> | ||||
▲ Show 20 Lines • Show All 204 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
void | void | ||||
kmod_tcpstat_inc(int statnum) | kmod_tcpstat_inc(int statnum) | ||||
{ | { | ||||
counter_u64_add(VNET(tcpstat)[statnum], 1); | counter_u64_add(VNET(tcpstat)[statnum], 1); | ||||
} | } | ||||
#ifdef TCP_HHOOK | |||||
/* | /* | ||||
* Wrapper for the TCP established input helper hook. | * Wrapper for the TCP established input helper hook. | ||||
*/ | */ | ||||
void | void | ||||
hhook_run_tcp_est_in(struct tcpcb *tp, struct tcphdr *th, struct tcpopt *to) | hhook_run_tcp_est_in(struct tcpcb *tp, struct tcphdr *th, struct tcpopt *to) | ||||
{ | { | ||||
struct tcp_hhook_data hhook_data; | struct tcp_hhook_data hhook_data; | ||||
if (V_tcp_hhh[HHOOK_TCP_EST_IN]->hhh_nhooks > 0) { | if (V_tcp_hhh[HHOOK_TCP_EST_IN]->hhh_nhooks > 0) { | ||||
hhook_data.tp = tp; | hhook_data.tp = tp; | ||||
hhook_data.th = th; | hhook_data.th = th; | ||||
hhook_data.to = to; | hhook_data.to = to; | ||||
hhook_run_hooks(V_tcp_hhh[HHOOK_TCP_EST_IN], &hhook_data, | hhook_run_hooks(V_tcp_hhh[HHOOK_TCP_EST_IN], &hhook_data, | ||||
tp->osd); | tp->osd); | ||||
} | } | ||||
} | } | ||||
#endif | |||||
/* | /* | ||||
* CC wrapper hook functions | * CC wrapper hook functions | ||||
*/ | */ | ||||
void | void | ||||
cc_ack_received(struct tcpcb *tp, struct tcphdr *th, uint16_t nsegs, | cc_ack_received(struct tcpcb *tp, struct tcphdr *th, uint16_t nsegs, | ||||
uint16_t type) | uint16_t type) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 1,442 Lines • ▼ Show 20 Lines | if (tlen == 0) { | ||||
if (!tp->t_rttlow || | if (!tp->t_rttlow || | ||||
tp->t_rttlow > ticks - tp->t_rtttime) | tp->t_rttlow > ticks - tp->t_rtttime) | ||||
tp->t_rttlow = ticks - tp->t_rtttime; | tp->t_rttlow = ticks - tp->t_rtttime; | ||||
tcp_xmit_timer(tp, | tcp_xmit_timer(tp, | ||||
ticks - tp->t_rtttime); | ticks - tp->t_rtttime); | ||||
} | } | ||||
acked = BYTES_THIS_ACK(tp, th); | acked = BYTES_THIS_ACK(tp, th); | ||||
#ifdef TCP_HHOOK | |||||
/* Run HHOOK_TCP_ESTABLISHED_IN helper hooks. */ | /* Run HHOOK_TCP_ESTABLISHED_IN helper hooks. */ | ||||
hhook_run_tcp_est_in(tp, th, &to); | hhook_run_tcp_est_in(tp, th, &to); | ||||
#endif | |||||
TCPSTAT_ADD(tcps_rcvackpack, nsegs); | TCPSTAT_ADD(tcps_rcvackpack, nsegs); | ||||
TCPSTAT_ADD(tcps_rcvackbyte, acked); | TCPSTAT_ADD(tcps_rcvackbyte, acked); | ||||
sbdrop(&so->so_snd, acked); | sbdrop(&so->so_snd, acked); | ||||
if (SEQ_GT(tp->snd_una, tp->snd_recover) && | if (SEQ_GT(tp->snd_una, tp->snd_recover) && | ||||
SEQ_LEQ(th->th_ack, tp->snd_recover)) | SEQ_LEQ(th->th_ack, tp->snd_recover)) | ||||
tp->snd_recover = th->th_ack - 1; | tp->snd_recover = th->th_ack - 1; | ||||
▲ Show 20 Lines • Show All 728 Lines • ▼ Show 20 Lines | if ((tp->t_flags & TF_SACK_PERMIT) && | ||||
sack_changed = tcp_sack_doack(tp, &to, th->th_ack); | sack_changed = tcp_sack_doack(tp, &to, th->th_ack); | ||||
else | else | ||||
/* | /* | ||||
* Reset the value so that previous (valid) value | * Reset the value so that previous (valid) value | ||||
* from the last ack with SACK doesn't get used. | * from the last ack with SACK doesn't get used. | ||||
*/ | */ | ||||
tp->sackhint.sacked_bytes = 0; | tp->sackhint.sacked_bytes = 0; | ||||
#ifdef TCP_HHOOK | |||||
/* Run HHOOK_TCP_ESTABLISHED_IN helper hooks. */ | /* Run HHOOK_TCP_ESTABLISHED_IN helper hooks. */ | ||||
hhook_run_tcp_est_in(tp, th, &to); | hhook_run_tcp_est_in(tp, th, &to); | ||||
#endif | |||||
if (SEQ_LEQ(th->th_ack, tp->snd_una)) { | if (SEQ_LEQ(th->th_ack, tp->snd_una)) { | ||||
u_int maxseg; | u_int maxseg; | ||||
maxseg = tcp_maxseg(tp); | maxseg = tcp_maxseg(tp); | ||||
if (tlen == 0 && | if (tlen == 0 && | ||||
(tiwin == tp->snd_wnd || | (tiwin == tp->snd_wnd || | ||||
(tp->t_flags & TF_SACK_PERMIT))) { | (tp->t_flags & TF_SACK_PERMIT))) { | ||||
▲ Show 20 Lines • Show All 1,348 Lines • Show Last 20 Lines |