From 2b05c21ecbe0259a11de9c596310489139d75639 Mon Sep 17 00:00:00 2001 From: mickey Date: Tue, 21 Mar 2000 23:31:26 +0000 Subject: [PATCH] add SIOCGIFMTU/SIOCSIFMTU; remediate redundant code of tun, ppp, sppp; chris@ ok --- sys/net/if.c | 28 +++++++++++++++++++++++++++- sys/net/if.h | 3 ++- sys/net/if_ppp.c | 9 +-------- sys/net/if_ppp.h | 6 +----- sys/net/if_tun.c | 13 ++----------- 5 files changed, 33 insertions(+), 26 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index 9109dcbedb6..f1e8c498d04 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.28 2000/03/12 03:54:43 itojun Exp $ */ +/* $OpenBSD: if.c,v 1.29 2000/03/21 23:31:26 mickey Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -697,6 +697,10 @@ ifioctl(so, cmd, data, p) ifr->ifr_metric = ifp->if_metric; break; + case SIOCGIFMTU: + ifr->ifr_mtu = ifp->if_mtu; + break; + case SIOCGIFDATA: error = copyout((caddr_t)&ifp->if_data, ifr->ifr_data, sizeof(ifp->if_data)); @@ -727,6 +731,28 @@ ifioctl(so, cmd, data, p) ifp->if_metric = ifr->ifr_metric; break; + case SIOCSIFMTU: + { +#ifdef INET6 + int oldmtu = ifp->if_mtu; +#endif + + if ((error = suser(p->p_ucred, &p->p_acflag)) != 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 SIOCADDMULTI: case SIOCDELMULTI: case SIOCSIFMEDIA: diff --git a/sys/net/if.h b/sys/net/if.h index 422b48dae05..9aac27e49e8 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if.h,v 1.15 2000/02/02 17:14:36 itojun Exp $ */ +/* $OpenBSD: if.h,v 1.16 2000/03/21 23:31:26 mickey Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -308,6 +308,7 @@ struct ifreq { #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ #define ifr_flags ifr_ifru.ifru_flags /* flags */ #define ifr_metric ifr_ifru.ifru_metric /* metric */ +#define ifr_mtu ifr_ifru.ifru_metric /* mtu (overload) */ #define ifr_media ifr_ifru.ifru_metric /* media options (overload) */ #define ifr_data ifr_ifru.ifru_data /* for use by interface */ }; diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c index 32d2aa9debf..46541d79576 100644 --- a/sys/net/if_ppp.c +++ b/sys/net/if_ppp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ppp.c,v 1.15 1999/12/08 06:50:18 itojun Exp $ */ +/* $OpenBSD: if_ppp.c,v 1.16 2000/03/21 23:31:27 mickey Exp $ */ /* $NetBSD: if_ppp.c,v 1.39 1997/05/17 21:11:59 christos Exp $ */ /* @@ -537,7 +537,6 @@ pppsioctl(ifp, cmd, data) u_long cmd; caddr_t data; { - register struct proc *p = curproc; /* XXX */ register struct ppp_softc *sc = ifp->if_softc; register struct ifaddr *ifa = (struct ifaddr *)data; register struct ifreq *ifr = (struct ifreq *)data; @@ -564,15 +563,9 @@ pppsioctl(ifp, cmd, data) break; case SIOCSIFMTU: - if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) - break; sc->sc_if.if_mtu = ifr->ifr_mtu; break; - case SIOCGIFMTU: - ifr->ifr_mtu = sc->sc_if.if_mtu; - break; - case SIOCADDMULTI: case SIOCDELMULTI: if (ifr == 0) { diff --git a/sys/net/if_ppp.h b/sys/net/if_ppp.h index 00eef54d77b..e4a4c6afdf0 100644 --- a/sys/net/if_ppp.h +++ b/sys/net/if_ppp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ppp.h,v 1.4 1997/09/05 04:26:59 millert Exp $ */ +/* $OpenBSD: if_ppp.h,v 1.5 2000/03/21 23:31:27 mickey Exp $ */ /* $NetBSD: if_ppp.h,v 1.11 1996/03/15 02:28:05 paulus Exp $ */ /* @@ -126,10 +126,6 @@ struct ifpppcstatsreq { #define SIOCGPPPSTATS _IOWR('i', 123, struct ifpppstatsreq) #define SIOCGPPPCSTATS _IOWR('i', 122, struct ifpppcstatsreq) -#if !defined(ifr_mtu) -#define ifr_mtu ifr_ifru.ifru_metric -#endif - #ifdef _KERNEL void pppattach __P((void)); int pppoutput __P((struct ifnet *, struct mbuf *, struct sockaddr *, diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index 05d51acf141..8e0984d2974 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tun.c,v 1.28 1999/12/08 06:50:18 itojun Exp $ */ +/* $OpenBSD: if_tun.c,v 1.29 2000/03/21 23:31:27 mickey Exp $ */ /* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */ /* @@ -306,18 +306,9 @@ tun_ioctl(ifp, cmd, data) tuninit((struct tun_softc *)(ifp->if_softc)); TUNDEBUG(("%s: broadcast address set\n", ifp->if_xname)); break; -#if 0 case SIOCSIFMTU: - if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) - break; - ((struct tun_softc *)(ifp->if_softc))->tun_if.if_mtu - = ((struct ifreq *)data)->ifr_mtu; - break; - case SIOCGIFMTU: - ((struct ifreq *)data)->ifr_mtu = - ((struct tun_softc *)(ifp->if_softc))->tun_if.if_mtu; + ifp->if_mtu = ((struct ifreq *)data)->ifr_mtu; break; -#endif case SIOCSIFFLAGS: break; default: -- 2.20.1