Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netinet/tcp_subr.c
Show First 20 Lines • Show All 1,081 Lines • ▼ Show 20 Lines | if (khelp_init_osd(HELPER_CLASS_TCP, tp->osd)) { | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
#ifdef VIMAGE | #ifdef VIMAGE | ||||
tp->t_vnet = inp->inp_vnet; | tp->t_vnet = inp->inp_vnet; | ||||
#endif | #endif | ||||
tp->t_timers = &tm->tt; | tp->t_timers = &tm->tt; | ||||
/* LIST_INIT(&tp->t_segq); */ /* XXX covered by M_ZERO */ | /* LIST_INIT(&tp->t_segq); */ /* XXX covered by M_ZERO */ | ||||
tp->t_maxseg = tp->t_maxopd = | tp->t_maxseg = | ||||
#ifdef INET6 | #ifdef INET6 | ||||
isipv6 ? V_tcp_v6mssdflt : | isipv6 ? V_tcp_v6mssdflt : | ||||
#endif /* INET6 */ | #endif /* INET6 */ | ||||
V_tcp_mssdflt; | V_tcp_mssdflt; | ||||
/* Set up our timeouts. */ | /* Set up our timeouts. */ | ||||
callout_init(&tp->t_timers->tt_rexmt, 1); | callout_init(&tp->t_timers->tt_rexmt, 1); | ||||
callout_init(&tp->t_timers->tt_persist, 1); | callout_init(&tp->t_timers->tt_persist, 1); | ||||
▲ Show 20 Lines • Show All 797 Lines • ▼ Show 20 Lines | if (!(inp->inp_flags & INP_TIMEWAIT) && | ||||
if (mtu < V_tcp_minmss + | if (mtu < V_tcp_minmss + | ||||
sizeof(struct tcpiphdr)) | sizeof(struct tcpiphdr)) | ||||
mtu = V_tcp_minmss + | mtu = V_tcp_minmss + | ||||
sizeof(struct tcpiphdr); | sizeof(struct tcpiphdr); | ||||
/* | /* | ||||
* Only process the offered MTU if it | * Only process the offered MTU if it | ||||
* is smaller than the current one. | * is smaller than the current one. | ||||
*/ | */ | ||||
if (mtu < tp->t_maxopd + | if (mtu < tp->t_maxseg + | ||||
sizeof(struct tcpiphdr)) { | sizeof(struct tcpiphdr)) { | ||||
bzero(&inc, sizeof(inc)); | bzero(&inc, sizeof(inc)); | ||||
inc.inc_faddr = faddr; | inc.inc_faddr = faddr; | ||||
inc.inc_fibnum = | inc.inc_fibnum = | ||||
inp->inp_inc.inc_fibnum; | inp->inp_inc.inc_fibnum; | ||||
tcp_hc_updatemtu(&inc, mtu); | tcp_hc_updatemtu(&inc, mtu); | ||||
tcp_mtudisc(inp, mtu); | tcp_mtudisc(inp, mtu); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 364 Lines • ▼ Show 20 Lines | if (cap != NULL) { | ||||
} | } | ||||
} | } | ||||
RTFREE(sro6.ro_rt); | RTFREE(sro6.ro_rt); | ||||
} | } | ||||
return (maxmtu); | return (maxmtu); | ||||
} | } | ||||
#endif /* INET6 */ | #endif /* INET6 */ | ||||
/* | |||||
* Calculate effective SMSS per RFC5681 definition for a given TCP | |||||
* connection at its current state, taking into account SACK and etc. | |||||
*/ | |||||
u_int | |||||
tcp_maxseg(const struct tcpcb *tp) | |||||
{ | |||||
u_int optlen; | |||||
if (tp->t_flags & TF_NOOPT) | |||||
return (tp->t_maxseg); | |||||
/* | |||||
* Here we have a simplified code from tcp_addoptions(), | |||||
* without a proper loop, and having most of paddings hardcoded. | |||||
* We might make mistakes with padding here in some edge cases, | |||||
* but this is harmless, since result of tcp_maxseg() is used | |||||
* only in cwnd and ssthresh estimations. | |||||
*/ | |||||
#define PAD(len) ((((len) / 4) + !!((len) % 4)) * 4) | |||||
if (TCPS_HAVEESTABLISHED(tp->t_state)) { | |||||
if (tp->t_flags & TF_RCVD_TSTMP) | |||||
optlen = TCPOLEN_TSTAMP_APPA; | |||||
else | |||||
optlen = 0; | |||||
#ifdef TCP_SIGNATURE | |||||
if (tp->t_flags & TF_SIGNATURE) | |||||
optlen += PAD(TCPOLEN_SIGNATURE); | |||||
#endif | |||||
if ((tp->t_flags & TF_SACK_PERMIT) && tp->rcv_numsacks > 0) { | |||||
optlen += TCPOLEN_SACKHDR; | |||||
optlen += tp->rcv_numsacks * TCPOLEN_SACK; | |||||
optlen = PAD(optlen); | |||||
} | |||||
} else { | |||||
if (tp->t_flags & TF_REQ_TSTMP) | |||||
optlen = TCPOLEN_TSTAMP_APPA; | |||||
else | |||||
optlen = PAD(TCPOLEN_MAXSEG); | |||||
if (tp->t_flags & TF_REQ_SCALE) | |||||
optlen += PAD(TCPOLEN_WINDOW); | |||||
#ifdef TCP_SIGNATURE | |||||
if (tp->t_flags & TF_SIGNATURE) | |||||
optlen += PAD(TCPOLEN_SIGNATURE); | |||||
#endif | |||||
if (tp->t_flags & TF_SACK_PERMIT) | |||||
optlen += PAD(TCPOLEN_SACK_PERMITTED); | |||||
} | |||||
#undef PAD | |||||
optlen = min(optlen, TCP_MAXOLEN); | |||||
return (tp->t_maxseg - optlen); | |||||
} | |||||
#ifdef IPSEC | #ifdef IPSEC | ||||
/* compute ESP/AH header size for TCP, including outer IP header. */ | /* compute ESP/AH header size for TCP, including outer IP header. */ | ||||
size_t | size_t | ||||
ipsec_hdrsiz_tcp(struct tcpcb *tp) | ipsec_hdrsiz_tcp(struct tcpcb *tp) | ||||
{ | { | ||||
struct inpcb *inp; | struct inpcb *inp; | ||||
struct mbuf *m; | struct mbuf *m; | ||||
▲ Show 20 Lines • Show All 575 Lines • Show Last 20 Lines |