From 757e9ec26720e43c8b9c56db2aae73a9f8a37a09 Mon Sep 17 00:00:00 2001 From: andre Date: Wed, 4 May 2005 13:48:44 +0000 Subject: If we don't get a suggested MTU during path MTU discovery look up the packet size of the packet that generated the response, step down the MTU by one step through ip_next_mtu() and try again. Suggested by: dwmalone --- sys/netinet/tcp_timewait.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'sys/netinet/tcp_timewait.c') diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c index 25a9266..bde7f09 100644 --- a/sys/netinet/tcp_timewait.c +++ b/sys/netinet/tcp_timewait.c @@ -1168,22 +1168,33 @@ tcp_ctlinput(cmd, sa, vip) * If we got a needfrag set the MTU * in the route to the suggested new * value (if given) and then notify. - * If no new MTU was suggested, then - * we guess a new one less than the - * current value. - * If the new MTU is unreasonably - * small (defined by sysctl tcp_minmss), - * then we up the MTU value to minimum. */ bzero(&inc, sizeof(inc)); inc.inc_flags = 0; /* IPv4 */ inc.inc_faddr = faddr; mtu = ntohs(icp->icmp_nextmtu); + /* + * If no alternative MTU was + * proposed, try the next smaller + * one. + */ + if (!mtu) + mtu = ip_next_mtu(ntohs(ip->ip_len), + 1); + if (mtu < max(296, (tcp_minmss) + + sizeof(struct tcpiphdr))) + mtu = 0; if (!mtu) - mtu = ip_next_mtu(mtu, 1); - if (mtu >= max(296, (tcp_minmss - + sizeof(struct tcpiphdr)))) + mtu = tcp_mssdflt + + sizeof(struct tcpiphdr); + /* + * Only cache the the MTU if it + * is smaller than the interface + * or route MTU. tcp_mtudisc() + * will do right thing by itself. + */ + if (mtu <= tcp_maxmtu(&inc)) tcp_hc_updatemtu(&inc, mtu); } -- cgit v1.1