From e52c654ee229f069ca2d720167cb753d60fac19b Mon Sep 17 00:00:00 2001 From: wollman Date: Mon, 16 Oct 1995 18:21:26 +0000 Subject: [PATCH] The ability to administratively change the MTU of an interface presents a few new wrinkles for MTU discovery which tcp_output() had better be prepared to handle. ip_output() is also modified to do something helpful in this case, since it has already calculated the information we need. --- sys/netinet/ip_output.c | 16 +++++++++++++++- sys/netinet/tcp_output.c | 14 +++++++++++++- sys/netinet/tcp_subr.c | 8 ++------ sys/netinet/tcp_timewait.c | 8 ++------ sys/netinet/tcp_var.h | 5 ++++- 5 files changed, 36 insertions(+), 15 deletions(-) diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 83e7382bc363..d536a8329023 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ip_output.c 8.3 (Berkeley) 1/21/94 - * $Id: ip_output.c,v 1.22 1995/07/02 16:45:07 joerg Exp $ + * $Id: ip_output.c,v 1.23 1995/07/26 18:05:13 wollman Exp $ */ #include @@ -331,6 +331,20 @@ sendit: */ if (ip->ip_off & IP_DF) { error = EMSGSIZE; +#ifdef MTUDISC + /* + * This case can happen if the user changed the MTU + * of an interface after enabling IP on it. Because + * most netifs don't keep track of routes pointing to + * them, there is no way for one to update all its + * routes when the MTU is changed. + */ + if ((ro->ro_rt->rt_flags & (RTF_UP | RTF_HOST)) + && !(ro->ro_rt->rt_rmx.rmx_locks & RTV_MTU) + && (ro->ro_rt->rt_rmx.rmx_mtu > ifp->if_mtu)) { + ro->ro_rt->rt_rmx.rmx_mtu = ifp->if_mtu; + } +#endif /* MTUDISC */ ipstat.ips_cantfrag++; goto bad; } diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index b14d645fbb18..9afaf97b6af6 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)tcp_output.c 8.4 (Berkeley) 5/24/95 - * $Id: tcp_output.c,v 1.13 1995/09/20 21:00:58 wollman Exp $ + * $Id: tcp_output.c,v 1.14 1995/09/22 20:05:58 wollman Exp $ */ #include @@ -689,6 +689,18 @@ out: tcp_quench(tp->t_inpcb, 0); return (0); } +#ifdef MTUDISC + if (error == EMSGSIZE) { + /* + * ip_output() will have already fixed the route + * for us. tcp_mtudisc() will, as its last action, + * initiate retransmission, so it is important to + * not do so here. + */ + tcp_mtudisc(tp->t_inpcb, 0); + return 0; + } +#endif /* MTUDISC */. if ((error == EHOSTUNREACH || error == ENETDOWN) && TCPS_HAVERCVDSYN(tp->t_state)) { tp->t_softerror = error; diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 404208399745..b0b75b8ee696 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)tcp_subr.c 8.2 (Berkeley) 5/24/95 - * $Id: tcp_subr.c,v 1.18 1995/10/10 17:45:40 wollman Exp $ + * $Id: tcp_subr.c,v 1.19 1995/10/12 17:37:24 wollman Exp $ */ #include @@ -429,10 +429,6 @@ tcp_notify(inp, error) sowwakeup(so); } -#ifdef MTUDISC -static void tcp_mtudisc __P((struct inpcb *, int)); -#endif /* MTUDISC */ - void tcp_ctlinput(cmd, sa, ip) int cmd; @@ -481,7 +477,7 @@ tcp_quench(inp, errno) * since we know the packet we just sent was dropped. * This duplicates some code in the tcp_mss() function in tcp_input.c. */ -static void +void tcp_mtudisc(inp, errno) struct inpcb *inp; int errno; diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c index 404208399745..b0b75b8ee696 100644 --- a/sys/netinet/tcp_timewait.c +++ b/sys/netinet/tcp_timewait.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)tcp_subr.c 8.2 (Berkeley) 5/24/95 - * $Id: tcp_subr.c,v 1.18 1995/10/10 17:45:40 wollman Exp $ + * $Id: tcp_subr.c,v 1.19 1995/10/12 17:37:24 wollman Exp $ */ #include @@ -429,10 +429,6 @@ tcp_notify(inp, error) sowwakeup(so); } -#ifdef MTUDISC -static void tcp_mtudisc __P((struct inpcb *, int)); -#endif /* MTUDISC */ - void tcp_ctlinput(cmd, sa, ip) int cmd; @@ -481,7 +477,7 @@ tcp_quench(inp, errno) * since we know the packet we just sent was dropped. * This duplicates some code in the tcp_mss() function in tcp_input.c. */ -static void +void tcp_mtudisc(inp, errno) struct inpcb *inp; int errno; diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index b2703ae2c955..0a1ce277ac60 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)tcp_var.h 8.4 (Berkeley) 5/24/95 - * $Id: tcp_var.h,v 1.19 1995/10/10 17:45:43 wollman Exp $ + * $Id: tcp_var.h,v 1.20 1995/10/12 17:37:25 wollman Exp $ */ #ifndef _NETINET_TCP_VAR_H_ @@ -349,6 +349,9 @@ void tcp_init __P((void)); void tcp_input __P((struct mbuf *, int)); void tcp_mss __P((struct tcpcb *, int)); int tcp_mssopt __P((struct tcpcb *)); +#ifdef MTUDISC +void tcp_mtudisc __P((struct inpcb *, int)); +#endif /* MTUDISC */ struct tcpcb * tcp_newtcpcb __P((struct inpcb *)); void tcp_notify __P((struct inpcb *, int));