summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2000-03-21 23:31:28 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2000-03-21 23:31:28 +0000
commit01e49275e22f2613d4f14b83996403c02d3b2b7b (patch)
tree94649eb2bd557a632b33fdbefd1b8b07ae4f2f28 /sys/net
parent51e702ed655a3cf3dc83d34c06005da09e639698 (diff)
add SIOCGIFMTU/SIOCSIFMTU; remediate redundant code of tun, ppp, sppp; chris@ ok
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if.c28
-rw-r--r--sys/net/if.h3
-rw-r--r--sys/net/if_ppp.c9
-rw-r--r--sys/net/if_ppp.h6
-rw-r--r--sys/net/if_tun.c13
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: