From a04884fcbe76e75472e2001ee980ce11b6d18dd3 Mon Sep 17 00:00:00 2001 From: Bill Fenner Date: Sun, 24 May 1998 18:41:04 +0000 Subject: [PATCH] Take IP options into account when calculating the allowable length of the TCP payload. See RFC1122 section 4.2.2.6 . This allows Path MTU discovery to be used along with IP options. PR: problem discovered by Kevin Lahey --- sys/netinet/tcp_output.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index cb7498ab0f7..1f067a9c71b 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -31,11 +31,13 @@ * SUCH DAMAGE. * * @(#)tcp_output.c 8.4 (Berkeley) 5/24/95 - * $Id: tcp_output.c,v 1.28 1998/02/20 13:37:39 bde Exp $ + * $Id: tcp_output.c,v 1.29 1998/04/06 06:52:44 phk Exp $ */ #include "opt_tcpdebug.h" +#include + #include #include #include @@ -79,7 +81,7 @@ tcp_output(tp) register struct mbuf *m; register struct tcpiphdr *ti; u_char opt[TCP_MAXOLEN]; - unsigned optlen, hdrlen; + unsigned ipoptlen, optlen, hdrlen; int idle, sendalot; struct rmxp_tao *taop; struct rmxp_tao tao_noncached; @@ -433,18 +435,25 @@ send: hdrlen += optlen; + if (tp->t_inpcb->inp_options) { + ipoptlen = tp->t_inpcb->inp_options->m_len - + offsetof(struct ipoption, ipopt_list); + } else { + ipoptlen = 0; + } + /* * Adjust data length if insertion of options will * bump the packet length beyond the t_maxopd length. * Clear the FIN bit because we cut off the tail of * the segment. */ - if (len + optlen > tp->t_maxopd) { + if (len + optlen + ipoptlen > tp->t_maxopd) { /* * If there is still more to send, don't close the connection. */ flags &= ~TH_FIN; - len = tp->t_maxopd - optlen; + len = tp->t_maxopd - optlen - ipoptlen; sendalot = 1; }