Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netinet/tcp_subr.c
Show First 20 Lines • Show All 3,007 Lines • ▼ Show 20 Lines | tcp_maxseg(const struct tcpcb *tp) | ||||
/* | /* | ||||
* Here we have a simplified code from tcp_addoptions(), | * Here we have a simplified code from tcp_addoptions(), | ||||
* without a proper loop, and having most of paddings hardcoded. | * without a proper loop, and having most of paddings hardcoded. | ||||
* We might make mistakes with padding here in some edge cases, | * We might make mistakes with padding here in some edge cases, | ||||
* but this is harmless, since result of tcp_maxseg() is used | * but this is harmless, since result of tcp_maxseg() is used | ||||
* only in cwnd and ssthresh estimations. | * only in cwnd and ssthresh estimations. | ||||
*/ | */ | ||||
#define PAD(len) ((((len) / 4) + !!((len) % 4)) * 4) | |||||
if (TCPS_HAVEESTABLISHED(tp->t_state)) { | if (TCPS_HAVEESTABLISHED(tp->t_state)) { | ||||
if (tp->t_flags & TF_RCVD_TSTMP) | if (tp->t_flags & TF_RCVD_TSTMP) | ||||
optlen = TCPOLEN_TSTAMP_APPA; | optlen = TCPOLEN_TSTAMP_APPA; | ||||
else | else | ||||
optlen = 0; | optlen = 0; | ||||
#if defined(IPSEC_SUPPORT) || defined(TCP_SIGNATURE) | #if defined(IPSEC_SUPPORT) || defined(TCP_SIGNATURE) | ||||
if (tp->t_flags & TF_SIGNATURE) | if (tp->t_flags & TF_SIGNATURE) | ||||
optlen += PAD(TCPOLEN_SIGNATURE); | optlen += PADTCPOLEN(TCPOLEN_SIGNATURE); | ||||
#endif | #endif | ||||
if ((tp->t_flags & TF_SACK_PERMIT) && tp->rcv_numsacks > 0) { | if ((tp->t_flags & TF_SACK_PERMIT) && tp->rcv_numsacks > 0) { | ||||
optlen += TCPOLEN_SACKHDR; | optlen += TCPOLEN_SACKHDR; | ||||
optlen += tp->rcv_numsacks * TCPOLEN_SACK; | optlen += tp->rcv_numsacks * TCPOLEN_SACK; | ||||
optlen = PAD(optlen); | optlen = PADTCPOLEN(optlen); | ||||
} | } | ||||
} else { | } else { | ||||
if (tp->t_flags & TF_REQ_TSTMP) | if (tp->t_flags & TF_REQ_TSTMP) | ||||
optlen = TCPOLEN_TSTAMP_APPA; | optlen = TCPOLEN_TSTAMP_APPA; | ||||
else | else | ||||
optlen = PAD(TCPOLEN_MAXSEG); | optlen = PADTCPOLEN(TCPOLEN_MAXSEG); | ||||
if (tp->t_flags & TF_REQ_SCALE) | if (tp->t_flags & TF_REQ_SCALE) | ||||
optlen += PAD(TCPOLEN_WINDOW); | optlen += PADTCPOLEN(TCPOLEN_WINDOW); | ||||
#if defined(IPSEC_SUPPORT) || defined(TCP_SIGNATURE) | #if defined(IPSEC_SUPPORT) || defined(TCP_SIGNATURE) | ||||
if (tp->t_flags & TF_SIGNATURE) | if (tp->t_flags & TF_SIGNATURE) | ||||
optlen += PAD(TCPOLEN_SIGNATURE); | optlen += PADTCPOLEN(TCPOLEN_SIGNATURE); | ||||
#endif | #endif | ||||
if (tp->t_flags & TF_SACK_PERMIT) | if (tp->t_flags & TF_SACK_PERMIT) | ||||
optlen += PAD(TCPOLEN_SACK_PERMITTED); | optlen += PADTCPOLEN(TCPOLEN_SACK_PERMITTED); | ||||
} | } | ||||
#undef PAD | #undef PAD | ||||
optlen = min(optlen, TCP_MAXOLEN); | optlen = min(optlen, TCP_MAXOLEN); | ||||
return (tp->t_maxseg - optlen); | return (tp->t_maxseg - optlen); | ||||
} | } | ||||
static int | static int | ||||
sysctl_drop(SYSCTL_HANDLER_ARGS) | sysctl_drop(SYSCTL_HANDLER_ARGS) | ||||
▲ Show 20 Lines • Show All 449 Lines • Show Last 20 Lines |