When the RACK stack computes the space for user data in a TCP segment,
it wasn't taking the IP level options into account. This patch fixes this. In addition, it also corrects a KASSERT and adds protection code to assure that the IP header chain and the TCP head fit in the first fragment as required by RFC 7112. Reviewed by: rrs@ MFC after: 3 days Sponsored by: Nertflix, Inc. Differential Revision: https://reviews.freebsd.org/D21666
This commit is contained in:
parent
699a34f40f
commit
5d8f9a3242
@ -7840,7 +7840,16 @@ send:
|
||||
hdrlen += sizeof(struct udphdr);
|
||||
}
|
||||
#endif
|
||||
ipoptlen = 0;
|
||||
#ifdef INET6
|
||||
if (isipv6)
|
||||
ipoptlen = ip6_optlen(tp->t_inpcb);
|
||||
else
|
||||
#endif
|
||||
if (tp->t_inpcb->inp_options)
|
||||
ipoptlen = tp->t_inpcb->inp_options->m_len -
|
||||
offsetof(struct ipoption, ipopt_list);
|
||||
else
|
||||
ipoptlen = 0;
|
||||
#if defined(IPSEC) || defined(IPSEC_SUPPORT)
|
||||
ipoptlen += ipsec_optlen;
|
||||
#endif
|
||||
@ -7913,6 +7922,18 @@ send:
|
||||
sendalot = 1;
|
||||
|
||||
} else {
|
||||
if (optlen + ipoptlen > tp->t_maxseg) {
|
||||
/*
|
||||
* Since we don't have enough space to put
|
||||
* the IP header chain and the TCP header in
|
||||
* one packet as required by RFC 7112, don't
|
||||
* send it.
|
||||
*/
|
||||
SOCKBUF_UNLOCK(&so->so_snd);
|
||||
error = EMSGSIZE;
|
||||
sack_rxmit = 0;
|
||||
goto out;
|
||||
}
|
||||
len = tp->t_maxseg - optlen - ipoptlen;
|
||||
sendalot = 1;
|
||||
}
|
||||
@ -8414,15 +8435,9 @@ send:
|
||||
m->m_pkthdr.csum_flags |= CSUM_TSO;
|
||||
m->m_pkthdr.tso_segsz = tp->t_maxseg - optlen;
|
||||
}
|
||||
#if defined(IPSEC) || defined(IPSEC_SUPPORT)
|
||||
KASSERT(len + hdrlen + ipoptlen - ipsec_optlen == m_length(m, NULL),
|
||||
("%s: mbuf chain shorter than expected: %d + %u + %u - %u != %u",
|
||||
__func__, len, hdrlen, ipoptlen, ipsec_optlen, m_length(m, NULL)));
|
||||
#else
|
||||
KASSERT(len + hdrlen + ipoptlen == m_length(m, NULL),
|
||||
("%s: mbuf chain shorter than expected: %d + %u + %u != %u",
|
||||
__func__, len, hdrlen, ipoptlen, m_length(m, NULL)));
|
||||
#endif
|
||||
KASSERT(len + hdrlen == m_length(m, NULL),
|
||||
("%s: mbuf chain different than expected: %d + %u != %u",
|
||||
__func__, len, hdrlen, m_length(m, NULL)));
|
||||
|
||||
#ifdef TCP_HHOOK
|
||||
/* Run HHOOK_TCP_ESTABLISHED_OUT helper hooks. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user