From a923c8476c6771493ee2bc4f277a429c9ae3eaff Mon Sep 17 00:00:00 2001 From: florian Date: Wed, 28 Oct 2015 12:14:25 +0000 Subject: [PATCH] Remove linkmtu and maxmtu from struct nd_ifinfo. IN6_LINKMTU can now die and ifp->if_mtu is the one true mtu. Suggested by and OK mpi@ --- sys/net/if.c | 16 +--------------- sys/netinet/tcp_input.c | 15 +++------------ sys/netinet6/icmp6.c | 4 ++-- sys/netinet6/ip6_forward.c | 14 +++++--------- sys/netinet6/ip6_mroute.c | 7 +++---- sys/netinet6/ip6_output.c | 34 ++++++--------------------------- sys/netinet6/nd6.c | 32 +------------------------------ sys/netinet6/nd6.h | 11 +---------- sys/netinet6/nd6_rtr.c | 39 +------------------------------------- usr.sbin/ndp/ndp.c | 5 ++--- 10 files changed, 25 insertions(+), 152 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index e433dcf9dba..3537e85245c 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.399 2015/10/27 10:52:17 mpi Exp $ */ +/* $OpenBSD: if.c,v 1.400 2015/10/28 12:14:25 florian Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -1734,26 +1734,12 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p) break; case SIOCSIFMTU: - { -#ifdef INET6 - int oldmtu = ifp->if_mtu; -#endif - if ((error = suser(p, 0)) != 0) return (error); if (ifp->if_ioctl == NULL) return (EOPNOTSUPP); error = (*ifp->if_ioctl)(ifp, cmd, data); - - /* - * If the link MTU changed, do network layer specific procedure. - */ -#ifdef INET6 - if (ifp->if_mtu != oldmtu) - nd6_setmtu(ifp); -#endif break; - } case SIOCSIFPHYADDR: case SIOCDIFPHYADDR: diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index a77cc639190..287a45a4881 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_input.c,v 1.306 2015/10/24 16:08:48 mpi Exp $ */ +/* $OpenBSD: tcp_input.c,v 1.307 2015/10/28 12:14:25 florian Exp $ */ /* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */ /* @@ -3045,22 +3045,13 @@ tcp_mss(struct tcpcb *tp, int offer) * for IPv6, path MTU discovery is always turned on, * or the node must use packet size <= 1280. */ - mss = IN6_LINKMTU(ifp) - iphlen - sizeof(struct tcphdr); + mss = ifp->if_mtu - iphlen - sizeof(struct tcphdr); } #endif /* INET6 */ /* Calculate the value that we offer in TCPOPT_MAXSEG */ if (offer != -1) { -#ifndef INET6 mssopt = ifp->if_mtu - iphlen - sizeof(struct tcphdr); -#else - if (tp->pf == AF_INET6) - mssopt = IN6_LINKMTU(ifp) - iphlen - - sizeof(struct tcphdr); - else - mssopt = ifp->if_mtu - iphlen - sizeof(struct tcphdr); -#endif - mssopt = max(tcp_mssdflt, mssopt); } @@ -3272,7 +3263,7 @@ tcp_mss_adv(struct mbuf *m, int af) #ifdef INET6 case AF_INET6: if (ifp != NULL) - mss = IN6_LINKMTU(ifp); + mss = ifp->if_mtu; iphlen = sizeof(struct ip6_hdr); break; #endif diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c index 4f7034cbb84..d87678240fa 100644 --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: icmp6.c,v 1.174 2015/10/22 15:37:47 bluhm Exp $ */ +/* $OpenBSD: icmp6.c,v 1.175 2015/10/28 12:14:25 florian Exp $ */ /* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */ /* @@ -1022,7 +1022,7 @@ icmp6_mtudisc_update(struct ip6ctlparam *ip6cp, int validated) if (rt && (rt->rt_flags & RTF_HOST) && !(rt->rt_rmx.rmx_locks & RTV_MTU) && (rt->rt_rmx.rmx_mtu > mtu || rt->rt_rmx.rmx_mtu == 0)) { - if (mtu < IN6_LINKMTU(rt->rt_ifp)) { + if (mtu < rt->rt_ifp->if_mtu) { icmp6stat.icp6s_pmtuchg++; rt->rt_rmx.rmx_mtu = mtu; } diff --git a/sys/netinet6/ip6_forward.c b/sys/netinet6/ip6_forward.c index d6a74dc2b01..6fc2bb250cc 100644 --- a/sys/netinet6/ip6_forward.c +++ b/sys/netinet6/ip6_forward.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_forward.c,v 1.84 2015/10/25 15:01:59 mpi Exp $ */ +/* $OpenBSD: ip6_forward.c,v 1.85 2015/10/28 12:14:25 florian Exp $ */ /* $KAME: ip6_forward.c,v 1.75 2001/06/29 12:42:13 jinmei Exp $ */ /* @@ -426,14 +426,10 @@ reroute: in6_proto_cksum_out(m, rt->rt_ifp); /* Check the size after pf_test to give pf a chance to refragment. */ - if (m->m_pkthdr.len > IN6_LINKMTU(rt->rt_ifp)) { - if (mcopy) { - u_long mtu; - - mtu = IN6_LINKMTU(rt->rt_ifp); - - icmp6_error(mcopy, ICMP6_PACKET_TOO_BIG, 0, mtu); - } + if (m->m_pkthdr.len > rt->rt_ifp->if_mtu) { + if (mcopy) + icmp6_error(mcopy, ICMP6_PACKET_TOO_BIG, 0, + rt->rt_ifp->if_mtu); m_freem(m); goto freert; } diff --git a/sys/netinet6/ip6_mroute.c b/sys/netinet6/ip6_mroute.c index 0474319fc53..22be5890e39 100644 --- a/sys/netinet6/ip6_mroute.c +++ b/sys/netinet6/ip6_mroute.c @@ -1512,7 +1512,6 @@ phyint_send6(struct ip6_hdr *ip6, struct mif6 *mifp, struct mbuf *m) static struct route_in6 ro; struct in6_multi *in6m; struct sockaddr_in6 *dst6; - u_long linkmtu; /* * Make a new reference to the packet; make sure that @@ -1572,8 +1571,7 @@ phyint_send6(struct ip6_hdr *ip6, struct mif6 *mifp, struct mbuf *m) * Put the packet into the sending queue of the outgoing interface * if it would fit in the MTU of the interface. */ - linkmtu = IN6_LINKMTU(ifp); - if (mb_copy->m_pkthdr.len <= linkmtu || linkmtu < IPV6_MMTU) { + if (mb_copy->m_pkthdr.len <= ifp->if_mtu || ifp->if_mtu < IPV6_MMTU) { dst6->sin6_len = sizeof(struct sockaddr_in6); dst6->sin6_family = AF_INET6; dst6->sin6_addr = ip6->ip6_dst; @@ -1590,7 +1588,8 @@ phyint_send6(struct ip6_hdr *ip6, struct mif6 *mifp, struct mbuf *m) #endif } else { if (ip6_mcast_pmtu) - icmp6_error(mb_copy, ICMP6_PACKET_TOO_BIG, 0, linkmtu); + icmp6_error(mb_copy, ICMP6_PACKET_TOO_BIG, 0, + ifp->if_mtu); else { #ifdef MRT6DEBUG char src[INET6_ADDRSTRLEN], dst[INET6_ADDRSTRLEN]; diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index 2fa1c68a4cd..eeac95d66a4 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_output.c,v 1.192 2015/10/25 14:43:06 florian Exp $ */ +/* $OpenBSD: ip6_output.c,v 1.193 2015/10/28 12:14:25 florian Exp $ */ /* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */ /* @@ -772,26 +772,7 @@ reroute: error = EMSGSIZE; goto bad; } - if (dontfrag && tlen > IN6_LINKMTU(ifp)) { /* case 2-b */ - /* - * Even if the DONTFRAG option is specified, we cannot send the - * packet when the data length is larger than the MTU of the - * outgoing interface. - * Notify the error by sending IPV6_PATHMTU ancillary data as - * well as returning an error code (the latter is not described - * in the API spec.) - */ -#if 0 - u_int32_t mtu32; - struct ip6ctlparam ip6cp; - - mtu32 = (u_int32_t)mtu; - bzero(&ip6cp, sizeof(ip6cp)); - ip6cp.ip6c_cmdarg = (void *)&mtu32; - pfctlinput2(PRC_MSGSIZE, sin6tosa(&ro_pmtu->ro_dst), - (void *)&ip6cp); -#endif - + if (dontfrag && tlen > ifp->if_mtu) { /* case 2-b */ error = EMSGSIZE; goto bad; } @@ -1161,14 +1142,11 @@ ip6_getpmtu(struct route_in6 *ro_pmtu, struct route_in6 *ro, } } if (ro_pmtu->ro_rt) { - u_int32_t ifmtu; - if (ifp == NULL) ifp = ro_pmtu->ro_rt->rt_ifp; - ifmtu = IN6_LINKMTU(ifp); mtu = ro_pmtu->ro_rt->rt_rmx.rmx_mtu; if (mtu == 0) - mtu = ifmtu; + mtu = ifp->if_mtu; else if (mtu < IPV6_MMTU) { /* * RFC2460 section 5, last paragraph: @@ -1180,7 +1158,7 @@ ip6_getpmtu(struct route_in6 *ro_pmtu, struct route_in6 *ro, */ alwaysfrag = 1; mtu = IPV6_MMTU; - } else if (mtu > ifmtu) { + } else if (mtu > ifp->if_mtu) { /* * The MTU on the route is larger than the MTU on * the interface! This shouldn't happen, unless the @@ -1189,12 +1167,12 @@ ip6_getpmtu(struct route_in6 *ro_pmtu, struct route_in6 *ro, * route to match the interface MTU (as long as the * field isn't locked). */ - mtu = ifmtu; + mtu = ifp->if_mtu; if (!(ro_pmtu->ro_rt->rt_rmx.rmx_locks & RTV_MTU)) ro_pmtu->ro_rt->rt_rmx.rmx_mtu = mtu; } } else if (ifp) { - mtu = IN6_LINKMTU(ifp); + mtu = ifp->if_mtu; } else error = EHOSTUNREACH; /* XXX */ diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index c065406742d..3507a125503 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6.c,v 1.163 2015/10/27 10:52:18 mpi Exp $ */ +/* $OpenBSD: nd6.c,v 1.164 2015/10/28 12:14:25 florian Exp $ */ /* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */ /* @@ -90,7 +90,6 @@ struct nd_prhead nd_prefix = { 0 }; int nd6_recalc_reachtm_interval = ND6_RECALC_REACHTM_INTERVAL; -void nd6_setmtu0(struct ifnet *, struct nd_ifinfo *); void nd6_slowtimo(void *); struct llinfo_nd6 *nd6_free(struct rtentry *, int); void nd6_llinfo_timer(void *); @@ -153,9 +152,6 @@ nd6_ifattach(struct ifnet *ifp) /* per-interface IFXF_AUTOCONF6 needs to be set too to accept RAs */ nd->flags = (ND6_IFF_PERFORMNUD | ND6_IFF_ACCEPT_RTADV); - /* XXX: we cannot call nd6_setmtu since ifp is not fully initialized */ - nd6_setmtu0(ifp, nd); - return nd; } @@ -166,32 +162,6 @@ nd6_ifdetach(struct nd_ifinfo *nd) free(nd, M_IP6NDP, 0); } -void -nd6_setmtu(struct ifnet *ifp) -{ - nd6_setmtu0(ifp, ND_IFINFO(ifp)); -} - -void -nd6_setmtu0(struct ifnet *ifp, struct nd_ifinfo *ndi) -{ - u_int32_t omaxmtu; - - omaxmtu = ndi->maxmtu; - ndi->maxmtu = ifp->if_mtu; - - /* - * Decreasing the interface MTU under IPV6 minimum MTU may cause - * undesirable situation. We thus notify the operator of the change - * explicitly. The check for omaxmtu is necessary to restrict the - * log to the case of changing the MTU, not initializing it. - */ - if (omaxmtu >= IPV6_MMTU && ndi->maxmtu < IPV6_MMTU) { - log(LOG_NOTICE, "%s: link MTU on %s (%lu) too small for IPv6\n", - __func__, ifp->if_xname, (unsigned long)ndi->maxmtu); - } -} - void nd6_option_init(void *opt, int icmp6len, union nd_opts *ndopts) { diff --git a/sys/netinet6/nd6.h b/sys/netinet6/nd6.h index 03ad2db22af..6ecd4dcb24d 100644 --- a/sys/netinet6/nd6.h +++ b/sys/netinet6/nd6.h @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6.h,v 1.51 2015/10/25 11:58:11 mpi Exp $ */ +/* $OpenBSD: nd6.h,v 1.52 2015/10/28 12:14:25 florian Exp $ */ /* $KAME: nd6.h,v 1.95 2002/06/08 11:31:06 itojun Exp $ */ /* @@ -49,8 +49,6 @@ #define ND6_LLINFO_PROBE 4 struct nd_ifinfo { - u_int32_t linkmtu; /* LinkMTU */ - u_int32_t maxmtu; /* Upper bound of LinkMTU */ u_int32_t basereachable; /* BaseReachableTime */ u_int32_t reachable; /* Reachable Time */ u_int32_t retrans; /* Retrans Timer */ @@ -136,13 +134,6 @@ struct in6_ndifreq { #define RS_LHCOOKIE(ifp) \ ((struct in6_ifextra *)(ifp)->if_afdata[AF_INET6])->rs_lhcookie -#define IN6_LINKMTU(ifp) \ - ((ND_IFINFO(ifp)->linkmtu && ND_IFINFO(ifp)->linkmtu < (ifp)->if_mtu) \ - ? ND_IFINFO(ifp)->linkmtu \ - : ((ND_IFINFO(ifp)->maxmtu && ND_IFINFO(ifp)->maxmtu < (ifp)->if_mtu) \ - ? ND_IFINFO(ifp)->maxmtu : (ifp)->if_mtu)) - - struct llinfo_nd6 { struct llinfo_nd6 *ln_next; struct llinfo_nd6 *ln_prev; diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c index d13f7a01526..e5533a513e7 100644 --- a/sys/netinet6/nd6_rtr.c +++ b/sys/netinet6/nd6_rtr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6_rtr.c,v 1.129 2015/10/25 21:32:16 florian Exp $ */ +/* $OpenBSD: nd6_rtr.c,v 1.130 2015/10/28 12:14:25 florian Exp $ */ /* $KAME: nd6_rtr.c,v 1.97 2001/02/07 11:09:13 itojun Exp $ */ /* @@ -528,43 +528,6 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len) } } - /* - * MTU - */ - if (ndopts.nd_opts_mtu && ndopts.nd_opts_mtu->nd_opt_mtu_len == 1) { - u_long mtu; - u_long maxmtu; - - mtu = ntohl(ndopts.nd_opts_mtu->nd_opt_mtu_mtu); - - /* lower bound */ - if (mtu < IPV6_MMTU) { - nd6log((LOG_INFO, "nd6_ra_input: bogus mtu option " - "mtu=%lu sent from %s, ignoring\n", - mtu, - inet_ntop(AF_INET6, &ip6->ip6_src, - src, sizeof(src)))); - goto skip; - } - - /* upper bound */ - maxmtu = (ndi->maxmtu && ndi->maxmtu < ifp->if_mtu) - ? ndi->maxmtu : ifp->if_mtu; - if (mtu <= maxmtu) { - ndi->linkmtu = mtu; - } else { - nd6log((LOG_INFO, "nd6_ra_input: bogus mtu " - "mtu=%lu sent from %s; " - "exceeds maxmtu %lu, ignoring\n", - mtu, - inet_ntop(AF_INET6, &ip6->ip6_src, - src, sizeof(src)), - maxmtu)); - } - } - - skip: - /* * Source link layer address */ diff --git a/usr.sbin/ndp/ndp.c b/usr.sbin/ndp/ndp.c index 288d6f10fc1..d14dd41c67a 100644 --- a/usr.sbin/ndp/ndp.c +++ b/usr.sbin/ndp/ndp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ndp.c,v 1.66 2015/10/25 11:44:30 deraadt Exp $ */ +/* $OpenBSD: ndp.c,v 1.67 2015/10/28 12:14:25 florian Exp $ */ /* $KAME: ndp.c,v 1.101 2002/07/17 08:46:33 itojun Exp $ */ /* @@ -966,8 +966,7 @@ ifinfo(char *ifname, int argc, char **argv) /* NOTREACHED */ } - printf("linkmtu=%d", ND.linkmtu); - printf(", basereachable=%ds%dms", + printf("basereachable=%ds%dms", ND.basereachable / 1000, ND.basereachable % 1000); printf(", reachable=%ds", ND.reachable); printf(", retrans=%ds%dms", ND.retrans / 1000, ND.retrans % 1000); -- 2.20.1