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 <kml@nas.nasa.gov>
This commit is contained in:
Bill Fenner 1998-05-24 18:41:04 +00:00
parent 0b9f580d2c
commit a04884fcbe

@ -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 <stddef.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/mbuf.h>
@ -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;
}