diff --git a/sys/altq/altq_afmap.c b/sys/altq/altq_afmap.c index 14be09a0316b..43d023fa66ba 100644 --- a/sys/altq/altq_afmap.c +++ b/sys/altq/altq_afmap.c @@ -1,4 +1,4 @@ -/* $NetBSD: altq_afmap.c,v 1.18 2007/03/04 05:59:00 christos Exp $ */ +/* $NetBSD: altq_afmap.c,v 1.19 2008/11/07 00:20:01 dyoung Exp $ */ /* $KAME: altq_afmap.c,v 1.12 2005/04/13 03:44:24 suz Exp $ */ /* @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: altq_afmap.c,v 1.18 2007/03/04 05:59:00 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: altq_afmap.c,v 1.19 2008/11/07 00:20:01 dyoung Exp $"); #ifdef _KERNEL_OPT #include "opt_altq.h" @@ -371,8 +371,7 @@ afmioctl(dev_t dev, ioctlcmd_t cmd, void *addr, int flag, flowmap = (struct atm_flowmap *)addr; flowmap->af_ifname[IFNAMSIZ-1] = '\0'; ifp = ifunit(flowmap->af_ifname); - if (ifp == NULL || ifp->if_ioctl == NULL || - (ifp->if_flags & IFF_RUNNING) == 0) + if (ifp == NULL || (ifp->if_flags & IFF_RUNNING) == 0) error = ENXIO; else error = ifp->if_ioctl(ifp, cmd, addr); diff --git a/sys/arch/acorn32/podulebus/if_ie.c b/sys/arch/acorn32/podulebus/if_ie.c index 75cdad94e9c3..415f8f419983 100644 --- a/sys/arch/acorn32/podulebus/if_ie.c +++ b/sys/arch/acorn32/podulebus/if_ie.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ie.c,v 1.19 2007/10/17 19:52:54 garbled Exp $ */ +/* $NetBSD: if_ie.c,v 1.20 2008/11/07 00:20:01 dyoung Exp $ */ /* * Copyright (c) 1995 Melvin Tang-Richardson. @@ -53,7 +53,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ie.c,v 1.19 2007/10/17 19:52:54 garbled Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ie.c,v 1.20 2008/11/07 00:20:01 dyoung Exp $"); #define IGNORE_ETHER1_IDROM_CHECKSUM @@ -614,14 +614,10 @@ iezero(sc, p, size) */ int -ieioctl(ifp, cmd, data) - struct ifnet *ifp; - u_long cmd; - void *data; +ieioctl(struct ifnet *ifp, unsigned long cmd, void *data) { struct ie_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; -/* struct ifreq *ifr = (struct ifreq *)data;*/ int s; int error=0; @@ -629,9 +625,9 @@ ieioctl(ifp, cmd, data) switch ( cmd ) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; - switch ( ifa->ifa_addr->sa_family ) { + switch (ifa->ifa_addr->sa_family ) { #ifdef INET case AF_INET: ieinit(sc); @@ -650,6 +646,8 @@ ieioctl(ifp, cmd, data) #define DOCLR(a,b) (a->if_flags&=~b) case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + return error; sc->promisc = ifp->if_flags & ( IFF_PROMISC | IFF_ALLMULTI ); if ( IZCLR(ifp,IFF_UP) && IZSET(ifp,IFF_RUNNING) ) @@ -671,7 +669,8 @@ ieioctl(ifp, cmd, data) } default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); + break; } (void)splx(s); return error; diff --git a/sys/arch/alpha/a12/if_ade.c b/sys/arch/alpha/a12/if_ade.c index 4d3803a1eab9..145f950ecaaa 100644 --- a/sys/arch/alpha/a12/if_ade.c +++ b/sys/arch/alpha/a12/if_ade.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ade.c,v 1.33 2008/03/24 12:24:37 yamt Exp $ */ +/* $NetBSD: if_ade.c,v 1.34 2008/11/07 00:20:01 dyoung Exp $ */ /* * NOTE: this version of if_de was modified for bounce buffers prior @@ -81,7 +81,7 @@ #define LCLDMA 1 #include -__KERNEL_RCSID(0, "$NetBSD: if_ade.c,v 1.33 2008/03/24 12:24:37 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ade.c,v 1.34 2008/11/07 00:20:01 dyoung Exp $"); #include "opt_inet.h" #include "opt_ns.h" @@ -3943,7 +3943,7 @@ tulip_ifioctl( s = TULIP_RAISESPL(); #endif switch (cmd) { - case SIOCSIFADDR: { + case SIOCINITIFADDR: { ifp->if_flags |= IFF_UP; switch(ifa->ifa_addr->sa_family) { #ifdef INET @@ -3982,13 +3982,9 @@ tulip_ifioctl( } break; } - case SIOCGIFADDR: { - memcpy((void *) ((struct sockaddr *)&ifr->ifr_data)->sa_data, - (void *) sc->tulip_enaddr, 6); - break; - } - case SIOCSIFFLAGS: { + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; tulip_init(sc); break; } @@ -4056,7 +4052,7 @@ tulip_ifioctl( } #endif default: { - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); break; } } diff --git a/sys/arch/alpha/a12/if_xb.c b/sys/arch/alpha/a12/if_xb.c index 6a5aab173444..e914a6f04bbc 100644 --- a/sys/arch/alpha/a12/if_xb.c +++ b/sys/arch/alpha/a12/if_xb.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_xb.c,v 1.18 2007/10/17 19:52:54 garbled Exp $ */ +/* $NetBSD: if_xb.c,v 1.19 2008/11/07 00:20:01 dyoung Exp $ */ /* [Notice revision 2.2] * Copyright (c) 1997, 1998 Avalon Computer Systems, Inc. @@ -74,7 +74,7 @@ #include "opt_avalon_a12.h" /* Config options headers */ #include /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: if_xb.c,v 1.18 2007/10/17 19:52:54 garbled Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_xb.c,v 1.19 2008/11/07 00:20:01 dyoung Exp $"); #include #include @@ -231,7 +231,7 @@ xbattach(parent, self, aux) xbfound = 1; ccp = &xb_configuration; xb_init_config(ccp, 1); - printf(": driver %s mtu %lu\n", "$Revision: 1.18 $", xbi.if_mtu); + printf(": driver %s mtu %lu\n", "$Revision: 1.19 $", xbi.if_mtu); } static void @@ -419,29 +419,20 @@ xb_stop() } static int -xb_ioctl(ifp, cmd, data) - struct ifnet *ifp; - u_long cmd; - void *data; +xb_ioctl(struct ifnet *ifp, unsigned long cmd, void *data) { struct ifaddr *ifa = (struct ifaddr *)data; int s, error = 0; s = splnet(); switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: xbi.if_flags |= IFF_UP; - switch (ifa->ifa_addr->sa_family) { -#ifdef INET - case AF_INET: - xb_init(ifp); - break; -#endif - default: - xb_init(ifp); - } + xb_init(ifp); break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; if ((ifp->if_flags & IFF_UP) == 0 && (ifp->if_flags & IFF_RUNNING) != 0) { xb_stop(); @@ -455,7 +446,7 @@ xb_ioctl(ifp, cmd, data) xb_debug = 1; break; default: - error = EINVAL; + error = ifioctl_common(ifp, cmd, data); break; } splx(s); diff --git a/sys/arch/amiga/dev/if_ed.c b/sys/arch/amiga/dev/if_ed.c index 9115377bc51b..1a03ec52b298 100644 --- a/sys/arch/amiga/dev/if_ed.c +++ b/sys/arch/amiga/dev/if_ed.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ed.c,v 1.55 2007/10/17 19:53:16 garbled Exp $ */ +/* $NetBSD: if_ed.c,v 1.56 2008/11/07 00:20:01 dyoung Exp $ */ /* * Device driver for National Semiconductor DS8390/WD83C690 based ethernet @@ -19,7 +19,7 @@ #include "opt_ns.h" #include -__KERNEL_RCSID(0, "$NetBSD: if_ed.c,v 1.55 2007/10/17 19:53:16 garbled Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ed.c,v 1.56 2008/11/07 00:20:01 dyoung Exp $"); #include "bpfilter.h" @@ -865,7 +865,7 @@ ed_ioctl(register struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; switch (ifa->ifa_addr->sa_family) { @@ -899,6 +899,11 @@ ed_ioctl(register struct ifnet *ifp, u_long cmd, void *data) break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + /* XXX if ed_init() would ed_stop(, 0), first, perhaps we + * can re-use the code in ether_ioctl(). + */ if ((ifp->if_flags & IFF_UP) == 0 && (ifp->if_flags & IFF_RUNNING) != 0) { /* @@ -941,7 +946,8 @@ ed_ioctl(register struct ifnet *ifp, u_long cmd, void *data) break; default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); + break; } splx(s); diff --git a/sys/arch/amiga/dev/if_es.c b/sys/arch/amiga/dev/if_es.c index f0758f14e973..0d110abef8ed 100644 --- a/sys/arch/amiga/dev/if_es.c +++ b/sys/arch/amiga/dev/if_es.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_es.c,v 1.42 2007/10/17 19:53:16 garbled Exp $ */ +/* $NetBSD: if_es.c,v 1.43 2008/11/07 00:20:01 dyoung Exp $ */ /* * Copyright (c) 1995 Michael L. Hitch @@ -38,7 +38,7 @@ #include "opt_ns.h" #include -__KERNEL_RCSID(0, "$NetBSD: if_es.c,v 1.42 2007/10/17 19:53:16 garbled Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_es.c,v 1.43 2008/11/07 00:20:01 dyoung Exp $"); #include "bpfilter.h" @@ -961,7 +961,7 @@ esstart(struct ifnet *ifp) } int -esioctl(register struct ifnet *ifp, u_long cmd, void *data) +esioctl(struct ifnet *ifp, u_long cmd, void *data) { struct es_softc *sc = ifp->if_softc; register struct ifaddr *ifa = (struct ifaddr *)data; @@ -972,7 +972,7 @@ esioctl(register struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; switch (ifa->ifa_addr->sa_family) { @@ -1005,6 +1005,9 @@ esioctl(register struct ifnet *ifp, u_long cmd, void *data) break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + /* XXX see the comment in ed_ioctl() about code re-use */ /* * If interface is marked down and it is running, then stop it */ @@ -1059,7 +1062,8 @@ esioctl(register struct ifnet *ifp, u_long cmd, void *data) break; default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); + break; } splx(s); diff --git a/sys/arch/amiga/dev/if_qn.c b/sys/arch/amiga/dev/if_qn.c index f4d2df9d81bb..885e17c9f064 100644 --- a/sys/arch/amiga/dev/if_qn.c +++ b/sys/arch/amiga/dev/if_qn.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_qn.c,v 1.31 2007/10/17 19:53:16 garbled Exp $ */ +/* $NetBSD: if_qn.c,v 1.32 2008/11/07 00:20:01 dyoung Exp $ */ /* * Copyright (c) 1995 Mika Kortelainen @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_qn.c,v 1.31 2007/10/17 19:53:16 garbled Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_qn.c,v 1.32 2008/11/07 00:20:01 dyoung Exp $"); #include "qn.h" #if NQN > 0 @@ -830,7 +830,7 @@ qnioctl(register struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; switch (ifa->ifa_addr->sa_family) { @@ -866,6 +866,9 @@ qnioctl(register struct ifnet *ifp, u_long cmd, void *data) break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + /* XXX see the comment in ed_ioctl() about code re-use */ if ((ifp->if_flags & IFF_UP) == 0 && (ifp->if_flags & IFF_RUNNING) != 0) { /* @@ -913,8 +916,7 @@ qnioctl(register struct ifnet *ifp, u_long cmd, void *data) break; default: - log(LOG_INFO, "qnioctl: default\n"); - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); } splx(s); diff --git a/sys/arch/mac68k/dev/if_mc.c b/sys/arch/mac68k/dev/if_mc.c index 55ca50e49477..61455560ab12 100644 --- a/sys/arch/mac68k/dev/if_mc.c +++ b/sys/arch/mac68k/dev/if_mc.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_mc.c,v 1.34 2007/10/17 19:55:13 garbled Exp $ */ +/* $NetBSD: if_mc.c,v 1.35 2008/11/07 00:20:01 dyoung Exp $ */ /*- * Copyright (c) 1997 David Huang @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.34 2007/10/17 19:55:13 garbled Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.35 2008/11/07 00:20:01 dyoung Exp $"); #include "opt_ddb.h" #include "opt_inet.h" @@ -178,23 +178,25 @@ mcioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifa = (struct ifaddr *)data; ifp->if_flags |= IFF_UP; + mcinit(sc); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: - mcinit(sc); arp_ifinit(ifp, ifa); break; #endif default: - mcinit(sc); break; } break; case SIOCSIFFLAGS: + if ((err = ifioctl_common(ifp, cmd, data)) != 0) + break; + /* XXX see the comment in ed_ioctl() about code re-use */ if ((ifp->if_flags & IFF_UP) == 0 && (ifp->if_flags & IFF_RUNNING) != 0) { /* @@ -233,7 +235,7 @@ mcioctl(struct ifnet *ifp, u_long cmd, void *data) } break; default: - err = EINVAL; + err = ether_ioctl(ifp, cmd, data); } splx(s); return (err); diff --git a/sys/arch/mac68k/nubus/if_netdock_nubus.c b/sys/arch/mac68k/nubus/if_netdock_nubus.c index a60b0591ddda..c6964cc1cb0d 100644 --- a/sys/arch/mac68k/nubus/if_netdock_nubus.c +++ b/sys/arch/mac68k/nubus/if_netdock_nubus.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_netdock_nubus.c,v 1.18 2008/04/04 09:49:33 hauke Exp $ */ +/* $NetBSD: if_netdock_nubus.c,v 1.19 2008/11/07 00:20:02 dyoung Exp $ */ /* * Copyright (C) 2000,2002 Daishi Kato @@ -43,7 +43,7 @@ /***********************/ #include -__KERNEL_RCSID(0, "$NetBSD: if_netdock_nubus.c,v 1.18 2008/04/04 09:49:33 hauke Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_netdock_nubus.c,v 1.19 2008/11/07 00:20:02 dyoung Exp $"); #include #include @@ -383,23 +383,25 @@ netdock_ioctl(struct ifnet *ifp, u_long cmd, void *data) int temp; switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifa = (struct ifaddr *)data; ifp->if_flags |= IFF_UP; + (void)netdock_init(sc); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: - (void)netdock_init(sc); arp_ifinit(ifp, ifa); break; #endif default: - (void)netdock_init(sc); break; } break; case SIOCSIFFLAGS: + if ((err = ifioctl_common(ifp, cmd, data)) != 0) + break; + /* XXX see the comment in ed_ioctl() about code re-use */ if ((ifp->if_flags & IFF_UP) == 0 && (ifp->if_flags & IFF_RUNNING) != 0) { netdock_stop(sc); @@ -427,7 +429,7 @@ netdock_ioctl(struct ifnet *ifp, u_long cmd, void *data) } break; default: - err = EINVAL; + err = ether_ioctl(ifp, cmd, data); break; } splx(s); diff --git a/sys/arch/macppc/dev/am79c950.c b/sys/arch/macppc/dev/am79c950.c index 3f8ab82786c8..4be55fe7c5db 100644 --- a/sys/arch/macppc/dev/am79c950.c +++ b/sys/arch/macppc/dev/am79c950.c @@ -1,4 +1,4 @@ -/* $NetBSD: am79c950.c,v 1.23 2007/10/17 19:55:17 garbled Exp $ */ +/* $NetBSD: am79c950.c,v 1.24 2008/11/07 00:20:02 dyoung Exp $ */ /*- * Copyright (c) 1997 David Huang @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: am79c950.c,v 1.23 2007/10/17 19:55:17 garbled Exp $"); +__KERNEL_RCSID(0, "$NetBSD: am79c950.c,v 1.24 2008/11/07 00:20:02 dyoung Exp $"); #include "opt_inet.h" @@ -190,23 +190,25 @@ mcioctl(ifp, cmd, data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifa = (struct ifaddr *)data; ifp->if_flags |= IFF_UP; + mcinit(sc); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: - mcinit(sc); arp_ifinit(ifp, ifa); break; #endif default: - mcinit(sc); break; } break; case SIOCSIFFLAGS: + if ((err = ifioctl_common(ifp, cmd, data)) != 0) + break; + /* XXX see the comment in ed_ioctl() about code re-use */ if ((ifp->if_flags & IFF_UP) == 0 && (ifp->if_flags & IFF_RUNNING) != 0) { /* @@ -252,7 +254,8 @@ mcioctl(ifp, cmd, data) break; default: - err = EINVAL; + err = ether_ioctl(ifp, cmd, data); + break; } splx(s); return (err); diff --git a/sys/arch/macppc/dev/if_bm.c b/sys/arch/macppc/dev/if_bm.c index 8f282918d6ae..bae35d336906 100644 --- a/sys/arch/macppc/dev/if_bm.c +++ b/sys/arch/macppc/dev/if_bm.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_bm.c,v 1.37 2008/09/26 03:39:23 macallan Exp $ */ +/* $NetBSD: if_bm.c,v 1.38 2008/11/07 00:20:02 dyoung Exp $ */ /*- * Copyright (C) 1998, 1999, 2000 Tsubai Masanari. All rights reserved. @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_bm.c,v 1.37 2008/09/26 03:39:23 macallan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_bm.c,v 1.38 2008/11/07 00:20:02 dyoung Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -719,10 +719,7 @@ bmac_watchdog(ifp) } int -bmac_ioctl(ifp, cmd, data) - struct ifnet *ifp; - u_long cmd; - void *data; +bmac_ioctl(struct ifnet *ifp, unsigned long cmd, void *data) { struct bmac_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; @@ -732,23 +729,25 @@ bmac_ioctl(ifp, cmd, data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; + bmac_init(sc); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: - bmac_init(sc); arp_ifinit(ifp, ifa); break; #endif default: - bmac_init(sc); break; } break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + /* XXX see the comment in ed_ioctl() about code re-use */ if ((ifp->if_flags & IFF_UP) == 0 && (ifp->if_flags & IFF_RUNNING) != 0) { /* @@ -795,7 +794,8 @@ bmac_ioctl(ifp, cmd, data) } break; default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); + break; } splx(s); diff --git a/sys/arch/macppc/dev/if_gm.c b/sys/arch/macppc/dev/if_gm.c index eb3864e87304..efaaf21196c4 100644 --- a/sys/arch/macppc/dev/if_gm.c +++ b/sys/arch/macppc/dev/if_gm.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_gm.c,v 1.33 2008/01/19 22:10:15 dyoung Exp $ */ +/* $NetBSD: if_gm.c,v 1.34 2008/11/07 00:20:02 dyoung Exp $ */ /*- * Copyright (c) 2000 Tsubai Masanari. All rights reserved. @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_gm.c,v 1.33 2008/01/19 22:10:15 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_gm.c,v 1.34 2008/11/07 00:20:02 dyoung Exp $"); #include "opt_inet.h" #include "rnd.h" @@ -791,10 +791,7 @@ gmac_init(sc) } int -gmac_ioctl(ifp, cmd, data) - struct ifnet *ifp; - u_long cmd; - void *data; +gmac_ioctl(struct ifnet *ifp, unsigned long cmd, void *data) { struct gmac_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; @@ -805,23 +802,25 @@ gmac_ioctl(ifp, cmd, data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; + gmac_init(sc); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: - gmac_init(sc); arp_ifinit(ifp, ifa); break; #endif default: - gmac_init(sc); break; } break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + /* XXX see the comment in ed_ioctl() about code re-use */ if ((ifp->if_flags & IFF_UP) == 0 && (ifp->if_flags & IFF_RUNNING) != 0) { /* @@ -868,7 +867,8 @@ gmac_ioctl(ifp, cmd, data) } break; default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); + break; } splx(s); diff --git a/sys/arch/mips/atheros/dev/if_ae.c b/sys/arch/mips/atheros/dev/if_ae.c index 77361470b735..695adeb8a640 100644 --- a/sys/arch/mips/atheros/dev/if_ae.c +++ b/sys/arch/mips/atheros/dev/if_ae.c @@ -1,4 +1,4 @@ -/* $Id: if_ae.c,v 1.14 2008/04/28 20:23:28 martin Exp $ */ +/* $Id: if_ae.c,v 1.15 2008/11/07 00:20:02 dyoung Exp $ */ /*- * Copyright (c) 2006 Urbana-Champaign Independent Media Center. * Copyright (c) 2006 Garrett D'Amore. @@ -98,7 +98,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ae.c,v 1.14 2008/04/28 20:23:28 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ae.c,v 1.15 2008/11/07 00:20:02 dyoung Exp $"); #include "bpfilter.h" @@ -154,6 +154,7 @@ static void ae_attach(device_t, device_t, void *); static int ae_detach(device_t, int); static int ae_activate(device_t, enum devact); +static int ae_ifflags_cb(struct ethercom *); static void ae_reset(struct ae_softc *); static void ae_idle(struct ae_softc *, u_int32_t); @@ -387,6 +388,7 @@ ae_attach(device_t parent, device_t self, void *aux) */ if_attach(ifp); ether_ifattach(ifp, enaddr); + ether_set_ifflags_cb(&sc->sc_ethercom, ae_ifflags_cb); #if NRND > 0 rnd_attach_source(&sc->sc_rnd_source, sc->sc_dev.dv_xname, @@ -813,6 +815,24 @@ ae_watchdog(struct ifnet *ifp) ae_start(ifp); } +/* If the interface is up and running, only modify the receive + * filter when changing to/from promiscuous mode. Otherwise return + * ENETRESET so that ether_ioctl will reset the chip. + */ +static int +ae_ifflags_cb(struct ethercom *ec) +{ + struct ifnet *ifp = &ec->ec_if; + struct ae_softc *sc = ifp->if_softc; + int change = ifp->if_flags ^ sc->sc_if_flags; + + if ((change & ~(IFF_CANTCHANGE|IFF_DEBUG)) != 0) + return ENETRESET; + else if ((change & IFF_PROMISC) != 0) + ae_filter_setup(sc); + return 0; +} + /* * ae_ioctl: [ifnet interface function] * @@ -826,37 +846,16 @@ ae_ioctl(struct ifnet *ifp, u_long cmd, void *data) s = splnet(); - switch (cmd) { - case SIOCSIFFLAGS: - /* If the interface is up and running, only modify the receive - * filter when setting promiscuous or debug mode. Otherwise - * fall through to ether_ioctl, which will reset the chip. - */ -#define RESETIGN (IFF_CANTCHANGE|IFF_DEBUG) - if (((ifp->if_flags & (IFF_UP|IFF_RUNNING)) - == (IFF_UP|IFF_RUNNING)) - && ((ifp->if_flags & (~RESETIGN)) - == (sc->sc_if_flags & (~RESETIGN)))) { - /* Set up the receive filter. */ + error = ether_ioctl(ifp, cmd, data); + if (error == ENETRESET) { + if (ifp->if_flags & IFF_RUNNING) { + /* + * Multicast list has changed. Set the + * hardware filter accordingly. + */ ae_filter_setup(sc); - error = 0; - break; -#undef RESETIGN } - /* FALLTHROUGH */ - default: - error = ether_ioctl(ifp, cmd, data); - if (error == ENETRESET) { - if (ifp->if_flags & IFF_RUNNING) { - /* - * Multicast list has changed. Set the - * hardware filter accordingly. - */ - ae_filter_setup(sc); - } - error = 0; - } - break; + error = 0; } /* Try to get more packets going. */ diff --git a/sys/arch/mips/sibyte/dev/sbmac.c b/sys/arch/mips/sibyte/dev/sbmac.c index fd30ef1ad909..932de71b9f41 100644 --- a/sys/arch/mips/sibyte/dev/sbmac.c +++ b/sys/arch/mips/sibyte/dev/sbmac.c @@ -1,4 +1,4 @@ -/* $NetBSD: sbmac.c,v 1.28 2008/02/07 01:21:52 dyoung Exp $ */ +/* $NetBSD: sbmac.c,v 1.29 2008/11/07 00:20:02 dyoung Exp $ */ /* * Copyright 2000, 2001, 2004 @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sbmac.c,v 1.28 2008/02/07 01:21:52 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sbmac.c,v 1.29 2008/11/07 00:20:02 dyoung Exp $"); #include "bpfilter.h" #include "opt_inet.h" @@ -1957,7 +1957,7 @@ sbmac_ether_ioctl(struct ifnet *ifp, u_long cmd, void *data) struct sbmac_softc *sc = ifp->if_softc; switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; switch (ifa->ifa_addr->sa_family) { @@ -1990,7 +1990,7 @@ sbmac_ether_ioctl(struct ifnet *ifp, u_long cmd, void *data) break; default: - return (EINVAL); + return ENOTTY; } return (0); @@ -2022,8 +2022,7 @@ sbmac_ioctl(struct ifnet *ifp, u_long command, void *data) s = splnet(); switch(command) { - case SIOCSIFADDR: - case SIOCGIFADDR: + case SIOCINITIFADDR: error = sbmac_ether_ioctl(ifp, command, data); break; case SIOCSIFMTU: @@ -2034,6 +2033,8 @@ sbmac_ioctl(struct ifnet *ifp, u_long command, void *data) error = 0; break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; if (ifp->if_flags & IFF_UP) { /* * If only the state of the PROMISC flag changed, @@ -2069,7 +2070,7 @@ sbmac_ioctl(struct ifnet *ifp, u_long command, void *data) } break; default: - error = EINVAL; + error = ether_ioctl(ifp, command, data); break; } diff --git a/sys/arch/newsmips/apbus/if_sn.c b/sys/arch/newsmips/apbus/if_sn.c index 2c5d7c460e74..b6d3c3e09c81 100644 --- a/sys/arch/newsmips/apbus/if_sn.c +++ b/sys/arch/newsmips/apbus/if_sn.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_sn.c,v 1.30 2008/04/09 15:40:30 tsutsui Exp $ */ +/* $NetBSD: if_sn.c,v 1.31 2008/11/07 00:20:02 dyoung Exp $ */ /* * National Semiconductor DP8393X SONIC Driver @@ -16,7 +16,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_sn.c,v 1.30 2008/04/09 15:40:30 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_sn.c,v 1.31 2008/11/07 00:20:02 dyoung Exp $"); #include "opt_inet.h" @@ -234,23 +234,24 @@ snioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifa = (struct ifaddr *)data; ifp->if_flags |= IFF_UP; + (void)sninit(sc); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: - (void)sninit(sc); arp_ifinit(ifp, ifa); break; #endif default: - (void)sninit(sc); break; } break; case SIOCSIFFLAGS: + if ((err = ifioctl_common(ifp, cmd, data)) != 0) + break; if ((ifp->if_flags & IFF_UP) == 0 && (ifp->if_flags & IFF_RUNNING) != 0) { /* @@ -294,7 +295,8 @@ snioctl(struct ifnet *ifp, u_long cmd, void *data) } break; default: - err = EINVAL; + err = ether_ioctl(ifp, cmd, data); + break; } splx(s); return err; diff --git a/sys/arch/next68k/dev/mb8795.c b/sys/arch/next68k/dev/mb8795.c index fd4c763bf67c..ef16722188c9 100644 --- a/sys/arch/next68k/dev/mb8795.c +++ b/sys/arch/next68k/dev/mb8795.c @@ -1,4 +1,4 @@ -/* $NetBSD: mb8795.c,v 1.42 2007/10/17 19:56:03 garbled Exp $ */ +/* $NetBSD: mb8795.c,v 1.43 2008/11/07 00:20:02 dyoung Exp $ */ /* * Copyright (c) 1998 Darrin B. Jewell * All rights reserved. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mb8795.c,v 1.42 2007/10/17 19:56:03 garbled Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mb8795.c,v 1.43 2008/11/07 00:20:02 dyoung Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -596,19 +596,18 @@ mb8795_ioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { - case SIOCSIFADDR: - DPRINTF(("%s: mb8795_ioctl() SIOCSIFADDR\n",sc->sc_dev.dv_xname)); + case SIOCINITIFADDR: + DPRINTF(("%s: mb8795_ioctl() SIOCINITIFADDR\n",sc->sc_dev.dv_xname)); ifp->if_flags |= IFF_UP; + mb8795_init(sc); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: - mb8795_init(sc); arp_ifinit(ifp, ifa); break; #endif default: - mb8795_init(sc); break; } break; @@ -616,27 +615,31 @@ mb8795_ioctl(struct ifnet *ifp, u_long cmd, void *data) case SIOCSIFFLAGS: DPRINTF(("%s: mb8795_ioctl() SIOCSIFFLAGS\n",sc->sc_dev.dv_xname)); - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_RUNNING: /* * If interface is marked down and it is running, then * stop it. */ /* ifp->if_flags &= ~IFF_RUNNING; */ mb8795_reset(sc); - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { + break; + case IFF_UP: /* * If interface is marked up and it is stopped, then * start it. */ mb8795_init(sc); - } else { + break; + default: /* * Reset the interface to pick up changes in any other * flags that affect hardware registers. */ mb8795_init(sc); + break; } #ifdef MB8795_DEBUG if (ifp->if_flags & IFF_DEBUG) @@ -668,7 +671,7 @@ mb8795_ioctl(struct ifnet *ifp, u_long cmd, void *data) break; default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); break; } diff --git a/sys/arch/sun2/dev/if_ec.c b/sys/arch/sun2/dev/if_ec.c index 6fa6d0a1cbfe..2893a320172a 100644 --- a/sys/arch/sun2/dev/if_ec.c +++ b/sys/arch/sun2/dev/if_ec.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ec.c,v 1.15 2008/07/06 13:29:50 tsutsui Exp $ */ +/* $NetBSD: if_ec.c,v 1.16 2008/11/07 00:20:02 dyoung Exp $ */ /* * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ec.c,v 1.15 2008/07/06 13:29:50 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ec.c,v 1.16 2008/11/07 00:20:02 dyoung Exp $"); #include "opt_inet.h" #include "opt_ns.h" @@ -601,7 +601,7 @@ ec_ioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; switch (ifa->ifa_addr->sa_family) { @@ -618,26 +618,30 @@ ec_ioctl(struct ifnet *ifp, u_long cmd, void *data) break; case SIOCSIFFLAGS: - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_RUNNING: /* * If interface is marked down and it is running, then * stop it. */ ifp->if_flags &= ~IFF_RUNNING; - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { + break; + case IFF_UP: /* * If interface is marked up and it is stopped, then * start it. */ ec_init(ifp); - } else { + break; + default: /* * Some other important flag might have changed, so * reset. */ ec_reset(ifp); + break; } break; @@ -647,7 +651,7 @@ ec_ioctl(struct ifnet *ifp, u_long cmd, void *data) break; default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); break; } diff --git a/sys/arch/sun3/dev/if_ie.c b/sys/arch/sun3/dev/if_ie.c index 1ec17e7d50d0..784283343a8d 100644 --- a/sys/arch/sun3/dev/if_ie.c +++ b/sys/arch/sun3/dev/if_ie.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ie.c,v 1.51 2008/06/28 12:13:38 tsutsui Exp $ */ +/* $NetBSD: if_ie.c,v 1.52 2008/11/07 00:20:02 dyoung Exp $ */ /*- * Copyright (c) 1993, 1994, 1995 Charles M. Hannum. @@ -98,7 +98,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ie.c,v 1.51 2008/06/28 12:13:38 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ie.c,v 1.52 2008/11/07 00:20:02 dyoung Exp $"); #include "opt_inet.h" #include "opt_ns.h" @@ -1530,7 +1530,7 @@ ieioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; switch (ifa->ifa_addr->sa_family) { @@ -1564,30 +1564,34 @@ ieioctl(struct ifnet *ifp, u_long cmd, void *data) break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; sc->promisc = ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI); - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_RUNNING: /* * If interface is marked down and it is running, then * stop it. */ iestop(sc); ifp->if_flags &= ~IFF_RUNNING; - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { + break; + case IFF_UP: /* * If interface is marked up and it is stopped, then * start it. */ ieinit(sc); - } else { + break; + default: /* * Reset the interface to pick up changes in any other * flags that affect hardware registers. */ iestop(sc); ieinit(sc); + break; } #ifdef IEDEBUG if (ifp->if_flags & IFF_DEBUG) @@ -1611,7 +1615,8 @@ ieioctl(struct ifnet *ifp, u_long cmd, void *data) break; default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); + break; } splx(s); return error; diff --git a/sys/dev/bi/if_ni.c b/sys/dev/bi/if_ni.c index 9fcc34f022de..4d97c424dbd8 100644 --- a/sys/dev/bi/if_ni.c +++ b/sys/dev/bi/if_ni.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ni.c,v 1.36 2008/07/09 17:51:21 joerg Exp $ */ +/* $NetBSD: if_ni.c,v 1.37 2008/11/07 00:20:02 dyoung Exp $ */ /* * Copyright (c) 2000 Ludd, University of Lule}, Sweden. All rights reserved. * @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ni.c,v 1.36 2008/07/09 17:51:21 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ni.c,v 1.37 2008/11/07 00:20:02 dyoung Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -697,7 +697,7 @@ niioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; switch(ifa->ifa_addr->sa_family) { #ifdef INET @@ -710,27 +710,33 @@ niioctl(struct ifnet *ifp, u_long cmd, void *data) break; case SIOCSIFFLAGS: - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_RUNNING: /* * If interface is marked down and it is running, * stop it. */ ifp->if_flags &= ~IFF_RUNNING; ni_setup(sc); - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { + break; + case IFF_UP: /* * If interface it marked up and it is stopped, then * start it. */ niinit(sc); - } else if ((ifp->if_flags & IFF_UP) != 0) { + break; + case IFF_UP|IFF_RUNNING: /* * Send a new setup packet to match any new changes. * (Like IFF_PROMISC etc) */ ni_setup(sc); + break; + default: + break; } break; @@ -751,8 +757,8 @@ niioctl(struct ifnet *ifp, u_long cmd, void *data) break; default: - error = EINVAL; - + error = ether_ioctl(ifp, cmd, data); + break; } splx(s); return (error); diff --git a/sys/dev/ic/an.c b/sys/dev/ic/an.c index 9bc8f9fc7937..e5b78b5092c6 100644 --- a/sys/dev/ic/an.c +++ b/sys/dev/ic/an.c @@ -1,4 +1,4 @@ -/* $NetBSD: an.c,v 1.52 2008/07/03 18:10:07 drochner Exp $ */ +/* $NetBSD: an.c,v 1.53 2008/11/07 00:20:02 dyoung Exp $ */ /* * Copyright (c) 1997, 1998, 1999 * Bill Paul . All rights reserved. @@ -77,7 +77,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: an.c,v 1.52 2008/07/03 18:10:07 drochner Exp $"); +__KERNEL_RCSID(0, "$NetBSD: an.c,v 1.53 2008/11/07 00:20:02 dyoung Exp $"); #include "bpfilter.h" @@ -889,6 +889,8 @@ an_ioctl(struct ifnet *ifp, u_long command, void *data) switch (command) { case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, command, data)) != 0) + break; if (ifp->if_flags & IFF_UP) { if (sc->sc_enabled) { /* diff --git a/sys/dev/ic/ath.c b/sys/dev/ic/ath.c index c85bfc4a53c9..63f30cdc348a 100644 --- a/sys/dev/ic/ath.c +++ b/sys/dev/ic/ath.c @@ -1,4 +1,4 @@ -/* $NetBSD: ath.c,v 1.102 2008/07/09 19:47:24 joerg Exp $ */ +/* $NetBSD: ath.c,v 1.103 2008/11/07 00:20:02 dyoung Exp $ */ /*- * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting @@ -41,7 +41,7 @@ __FBSDID("$FreeBSD: src/sys/dev/ath/if_ath.c,v 1.104 2005/09/16 10:09:23 ru Exp $"); #endif #ifdef __NetBSD__ -__KERNEL_RCSID(0, "$NetBSD: ath.c,v 1.102 2008/07/09 19:47:24 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ath.c,v 1.103 2008/11/07 00:20:02 dyoung Exp $"); #endif /* @@ -5148,6 +5148,8 @@ ath_ioctl(struct ifnet *ifp, u_long cmd, void *data) ATH_LOCK(sc); switch (cmd) { case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; if (IS_RUNNING(ifp)) { /* * To avoid rescanning another access point, diff --git a/sys/dev/ic/atw.c b/sys/dev/ic/atw.c index ae30c5a42e3b..1f55bae6353d 100644 --- a/sys/dev/ic/atw.c +++ b/sys/dev/ic/atw.c @@ -1,4 +1,4 @@ -/* $NetBSD: atw.c,v 1.140 2008/07/09 20:07:19 joerg Exp $ */ +/* $NetBSD: atw.c,v 1.141 2008/11/07 00:20:02 dyoung Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2002, 2003, 2004 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: atw.c,v 1.140 2008/07/09 20:07:19 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: atw.c,v 1.141 2008/11/07 00:20:02 dyoung Exp $"); #include "bpfilter.h" @@ -3838,6 +3838,8 @@ atw_ioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; if (ifp->if_flags & IFF_UP) { if (ATW_IS_ENABLED(sc)) { /* diff --git a/sys/dev/ic/awi.c b/sys/dev/ic/awi.c index e0cfe0ae5290..220e548f2040 100644 --- a/sys/dev/ic/awi.c +++ b/sys/dev/ic/awi.c @@ -1,4 +1,4 @@ -/* $NetBSD: awi.c,v 1.80 2008/05/16 22:11:51 dyoung Exp $ */ +/* $NetBSD: awi.c,v 1.81 2008/11/07 00:20:02 dyoung Exp $ */ /*- * Copyright (c) 1999,2000,2001 The NetBSD Foundation, Inc. @@ -79,7 +79,7 @@ #include #ifdef __NetBSD__ -__KERNEL_RCSID(0, "$NetBSD: awi.c,v 1.80 2008/05/16 22:11:51 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: awi.c,v 1.81 2008/11/07 00:20:02 dyoung Exp $"); #endif #ifdef __FreeBSD__ __FBSDID("$FreeBSD: src/sys/dev/awi/awi.c,v 1.30 2004/01/15 13:30:06 onoe Exp $"); @@ -902,6 +902,8 @@ awi_ioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; if (ifp->if_flags & IFF_UP) { if (sc->sc_enabled) { /* diff --git a/sys/dev/ic/dp8390.c b/sys/dev/ic/dp8390.c index 2b468f38cddd..034ea777ce6a 100644 --- a/sys/dev/ic/dp8390.c +++ b/sys/dev/ic/dp8390.c @@ -1,4 +1,4 @@ -/* $NetBSD: dp8390.c,v 1.68 2008/03/12 14:31:11 cube Exp $ */ +/* $NetBSD: dp8390.c,v 1.69 2008/11/07 00:20:02 dyoung Exp $ */ /* * Device driver for National Semiconductor DS8390/WD83C690 based ethernet @@ -14,7 +14,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: dp8390.c,v 1.68 2008/03/12 14:31:11 cube Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dp8390.c,v 1.69 2008/11/07 00:20:02 dyoung Exp $"); #include "opt_ipkdb.h" #include "opt_inet.h" @@ -873,25 +873,26 @@ dp8390_ioctl(ifp, cmd, data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: if ((error = dp8390_enable(sc)) != 0) break; ifp->if_flags |= IFF_UP; + dp8390_init(sc); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: - dp8390_init(sc); arp_ifinit(ifp, ifa); break; #endif default: - dp8390_init(sc); break; } break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { case IFF_RUNNING: /* @@ -951,7 +952,7 @@ dp8390_ioctl(ifp, cmd, data) break; default: - error = ENODEV; + error = ether_ioctl(ifp, cmd, data); break; } diff --git a/sys/dev/ic/elinkxl.c b/sys/dev/ic/elinkxl.c index c515d60e4b2d..8448e86e1daa 100644 --- a/sys/dev/ic/elinkxl.c +++ b/sys/dev/ic/elinkxl.c @@ -1,4 +1,4 @@ -/* $NetBSD: elinkxl.c,v 1.105 2008/04/28 20:23:49 martin Exp $ */ +/* $NetBSD: elinkxl.c,v 1.106 2008/11/07 00:20:02 dyoung Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: elinkxl.c,v 1.105 2008/04/28 20:23:49 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: elinkxl.c,v 1.106 2008/11/07 00:20:02 dyoung Exp $"); #include "bpfilter.h" #include "rnd.h" @@ -84,6 +84,8 @@ int exdebug = 0; int ex_media_chg(struct ifnet *ifp); void ex_media_stat(struct ifnet *ifp, struct ifmediareq *req); +static int ex_ifflags_cb(struct ethercom *); + void ex_probe_media(struct ex_softc *); void ex_set_filter(struct ex_softc *); void ex_set_media(struct ex_softc *); @@ -432,6 +434,7 @@ ex_config(struct ex_softc *sc) if_attach(ifp); ether_ifattach(ifp, macaddr); + ether_set_ifflags_cb(&sc->sc_ethercom, ex_ifflags_cb); GO_WINDOW(1); @@ -1437,6 +1440,20 @@ ex_intr(void *arg) return ret; } +static int +ex_ifflags_cb(struct ethercom *ec) +{ + struct ifnet *ifp = &ec->ec_if; + struct ex_softc *sc = ifp->if_softc; + int change = ifp->if_flags ^ sc->sc_if_flags; + + if ((change & ~(IFF_CANTCHANGE|IFF_DEBUG)) != 0) + return ENETRESET; + else if ((change & IFF_PROMISC) != 0) + ex_set_mc(sc); + return 0; +} + int ex_ioctl(struct ifnet *ifp, u_long cmd, void *data) { @@ -1451,22 +1468,6 @@ ex_ioctl(struct ifnet *ifp, u_long cmd, void *data) case SIOCGIFMEDIA: error = ifmedia_ioctl(ifp, ifr, &sc->ex_mii.mii_media, cmd); break; - case SIOCSIFFLAGS: - /* If the interface is up and running, only modify the receive - * filter when setting promiscuous or debug mode. Otherwise - * fall through to ether_ioctl, which will reset the chip. - */ -#define RESETIGN (IFF_CANTCHANGE|IFF_DEBUG) - if (((ifp->if_flags & (IFF_UP|IFF_RUNNING)) - == (IFF_UP|IFF_RUNNING)) - && ((ifp->if_flags & (~RESETIGN)) - == (sc->sc_if_flags & (~RESETIGN)))) { - ex_set_mc(sc); - error = 0; - break; -#undef RESETIGN - } - /* FALLTHROUGH */ default: if ((error = ether_ioctl(ifp, cmd, data)) != ENETRESET) break; diff --git a/sys/dev/ic/gem.c b/sys/dev/ic/gem.c index 9682f3717625..c29b5b4c0a99 100644 --- a/sys/dev/ic/gem.c +++ b/sys/dev/ic/gem.c @@ -1,4 +1,4 @@ -/* $NetBSD: gem.c,v 1.78 2008/09/15 19:50:28 jdc Exp $ */ +/* $NetBSD: gem.c,v 1.79 2008/11/07 00:20:02 dyoung Exp $ */ /* * @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: gem.c,v 1.78 2008/09/15 19:50:28 jdc Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gem.c,v 1.79 2008/11/07 00:20:02 dyoung Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -119,6 +119,8 @@ static int gem_mii_readreg(struct device *, int, int); static void gem_mii_writereg(struct device *, int, int, int); static void gem_mii_statchg(struct device *); +static int gem_ifflags_cb(struct ethercom *); + void gem_statuschange(struct gem_softc *); int gem_ser_mediachange(struct ifnet *); @@ -451,6 +453,7 @@ gem_attach(sc, enaddr) /* Attach the interface. */ if_attach(ifp); ether_ifattach(ifp, enaddr); + ether_set_ifflags_cb(&sc->sc_ethercom, gem_ifflags_cb); sc->sc_sh = shutdownhook_establish(gem_shutdown, sc); if (sc->sc_sh == NULL) @@ -2472,38 +2475,33 @@ gem_ser_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr) ifmr->ifm_status = sc->sc_mii.mii_media_status; } +static int +gem_ifflags_cb(struct ethercom *ec) +{ + struct ifnet *ifp = &ec->ec_if; + struct gem_softc *sc = ifp->if_softc; + int change = ifp->if_flags ^ sc->sc_if_flags; + + if ((change & ~(IFF_CANTCHANGE|IFF_DEBUG)) != 0) + return ENETRESET; + else if ((change & IFF_PROMISC) != 0) + gem_setladrf(sc); + return 0; +} + /* * Process an ioctl request. */ int -gem_ioctl(ifp, cmd, data) - struct ifnet *ifp; - u_long cmd; - void *data; +gem_ioctl(struct ifnet *ifp, unsigned long cmd, void *data) { struct gem_softc *sc = ifp->if_softc; int s, error = 0; s = splnet(); - switch (cmd) { - case SIOCSIFFLAGS: -#define RESETIGN (IFF_CANTCHANGE|IFF_DEBUG) - if (((ifp->if_flags & (IFF_UP|IFF_RUNNING)) - == (IFF_UP|IFF_RUNNING)) - && ((ifp->if_flags & (~RESETIGN)) - == (sc->sc_if_flags & (~RESETIGN)))) { - gem_setladrf(sc); - break; - } -#undef RESETIGN - /*FALLTHROUGH*/ - default: - if ((error = ether_ioctl(ifp, cmd, data)) != ENETRESET) - break; - + if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) { error = 0; - if (cmd != SIOCADDMULTI && cmd != SIOCDELMULTI) ; else if (ifp->if_flags & IFF_RUNNING) { @@ -2513,7 +2511,6 @@ gem_ioctl(ifp, cmd, data) */ gem_setladrf(sc); } - break; } /* Try to get things going again */ diff --git a/sys/dev/ic/hd64570.c b/sys/dev/ic/hd64570.c index d2cff14f78c3..b78b8fd7e2ee 100644 --- a/sys/dev/ic/hd64570.c +++ b/sys/dev/ic/hd64570.c @@ -1,4 +1,4 @@ -/* $NetBSD: hd64570.c,v 1.39 2008/04/08 12:07:26 cegger Exp $ */ +/* $NetBSD: hd64570.c,v 1.40 2008/11/07 00:20:02 dyoung Exp $ */ /* * Copyright (c) 1999 Christian E. Hopps @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: hd64570.c,v 1.39 2008/04/08 12:07:26 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hd64570.c,v 1.40 2008/11/07 00:20:02 dyoung Exp $"); #include "bpfilter.h" #include "opt_inet.h" @@ -926,10 +926,10 @@ sca_output( } static int -sca_ioctl(ifp, cmd, addr) +sca_ioctl(ifp, cmd, data) struct ifnet *ifp; u_long cmd; - void *addr; + void *data; { struct ifreq *ifr; struct ifaddr *ifa; @@ -938,12 +938,12 @@ sca_ioctl(ifp, cmd, addr) s = splnet(); - ifr = (struct ifreq *)addr; - ifa = (struct ifaddr *)addr; + ifr = (struct ifreq *)data; + ifa = (struct ifaddr *)data; error = 0; switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: switch(ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: @@ -997,6 +997,8 @@ sca_ioctl(ifp, cmd, addr) break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; if (ifr->ifr_flags & IFF_UP) { ifp->if_flags |= IFF_UP; sca_port_up(ifp->if_softc); @@ -1008,7 +1010,7 @@ sca_ioctl(ifp, cmd, addr) break; default: - error = EINVAL; + error = ifioctl_common(ifp, cmd, data); } splx(s); diff --git a/sys/dev/ic/hme.c b/sys/dev/ic/hme.c index 513009435bbb..d693c8630783 100644 --- a/sys/dev/ic/hme.c +++ b/sys/dev/ic/hme.c @@ -1,4 +1,4 @@ -/* $NetBSD: hme.c,v 1.66 2008/05/04 17:06:09 xtraeme Exp $ */ +/* $NetBSD: hme.c,v 1.67 2008/11/07 00:20:02 dyoung Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: hme.c,v 1.66 2008/05/04 17:06:09 xtraeme Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hme.c,v 1.67 2008/11/07 00:20:02 dyoung Exp $"); /* #define HMEDEBUG */ @@ -1400,10 +1400,7 @@ hme_mediachange(ifp) * Process an ioctl request. */ int -hme_ioctl(ifp, cmd, data) - struct ifnet *ifp; - u_long cmd; - void *data; +hme_ioctl(struct ifnet *ifp, unsigned long cmd, void *data) { struct hme_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; @@ -1413,7 +1410,7 @@ hme_ioctl(ifp, cmd, data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: @@ -1435,25 +1432,32 @@ hme_ioctl(ifp, cmd, data) case SIOCSIFFLAGS: #ifdef HMEDEBUG - sc->sc_debug = (ifp->if_flags & IFF_DEBUG) != 0 ? 1 : 0; + { + struct ifreq *ifr = data; + sc->sc_debug = + (ifr->ifr_flags & IFF_DEBUG) != 0 ? 1 : 0; + } #endif + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_RUNNING: /* * If interface is marked down and it is running, then * stop it. */ hme_stop(sc, false); ifp->if_flags &= ~IFF_RUNNING; - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { + break; + case IFF_UP: /* * If interface is marked up and it is stopped, then * start it. */ error = hme_init(sc); - } else if ((ifp->if_flags & IFF_UP) != 0) { + break; + case IFF_UP|IFF_RUNNING: /* * If setting debug or promiscuous mode, do not reset * the chip; for everything else, call hme_init() @@ -1468,6 +1472,9 @@ hme_ioctl(ifp, cmd, data) error = hme_init(sc); } #undef RESETIGN + break; + case 0: + break; } if (sc->sc_ec_capenable != sc->sc_ethercom.ec_capenable) diff --git a/sys/dev/ic/i82586.c b/sys/dev/ic/i82586.c index cab9d284a19a..882c3e916631 100644 --- a/sys/dev/ic/i82586.c +++ b/sys/dev/ic/i82586.c @@ -1,4 +1,4 @@ -/* $NetBSD: i82586.c,v 1.62 2008/04/28 20:23:50 martin Exp $ */ +/* $NetBSD: i82586.c,v 1.63 2008/11/07 00:20:02 dyoung Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -137,7 +137,7 @@ Mode of operation: */ #include -__KERNEL_RCSID(0, "$NetBSD: i82586.c,v 1.62 2008/04/28 20:23:50 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: i82586.c,v 1.63 2008/11/07 00:20:02 dyoung Exp $"); #include "bpfilter.h" @@ -1772,10 +1772,7 @@ i82586_stop( } int -i82586_ioctl(ifp, cmd, data) - struct ifnet *ifp; - u_long cmd; - void *data; +i82586_ioctl(struct ifnet *ifp, unsigned long cmd, void *data) { struct ie_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *)data; @@ -1829,7 +1826,7 @@ again: memcmp(enm->enm_addrlo, enm->enm_addrhi, 6) != 0) { sc->sc_ethercom.ec_if.if_flags |= IFF_ALLMULTI; i82586_ioctl(&sc->sc_ethercom.ec_if, - SIOCSIFFLAGS, (void *)0); + SIOCSIFFLAGS, NULL); return; } ETHER_NEXT_MULTI(step, enm); diff --git a/sys/dev/ic/lance.c b/sys/dev/ic/lance.c index 55e8dd8257bb..ece98f58cd2c 100644 --- a/sys/dev/ic/lance.c +++ b/sys/dev/ic/lance.c @@ -1,4 +1,4 @@ -/* $NetBSD: lance.c,v 1.41 2008/04/28 20:23:50 martin Exp $ */ +/* $NetBSD: lance.c,v 1.42 2008/11/07 00:20:02 dyoung Exp $ */ /*- * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lance.c,v 1.41 2008/04/28 20:23:50 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lance.c,v 1.42 2008/11/07 00:20:02 dyoung Exp $"); #include "bpfilter.h" #include "rnd.h" @@ -543,31 +543,25 @@ lance_ioctl(struct ifnet *ifp, u_long cmd, void *data) s = splnet(); switch (cmd) { - case SIOCSIFADDR: - case SIOCSIFFLAGS: - error = ether_ioctl(ifp, cmd, data); - break; - case SIOCADDMULTI: - case SIOCDELMULTI: - if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) { - /* - * Multicast list has changed; set the hardware filter - * accordingly. - */ - if (ifp->if_flags & IFF_RUNNING) - lance_reset(sc); - error = 0; - } - break; - case SIOCGIFMEDIA: case SIOCSIFMEDIA: error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd); break; - default: - error = EINVAL; + if ((error = ether_ioctl(ifp, cmd, data)) != ENETRESET) + break; + error = 0; + if (cmd != SIOCADDMULTI && cmd != SIOCDELMULTI) + break; + if (ifp->if_flags & IFF_RUNNING) { + /* + * Multicast list has changed; set the hardware filter + * accordingly. + */ + lance_reset(sc); + } break; + } splx(s); diff --git a/sys/dev/ic/lemac.c b/sys/dev/ic/lemac.c index e79ceffe234f..dd8cce73a461 100644 --- a/sys/dev/ic/lemac.c +++ b/sys/dev/ic/lemac.c @@ -1,4 +1,4 @@ -/* $NetBSD: lemac.c,v 1.35 2008/04/08 12:07:26 cegger Exp $ */ +/* $NetBSD: lemac.c,v 1.36 2008/11/07 00:20:02 dyoung Exp $ */ /*- * Copyright (c) 1994, 1995, 1997 Matt Thomas @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lemac.c,v 1.35 2008/04/08 12:07:26 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lemac.c,v 1.36 2008/11/07 00:20:02 dyoung Exp $"); #include "opt_inet.h" #include "rnd.h" @@ -757,7 +757,7 @@ lemac_ifioctl( s = splnet(); switch (cmd) { - case SIOCSIFADDR: { + case SIOCINITIFADDR: { struct ifaddr *ifa = (struct ifaddr *)data; ifp->if_flags |= IFF_UP; @@ -779,6 +779,8 @@ lemac_ifioctl( } case SIOCSIFFLAGS: { + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; lemac_init(sc); break; } @@ -805,7 +807,7 @@ lemac_ifioctl( } default: { - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); break; } } diff --git a/sys/dev/ic/mb86950.c b/sys/dev/ic/mb86950.c index b70b4f26539c..62081069c0a1 100644 --- a/sys/dev/ic/mb86950.c +++ b/sys/dev/ic/mb86950.c @@ -1,4 +1,4 @@ -/* $NetBSD: mb86950.c,v 1.11 2008/04/08 12:07:26 cegger Exp $ */ +/* $NetBSD: mb86950.c,v 1.12 2008/11/07 00:20:02 dyoung Exp $ */ /* * All Rights Reserved, Copyright (C) Fujitsu Limited 1995 @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mb86950.c,v 1.11 2008/04/08 12:07:26 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mb86950.c,v 1.12 2008/11/07 00:20:02 dyoung Exp $"); /* * Device driver for Fujitsu mb86950 based Ethernet cards. @@ -444,10 +444,7 @@ mb86950_watchdog(ifp) * Process an ioctl request. */ int -mb86950_ioctl(ifp, cmd, data) - struct ifnet *ifp; - u_long cmd; - void *data; +mb86950_ioctl(struct ifnet *ifp, unsigned long cmd, void *data) { struct mb86950_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; @@ -458,32 +455,34 @@ mb86950_ioctl(ifp, cmd, data) s = splnet(); switch (cmd) { - case SIOCSIFADDR: - /* XXX depreciated ? What should I use instead? */ + case SIOCINITIFADDR: + /* XXX deprecated ? What should I use instead? */ if ((error = mb86950_enable(sc)) != 0) break; ifp->if_flags |= IFF_UP; + mb86950_init(sc); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: - mb86950_init(sc); arp_ifinit(ifp, ifa); break; #endif default: - mb86950_init(sc); break; } break; case SIOCSIFFLAGS: - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + /* XXX re-use ether_ioctl() */ + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_RUNNING: /* * If interface is marked down and it is running, then * stop it. @@ -491,9 +490,8 @@ mb86950_ioctl(ifp, cmd, data) mb86950_stop(sc); ifp->if_flags &= ~IFF_RUNNING; mb86950_disable(sc); - - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { + break; + case IFF_UP: /* * If interface is marked up and it is stopped, then * start it. @@ -501,15 +499,19 @@ mb86950_ioctl(ifp, cmd, data) if ((error = mb86950_enable(sc)) != 0) break; mb86950_init(sc); - - } else if ((ifp->if_flags & IFF_UP) != 0) { + break; + case IFF_UP|IFF_RUNNING: /* * Reset the interface to pick up changes in any other * flags that affect hardware registers. */ -/* Setmode not supported +#if 0 + /* Setmode not supported */ mb86950_setmode(sc); -*/ +#endif + break; + case 0: + break; } #if ESTAR_DEBUG >= 1 @@ -528,7 +530,7 @@ mb86950_ioctl(ifp, cmd, data) break; default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); break; } diff --git a/sys/dev/ic/mb86960.c b/sys/dev/ic/mb86960.c index 36e3dbda67e6..6e1284ebaddb 100644 --- a/sys/dev/ic/mb86960.c +++ b/sys/dev/ic/mb86960.c @@ -1,4 +1,4 @@ -/* $NetBSD: mb86960.c,v 1.70 2008/04/12 06:37:51 tsutsui Exp $ */ +/* $NetBSD: mb86960.c,v 1.71 2008/11/07 00:20:02 dyoung Exp $ */ /* * All Rights Reserved, Copyright (C) Fujitsu Limited 1995 @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mb86960.c,v 1.70 2008/04/12 06:37:51 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mb86960.c,v 1.71 2008/11/07 00:20:02 dyoung Exp $"); /* * Device driver for Fujitsu MB86960A/MB86965A based Ethernet cards. @@ -1188,27 +1188,29 @@ mb86960_ioctl(struct ifnet *ifp, u_long cmd, void *data) s = splnet(); switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: if ((error = mb86960_enable(sc)) != 0) break; ifp->if_flags |= IFF_UP; + mb86960_init(sc); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: - mb86960_init(sc); arp_ifinit(ifp, ifa); break; #endif default: - mb86960_init(sc); break; } break; case SIOCSIFFLAGS: - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + /* XXX re-use ether_ioctl() */ + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_RUNNING: /* * If interface is marked down and it is running, then * stop it. @@ -1216,8 +1218,8 @@ mb86960_ioctl(struct ifnet *ifp, u_long cmd, void *data) mb86960_stop(sc); ifp->if_flags &= ~IFF_RUNNING; mb86960_disable(sc); - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { + break; + case IFF_UP: /* * If interface is marked up and it is stopped, then * start it. @@ -1225,12 +1227,16 @@ mb86960_ioctl(struct ifnet *ifp, u_long cmd, void *data) if ((error = mb86960_enable(sc)) != 0) break; mb86960_init(sc); - } else if ((ifp->if_flags & IFF_UP) != 0) { + break; + case IFF_UP|IFF_RUNNING: /* * Reset the interface to pick up changes in any other * flags that affect hardware registers. */ mb86960_setmode(sc); + break; + case 0: + break; } #if FE_DEBUG >= 1 /* "ifconfig fe0 debug" to print register dump. */ @@ -1267,7 +1273,7 @@ mb86960_ioctl(struct ifnet *ifp, u_long cmd, void *data) break; default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); break; } diff --git a/sys/dev/ic/midway.c b/sys/dev/ic/midway.c index ece0ddd7bdfb..15bd91356c95 100644 --- a/sys/dev/ic/midway.c +++ b/sys/dev/ic/midway.c @@ -1,4 +1,4 @@ -/* $NetBSD: midway.c,v 1.82 2008/09/08 23:36:54 gmcgarry Exp $ */ +/* $NetBSD: midway.c,v 1.83 2008/11/07 00:20:02 dyoung Exp $ */ /* (sync'd to midway.c 1.68) */ /* @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: midway.c,v 1.82 2008/09/08 23:36:54 gmcgarry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: midway.c,v 1.83 2008/11/07 00:20:02 dyoung Exp $"); #include "opt_natm.h" @@ -1199,39 +1199,30 @@ void *data; #endif break; #endif - case SIOCSIFADDR: -#ifdef INET6 - case SIOCSIFADDR_IN6: -#endif + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; + en_reset(sc); + en_init(sc); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: - en_reset(sc); - en_init(sc); ifa->ifa_rtrequest = atm_rtrequest; /* ??? */ break; #endif #ifdef INET6 case AF_INET6: - en_reset(sc); - en_init(sc); ifa->ifa_rtrequest = atm_rtrequest; /* ??? */ break; #endif default: /* what to do if not INET? */ - en_reset(sc); - en_init(sc); break; } break; - case SIOCGIFADDR: - error = EINVAL; - break; - case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; #ifdef ATM_PVCEXT /* point-2-point pvc is allowed to change if_flags */ if (((ifp->if_flags & IFF_UP) && !(ifp->if_flags & IFF_RUNNING)) @@ -1344,7 +1335,7 @@ void *data; #endif /* ATM_PVCEXT */ default: - error = EINVAL; + error = ifioctl_common(ifp, cmd, data); break; } splx(s); diff --git a/sys/dev/ic/pdq_ifsubr.c b/sys/dev/ic/pdq_ifsubr.c index 2a713b97b33c..ee57a6a2c8c0 100644 --- a/sys/dev/ic/pdq_ifsubr.c +++ b/sys/dev/ic/pdq_ifsubr.c @@ -1,4 +1,4 @@ -/* $NetBSD: pdq_ifsubr.c,v 1.52 2008/04/08 12:07:27 cegger Exp $ */ +/* $NetBSD: pdq_ifsubr.c,v 1.53 2008/11/07 00:20:02 dyoung Exp $ */ /*- * Copyright (c) 1995, 1996 Matt Thomas @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pdq_ifsubr.c,v 1.52 2008/04/08 12:07:27 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pdq_ifsubr.c,v 1.53 2008/11/07 00:20:02 dyoung Exp $"); #ifdef __NetBSD__ #include "opt_inet.h" @@ -105,21 +105,6 @@ __KERNEL_RCSID(0, "$NetBSD: pdq_ifsubr.c,v 1.52 2008/04/08 12:07:27 cegger Exp $ #include "pdqreg.h" #endif -#if defined(__bsdi__) && _BSDI_VERSION < 199506 /* XXX */ -static void -arp_ifinit( - struct arpcom *ac, - struct ifaddr *ifa) -{ - sc->sc_ac.ac_ipaddr = IA_SIN(ifa)->sin_addr; - arpwhohas(&sc->sc_ac, &IA_SIN(ifa)->sin_addr); -#if _BSDI_VERSION >= 199401 - ifa->ifa_rtrequest = arp_rtrequest; - ifa->ifa_flags |= RTF_CLONING; -#endif -#endif - - void pdq_ifinit( pdq_softc_t *sc) @@ -425,35 +410,25 @@ pdq_ifioctl( s = PDQ_OS_SPL_RAISE(); switch (cmd) { - case SIOCSIFADDR: { + case SIOCINITIFADDR: { struct ifaddr *ifa = (struct ifaddr *)data; ifp->if_flags |= IFF_UP; + pdq_ifinit(sc); switch(ifa->ifa_addr->sa_family) { #if defined(INET) - case AF_INET: { - pdq_ifinit(sc); + case AF_INET: PDQ_ARP_IFINIT(sc, ifa); break; - } #endif /* INET */ - - - default: { - pdq_ifinit(sc); + default: break; - } } break; } - case SIOCGIFADDR: { - struct ifreq *ifr = (struct ifreq *)data; - error = ifreq_setaddr(cmd, ifr, - (const struct sockaddr *)sc->sc_if.if_sadl); - break; - } - case SIOCSIFFLAGS: { + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; pdq_ifinit(sc); break; } @@ -500,7 +475,7 @@ pdq_ifioctl( #endif default: { - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); break; } } diff --git a/sys/dev/ic/rrunner.c b/sys/dev/ic/rrunner.c index b2f10476cd52..64da888621b9 100644 --- a/sys/dev/ic/rrunner.c +++ b/sys/dev/ic/rrunner.c @@ -1,4 +1,4 @@ -/* $NetBSD: rrunner.c,v 1.67 2008/06/08 12:43:51 tsutsui Exp $ */ +/* $NetBSD: rrunner.c,v 1.68 2008/11/07 00:20:02 dyoung Exp $ */ /* * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rrunner.c,v 1.67 2008/06/08 12:43:51 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rrunner.c,v 1.68 2008/11/07 00:20:02 dyoung Exp $"); #include "opt_inet.h" @@ -2939,7 +2939,7 @@ eshioctl(ifp, cmd, data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; if ((sc->sc_flags & ESH_FL_INITIALIZED) == 0) { eshinit(sc); @@ -2973,6 +2973,8 @@ eshioctl(ifp, cmd, data) break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; if ((ifp->if_flags & IFF_UP) == 0 && (ifp->if_flags & IFF_RUNNING) != 0) { /* @@ -3021,7 +3023,7 @@ eshioctl(ifp, cmd, data) break; default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); break; } diff --git a/sys/dev/ic/rt2560.c b/sys/dev/ic/rt2560.c index b4546e4ec16a..98ed35f74fa6 100644 --- a/sys/dev/ic/rt2560.c +++ b/sys/dev/ic/rt2560.c @@ -1,4 +1,4 @@ -/* $NetBSD: rt2560.c,v 1.19 2008/04/08 12:07:27 cegger Exp $ */ +/* $NetBSD: rt2560.c,v 1.20 2008/11/07 00:20:02 dyoung Exp $ */ /* $OpenBSD: rt2560.c,v 1.15 2006/04/20 20:31:12 miod Exp $ */ /* $FreeBSD: rt2560.c,v 1.3 2006/03/21 21:15:43 damien Exp $*/ @@ -24,7 +24,7 @@ * http://www.ralinktech.com/ */ #include -__KERNEL_RCSID(0, "$NetBSD: rt2560.c,v 1.19 2008/04/08 12:07:27 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rt2560.c,v 1.20 2008/11/07 00:20:02 dyoung Exp $"); #include "bpfilter.h" @@ -2201,6 +2201,8 @@ rt2560_ioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; if (ifp->if_flags & IFF_UP) { if (ifp->if_flags & IFF_RUNNING) rt2560_update_promisc(sc); diff --git a/sys/dev/ic/rt2661.c b/sys/dev/ic/rt2661.c index c418b30300a0..6c0fad757cbf 100644 --- a/sys/dev/ic/rt2661.c +++ b/sys/dev/ic/rt2661.c @@ -1,4 +1,4 @@ -/* $NetBSD: rt2661.c,v 1.24 2008/04/29 22:21:45 scw Exp $ */ +/* $NetBSD: rt2661.c,v 1.25 2008/11/07 00:20:03 dyoung Exp $ */ /* $OpenBSD: rt2661.c,v 1.17 2006/05/01 08:41:11 damien Exp $ */ /* $FreeBSD: rt2560.c,v 1.5 2006/06/02 19:59:31 csjp Exp $ */ @@ -25,7 +25,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rt2661.c,v 1.24 2008/04/29 22:21:45 scw Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rt2661.c,v 1.25 2008/11/07 00:20:03 dyoung Exp $"); #include "bpfilter.h" @@ -1931,6 +1931,8 @@ rt2661_ioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; if (ifp->if_flags & IFF_UP) { if (ifp->if_flags & IFF_RUNNING) rt2661_update_promisc(sc); diff --git a/sys/dev/ic/rtw.c b/sys/dev/ic/rtw.c index 46b549e52d52..bcad107b9c8f 100644 --- a/sys/dev/ic/rtw.c +++ b/sys/dev/ic/rtw.c @@ -1,4 +1,4 @@ -/* $NetBSD: rtw.c,v 1.104 2008/03/15 00:21:12 dyoung Exp $ */ +/* $NetBSD: rtw.c,v 1.105 2008/11/07 00:20:03 dyoung Exp $ */ /*- * Copyright (c) 2004, 2005, 2006, 2007 David Young. All rights * reserved. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rtw.c,v 1.104 2008/03/15 00:21:12 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rtw.c,v 1.105 2008/11/07 00:20:03 dyoung Exp $"); #include "bpfilter.h" @@ -2970,7 +2970,9 @@ rtw_ioctl(struct ifnet *ifp, u_long cmd, void *data) s = splnet(); if (cmd == SIOCSIFFLAGS) { - if ((ifp->if_flags & IFF_UP) != 0) { + if ((rc = ifioctl_common(ifp, cmd, data)) != 0) + ; + else if ((ifp->if_flags & IFF_UP) != 0) { if (device_is_active(sc->sc_dev)) rtw_pktfilt_load(sc); else diff --git a/sys/dev/ic/sgec.c b/sys/dev/ic/sgec.c index afcaa429a314..91dde6b6a4a5 100644 --- a/sys/dev/ic/sgec.c +++ b/sys/dev/ic/sgec.c @@ -1,4 +1,4 @@ -/* $NetBSD: sgec.c,v 1.35 2008/03/11 05:34:01 matt Exp $ */ +/* $NetBSD: sgec.c,v 1.36 2008/11/07 00:20:03 dyoung Exp $ */ /* * Copyright (c) 1999 Ludd, University of Lule}, Sweden. All rights reserved. * @@ -45,7 +45,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sgec.c,v 1.35 2008/03/11 05:34:01 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sgec.c,v 1.36 2008/11/07 00:20:03 dyoung Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -547,7 +547,7 @@ zeioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; switch(ifa->ifa_addr->sa_family) { #ifdef INET @@ -560,8 +560,11 @@ zeioctl(struct ifnet *ifp, u_long cmd, void *data) break; case SIOCSIFFLAGS: - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + /* XXX re-use ether_ioctl() */ + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_RUNNING: /* * If interface is marked down and it is running, * stop it. (by disabling receive mechanism). @@ -569,19 +572,23 @@ zeioctl(struct ifnet *ifp, u_long cmd, void *data) ZE_WCSR(ZE_CSR6, ZE_RCSR(ZE_CSR6) & ~(ZE_NICSR6_ST|ZE_NICSR6_SR)); ifp->if_flags &= ~IFF_RUNNING; - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { + break; + case IFF_UP: /* * If interface it marked up and it is stopped, then * start it. */ zeinit(sc); - } else if ((ifp->if_flags & IFF_UP) != 0) { + break; + case IFF_UP|IFF_RUNNING: /* * Send a new setup packet to match any new changes. * (Like IFF_PROMISC etc) */ ze_setup(sc); + break; + case 0: + break; } break; @@ -602,7 +609,7 @@ zeioctl(struct ifnet *ifp, u_long cmd, void *data) break; default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); } splx(s); diff --git a/sys/dev/ic/smc90cx6.c b/sys/dev/ic/smc90cx6.c index 0b028bd86d2e..f114dadf3c65 100644 --- a/sys/dev/ic/smc90cx6.c +++ b/sys/dev/ic/smc90cx6.c @@ -1,4 +1,4 @@ -/* $NetBSD: smc90cx6.c,v 1.56 2008/04/28 20:23:51 martin Exp $ */ +/* $NetBSD: smc90cx6.c,v 1.57 2008/11/07 00:20:03 dyoung Exp $ */ /*- * Copyright (c) 1994, 1995, 1998 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: smc90cx6.c,v 1.56 2008/04/28 20:23:51 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: smc90cx6.c,v 1.57 2008/11/07 00:20:03 dyoung Exp $"); /* #define BAHSOFTCOPY */ #define BAHRETRANSMIT /**/ @@ -276,7 +276,7 @@ bah_reset(sc) #endif /* tell the routing level about the (possibly changed) link address */ - if_set_sadl(ifp, &linkaddress, sizeof(linkaddress)); + if_set_sadl(ifp, &linkaddress, sizeof(linkaddress), false); /* POR is NMI, but we need it below: */ sc->sc_intmask = BAH_RECON|BAH_POR; @@ -922,36 +922,39 @@ bah_ioctl(ifp, cmd, data) #endif switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; + bah_init(sc); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: - bah_init(sc); arp_ifinit(ifp, ifa); break; #endif default: - bah_init(sc); break; } case SIOCSIFFLAGS: - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + /* XXX re-use ether_ioctl() */ + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_RUNNING: /* * If interface is marked down and it is running, * then stop it. */ bah_stop(sc); ifp->if_flags &= ~IFF_RUNNING; - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { + break; + case IFF_UP: /* * If interface is marked up and it is stopped, then * start it. */ bah_init(sc); + break; } break; @@ -969,7 +972,7 @@ bah_ioctl(ifp, cmd, data) break; default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); } splx(s); diff --git a/sys/dev/ic/smc91cxx.c b/sys/dev/ic/smc91cxx.c index 20111bed330c..dfa14a4b8e01 100644 --- a/sys/dev/ic/smc91cxx.c +++ b/sys/dev/ic/smc91cxx.c @@ -1,4 +1,4 @@ -/* $NetBSD: smc91cxx.c,v 1.70 2008/09/03 20:36:24 rjs Exp $ */ +/* $NetBSD: smc91cxx.c,v 1.71 2008/11/07 00:20:03 dyoung Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: smc91cxx.c,v 1.70 2008/09/03 20:36:24 rjs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: smc91cxx.c,v 1.71 2008/11/07 00:20:03 dyoung Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -1353,27 +1353,29 @@ smc91cxx_ioctl(ifp, cmd, data) s = splnet(); switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: if ((error = smc91cxx_enable(sc)) != 0) break; ifp->if_flags |= IFF_UP; + smc91cxx_init(sc); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: - smc91cxx_init(sc); - arp_ifinit(ifp, ifa); - break; + arp_ifinit(ifp, ifa); + break; #endif default: - smc91cxx_init(sc); break; } break; case SIOCSIFFLAGS: - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + /* XXX re-use ether_ioctl() */ + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_RUNNING: /* * If interface is marked down and it is running, * stop it. @@ -1381,8 +1383,8 @@ smc91cxx_ioctl(ifp, cmd, data) smc91cxx_stop(sc); ifp->if_flags &= ~IFF_RUNNING; smc91cxx_disable(sc); - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { + break; + case IFF_UP: /* * If interface is marked up and it is stopped, * start it. @@ -1390,12 +1392,16 @@ smc91cxx_ioctl(ifp, cmd, data) if ((error = smc91cxx_enable(sc)) != 0) break; smc91cxx_init(sc); - } else if ((ifp->if_flags & IFF_UP) != 0) { + break; + case IFF_UP|IFF_RUNNING: /* * Reset the interface to pick up changes in any * other flags that affect hardware registers. */ smc91cxx_reset(sc); + break; + case 0: + break; } break; @@ -1423,7 +1429,7 @@ smc91cxx_ioctl(ifp, cmd, data) break; default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); break; } diff --git a/sys/dev/ic/tropic.c b/sys/dev/ic/tropic.c index ed0561378740..7711758a8d23 100644 --- a/sys/dev/ic/tropic.c +++ b/sys/dev/ic/tropic.c @@ -1,4 +1,4 @@ -/* $NetBSD: tropic.c,v 1.34 2008/04/08 12:07:27 cegger Exp $ */ +/* $NetBSD: tropic.c,v 1.35 2008/11/07 00:20:03 dyoung Exp $ */ /* * Ported to NetBSD by Onno van der Linden @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tropic.c,v 1.34 2008/04/08 12:07:27 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tropic.c,v 1.35 2008/11/07 00:20:03 dyoung Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -1525,10 +1525,7 @@ struct ifnet *ifp; * tr_ioctl - process an ioctl request */ int -tr_ioctl(ifp, cmd, data) -struct ifnet *ifp; -u_long cmd; -void *data; +tr_ioctl(struct ifnet *ifp, u_long cmd, void *data) { struct tr_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *) data; @@ -1539,68 +1536,65 @@ void *data; s = splnet(); switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: if ((error = tr_enable(sc)) != 0) break; + /* XXX if not running */ + if ((ifp->if_flags & IFF_RUNNING) == 0) { + tr_init(sc); /* before arp_ifinit/arpwhohas */ + tr_sleep(sc); + } switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: - /* XXX if not running */ - if ((ifp->if_flags & IFF_RUNNING) == 0) { - tr_init(sc); /* before arp_ifinit */ - tr_sleep(sc); - } arp_ifinit(ifp, ifa); break; #endif /*INET*/ default: - /* XXX if not running */ - if ((ifp->if_flags & IFF_RUNNING) == 0) { - tr_init(sc); /* before arpwhohas */ - tr_sleep(sc); - } break; } break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; /* * 1- If the adapter is DOWN , turn the device off * ie. adapter down but still running * 2- If the adapter is UP, turn the device on * ie. adapter up but not running yet */ - if ((ifp->if_flags & (IFF_RUNNING | IFF_UP)) == IFF_RUNNING) { + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_RUNNING: tr_stop(sc); ifp->if_flags &= ~IFF_RUNNING; tr_disable(sc); - } - else if ((ifp->if_flags & (IFF_RUNNING | IFF_UP)) == IFF_UP) { + break; + case IFF_UP: if ((error = tr_enable(sc)) != 0) break; tr_init(sc); tr_sleep(sc); - } - else { -/* - * XXX handle other flag changes - */ + break; + default: + /* + * XXX handle other flag changes + */ + break; } break; case SIOCGIFMEDIA: case SIOCSIFMEDIA: error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd); break; -#ifdef SIOCSIFMTU case SIOCSIFMTU: if (ifr->ifr_mtu > sc->sc_maxmtu) error = EINVAL; else if ((error = ifioctl_common(ifp, cmd, data)) == ENETRESET) error = 0; break; -#endif default: - error = EINVAL; + error = ifioctl_common(ifp, cmd, data); } splx(s); return (error); diff --git a/sys/dev/ic/tulip.c b/sys/dev/ic/tulip.c index 8de88c536d12..3b73c5f6ff6c 100644 --- a/sys/dev/ic/tulip.c +++ b/sys/dev/ic/tulip.c @@ -1,4 +1,4 @@ -/* $NetBSD: tulip.c,v 1.163 2008/04/28 20:23:51 martin Exp $ */ +/* $NetBSD: tulip.c,v 1.164 2008/11/07 00:20:03 dyoung Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2002 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.163 2008/04/28 20:23:51 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.164 2008/11/07 00:20:03 dyoung Exp $"); #include "bpfilter.h" @@ -93,6 +93,7 @@ static void tlp_watchdog(struct ifnet *); static int tlp_ioctl(struct ifnet *, u_long, void *); static int tlp_init(struct ifnet *); static void tlp_stop(struct ifnet *, int); +static int tlp_ifflags_cb(struct ethercom *); static void tlp_rxdrain(struct tulip_softc *); static int tlp_add_rxbuf(struct tulip_softc *, int); @@ -525,6 +526,7 @@ tlp_attach(struct tulip_softc *sc, const u_int8_t *enaddr) */ if_attach(ifp); ether_ifattach(ifp, enaddr); + ether_set_ifflags_cb(&sc->sc_ethercom, tlp_ifflags_cb); #if NRND > 0 rnd_attach_source(&sc->sc_rnd_source, device_xname(&sc->sc_dev), RND_TYPE_NET, 0); @@ -958,6 +960,24 @@ tlp_watchdog(struct ifnet *ifp) tlp_start(ifp); } +/* If the interface is up and running, only modify the receive + * filter when setting promiscuous or debug mode. Otherwise fall + * through to ether_ioctl, which will reset the chip. + */ +static int +tlp_ifflags_cb(struct ethercom *ec) +{ + struct ifnet *ifp = &ec->ec_if; + struct tulip_softc *sc = ifp->if_softc; + int change = ifp->if_flags ^ sc->sc_if_flags; + + if ((change & ~(IFF_CANTCHANGE|IFF_DEBUG)) != 0) + return ENETRESET; + if ((change & IFF_PROMISC) != 0) + (*sc->sc_filter_setup)(sc); + return 0; +} + /* * tlp_ioctl: [ifnet interface function] * @@ -977,23 +997,6 @@ tlp_ioctl(struct ifnet *ifp, u_long cmd, void *data) case SIOCGIFMEDIA: error = ifmedia_ioctl(ifp, ifr, &sc->sc_mii.mii_media, cmd); break; - case SIOCSIFFLAGS: - /* If the interface is up and running, only modify the receive - * filter when setting promiscuous or debug mode. Otherwise - * fall through to ether_ioctl, which will reset the chip. - */ -#define RESETIGN (IFF_CANTCHANGE|IFF_DEBUG) - if (((ifp->if_flags & (IFF_UP|IFF_RUNNING)) - == (IFF_UP|IFF_RUNNING)) - && ((ifp->if_flags & (~RESETIGN)) - == (sc->sc_if_flags & (~RESETIGN)))) { - /* Set up the receive filter. */ - (*sc->sc_filter_setup)(sc); - error = 0; - break; -#undef RESETIGN - } - /* FALLTHROUGH */ default: error = ether_ioctl(ifp, cmd, data); if (error == ENETRESET) { diff --git a/sys/dev/ic/wi.c b/sys/dev/ic/wi.c index 4df8bd8e2299..e58e248c09dd 100644 --- a/sys/dev/ic/wi.c +++ b/sys/dev/ic/wi.c @@ -1,4 +1,4 @@ -/* $NetBSD: wi.c,v 1.226 2008/04/28 20:23:51 martin Exp $ */ +/* $NetBSD: wi.c,v 1.227 2008/11/07 00:20:03 dyoung Exp $ */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -99,7 +99,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wi.c,v 1.226 2008/04/28 20:23:51 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wi.c,v 1.227 2008/11/07 00:20:03 dyoung Exp $"); #define WI_HERMES_AUTOINC_WAR /* Work around data write autoinc bug. */ #define WI_HERMES_STATS_WAR /* Work around stats counter bug. */ @@ -1325,6 +1325,8 @@ wi_ioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; /* * Can't do promisc and hostap at the same time. If all that's * changing is the promisc flag, try to short-circuit a call to @@ -2260,8 +2262,9 @@ wi_set_cfg(struct ifnet *ifp, u_long cmd, void *data) len = (wreq.wi_len - 1) * 2; switch (wreq.wi_type) { case WI_RID_MAC_NODE: + /* XXX convert to SIOCALIFADDR, AF_LINK, IFLR_ACTIVE */ (void)memcpy(ic->ic_myaddr, wreq.wi_val, ETHER_ADDR_LEN); - if_set_sadl(ifp, ic->ic_myaddr, ETHER_ADDR_LEN); + if_set_sadl(ifp, ic->ic_myaddr, ETHER_ADDR_LEN, false); wi_write_rid(sc, WI_RID_MAC_NODE, ic->ic_myaddr, IEEE80211_ADDR_LEN); break; diff --git a/sys/dev/ieee1394/if_fwip.c b/sys/dev/ieee1394/if_fwip.c index 083a5877ba55..3163400d6154 100644 --- a/sys/dev/ieee1394/if_fwip.c +++ b/sys/dev/ieee1394/if_fwip.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_fwip.c,v 1.15 2008/06/24 10:13:51 gmcgarry Exp $ */ +/* $NetBSD: if_fwip.c,v 1.16 2008/11/07 00:20:07 dyoung Exp $ */ /*- * Copyright (c) 2004 * Doug Rabson @@ -38,7 +38,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_fwip.c,v 1.15 2008/06/24 10:13:51 gmcgarry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_fwip.c,v 1.16 2008/11/07 00:20:07 dyoung Exp $"); #ifdef HAVE_KERNEL_OPTION_HEADERS #include "opt_device_polling.h" @@ -540,19 +540,13 @@ fwip_ioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { case SIOCSIFFLAGS: s = splfwnet(); - if (ifp->if_flags & IFF_UP) { -#if defined(__FreeBSD__) - if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) -#elif defined(__NetBSD__) + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + ; + else if (ifp->if_flags & IFF_UP) { if (!(ifp->if_flags & IFF_RUNNING)) -#endif FWIP_INIT(fwip); } else { -#if defined(__FreeBSD__) - if (ifp->if_drv_flags & IFF_DRV_RUNNING) -#elif defined(__NetBSD__) if (ifp->if_flags & IFF_RUNNING) -#endif FWIP_STOP(fwip); } splx(s); @@ -592,22 +586,11 @@ fwip_ioctl(struct ifnet *ifp, u_long cmd, void *data) #endif /* DEVICE_POLLING */ break; -#if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) || defined(__NetBSD__) default: -#else - case SIOCSIFADDR: - case SIOCGIFADDR: - case SIOCSIFMTU: -#endif s = splfwnet(); error = FIREWIRE_IOCTL(ifp, cmd, data); splx(s); return (error); -#if defined(__DragonFly__) || \ - (defined(__FreeBSD__) && __FreeBSD_version < 500000) - default: - return (EINVAL); -#endif } return error; diff --git a/sys/dev/if_ndis/if_ndis.c b/sys/dev/if_ndis/if_ndis.c index 7cacc2fcfd6f..7b3db4b7733e 100644 --- a/sys/dev/if_ndis/if_ndis.c +++ b/sys/dev/if_ndis/if_ndis.c @@ -35,7 +35,7 @@ __FBSDID("$FreeBSD: src/sys/dev/if_ndis/if_ndis.c,v 1.69.2.6 2005/03/31 04:24:36 wpaul Exp $"); #endif #ifdef __NetBSD__ -__KERNEL_RCSID(0, "$NetBSD: if_ndis.c,v 1.18 2008/04/08 06:12:21 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ndis.c,v 1.19 2008/11/07 00:20:07 dyoung Exp $"); #endif #ifdef __FreeBSD__ @@ -2522,10 +2522,7 @@ ndis_getstate_80211(sc) } static int -ndis_ioctl(ifp, command, data) - struct ifnet *ifp; - u_long command; - void * data; +ndis_ioctl(struct ifnet *ifp, u_long command, void *data) { struct ndis_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *) data; @@ -2541,6 +2538,8 @@ ndis_ioctl(ifp, command, data) switch(command) { case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, command, data)) != 0) + break; if (ifp->if_flags & IFF_UP) { if (ifp->if_flags & IFF_RUNNING && ifp->if_flags & IFF_PROMISC && @@ -2561,11 +2560,7 @@ ndis_ioctl(ifp, command, data) OID_GEN_CURRENT_PACKET_FILTER, &sc->ndis_filter, &i); } else -#ifdef __FreeBSD__ - ndis_init(sc); -#else /* __NetBSD__ */ ndis_init(ifp); -#endif } else { if (ifp->if_flags & IFF_RUNNING) ndis_stop(sc); @@ -2618,11 +2613,7 @@ ndis_ioctl(ifp, command, data) default: sc->ndis_skip = 1; if (sc->ndis_80211) { -#ifdef __FreeBSD__ - error = ieee80211_ioctl(ifp, command, data); -#else /* __NetBSD__ */ error = ieee80211_ioctl(&sc->ic, command, data); -#endif if (error == ENETRESET) { ndis_setstate_80211(sc); diff --git a/sys/dev/isa/if_eg.c b/sys/dev/isa/if_eg.c index 60ff5f48a67c..ae45d4a7e6fc 100644 --- a/sys/dev/isa/if_eg.c +++ b/sys/dev/isa/if_eg.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_eg.c,v 1.76 2008/04/08 20:08:49 cegger Exp $ */ +/* $NetBSD: if_eg.c,v 1.77 2008/11/07 00:20:07 dyoung Exp $ */ /* * Copyright (c) 1993 Dean Huxley @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_eg.c,v 1.76 2008/04/08 20:08:49 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_eg.c,v 1.77 2008/11/07 00:20:07 dyoung Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -838,10 +838,7 @@ bad: } int -egioctl(ifp, cmd, data) - struct ifnet *ifp; - u_long cmd; - void *data; +egioctl(struct ifnet *ifp, unsigned long cmd, void *data) { struct eg_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; @@ -851,39 +848,42 @@ egioctl(ifp, cmd, data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; + eginit(sc); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: - eginit(sc); arp_ifinit(ifp, ifa); break; #endif default: - eginit(sc); break; } break; case SIOCSIFFLAGS: - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + /* XXX re-use ether_ioctl() */ + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_RUNNING: /* * If interface is marked down and it is running, then * stop it. */ egstop(sc); ifp->if_flags &= ~IFF_RUNNING; - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { + break; + case IFF_UP: /* * If interface is marked up and it is stopped, then * start it. */ eginit(sc); - } else { + break; + default: sc->eg_pcb[0] = EG_CMD_GETSTATS; sc->eg_pcb[1] = 0; if (egwritePCB(sc->sc_iot, sc->sc_ioh, sc->eg_pcb) != 0) { @@ -894,11 +894,12 @@ egioctl(ifp, cmd, data) * IFF_MULTICAST, IFF_PROMISC, * IFF_LINK0, IFF_LINK1, */ + break; } break; default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); break; } diff --git a/sys/dev/isa/if_el.c b/sys/dev/isa/if_el.c index e5a66d720af8..58588b86a9a8 100644 --- a/sys/dev/isa/if_el.c +++ b/sys/dev/isa/if_el.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_el.c,v 1.80 2008/04/08 20:08:50 cegger Exp $ */ +/* $NetBSD: if_el.c,v 1.81 2008/11/07 00:20:07 dyoung Exp $ */ /* * Copyright (c) 1994, Matthew E. Kimmel. Permission is hereby granted @@ -19,7 +19,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_el.c,v 1.80 2008/04/08 20:08:50 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_el.c,v 1.81 2008/11/07 00:20:07 dyoung Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -682,10 +682,7 @@ bad: * Process an ioctl request. This code needs some work - it looks pretty ugly. */ int -elioctl(ifp, cmd, data) - struct ifnet *ifp; - u_long cmd; - void *data; +elioctl(struct ifnet *ifp, u_long cmd, void *data) { struct el_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; @@ -695,49 +692,53 @@ elioctl(ifp, cmd, data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; + elinit(sc); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: - elinit(sc); arp_ifinit(ifp, ifa); break; #endif default: - elinit(sc); break; } break; case SIOCSIFFLAGS: - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + /* XXX re-use ether_ioctl() */ + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_RUNNING: /* * If interface is marked down and it is running, then * stop it. */ elstop(sc); ifp->if_flags &= ~IFF_RUNNING; - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { + break; + case IFF_UP: /* * If interface is marked up and it is stopped, then * start it. */ elinit(sc); - } else { + break; + default: /* * Some other important flag might have changed, so * reset. */ elreset(sc); + break; } break; default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); break; } diff --git a/sys/dev/isa/if_hp.c b/sys/dev/isa/if_hp.c index 7356a39eb8ee..7368a9231906 100644 --- a/sys/dev/isa/if_hp.c +++ b/sys/dev/isa/if_hp.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_hp.c,v 1.44 2008/04/08 20:08:50 cegger Exp $ */ +/* $NetBSD: if_hp.c,v 1.45 2008/11/07 00:20:07 dyoung Exp $ */ /* XXX THIS DRIVER IS BROKEN. IT WILL NOT EVEN COMPILE. */ @@ -80,7 +80,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_hp.c,v 1.44 2008/04/08 20:08:50 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_hp.c,v 1.45 2008/11/07 00:20:07 dyoung Exp $"); #include "hp.h" #if NHP > 0 @@ -963,10 +963,7 @@ hpget(buf, totlen, off0, ifp) /* * Process an ioctl request. */ -hpioctl(ifp, cmd, data) - struct ifnet *ifp; - u_long cmd; - void *data; +hpioctl(struct ifnet *ifp, u_long cmd, void *data) { struct ifaddr *ifa = (struct ifaddr *) data; struct hp_softc *ns = &hp_softc[ifp->if_unit]; @@ -976,38 +973,43 @@ hpioctl(ifp, cmd, data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; + hpinit(ifp->if_unit); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: - hpinit(ifp->if_unit); /* before arpwhohas */ ((struct arpcom *) ifp)->ac_ipaddr = IA_SIN(ifa)->sin_addr; arpwhohas((struct arpcom *) ifp, &IA_SIN(ifa)->sin_addr); break; #endif default: - hpinit(ifp->if_unit); break; } break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; #ifdef HP_DEBUG printf("hp: setting flags, up: %s, running: %s\n", ifp->if_flags & IFF_UP ? "yes" : "no", ifp->if_flags & IFF_RUNNING ? "yes" : "no"); #endif - if ((ifp->if_flags & IFF_UP) == 0 && - ifp->if_flags & IFF_RUNNING) { + /* XXX re-use ether_ioctl() */ + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_RUNNING: ifp->if_flags &= ~IFF_RUNNING; outb(ns->ns_port + ds_cmd, DSCM_STOP | DSCM_NODMA); - } else - if (ifp->if_flags & IFF_UP && - (ifp->if_flags & IFF_RUNNING) == 0) - hpinit(ifp->if_unit); + break; + case IFF_UP: + hpinit(ifp->if_unit); + break; + default: + break; + } break; #ifdef notdef @@ -1018,7 +1020,7 @@ hpioctl(ifp, cmd, data) #endif default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); } splx(s); return (error); diff --git a/sys/dev/isa/if_iy.c b/sys/dev/isa/if_iy.c index 7d2626708f36..0341f34b866d 100644 --- a/sys/dev/isa/if_iy.c +++ b/sys/dev/isa/if_iy.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_iy.c,v 1.80 2008/04/28 20:23:52 martin Exp $ */ +/* $NetBSD: if_iy.c,v 1.81 2008/11/07 00:20:07 dyoung Exp $ */ /* #define IYDEBUG */ /* #define IYMEMDEBUG */ @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_iy.c,v 1.80 2008/04/28 20:23:52 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_iy.c,v 1.81 2008/11/07 00:20:07 dyoung Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -1186,10 +1186,7 @@ struct iy_softc *sc; } int -iyioctl(ifp, cmd, data) - struct ifnet *ifp; - u_long cmd; - void *data; +iyioctl(struct ifnet *ifp, u_long cmd, void *data) { struct iy_softc *sc; struct ifaddr *ifa; @@ -1209,46 +1206,50 @@ iyioctl(ifp, cmd, data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; + iyinit(sc); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: - iyinit(sc); arp_ifinit(ifp, ifa); break; #endif default: - iyinit(sc); break; } break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; sc->promisc = ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI); - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { + /* XXX re-use ether_ioctl() */ + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_RUNNING: /* * If interface is marked down and it is running, then * stop it. */ iystop(sc); ifp->if_flags &= ~IFF_RUNNING; - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { + break; + case IFF_UP: /* * If interface is marked up and it is stopped, then * start it. */ iyinit(sc); - } else { + break; + default: /* * Reset the interface to pick up changes in any other * flags that affect hardware registers. */ iystop(sc); iyinit(sc); + break; } #ifdef IYDEBUGX if (ifp->if_flags & IFF_DEBUG) @@ -1279,7 +1280,7 @@ iyioctl(ifp, cmd, data) error = ifmedia_ioctl(ifp, ifr, &sc->iy_ifmedia, cmd); break; default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); } splx(s); return error; diff --git a/sys/dev/marvell/if_gfe.c b/sys/dev/marvell/if_gfe.c index e64e1c236d96..bdd07dd13bb9 100644 --- a/sys/dev/marvell/if_gfe.c +++ b/sys/dev/marvell/if_gfe.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_gfe.c,v 1.30 2008/06/10 22:44:07 he Exp $ */ +/* $NetBSD: if_gfe.c,v 1.31 2008/11/07 00:20:07 dyoung Exp $ */ /* * Copyright (c) 2002 Allegro Networks, Inc., Wasabi Systems, Inc. @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_gfe.c,v 1.30 2008/06/10 22:44:07 he Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_gfe.c,v 1.31 2008/11/07 00:20:07 dyoung Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -436,23 +436,25 @@ gfe_ifioctl(struct ifnet *ifp, u_long cmd, void *data) s = splnet(); switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; + error = gfe_whack(sc, GE_WHACK_START); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: - error = gfe_whack(sc, GE_WHACK_START); if (error == 0) arp_ifinit(ifp, ifa); break; #endif default: - error = gfe_whack(sc, GE_WHACK_START); break; } break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + /* XXX re-use ether_ioctl() */ switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { case IFF_UP|IFF_RUNNING:/* active->active, update */ error = gfe_whack(sc, GE_WHACK_CHANGE); @@ -490,7 +492,7 @@ gfe_ifioctl(struct ifnet *ifp, u_long cmd, void *data) break; default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); break; } splx(s); diff --git a/sys/dev/ofw/ofnet.c b/sys/dev/ofw/ofnet.c index cad542738956..ea61f3f4c1db 100644 --- a/sys/dev/ofw/ofnet.c +++ b/sys/dev/ofw/ofnet.c @@ -1,4 +1,4 @@ -/* $NetBSD: ofnet.c,v 1.41 2008/04/08 20:11:58 cegger Exp $ */ +/* $NetBSD: ofnet.c,v 1.42 2008/11/07 00:20:07 dyoung Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ofnet.c,v 1.41 2008/04/08 20:11:58 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ofnet.c,v 1.42 2008/11/07 00:20:07 dyoung Exp $"); #include "ofnet.h" #include "opt_inet.h" @@ -374,7 +374,7 @@ ofnet_ioctl(struct ifnet *ifp, u_long cmd, void *data) int error = 0; switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; switch (ifa->ifa_addr->sa_family) { @@ -389,20 +389,25 @@ ofnet_ioctl(struct ifnet *ifp, u_long cmd, void *data) ofnet_init(of); break; case SIOCSIFFLAGS: - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + /* XXX re-use ether_ioctl() */ + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_RUNNING: /* If interface is down, but running, stop it. */ ofnet_stop(of); - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { + break; + case IFF_UP: /* If interface is up, but not running, start it. */ ofnet_init(of); - } else { + break; + default: /* Other flags are ignored. */ + break; } break; default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); break; } return error; diff --git a/sys/dev/pci/cxgb_main.c b/sys/dev/pci/cxgb_main.c index f9f1dc3df786..1385c2811766 100644 --- a/sys/dev/pci/cxgb_main.c +++ b/sys/dev/pci/cxgb_main.c @@ -29,7 +29,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #ifdef __NetBSD__ -__KERNEL_RCSID(0, "$NetBSD: cxgb_main.c,v 1.11 2008/02/07 01:21:55 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cxgb_main.c,v 1.12 2008/11/07 00:20:07 dyoung Exp $"); #endif #ifdef __FreeBSD__ __FBSDID("$FreeBSD: src/sys/dev/cxgb/cxgb_main.c,v 1.36 2007/09/11 23:49:27 kmacy Exp $"); @@ -2356,10 +2356,8 @@ cxgb_ioctl(struct ifnet *ifp, unsigned long command, void *data) error = cxgb_set_mtu(p, ifr->ifr_mtu); printf("SIOCSIFMTU: error=%d\n", error); break; - case SIOCSIFADDR: - printf("SIOCSIFADDR:\n"); - case SIOCGIFADDR: - printf("SIOCGIFADDR:\n"); + case SIOCINITIFADDR: + printf("SIOCINITIFADDR:\n"); PORT_LOCK(p); if (ifa->ifa_addr->sa_family == AF_INET) { ifp->if_flags |= IFF_UP; @@ -2372,6 +2370,8 @@ cxgb_ioctl(struct ifnet *ifp, unsigned long command, void *data) break; case SIOCSIFFLAGS: printf("SIOCSIFFLAGS:\n"); + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; callout_drain(&p->adapter->cxgb_tick_ch); PORT_LOCK(p); if (ifp->if_flags & IFF_UP) { diff --git a/sys/dev/pci/if_bge.c b/sys/dev/pci/if_bge.c index a212ec81a7ab..9081e7d86ce1 100644 --- a/sys/dev/pci/if_bge.c +++ b/sys/dev/pci/if_bge.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_bge.c,v 1.152 2008/08/31 19:57:03 tron Exp $ */ +/* $NetBSD: if_bge.c,v 1.153 2008/11/07 00:20:07 dyoung Exp $ */ /* * Copyright (c) 2001 Wind River Systems @@ -79,7 +79,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.152 2008/08/31 19:57:03 tron Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.153 2008/11/07 00:20:07 dyoung Exp $"); #include "bpfilter.h" #include "vlan.h" @@ -4290,6 +4290,8 @@ bge_ioctl(struct ifnet *ifp, u_long command, void *data) switch(command) { case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, command, data)) != 0) + break; if (ifp->if_flags & IFF_UP) { /* * If only the state of the PROMISC flag changed, diff --git a/sys/dev/pci/if_de.c b/sys/dev/pci/if_de.c index 70e555831112..2a14de765afb 100644 --- a/sys/dev/pci/if_de.c +++ b/sys/dev/pci/if_de.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_de.c,v 1.128 2008/04/10 19:13:36 cegger Exp $ */ +/* $NetBSD: if_de.c,v 1.129 2008/11/07 00:20:07 dyoung Exp $ */ /*- * Copyright (c) 1994-1997 Matt Thomas (matt@3am-software.com) @@ -37,7 +37,7 @@ * board which support 21040, 21041, or 21140 (mostly). */ #include -__KERNEL_RCSID(0, "$NetBSD: if_de.c,v 1.128 2008/04/10 19:13:36 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_de.c,v 1.129 2008/11/07 00:20:07 dyoung Exp $"); #define TULIP_HDR_DATA @@ -4744,10 +4744,7 @@ tulip_txput_setup( * defined or not. */ static int -tulip_ifioctl( - struct ifnet * ifp, - ioctl_cmd_t cmd, - void *data) +tulip_ifioctl(struct ifnet *ifp, unsigned long cmd, void *data) { TULIP_PERFSTART(ifioctl) tulip_softc_t * const sc = TULIP_IFP_TO_SOFTC(ifp); @@ -4762,32 +4759,24 @@ tulip_ifioctl( s = TULIP_RAISESPL(); #endif switch (cmd) { - case SIOCSIFADDR: { + case SIOCINITIFADDR: { ifp->if_flags |= IFF_UP; + tulip_init(sc); switch(ifa->ifa_addr->sa_family) { #ifdef INET - case AF_INET: { - tulip_init(sc); + case AF_INET: TULIP_ARP_IFINIT(sc, ifa); break; - } #endif /* INET */ - - - default: { - tulip_init(sc); + default: break; - } } break; } - case SIOCGIFADDR: { - memcpy((void *) ((struct sockaddr *)&ifr->ifr_data)->sa_data, - (void *) sc->tulip_enaddr, ETHER_ADDR_LEN); - break; - } case SIOCSIFFLAGS: { + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; #if !defined(IFM_ETHER) int flags = 0; if (ifp->if_flags & IFF_LINK0) flags |= 1; @@ -4882,7 +4871,7 @@ tulip_ifioctl( } #endif default: { - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); break; } } diff --git a/sys/dev/pci/if_dge.c b/sys/dev/pci/if_dge.c index 49effc748407..6f2fc9c5d40b 100644 --- a/sys/dev/pci/if_dge.c +++ b/sys/dev/pci/if_dge.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_dge.c,v 1.21 2008/04/10 19:13:36 cegger Exp $ */ +/* $NetBSD: if_dge.c,v 1.22 2008/11/07 00:20:07 dyoung Exp $ */ /* * Copyright (c) 2004, SUNET, Swedish University Computer Network. @@ -80,7 +80,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_dge.c,v 1.21 2008/04/10 19:13:36 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_dge.c,v 1.22 2008/11/07 00:20:07 dyoung Exp $"); #include "bpfilter.h" #include "rnd.h" @@ -1428,6 +1428,8 @@ dge_ioctl(struct ifnet *ifp, u_long cmd, void *data) break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; /* extract link flags */ if ((ifp->if_flags & IFF_LINK0) == 0 && (ifp->if_flags & IFF_LINK1) == 0) diff --git a/sys/dev/pci/if_ipw.c b/sys/dev/pci/if_ipw.c index ee0995a42f03..41ba7ee63b1b 100644 --- a/sys/dev/pci/if_ipw.c +++ b/sys/dev/pci/if_ipw.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ipw.c,v 1.42 2008/10/30 00:27:32 joerg Exp $ */ +/* $NetBSD: if_ipw.c,v 1.43 2008/11/07 00:20:07 dyoung Exp $ */ /* FreeBSD: src/sys/dev/ipw/if_ipw.c,v 1.15 2005/11/13 17:17:40 damien Exp */ /*- @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ipw.c,v 1.42 2008/10/30 00:27:32 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ipw.c,v 1.43 2008/11/07 00:20:07 dyoung Exp $"); /*- * Intel(R) PRO/Wireless 2100 MiniPCI driver @@ -1616,6 +1616,8 @@ ipw_ioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; if (ifp->if_flags & IFF_UP) { if (!(ifp->if_flags & IFF_RUNNING)) ipw_init(ifp); @@ -1994,7 +1996,6 @@ ipw_config(struct ipw_softc *sc) } DPRINTF(("Setting MAC to %s\n", ether_sprintf(ic->ic_myaddr))); - if_set_sadl(ifp, ic->ic_myaddr, IEEE80211_ADDR_LEN); error = ipw_cmd(sc, IPW_CMD_SET_MAC_ADDRESS, ic->ic_myaddr, IEEE80211_ADDR_LEN); if (error != 0) diff --git a/sys/dev/pci/if_iwi.c b/sys/dev/pci/if_iwi.c index de0a6bf2781f..ad569f2ee5b0 100644 --- a/sys/dev/pci/if_iwi.c +++ b/sys/dev/pci/if_iwi.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_iwi.c,v 1.74 2008/10/30 00:27:32 joerg Exp $ */ +/* $NetBSD: if_iwi.c,v 1.75 2008/11/07 00:20:07 dyoung Exp $ */ /*- * Copyright (c) 2004, 2005 @@ -28,7 +28,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_iwi.c,v 1.74 2008/10/30 00:27:32 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_iwi.c,v 1.75 2008/11/07 00:20:07 dyoung Exp $"); /*- * Intel(R) PRO/Wireless 2200BG/2225BG/2915ABG driver @@ -1824,6 +1824,8 @@ iwi_ioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; if (ifp->if_flags & IFF_UP) { if (!(ifp->if_flags & IFF_RUNNING)) iwi_init(ifp); diff --git a/sys/dev/pci/if_iwn.c b/sys/dev/pci/if_iwn.c index c79317efa41a..df1643322ec9 100644 --- a/sys/dev/pci/if_iwn.c +++ b/sys/dev/pci/if_iwn.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_iwn.c,v 1.24 2008/11/06 12:03:43 blymn Exp $ */ +/* $NetBSD: if_iwn.c,v 1.25 2008/11/07 00:20:07 dyoung Exp $ */ /*- * Copyright (c) 2007 @@ -18,7 +18,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_iwn.c,v 1.24 2008/11/06 12:03:43 blymn Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_iwn.c,v 1.25 2008/11/07 00:20:07 dyoung Exp $"); /* @@ -2296,6 +2296,8 @@ iwn_ioctl(struct ifnet *ifp, u_long cmd, void * data) switch (cmd) { case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; if (ifp->if_flags & IFF_UP) { if (!(ifp->if_flags & IFF_RUNNING)) iwn_init(ifp); diff --git a/sys/dev/pci/if_lmc.c b/sys/dev/pci/if_lmc.c index d86094f77b6e..b6a9ce9f418c 100644 --- a/sys/dev/pci/if_lmc.c +++ b/sys/dev/pci/if_lmc.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_lmc.c,v 1.43 2008/06/27 00:53:41 gmcgarry Exp $ */ +/* $NetBSD: if_lmc.c,v 1.44 2008/11/07 00:20:07 dyoung Exp $ */ /*- * Copyright (c) 2002-2006 David Boggs. @@ -142,7 +142,7 @@ #if defined(__NetBSD__) # include -__KERNEL_RCSID(0, "$NetBSD: if_lmc.c,v 1.43 2008/06/27 00:53:41 gmcgarry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_lmc.c,v 1.44 2008/11/07 00:20:07 dyoung Exp $"); # include /* OS version */ /* -DLKM is passed on the compiler command line */ # include "opt_inet.h" /* INET6, INET */ @@ -3549,11 +3549,13 @@ rawip_ioctl(softc_t *sc, u_long cmd, void *data) case SIOCDELMULTI: if (sc->config.debug) printf("%s: rawip_ioctl: SIOCADD/DELMULTI\n", NAME_UNIT); - case SIOCAIFADDR: case SIOCSIFFLAGS: + error = ifioctl_common(sc->ifp, cmd, data); + break; + case SIOCAIFADDR: case SIOCSIFDSTADDR: break; - case SIOCSIFADDR: + case SIOCINITIFADDR: sc->ifp->if_flags |= IFF_UP; /* a Unix tradition */ break; case SIOCSIFMTU: diff --git a/sys/dev/pci/if_nfe.c b/sys/dev/pci/if_nfe.c index c81b0dfbfa32..17aada93db10 100644 --- a/sys/dev/pci/if_nfe.c +++ b/sys/dev/pci/if_nfe.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_nfe.c,v 1.36 2008/06/17 12:59:32 cube Exp $ */ +/* $NetBSD: if_nfe.c,v 1.37 2008/11/07 00:20:07 dyoung Exp $ */ /* $OpenBSD: if_nfe.c,v 1.77 2008/02/05 16:52:50 brad Exp $ */ /*- @@ -21,7 +21,7 @@ /* Driver for NVIDIA nForce MCP Fast Ethernet and Gigabit Ethernet */ #include -__KERNEL_RCSID(0, "$NetBSD: if_nfe.c,v 1.36 2008/06/17 12:59:32 cube Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_nfe.c,v 1.37 2008/11/07 00:20:07 dyoung Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -74,6 +74,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_nfe.c,v 1.36 2008/06/17 12:59:32 cube Exp $"); #include #include +static int nfe_ifflags_cb(struct ethercom *); + int nfe_match(device_t, cfdata_t, void *); void nfe_attach(device_t, device_t, void *); void nfe_power(int, void *); @@ -363,10 +365,8 @@ nfe_attach(device_t parent, device_t self, void *aux) IFQ_SET_READY(&ifp->if_snd); strlcpy(ifp->if_xname, device_xname(self), IFNAMSIZ); -#ifdef notyet if (sc->sc_flags & NFE_USE_JUMBO) - ifp->if_hardmtu = NFE_JUMBO_MTU; -#endif + sc->sc_ethercom.ec_capabilities |= ETHERCAP_JUMBO_MTU; #if NVLAN > 0 if (sc->sc_flags & NFE_HW_VLAN) @@ -400,6 +400,7 @@ nfe_attach(device_t parent, device_t self, void *aux) if_attach(ifp); ether_ifattach(ifp, sc->sc_enaddr); + ether_set_ifflags_cb(&sc->sc_ethercom, nfe_ifflags_cb); callout_init(&sc->sc_tick_ch, 0); callout_setfunc(&sc->sc_tick_ch, nfe_tick, sc); @@ -572,18 +573,37 @@ nfe_intr(void *arg) return handled; } +static int +nfe_ifflags_cb(struct ethercom *ec) +{ + struct ifnet *ifp = &ec->ec_if; + struct nfe_softc *sc = ifp->if_softc; + int change = ifp->if_flags ^ sc->sc_if_flags; + + /* + * If only the PROMISC flag changes, then + * don't do a full re-init of the chip, just update + * the Rx filter. + */ + if ((change & ~(IFF_CANTCHANGE|IFF_DEBUG)) != 0) + return ENETRESET; + else if ((change & IFF_PROMISC) != 0) + nfe_setmulti(sc); + + return 0; +} + int nfe_ioctl(struct ifnet *ifp, u_long cmd, void *data) { struct nfe_softc *sc = ifp->if_softc; - struct ifreq *ifr = (struct ifreq *)data; struct ifaddr *ifa = (struct ifaddr *)data; int s, error = 0; s = splnet(); switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; nfe_init(ifp); switch (ifa->ifa_addr->sa_family) { @@ -596,35 +616,6 @@ nfe_ioctl(struct ifnet *ifp, u_long cmd, void *data) break; } break; - case SIOCSIFMTU: - if (ifr->ifr_mtu < ETHERMIN || - ((sc->sc_flags & NFE_USE_JUMBO) && - ifr->ifr_mtu > ETHERMTU_JUMBO) || - (!(sc->sc_flags & NFE_USE_JUMBO) && - ifr->ifr_mtu > ETHERMTU)) - error = EINVAL; - else if ((error = ifioctl_common(ifp, cmd, data)) == ENETRESET) - error = 0; - break; - case SIOCSIFFLAGS: - if (ifp->if_flags & IFF_UP) { - /* - * If only the PROMISC or ALLMULTI flag changes, then - * don't do a full re-init of the chip, just update - * the Rx filter. - */ - if ((ifp->if_flags & IFF_RUNNING) && - ((ifp->if_flags ^ sc->sc_if_flags) & - (IFF_ALLMULTI | IFF_PROMISC)) != 0) { - nfe_setmulti(sc); - } else - nfe_init(ifp); - } else { - if (ifp->if_flags & IFF_RUNNING) - nfe_stop(ifp, 1); - } - sc->sc_if_flags = ifp->if_flags; - break; default: if ((error = ether_ioctl(ifp, cmd, data)) != ENETRESET) break; @@ -637,6 +628,7 @@ nfe_ioctl(struct ifnet *ifp, u_long cmd, void *data) nfe_setmulti(sc); break; } + sc->sc_if_flags = ifp->if_flags; splx(s); diff --git a/sys/dev/pci/if_sip.c b/sys/dev/pci/if_sip.c index 3f1b1a36ebe6..c293ada8080a 100644 --- a/sys/dev/pci/if_sip.c +++ b/sys/dev/pci/if_sip.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_sip.c,v 1.134 2008/05/05 20:19:09 dyoung Exp $ */ +/* $NetBSD: if_sip.c,v 1.135 2008/11/07 00:20:07 dyoung Exp $ */ /*- * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_sip.c,v 1.134 2008/05/05 20:19:09 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_sip.c,v 1.135 2008/11/07 00:20:07 dyoung Exp $"); #include "bpfilter.h" #include "rnd.h" @@ -559,6 +559,7 @@ sip_init_rxdesc(struct sip_softc *sc, int x) #define SIP_TIMEOUT 1000 +static int sip_ifflags_cb(struct ethercom *); static void sipcom_start(struct ifnet *); static void sipcom_watchdog(struct ifnet *); static int sipcom_ioctl(struct ifnet *, u_long, void *); @@ -1283,6 +1284,7 @@ sipcom_attach(device_t parent, device_t self, void *aux) */ if_attach(ifp); ether_ifattach(ifp, enaddr); + ether_set_ifflags_cb(&sc->sc_ethercom, sip_ifflags_cb); sc->sc_prev.ec_capenable = sc->sc_ethercom.ec_capenable; sc->sc_prev.is_vlan = VLAN_ATTACHED(&(sc)->sc_ethercom); sc->sc_prev.if_capenable = ifp->if_capenable; @@ -1719,6 +1721,30 @@ sipcom_watchdog(struct ifnet *ifp) sipcom_start(ifp); } +/* If the interface is up and running, only modify the receive + * filter when setting promiscuous or debug mode. Otherwise fall + * through to ether_ioctl, which will reset the chip. + */ +static int +sip_ifflags_cb(struct ethercom *ec) +{ +#define COMPARE_EC(sc) (((sc)->sc_prev.ec_capenable \ + == (sc)->sc_ethercom.ec_capenable) \ + && ((sc)->sc_prev.is_vlan == \ + VLAN_ATTACHED(&(sc)->sc_ethercom) )) +#define COMPARE_IC(sc, ifp) ((sc)->sc_prev.if_capenable == (ifp)->if_capenable) + struct ifnet *ifp = &ec->ec_if; + struct sip_softc *sc = ifp->if_softc; + int change = ifp->if_flags ^ sc->sc_if_flags; + + if ((change & ~(IFF_CANTCHANGE|IFF_DEBUG)) != 0 || !COMPARE_EC(sc) || + !COMPARE_IC(sc, ifp)) + return ENETRESET; + /* Set up the receive filter. */ + (*sc->sc_model->sip_variant->sipv_set_filter)(sc); + return 0; +} + /* * sip_ioctl: [ifnet interface function] * @@ -1762,34 +1788,7 @@ sipcom_ioctl(struct ifnet *ifp, u_long cmd, void *data) } sc->sc_flowflags = ifr->ifr_media & IFM_ETH_FMASK; } - goto ethioctl; - case SIOCSIFFLAGS: - /* If the interface is up and running, only modify the receive - * filter when setting promiscuous or debug mode. Otherwise - * fall through to ether_ioctl, which will reset the chip. - */ - -#define COMPARE_EC(sc) (((sc)->sc_prev.ec_capenable \ - == (sc)->sc_ethercom.ec_capenable) \ - && ((sc)->sc_prev.is_vlan == \ - VLAN_ATTACHED(&(sc)->sc_ethercom) )) - -#define COMPARE_IC(sc, ifp) ((sc)->sc_prev.if_capenable == (ifp)->if_capenable) - -#define RESETIGN (IFF_CANTCHANGE|IFF_DEBUG) - if (((ifp->if_flags & (IFF_UP|IFF_RUNNING)) - == (IFF_UP|IFF_RUNNING)) - && ((ifp->if_flags & (~RESETIGN)) - == (sc->sc_if_flags & (~RESETIGN))) - && COMPARE_EC(sc) && COMPARE_IC(sc, ifp)) { - /* Set up the receive filter. */ - (*sc->sc_model->sip_variant->sipv_set_filter)(sc); - error = 0; - break; -#undef RESETIGN - } - /* FALLTHROUGH */ - ethioctl: + /*FALLTHROUGH*/ default: if ((error = ether_ioctl(ifp, cmd, data)) != ENETRESET) break; diff --git a/sys/dev/pci/if_sk.c b/sys/dev/pci/if_sk.c index 5c049ff8438b..48da60c81d1c 100644 --- a/sys/dev/pci/if_sk.c +++ b/sys/dev/pci/if_sk.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_sk.c,v 1.54 2008/09/09 05:54:23 cegger Exp $ */ +/* $NetBSD: if_sk.c,v 1.55 2008/11/07 00:20:07 dyoung Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -115,7 +115,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_sk.c,v 1.54 2008/09/09 05:54:23 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_sk.c,v 1.55 2008/11/07 00:20:07 dyoung Exp $"); #include "bpfilter.h" #include "rnd.h" @@ -1003,6 +1003,8 @@ sk_ioctl(struct ifnet *ifp, u_long command, void *data) case SIOCSIFFLAGS: DPRINTFN(2, ("sk_ioctl IFFLAGS\n")); + if ((error = ifioctl_common(ifp, command, data)) != 0) + break; if (ifp->if_flags & IFF_UP) { if (ifp->if_flags & IFF_RUNNING && ifp->if_flags & IFF_PROMISC && diff --git a/sys/dev/pci/if_ti.c b/sys/dev/pci/if_ti.c index 6256bc4d5c53..bc134a7261be 100644 --- a/sys/dev/pci/if_ti.c +++ b/sys/dev/pci/if_ti.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ti.c,v 1.81 2008/04/10 19:13:37 cegger Exp $ */ +/* $NetBSD: if_ti.c,v 1.82 2008/11/07 00:20:07 dyoung Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -81,7 +81,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ti.c,v 1.81 2008/04/10 19:13:37 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ti.c,v 1.82 2008/11/07 00:20:07 dyoung Exp $"); #include "bpfilter.h" #include "opt_inet.h" @@ -2706,7 +2706,7 @@ ti_ether_ioctl(struct ifnet *ifp, u_long cmd, void *data) } switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: switch (ifa->ifa_addr->sa_family) { #ifdef INET @@ -2737,8 +2737,7 @@ ti_ioctl(struct ifnet *ifp, u_long command, void *data) s = splnet(); switch (command) { - case SIOCSIFADDR: - case SIOCGIFADDR: + case SIOCINITIFADDR: error = ti_ether_ioctl(ifp, command, data); break; case SIOCSIFMTU: @@ -2750,6 +2749,8 @@ ti_ioctl(struct ifnet *ifp, u_long command, void *data) } break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, command, data)) != 0) + break; if (ifp->if_flags & IFF_UP) { /* * If only the state of the PROMISC flag changed, diff --git a/sys/dev/pci/if_txp.c b/sys/dev/pci/if_txp.c index 63de2682979d..5439a68dde82 100644 --- a/sys/dev/pci/if_txp.c +++ b/sys/dev/pci/if_txp.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_txp.c,v 1.26 2008/04/10 19:13:37 cegger Exp $ */ +/* $NetBSD: if_txp.c,v 1.27 2008/11/07 00:20:07 dyoung Exp $ */ /* * Copyright (c) 2001 @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_txp.c,v 1.26 2008/04/10 19:13:37 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_txp.c,v 1.27 2008/11/07 00:20:07 dyoung Exp $"); #include "bpfilter.h" #include "opt_inet.h" @@ -1254,10 +1254,7 @@ txp_dma_free(sc, dma) } int -txp_ioctl(ifp, command, data) - struct ifnet *ifp; - u_long command; - void *data; +txp_ioctl(struct ifnet *ifp, u_long command, void *data) { struct txp_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *)data; @@ -1274,21 +1271,22 @@ txp_ioctl(ifp, command, data) #endif switch(command) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; + txp_init(sc); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: - txp_init(sc); arp_ifinit(ifp, ifa); break; #endif /* INET */ default: - txp_init(sc); break; } break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, command, data)) != 0) + break; if (ifp->if_flags & IFF_UP) { txp_init(sc); } else { @@ -1318,7 +1316,7 @@ txp_ioctl(ifp, command, data) error = ifmedia_ioctl(ifp, ifr, &sc->sc_ifmedia, command); break; default: - error = EINVAL; + error = ether_ioctl(ifp, command, data); break; } diff --git a/sys/dev/pci/if_vge.c b/sys/dev/pci/if_vge.c index ef8e2d3a80b9..291b1566e13a 100644 --- a/sys/dev/pci/if_vge.c +++ b/sys/dev/pci/if_vge.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_vge.c,v 1.41 2008/04/10 19:13:37 cegger Exp $ */ +/* $NetBSD: if_vge.c,v 1.42 2008/11/07 00:20:07 dyoung Exp $ */ /*- * Copyright (c) 2004 @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_vge.c,v 1.41 2008/04/10 19:13:37 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_vge.c,v 1.42 2008/11/07 00:20:07 dyoung Exp $"); /* * VIA Networking Technologies VT612x PCI gigabit ethernet NIC driver. @@ -115,8 +115,6 @@ __KERNEL_RCSID(0, "$NetBSD: if_vge.c,v 1.41 2008/04/10 19:13:37 cegger Exp $"); #include -#define VGE_JUMBO_MTU 9000 - #define VGE_IFQ_MAXLEN 64 #define VGE_RING_ALIGN 256 @@ -295,6 +293,8 @@ struct vge_softc { static inline void vge_set_txaddr(struct vge_txfrag *, bus_addr_t); static inline void vge_set_rxaddr(struct vge_rxdesc *, bus_addr_t); +static int vge_ifflags_cb(struct ethercom *); + static int vge_match(struct device *, struct cfdata *, void *); static void vge_attach(struct device *, struct device *, void *); @@ -1054,6 +1054,7 @@ vge_attach(struct device *parent, struct device *self, void *aux) */ if_attach(ifp); ether_ifattach(ifp, eaddr); + ether_set_ifflags_cb(&sc->sc_ethercom, vge_ifflags_cb); callout_init(&sc->sc_timeout, 0); callout_setfunc(&sc->sc_timeout, vge_tick, sc); @@ -1995,6 +1996,26 @@ vge_miibus_statchg(struct device *self) } } +static int +vge_ifflags_cb(struct ethercom *ec) +{ + struct ifnet *ifp = &ec->ec_if; + struct vge_softc *sc = ifp->if_softc; + int change = ifp->if_flags ^ sc->sc_if_flags; + + if ((change & ~(IFF_CANTCHANGE|IFF_DEBUG)) != 0) + return ENETRESET; + else if ((change & IFF_PROMISC) == 0) + return 0; + + if ((ifp->if_flags & IFF_PROMISC) == 0) + CSR_CLRBIT_1(sc, VGE_RXCTL, VGE_RXCTL_RX_PROMISC); + else + CSR_SETBIT_1(sc, VGE_RXCTL, VGE_RXCTL_RX_PROMISC); + vge_setmulti(sc); + return 0; +} + static int vge_ioctl(struct ifnet *ifp, u_long command, void *data) { @@ -2008,41 +2029,8 @@ vge_ioctl(struct ifnet *ifp, u_long command, void *data) s = splnet(); - switch (command) { - case SIOCSIFMTU: - if (ifr->ifr_mtu > VGE_JUMBO_MTU) - error = EINVAL; - else if ((error = ifioctl_common(ifp, command, data)) == ENETRESET) - error = 0; - break; - case SIOCSIFFLAGS: - if (ifp->if_flags & IFF_UP) { - if (ifp->if_flags & IFF_RUNNING && - ifp->if_flags & IFF_PROMISC && - (sc->sc_if_flags & IFF_PROMISC) == 0) { - CSR_SETBIT_1(sc, VGE_RXCTL, - VGE_RXCTL_RX_PROMISC); - vge_setmulti(sc); - } else if (ifp->if_flags & IFF_RUNNING && - (ifp->if_flags & IFF_PROMISC) == 0 && - sc->sc_if_flags & IFF_PROMISC) { - CSR_CLRBIT_1(sc, VGE_RXCTL, - VGE_RXCTL_RX_PROMISC); - vge_setmulti(sc); - } else - vge_init(ifp); - } else { - if (ifp->if_flags & IFF_RUNNING) - vge_stop(sc); - } - sc->sc_if_flags = ifp->if_flags; - break; - default: - if ((error = ether_ioctl(ifp, command, data)) != ENETRESET) - break; - + if ((error = ether_ioctl(ifp, command, data)) == ENETRESET) { error = 0; - if (command != SIOCADDMULTI && command != SIOCDELMULTI) ; else if (ifp->if_flags & IFF_RUNNING) { @@ -2052,8 +2040,8 @@ vge_ioctl(struct ifnet *ifp, u_long command, void *data) */ vge_setmulti(sc); } - break; } + sc->sc_if_flags = ifp->if_flags; splx(s); return error; diff --git a/sys/dev/pci/if_wpi.c b/sys/dev/pci/if_wpi.c index 0a5d31b14cfe..5b64fe68487a 100644 --- a/sys/dev/pci/if_wpi.c +++ b/sys/dev/pci/if_wpi.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_wpi.c,v 1.39 2008/07/02 03:42:55 cube Exp $ */ +/* $NetBSD: if_wpi.c,v 1.40 2008/11/07 00:20:07 dyoung Exp $ */ /*- * Copyright (c) 2006, 2007 @@ -18,7 +18,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wpi.c,v 1.39 2008/07/02 03:42:55 cube Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wpi.c,v 1.40 2008/11/07 00:20:07 dyoung Exp $"); /* * Driver for Intel PRO/Wireless 3945ABG 802.11 network adapters. @@ -2035,6 +2035,8 @@ wpi_ioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; if (ifp->if_flags & IFF_UP) { if (!(ifp->if_flags & IFF_RUNNING)) wpi_init(ifp); diff --git a/sys/dev/pcmcia/if_cnw.c b/sys/dev/pcmcia/if_cnw.c index ee94db14c6ea..4aa5c235685a 100644 --- a/sys/dev/pcmcia/if_cnw.c +++ b/sys/dev/pcmcia/if_cnw.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_cnw.c,v 1.44 2008/04/28 20:23:56 martin Exp $ */ +/* $NetBSD: if_cnw.c,v 1.45 2008/11/07 00:20:12 dyoung Exp $ */ /*- * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc. @@ -105,7 +105,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_cnw.c,v 1.44 2008/04/28 20:23:56 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_cnw.c,v 1.45 2008/11/07 00:20:12 dyoung Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -1015,10 +1015,7 @@ cnw_intr(arg) * Handle device ioctls. */ int -cnw_ioctl(ifp, cmd, data) - struct ifnet *ifp; - u_long cmd; - void *data; +cnw_ioctl(struct ifnet *ifp, u_long cmd, void *data) { struct cnw_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; @@ -1027,7 +1024,7 @@ cnw_ioctl(ifp, cmd, data) struct lwp *l = curlwp; /*XXX*/ switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: case SIOCSIFFLAGS: case SIOCADDMULTI: case SIOCDELMULTI: @@ -1050,40 +1047,46 @@ cnw_ioctl(ifp, cmd, data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: if (!(ifp->if_flags & IFF_RUNNING) && (error = cnw_enable(sc)) != 0) break; ifp->if_flags |= IFF_UP; + cnw_init(sc); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: - cnw_init(sc); arp_ifinit(&sc->sc_ethercom.ec_if, ifa); break; #endif default: - cnw_init(sc); break; } break; case SIOCSIFFLAGS: - if ((ifp->if_flags & (IFF_UP | IFF_RUNNING)) == IFF_RUNNING) { + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + /* XXX re-use ether_ioctl() */ + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_RUNNING: /* * The interface is marked down and it is running, so * stop it. */ cnw_disable(sc); - } else if ((ifp->if_flags & (IFF_UP | IFF_RUNNING)) == IFF_UP){ + break; + case IFF_UP: /* * The interface is marked up and it is stopped, so * start it. */ error = cnw_enable(sc); - } else { + break; + default: /* IFF_PROMISC may be changed */ cnw_init(sc); + break; } break; @@ -1124,7 +1127,7 @@ cnw_ioctl(ifp, cmd, data) break; default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); break; } diff --git a/sys/dev/pcmcia/if_ray.c b/sys/dev/pcmcia/if_ray.c index 444064452623..9b854a8c3c66 100644 --- a/sys/dev/pcmcia/if_ray.c +++ b/sys/dev/pcmcia/if_ray.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ray.c,v 1.70 2008/04/05 21:31:23 cegger Exp $ */ +/* $NetBSD: if_ray.c,v 1.71 2008/11/07 00:20:12 dyoung Exp $ */ /* * Copyright (c) 2000 Christian E. Hopps @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ray.c,v 1.70 2008/04/05 21:31:23 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ray.c,v 1.71 2008/11/07 00:20:12 dyoung Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -870,10 +870,7 @@ ray_reset_resetloop(arg) } static int -ray_ioctl(ifp, cmd, data) - struct ifnet *ifp; - u_long cmd; - void *data; +ray_ioctl(struct ifnet *ifp, u_long cmd, void *data) { struct ieee80211_nwid nwid; struct ray_param_req pr; @@ -892,8 +889,8 @@ ray_ioctl(ifp, cmd, data) RAY_DPRINTF(("%s: ioctl: cmd 0x%lx data 0x%lx\n", ifp->if_xname, cmd, (long)data)); switch (cmd) { - case SIOCSIFADDR: - RAY_DPRINTF(("%s: ioctl: cmd SIOCSIFADDR\n", ifp->if_xname)); + case SIOCINITIFADDR: + RAY_DPRINTF(("%s: ioctl: cmd SIOCINITIFADDR\n", ifp->if_xname)); if ((ifp->if_flags & IFF_RUNNING) == 0) if ((error = ray_enable(sc))) break; @@ -911,6 +908,8 @@ ray_ioctl(ifp, cmd, data) break; case SIOCSIFFLAGS: RAY_DPRINTF(("%s: ioctl: cmd SIOCSIFFLAGS\n", ifp->if_xname)); + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; if (ifp->if_flags & IFF_UP) { if ((ifp->if_flags & IFF_RUNNING) == 0) { if ((error = ray_enable(sc))) @@ -1001,7 +1000,7 @@ ray_ioctl(ifp, cmd, data) #endif default: RAY_DPRINTF(("%s: ioctl: unknown\n", ifp->if_xname)); - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); break; } diff --git a/sys/dev/pcmcia/if_xi.c b/sys/dev/pcmcia/if_xi.c index 655d6bb2957c..d66ab9c0be67 100644 --- a/sys/dev/pcmcia/if_xi.c +++ b/sys/dev/pcmcia/if_xi.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_xi.c,v 1.64 2008/04/05 21:31:23 cegger Exp $ */ +/* $NetBSD: if_xi.c,v 1.65 2008/11/07 00:20:12 dyoung Exp $ */ /* OpenBSD: if_xe.c,v 1.9 1999/09/16 11:28:42 niklas Exp */ /* @@ -55,7 +55,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_xi.c,v 1.64 2008/04/05 21:31:23 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_xi.c,v 1.65 2008/11/07 00:20:12 dyoung Exp $"); #include "opt_inet.h" #include "opt_ipx.h" @@ -914,23 +914,22 @@ xi_ether_ioctl(ifp, cmd, data) DPRINTF(XID_CONFIG, ("xi_ether_ioctl()\n")); switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: if ((error = xi_enable(sc)) != 0) break; ifp->if_flags |= IFF_UP; + xi_init(sc); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: - xi_init(sc); arp_ifinit(ifp, ifa); break; #endif /* INET */ default: - xi_init(sc); break; } break; @@ -943,10 +942,7 @@ xi_ether_ioctl(ifp, cmd, data) } STATIC int -xi_ioctl(ifp, cmd, data) - struct ifnet *ifp; - u_long cmd; - void *data; +xi_ioctl(struct ifnet *ifp, u_long cmd, void *data) { struct xi_softc *sc = ifp->if_softc; int s, error = 0; @@ -956,13 +952,16 @@ xi_ioctl(ifp, cmd, data) s = splnet(); switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: error = xi_ether_ioctl(ifp, cmd, data); break; case SIOCSIFFLAGS: - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + /* XXX re-use ether_ioctl() */ + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_RUNNING: /* * If interface is marked down and it is running, * stop it. @@ -970,8 +969,8 @@ xi_ioctl(ifp, cmd, data) xi_stop(sc); ifp->if_flags &= ~IFF_RUNNING; xi_disable(sc); - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { + break; + case IFF_UP: /* * If interface is marked up and it is stopped, * start it. @@ -979,12 +978,16 @@ xi_ioctl(ifp, cmd, data) if ((error = xi_enable(sc)) != 0) break; xi_init(sc); - } else if ((ifp->if_flags & IFF_UP) != 0) { + break; + case IFF_UP|IFF_RUNNING: /* * Reset the interface to pick up changes in any * other flags that affect hardware registers. */ xi_set_address(sc); + break; + case 0: + break; } break; @@ -1009,7 +1012,7 @@ xi_ioctl(ifp, cmd, data) break; default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); break; } diff --git a/sys/dev/ppbus/if_plip.c b/sys/dev/ppbus/if_plip.c index 056657c4616c..6c596403727e 100644 --- a/sys/dev/ppbus/if_plip.c +++ b/sys/dev/ppbus/if_plip.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_plip.c,v 1.21 2008/04/18 14:56:40 cegger Exp $ */ +/* $NetBSD: if_plip.c,v 1.22 2008/11/07 00:20:12 dyoung Exp $ */ /*- * Copyright (c) 1997 Poul-Henning Kamp @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_plip.c,v 1.21 2008/04/18 14:56:40 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_plip.c,v 1.22 2008/11/07 00:20:12 dyoung Exp $"); /* * Parallel port TCP/IP interfaces added. I looked at the driver from @@ -345,7 +345,7 @@ lpfreetables (void) /* Process an ioctl request. */ static int -lpioctl (struct ifnet *ifp, u_long cmd, void *data) +lpioctl(struct ifnet *ifp, u_long cmd, void *data) { struct lp_softc * sc = ifp->if_softc; device_t dev = sc->ppbus_dev.sc_dev; @@ -372,7 +372,7 @@ lpioctl (struct ifnet *ifp, u_long cmd, void *data) error = EAFNOSUPPORT; break; - case SIOCSIFADDR: + case SIOCINITIFADDR: if (ifa->ifa_addr->sa_family != AF_INET) { error = EAFNOSUPPORT; break; @@ -380,6 +380,8 @@ lpioctl (struct ifnet *ifp, u_long cmd, void *data) ifp->if_flags |= IFF_UP; /* FALLTHROUGH */ case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; if((ifp->if_flags & (IFF_UP|IFF_RUNNING)) == IFF_UP) { if((error = ppbus_request_bus(ppbus, dev, 0, 0))) break; @@ -459,7 +461,7 @@ lpioctl (struct ifnet *ifp, u_long cmd, void *data) */ default: LP_PRINTF("LP:ioctl(0x%lx)\n", cmd); - error = EINVAL; + error = ifioctl_common(ifp, cmd, data); } end: diff --git a/sys/dev/qbus/if_dmc.c b/sys/dev/qbus/if_dmc.c index 89811292e303..fe2ef1a55e10 100644 --- a/sys/dev/qbus/if_dmc.c +++ b/sys/dev/qbus/if_dmc.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_dmc.c,v 1.16 2008/04/05 19:16:49 cegger Exp $ */ +/* $NetBSD: if_dmc.c,v 1.17 2008/11/07 00:20:12 dyoung Exp $ */ /* * Copyright (c) 1982, 1986 Regents of the University of California. * All rights reserved. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_dmc.c,v 1.16 2008/04/05 19:16:49 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_dmc.c,v 1.17 2008/11/07 00:20:12 dyoung Exp $"); #undef DMCDEBUG /* for base table dump on fatal error */ @@ -841,7 +841,7 @@ dmcioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; if ((ifp->if_flags & IFF_RUNNING) == 0) dmcinit(ifp); @@ -853,6 +853,8 @@ dmcioctl(struct ifnet *ifp, u_long cmd, void *data) break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; if ((ifp->if_flags & IFF_UP) == 0 && sc->sc_flag & DMC_RUNNING) dmcdown(sc); @@ -862,7 +864,7 @@ dmcioctl(struct ifnet *ifp, u_long cmd, void *data) break; default: - error = EINVAL; + error = ifioctl_common(ifp, cmd, data); } splx(s); return (error); diff --git a/sys/dev/qbus/if_qe.c b/sys/dev/qbus/if_qe.c index 71b3f7a00931..7294933d9ddc 100644 --- a/sys/dev/qbus/if_qe.c +++ b/sys/dev/qbus/if_qe.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_qe.c,v 1.67 2008/03/11 05:34:01 matt Exp $ */ +/* $NetBSD: if_qe.c,v 1.68 2008/11/07 00:20:12 dyoung Exp $ */ /* * Copyright (c) 1999 Ludd, University of Lule}, Sweden. All rights reserved. * @@ -38,7 +38,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_qe.c,v 1.67 2008/03/11 05:34:01 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_qe.c,v 1.68 2008/11/07 00:20:12 dyoung Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -660,7 +660,7 @@ qeioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; switch(ifa->ifa_addr->sa_family) { #ifdef INET @@ -673,8 +673,11 @@ qeioctl(struct ifnet *ifp, u_long cmd, void *data) break; case SIOCSIFFLAGS: - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + /* XXX re-use ether_ioctl() */ + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_RUNNING: /* * If interface is marked down and it is running, * stop it. (by disabling receive mechanism). @@ -682,19 +685,23 @@ qeioctl(struct ifnet *ifp, u_long cmd, void *data) QE_WCSR(QE_CSR_CSR, QE_RCSR(QE_CSR_CSR) & ~QE_RCV_ENABLE); ifp->if_flags &= ~IFF_RUNNING; - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { + break; + case IFF_UP: /* * If interface it marked up and it is stopped, then * start it. */ qeinit(sc); - } else if ((ifp->if_flags & IFF_UP) != 0) { + break; + case IFF_UP|IFF_RUNNING: /* * Send a new setup packet to match any new changes. * (Like IFF_PROMISC etc) */ qe_setup(sc); + break; + case 0: + break; } break; @@ -715,8 +722,7 @@ qeioctl(struct ifnet *ifp, u_long cmd, void *data) break; default: - error = EINVAL; - + error = ether_ioctl(ifp, cmd, data); } splx(s); return (error); diff --git a/sys/dev/sbus/be.c b/sys/dev/sbus/be.c index 20b6e3992fd2..ae7017c3cec2 100644 --- a/sys/dev/sbus/be.c +++ b/sys/dev/sbus/be.c @@ -1,4 +1,4 @@ -/* $NetBSD: be.c,v 1.59 2008/05/04 17:14:41 xtraeme Exp $ */ +/* $NetBSD: be.c,v 1.60 2008/11/07 00:20:12 dyoung Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: be.c,v 1.59 2008/05/04 17:14:41 xtraeme Exp $"); +__KERNEL_RCSID(0, "$NetBSD: be.c,v 1.60 2008/11/07 00:20:12 dyoung Exp $"); #include "opt_ddb.h" #include "opt_inet.h" @@ -971,10 +971,7 @@ berint(sc) } int -beioctl(ifp, cmd, data) - struct ifnet *ifp; - u_long cmd; - void *data; +beioctl(struct ifnet *ifp, u_long cmd, void *data) { struct be_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; @@ -984,44 +981,48 @@ beioctl(ifp, cmd, data) s = splnet(); switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; + beinit(sc); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: - beinit(sc); arp_ifinit(ifp, ifa); break; #endif /* INET */ default: - beinit(sc); break; } break; case SIOCSIFFLAGS: - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + /* XXX re-use ether_ioctl() */ + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_RUNNING: /* * If interface is marked down and it is running, then * stop it. */ bestop(sc); ifp->if_flags &= ~IFF_RUNNING; - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { + break; + case IFF_UP: /* * If interface is marked up and it is stopped, then * start it. */ beinit(sc); - } else { + break; + default: /* * Reset the interface to pick up changes in any other * flags that affect hardware registers. */ bestop(sc); beinit(sc); + break; } #ifdef BEDEBUG if (ifp->if_flags & IFF_DEBUG) @@ -1048,7 +1049,7 @@ beioctl(ifp, cmd, data) error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd); break; default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); break; } splx(s); diff --git a/sys/dev/sbus/qe.c b/sys/dev/sbus/qe.c index e5daf871b415..96f378e109f8 100644 --- a/sys/dev/sbus/qe.c +++ b/sys/dev/sbus/qe.c @@ -1,4 +1,4 @@ -/* $NetBSD: qe.c,v 1.45 2008/04/28 20:23:57 martin Exp $ */ +/* $NetBSD: qe.c,v 1.46 2008/11/07 00:20:12 dyoung Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: qe.c,v 1.45 2008/04/28 20:23:57 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: qe.c,v 1.46 2008/11/07 00:20:12 dyoung Exp $"); #define QEDEBUG @@ -923,46 +923,48 @@ qeioctl(ifp, cmd, data) s = splnet(); switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; + qeinit(sc); switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: - qeinit(sc); arp_ifinit(ifp, ifa); break; #endif /* INET */ default: - qeinit(sc); break; } break; case SIOCSIFFLAGS: - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + /* XXX re-use ether_ioctl() */ + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_RUNNING: /* * If interface is marked down and it is running, then * stop it. */ qestop(sc); ifp->if_flags &= ~IFF_RUNNING; - - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { + break; + case IFF_UP: /* * If interface is marked up and it is stopped, then * start it. */ qeinit(sc); - - } else { + break; + default: /* * Reset the interface to pick up changes in any other * flags that affect hardware registers. */ qestop(sc); qeinit(sc); + break; } #ifdef QEDEBUG sc->sc_debug = (ifp->if_flags & IFF_DEBUG) != 0 ? 1 : 0; diff --git a/sys/dev/scsipi/if_se.c b/sys/dev/scsipi/if_se.c index 06edb68036ce..efd8ec7f0deb 100644 --- a/sys/dev/scsipi/if_se.c +++ b/sys/dev/scsipi/if_se.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_se.c,v 1.72 2008/06/08 18:18:34 tsutsui Exp $ */ +/* $NetBSD: if_se.c,v 1.73 2008/11/07 00:20:12 dyoung Exp $ */ /* * Copyright (c) 1997 Ian W. Dall @@ -59,7 +59,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_se.c,v 1.72 2008/06/08 18:18:34 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_se.c,v 1.73 2008/11/07 00:20:12 dyoung Exp $"); #include "opt_inet.h" #include "opt_atalk.h" @@ -977,10 +977,7 @@ se_stop(sc) * Process an ioctl request. */ static int -se_ioctl(ifp, cmd, data) - struct ifnet *ifp; - u_long cmd; - void *data; +se_ioctl(struct ifnet *ifp, u_long cmd, void *data) { struct se_softc *sc = ifp->if_softc; struct ifaddr *ifa = (struct ifaddr *)data; @@ -992,7 +989,7 @@ se_ioctl(ifp, cmd, data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: if ((error = se_enable(sc)) != 0) break; ifp->if_flags |= IFF_UP; @@ -1024,8 +1021,11 @@ se_ioctl(ifp, cmd, data) case SIOCSIFFLAGS: - if ((ifp->if_flags & IFF_UP) == 0 && - (ifp->if_flags & IFF_RUNNING) != 0) { + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + /* XXX re-use ether_ioctl() */ + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_RUNNING: /* * If interface is marked down and it is running, then * stop it. @@ -1033,8 +1033,8 @@ se_ioctl(ifp, cmd, data) se_stop(sc); ifp->if_flags &= ~IFF_RUNNING; se_disable(sc); - } else if ((ifp->if_flags & IFF_UP) != 0 && - (ifp->if_flags & IFF_RUNNING) == 0) { + break; + case IFF_UP: /* * If interface is marked up and it is stopped, then * start it. @@ -1042,12 +1042,15 @@ se_ioctl(ifp, cmd, data) if ((error = se_enable(sc)) != 0) break; error = se_init(sc); - } else if (sc->sc_enabled) { + break; + default: /* * Reset the interface to pick up changes in any other * flags that affect hardware registers. */ - error = se_init(sc); + if (sc->sc_enabled) + error = se_init(sc); + break; } #ifdef SEDEBUG if (ifp->if_flags & IFF_DEBUG) @@ -1077,7 +1080,7 @@ se_ioctl(ifp, cmd, data) default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); break; } diff --git a/sys/dev/usb/if_aue.c b/sys/dev/usb/if_aue.c index 7f873f02e775..275fdd0b557d 100644 --- a/sys/dev/usb/if_aue.c +++ b/sys/dev/usb/if_aue.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_aue.c,v 1.111 2008/05/24 16:40:58 cube Exp $ */ +/* $NetBSD: if_aue.c,v 1.112 2008/11/07 00:20:12 dyoung Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 * Bill Paul . All rights reserved. @@ -77,7 +77,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.111 2008/05/24 16:40:58 cube Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.112 2008/11/07 00:20:12 dyoung Exp $"); #if defined(__NetBSD__) #include "opt_inet.h" @@ -1587,7 +1587,7 @@ aue_ioctl(struct ifnet *ifp, u_long command, void *data) s = splnet(); switch(command) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; aue_init(sc); @@ -1612,6 +1612,8 @@ aue_ioctl(struct ifnet *ifp, u_long command, void *data) break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, command, data)) != 0) + break; if (ifp->if_flags & IFF_UP) { if (ifp->if_flags & IFF_RUNNING && ifp->if_flags & IFF_PROMISC && @@ -1647,7 +1649,7 @@ aue_ioctl(struct ifnet *ifp, u_long command, void *data) } break; default: - error = EINVAL; + error = ether_ioctl(ifp, command, data); break; } diff --git a/sys/dev/usb/if_axe.c b/sys/dev/usb/if_axe.c index a56df4c95899..70724331af76 100644 --- a/sys/dev/usb/if_axe.c +++ b/sys/dev/usb/if_axe.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_axe.c,v 1.25 2008/05/24 16:40:58 cube Exp $ */ +/* $NetBSD: if_axe.c,v 1.26 2008/11/07 00:20:12 dyoung Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000-2003 @@ -73,7 +73,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.25 2008/05/24 16:40:58 cube Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.26 2008/11/07 00:20:12 dyoung Exp $"); #if defined(__NetBSD__) #include "opt_inet.h" @@ -1134,7 +1134,7 @@ axe_ioctl(struct ifnet *ifp, u_long cmd, void *data) int error = 0; switch(cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; axe_init(sc); @@ -1159,6 +1159,8 @@ axe_ioctl(struct ifnet *ifp, u_long cmd, void *data) break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; if (ifp->if_flags & IFF_UP) { if (ifp->if_flags & IFF_RUNNING && ifp->if_flags & IFF_PROMISC && @@ -1209,7 +1211,7 @@ axe_ioctl(struct ifnet *ifp, u_long cmd, void *data) } break; default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); break; } diff --git a/sys/dev/usb/if_cdce.c b/sys/dev/usb/if_cdce.c index 9dccf4399066..073a694930c6 100644 --- a/sys/dev/usb/if_cdce.c +++ b/sys/dev/usb/if_cdce.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_cdce.c,v 1.18 2008/09/24 07:19:18 ws Exp $ */ +/* $NetBSD: if_cdce.c,v 1.19 2008/11/07 00:20:12 dyoung Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000-2003 Bill Paul @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_cdce.c,v 1.18 2008/09/24 07:19:18 ws Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_cdce.c,v 1.19 2008/11/07 00:20:12 dyoung Exp $"); #include "bpfilter.h" #ifdef __NetBSD__ #include "opt_inet.h" @@ -434,7 +434,7 @@ cdce_ioctl(struct ifnet *ifp, u_long command, void *data) s = splnet(); switch(command) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; cdce_init(sc); switch (ifa->ifa_addr->sa_family) { @@ -458,18 +458,23 @@ cdce_ioctl(struct ifnet *ifp, u_long command, void *data) break; case SIOCSIFFLAGS: - if (ifp->if_flags & IFF_UP) { - if (!(ifp->if_flags & IFF_RUNNING)) - cdce_init(sc); - } else { - if (ifp->if_flags & IFF_RUNNING) - cdce_stop(sc); + if ((error = ifioctl_common(ifp, command, data)) != 0) + break; + /* XXX re-use ether_ioctl() */ + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_UP: + cdce_init(sc); + break; + case IFF_RUNNING: + cdce_stop(sc); + break; + default: + break; } - error = 0; break; default: - error = EINVAL; + error = ether_ioctl(ifp, command, data); break; } diff --git a/sys/dev/usb/if_cue.c b/sys/dev/usb/if_cue.c index 807adcbec2e1..1bd431d5a397 100644 --- a/sys/dev/usb/if_cue.c +++ b/sys/dev/usb/if_cue.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_cue.c,v 1.53 2008/05/24 16:40:58 cube Exp $ */ +/* $NetBSD: if_cue.c,v 1.54 2008/11/07 00:20:12 dyoung Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 * Bill Paul . All rights reserved. @@ -56,7 +56,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_cue.c,v 1.53 2008/05/24 16:40:58 cube Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_cue.c,v 1.54 2008/11/07 00:20:12 dyoung Exp $"); #if defined(__NetBSD__) #include "opt_inet.h" @@ -1162,7 +1162,7 @@ cue_ioctl(struct ifnet *ifp, u_long command, void *data) s = splnet(); switch(command) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; cue_init(sc); @@ -1187,6 +1187,8 @@ cue_ioctl(struct ifnet *ifp, u_long command, void *data) break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, command, data)) != 0) + break; if (ifp->if_flags & IFF_UP) { if (ifp->if_flags & IFF_RUNNING && ifp->if_flags & IFF_PROMISC && @@ -1213,7 +1215,7 @@ cue_ioctl(struct ifnet *ifp, u_long command, void *data) error = 0; break; default: - error = EINVAL; + error = ether_ioctl(ifp, command, data); break; } diff --git a/sys/dev/usb/if_kue.c b/sys/dev/usb/if_kue.c index ea63e36935c4..e340fd53f2d7 100644 --- a/sys/dev/usb/if_kue.c +++ b/sys/dev/usb/if_kue.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_kue.c,v 1.63 2008/05/24 16:40:58 cube Exp $ */ +/* $NetBSD: if_kue.c,v 1.64 2008/11/07 00:20:12 dyoung Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 * Bill Paul . All rights reserved. @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_kue.c,v 1.63 2008/05/24 16:40:58 cube Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_kue.c,v 1.64 2008/11/07 00:20:12 dyoung Exp $"); #if defined(__NetBSD__) #include "opt_inet.h" @@ -1069,7 +1069,7 @@ kue_ioctl(struct ifnet *ifp, u_long command, void *data) s = splnet(); switch(command) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; kue_init(sc); @@ -1094,6 +1094,8 @@ kue_ioctl(struct ifnet *ifp, u_long command, void *data) break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, command, data)) != 0) + break; if (ifp->if_flags & IFF_UP) { if (ifp->if_flags & IFF_RUNNING && ifp->if_flags & IFF_PROMISC && @@ -1122,7 +1124,7 @@ kue_ioctl(struct ifnet *ifp, u_long command, void *data) error = 0; break; default: - error = EINVAL; + error = ether_ioctl(ifp, command, data); break; } diff --git a/sys/dev/usb/if_rum.c b/sys/dev/usb/if_rum.c index fc5b7e70701c..8483b0a37176 100644 --- a/sys/dev/usb/if_rum.c +++ b/sys/dev/usb/if_rum.c @@ -1,5 +1,5 @@ /* $OpenBSD: if_rum.c,v 1.40 2006/09/18 16:20:20 damien Exp $ */ -/* $NetBSD: if_rum.c,v 1.23 2008/10/21 12:21:46 jun Exp $ */ +/* $NetBSD: if_rum.c,v 1.24 2008/11/07 00:20:12 dyoung Exp $ */ /*- * Copyright (c) 2005-2007 Damien Bergamini @@ -24,7 +24,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_rum.c,v 1.23 2008/10/21 12:21:46 jun Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_rum.c,v 1.24 2008/11/07 00:20:12 dyoung Exp $"); #include "bpfilter.h" @@ -1373,14 +1373,21 @@ rum_ioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { case SIOCSIFFLAGS: - if (ifp->if_flags & IFF_UP) { - if (ifp->if_flags & IFF_RUNNING) - rum_update_promisc(sc); - else - rum_init(ifp); - } else { - if (ifp->if_flags & IFF_RUNNING) - rum_stop(ifp, 1); + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + /* XXX re-use ether_ioctl() */ + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_UP|IFF_RUNNING: + rum_update_promisc(sc); + break; + case IFF_UP: + rum_init(ifp); + break; + case IFF_RUNNING: + rum_stop(ifp, 1); + break; + case 0: + break; } break; diff --git a/sys/dev/usb/if_upl.c b/sys/dev/usb/if_upl.c index 3a810983fac8..fb7288fe15f0 100644 --- a/sys/dev/usb/if_upl.c +++ b/sys/dev/usb/if_upl.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_upl.c,v 1.32 2008/05/24 16:40:58 cube Exp $ */ +/* $NetBSD: if_upl.c,v 1.33 2008/11/07 00:20:13 dyoung Exp $ */ /* * Copyright (c) 2000 The NetBSD Foundation, Inc. * All rights reserved. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_upl.c,v 1.32 2008/05/24 16:40:58 cube Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_upl.c,v 1.33 2008/11/07 00:20:13 dyoung Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -856,7 +856,7 @@ upl_ioctl(struct ifnet *ifp, u_long command, void *data) s = splnet(); switch(command) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; upl_init(sc); @@ -876,17 +876,22 @@ upl_ioctl(struct ifnet *ifp, u_long command, void *data) break; case SIOCSIFFLAGS: - if (ifp->if_flags & IFF_UP) { - if (!(ifp->if_flags & IFF_RUNNING)) - upl_init(sc); - } else { - if (ifp->if_flags & IFF_RUNNING) - upl_stop(sc); + if ((error = ifioctl_common(ifp, command, data)) != 0) + break; + /* XXX re-use ether_ioctl() */ + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_UP: + upl_init(sc); + break; + case IFF_RUNNING: + upl_stop(sc); + break; + default: + break; } - error = 0; break; default: - error = EINVAL; + error = ifioctl_common(ifp, command, data); break; } diff --git a/sys/dev/usb/if_ural.c b/sys/dev/usb/if_ural.c index 7e746794318c..8da6bb10d771 100644 --- a/sys/dev/usb/if_ural.c +++ b/sys/dev/usb/if_ural.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ural.c,v 1.30 2008/05/24 16:40:58 cube Exp $ */ +/* $NetBSD: if_ural.c,v 1.31 2008/11/07 00:20:13 dyoung Exp $ */ /* $FreeBSD: /repoman/r/ncvs/src/sys/dev/usb/if_ural.c,v 1.40 2006/06/02 23:14:40 sam Exp $ */ /*- @@ -24,7 +24,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ural.c,v 1.30 2008/05/24 16:40:58 cube Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ural.c,v 1.31 2008/11/07 00:20:13 dyoung Exp $"); #include "bpfilter.h" @@ -1505,14 +1505,21 @@ ural_ioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { case SIOCSIFFLAGS: - if (ifp->if_flags & IFF_UP) { - if (ifp->if_flags & IFF_RUNNING) - ural_update_promisc(sc); - else - ural_init(ifp); - } else { - if (ifp->if_flags & IFF_RUNNING) - ural_stop(ifp, 1); + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + /* XXX re-use ether_ioctl() */ + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_UP|IFF_RUNNING: + ural_update_promisc(sc); + break; + case IFF_UP: + ural_init(ifp); + break; + case IFF_RUNNING: + ural_stop(ifp, 1); + break; + case 0: + break; } break; diff --git a/sys/dev/usb/if_zyd.c b/sys/dev/usb/if_zyd.c index 429d5422047c..c324b313ba1f 100644 --- a/sys/dev/usb/if_zyd.c +++ b/sys/dev/usb/if_zyd.c @@ -1,5 +1,5 @@ /* $OpenBSD: if_zyd.c,v 1.52 2007/02/11 00:08:04 jsg Exp $ */ -/* $NetBSD: if_zyd.c,v 1.14 2008/09/21 09:38:27 freza Exp $ */ +/* $NetBSD: if_zyd.c,v 1.15 2008/11/07 00:20:13 dyoung Exp $ */ /*- * Copyright (c) 2006 by Damien Bergamini @@ -22,7 +22,7 @@ * ZyDAS ZD1211/ZD1211B USB WLAN driver. */ #include -__KERNEL_RCSID(0, "$NetBSD: if_zyd.c,v 1.14 2008/09/21 09:38:27 freza Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_zyd.c,v 1.15 2008/11/07 00:20:13 dyoung Exp $"); #include "bpfilter.h" @@ -2419,18 +2419,24 @@ zyd_ioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { case SIOCSIFFLAGS: - if (ifp->if_flags & IFF_UP) { - if (!(ifp->if_flags & IFF_RUNNING)) - zyd_init(ifp); - } else { - if (ifp->if_flags & IFF_RUNNING) - zyd_stop(ifp, 1); + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + /* XXX re-use ether_ioctl() */ + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_UP: + zyd_init(ifp); + break; + case IFF_RUNNING: + zyd_stop(ifp, 1); + break; + default: + break; } break; default: if (!sc->attached) - error = ENOTTY; + error = ENXIO; else error = ieee80211_ioctl(ic, cmd, data); } diff --git a/sys/dist/pf/net/if_pflog.c b/sys/dist/pf/net/if_pflog.c index 35827bdc3e8a..cf0664a9452d 100644 --- a/sys/dist/pf/net/if_pflog.c +++ b/sys/dist/pf/net/if_pflog.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_pflog.c,v 1.12 2008/06/18 09:06:27 yamt Exp $ */ +/* $NetBSD: if_pflog.c,v 1.13 2008/11/07 00:20:13 dyoung Exp $ */ /* $OpenBSD: if_pflog.c,v 1.24 2007/05/26 17:13:30 jason Exp $ */ /* @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_pflog.c,v 1.12 2008/06/18 09:06:27 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_pflog.c,v 1.13 2008/11/07 00:20:13 dyoung Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -223,21 +223,26 @@ pflogoutput(struct ifnet *ifp, struct mbuf *m, int pflogioctl(struct ifnet *ifp, u_long cmd, void *data) { + int error = 0; + switch (cmd) { - case SIOCSIFADDR: + case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + /*FALLTHROUGH*/ + case SIOCINITIFADDR: case SIOCAIFADDR: case SIOCSIFDSTADDR: - case SIOCSIFFLAGS: if (ifp->if_flags & IFF_UP) ifp->if_flags |= IFF_RUNNING; else ifp->if_flags &= ~IFF_RUNNING; break; default: - return (EINVAL); + error = ifioctl_common(ifp, cmd, data); } - return (0); + return error; } int diff --git a/sys/net/agr/if_agr.c b/sys/net/agr/if_agr.c index 8ea39fc201e9..77fb4cc5019b 100644 --- a/sys/net/agr/if_agr.c +++ b/sys/net/agr/if_agr.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_agr.c,v 1.21 2008/05/19 02:53:47 yamt Exp $ */ +/* $NetBSD: if_agr.c,v 1.22 2008/11/07 00:20:18 dyoung Exp $ */ /*- * Copyright (c)2005 YAMAMOTO Takashi, @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_agr.c,v 1.21 2008/05/19 02:53:47 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_agr.c,v 1.22 2008/11/07 00:20:18 dyoung Exp $"); #include "bpfilter.h" #include "opt_inet.h" @@ -532,11 +532,10 @@ agr_addport(struct ifnet *ifp, struct ifnet *ifp_port) * start to modify ifp_port. */ - error = (*ifp_port->if_ioctl)(ifp_port, SIOCSIFADDR, - (void *)ifp->if_dl); + error = (*ifp_port->if_ioctl)(ifp_port, SIOCINITIFADDR, ifp->if_dl); if (error) { - printf("%s: SIOCSIFADDR error %d\n", __func__, error); + printf("%s: SIOCINITIFADDR error %d\n", __func__, error); goto cleanup; } port->port_flags |= AGRPORT_LADDRCHANGED; @@ -696,7 +695,7 @@ agrport_cleanup(struct agr_softc *sc, struct agr_port *port) port->port_origlladdr, ifp_port->if_addrlen); memset(&ifa, 0, sizeof(ifa)); ifa.ifa_addr = &u.sa; - error = agrport_ioctl(port, SIOCSIFADDR, &ifa); + error = agrport_ioctl(port, SIOCINITIFADDR, &ifa); #endif if (error) { printf("%s: if_init error %d\n", __func__, error); @@ -751,14 +750,33 @@ agr_ioctl_filter(struct ifnet *ifp, u_long cmd, void *arg) KASSERT(port); switch (cmd) { - case SIOCGIFADDR: - case SIOCGIFMEDIA: - case SIOCSIFFLAGS: /* XXX */ - error = agrport_ioctl(port, cmd, arg); - break; - default: + case SIOCADDMULTI: /* add m'cast addr */ + case SIOCAIFADDR: /* add/chg IF alias */ + case SIOCALIFADDR: /* add IF addr */ + case SIOCDELMULTI: /* del m'cast addr */ + case SIOCDIFADDR: /* delete IF addr */ + case SIOCDIFPHYADDR: /* delete gif addrs */ + case SIOCDLIFADDR: /* delete IF addr */ + case SIOCINITIFADDR: + case SIOCSDRVSPEC: /* set driver-specific parameters */ + case SIOCSIFADDR: /* set ifnet address */ + case SIOCSIFBRDADDR: /* set broadcast addr */ + case SIOCSIFDSTADDR: /* set p-p address */ + case SIOCSIFGENERIC: /* generic IF set op */ + case SIOCSIFMEDIA: /* set net media */ + case SIOCSIFMETRIC: /* set IF metric */ + case SIOCSIFMTU: /* set ifnet mtu */ + case SIOCSIFNETMASK: /* set net addr mask */ + case SIOCSIFPHYADDR: /* set gif addres */ + case SIOCSLIFPHYADDR: /* set gif addrs */ + case SIOCSVH: /* set carp param */ error = EBUSY; break; + case SIOCSIFCAP: /* XXX */ + case SIOCSIFFLAGS: /* XXX */ + default: + error = agrport_ioctl(port, cmd, arg); + break; } return error; } @@ -801,7 +819,6 @@ agr_ioctl(struct ifnet *ifp, u_long cmd, void *data) struct agr_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *)data; struct ifaddr *ifa = (struct ifaddr *)data; - struct sockaddr *sa; struct agrreq ar; int error = 0; int s; @@ -811,7 +828,7 @@ agr_ioctl(struct ifnet *ifp, u_long cmd, void *data) s = splnet(); switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: if (sc->sc_nports == 0) { error = EINVAL; break; @@ -828,16 +845,13 @@ agr_ioctl(struct ifnet *ifp, u_long cmd, void *data) } break; - case SIOCGIFADDR: - sa = (struct sockaddr *)&ifr->ifr_data; - memcpy(sa->sa_data, CLLADDR(ifp->if_sadl), ifp->if_addrlen); - break; - #if 0 /* notyet */ case SIOCSIFMTU: #endif case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; agr_config_promisc(sc); break; @@ -878,7 +892,7 @@ agr_ioctl(struct ifnet *ifp, u_long cmd, void *data) break; default: - error = EINVAL; + error = ifioctl_common(ifp, cmd, data); break; } diff --git a/sys/net/if.c b/sys/net/if.c index f15185c22a0c..ee0c730354c4 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $NetBSD: if.c,v 1.230 2008/10/24 21:46:09 dyoung Exp $ */ +/* $NetBSD: if.c,v 1.231 2008/11/07 00:20:13 dyoung Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc. @@ -90,7 +90,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.230 2008/10/24 21:46:09 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.231 2008/11/07 00:20:13 dyoung Exp $"); #include "opt_inet.h" @@ -278,7 +278,7 @@ struct ifnet **ifindex2ifnet = NULL; struct ifnet *lo0ifp; void -if_set_sadl(struct ifnet *ifp, const void *lla, u_char addrlen) +if_set_sadl(struct ifnet *ifp, const void *lla, u_char addrlen, bool factory) { struct ifaddr *ifa; struct sockaddr_dl *sdl; @@ -289,6 +289,10 @@ if_set_sadl(struct ifnet *ifp, const void *lla, u_char addrlen) sdl = satosdl(ifa->ifa_addr); (void)sockaddr_dl_setaddr(sdl, sdl->sdl_len, lla, ifp->if_addrlen); + if (factory) { + ifp->if_hwdl = ifp->if_dl; + IFAREF(ifp->if_hwdl); + } /* TBD routing socket */ } @@ -388,8 +392,9 @@ if_activate_sadl(struct ifnet *ifp, struct ifaddr *ifa, if_deactivate_sadl(ifp); if_sadl_setrefs(ifp, ifa); + IFADDR_FOREACH(ifa, ifp) + rtinit(ifa, RTM_LLINFO_UPD, 0); splx(s); - rt_ifmsg(ifp); } /* @@ -416,8 +421,11 @@ if_free_sadl(struct ifnet *ifp) s = splnet(); rtinit(ifa, RTM_DELETE, 0); ifa_remove(ifp, ifa); - if_deactivate_sadl(ifp); + if (ifp->if_hwdl == ifa) { + IFAFREE(ifa); + ifp->if_hwdl = NULL; + } splx(s); } @@ -436,6 +444,9 @@ if_attach(struct ifnet *ifp) } TAILQ_INIT(&ifp->if_addrlist); TAILQ_INSERT_TAIL(&ifnet, ifp, if_list); + if (ifp->if_ioctl == NULL) + ifp->if_ioctl = ifioctl_common; + ifp->if_index = if_index; if (ifindex2ifnet == NULL) if_index++; @@ -1576,6 +1587,8 @@ ifioctl(struct socket *so, u_long cmd, void *data, struct lwp *l) #endif case SIOCGIFCONF: return ifconf(cmd, data); + case SIOCINITIFADDR: + return EPERM; } #ifdef COMPAT_OIFREQ @@ -1648,47 +1661,13 @@ ifioctl(struct socket *so, u_long cmd, void *data, struct lwp *l) } oif_flags = ifp->if_flags; - switch (cmd) { - case SIOCSIFFLAGS: - ifioctl_common(ifp, cmd, data); - if (ifp->if_ioctl) - (void)(*ifp->if_ioctl)(ifp, cmd, data); - break; - - case SIOCSIFPHYADDR: - case SIOCDIFPHYADDR: -#ifdef INET6 - case SIOCSIFPHYADDR_IN6: -#endif - case SIOCSLIFPHYADDR: - case SIOCADDMULTI: - case SIOCDELMULTI: - case SIOCSIFMEDIA: - case SIOCGIFPSRCADDR: - case SIOCGIFPDSTADDR: - case SIOCGLIFPHYADDR: - case SIOCGIFMEDIA: - case SIOCG80211: - case SIOCS80211: - case SIOCS80211NWID: - case SIOCS80211NWKEY: - case SIOCS80211POWER: - case SIOCS80211BSSID: - case SIOCS80211CHANNEL: - case SIOCSIFCAP: - case SIOCSIFMTU: - if (ifp->if_ioctl == NULL) - return EOPNOTSUPP; - error = (*ifp->if_ioctl)(ifp, cmd, data); - break; - - default: - error = ifioctl_common(ifp, cmd, data); - if (error != ENOTTY) - break; - if (so->so_proto == NULL) - return EOPNOTSUPP; + error = (*ifp->if_ioctl)(ifp, cmd, data); + if (error != ENOTTY) + ; + else if (so->so_proto == NULL) + return EOPNOTSUPP; + else { #ifdef COMPAT_OSOCK error = compat_ifioctl(so, ocmd, cmd, data, l); #else @@ -1696,7 +1675,6 @@ ifioctl(struct socket *so, u_long cmd, void *data, struct lwp *l) (struct mbuf *)cmd, (struct mbuf *)data, (struct mbuf *)ifp, l); #endif - break; } if (((oif_flags ^ ifp->if_flags) & IFF_UP) != 0) { diff --git a/sys/net/if.h b/sys/net/if.h index 3c64678f4018..1b4eaeb8cf55 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -1,4 +1,4 @@ -/* $NetBSD: if.h,v 1.140 2008/10/24 17:07:33 dyoung Exp $ */ +/* $NetBSD: if.h,v 1.141 2008/11/07 00:20:13 dyoung Exp $ */ /*- * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -268,7 +268,17 @@ struct ifnet { /* and the entries */ (struct ifnet *); struct ifaltq if_snd; /* output queue (includes altq) */ struct ifaddr *if_dl; /* identity of this interface. */ - const struct sockaddr_dl *if_sadl; /* pointer to our sockaddr_dl */ + const struct sockaddr_dl *if_sadl; /* pointer to sockaddr_dl + * of if_dl + */ + /* if_hwdl: h/w identity + * + * May be NULL. If not NULL, it is the address assigned + * to the interface by the manufacturer, so it very likely + * to be unique. It MUST NOT be deleted. It is highly + * suitable for deriving the EUI64 for the interface. + */ + struct ifaddr *if_hwdl; const uint8_t *if_broadcastaddr;/* linklevel broadcast bytestring */ void *if_bridge; /* bridge glue */ int if_dlt; /* data link type () */ @@ -643,6 +653,7 @@ struct if_laddrreq { unsigned int flags; #define IFLR_PREFIX 0x8000 /* in: prefix given out: kernel fills id */ #define IFLR_ACTIVE 0x4000 /* in/out: link-layer address activation */ +#define IFLR_FACTORY 0x2000 /* in/out: factory link-layer address */ unsigned int prefixlen; /* in/out */ struct sockaddr_storage addr; /* in/out */ struct sockaddr_storage dstaddr; /* out */ @@ -826,7 +837,7 @@ void if_initname(struct ifnet *, const char *, int); struct ifaddr *if_dl_create(const struct ifnet *, const struct sockaddr_dl **); void if_activate_sadl(struct ifnet *, struct ifaddr *, const struct sockaddr_dl *); -void if_set_sadl(struct ifnet *, const void *, u_char); +void if_set_sadl(struct ifnet *, const void *, u_char, bool); void if_alloc_sadl(struct ifnet *); void if_free_sadl(struct ifnet *); void if_attach(struct ifnet *); diff --git a/sys/net/if_arcsubr.c b/sys/net/if_arcsubr.c index fc738426533a..0cb9b1fd49fe 100644 --- a/sys/net/if_arcsubr.c +++ b/sys/net/if_arcsubr.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_arcsubr.c,v 1.59 2008/02/20 17:05:52 matt Exp $ */ +/* $NetBSD: if_arcsubr.c,v 1.60 2008/11/07 00:20:13 dyoung Exp $ */ /* * Copyright (c) 1994, 1995 Ignatios Souvatzis @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_arcsubr.c,v 1.59 2008/02/20 17:05:52 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_arcsubr.c,v 1.60 2008/11/07 00:20:13 dyoung Exp $"); #include "opt_inet.h" @@ -645,7 +645,7 @@ arc_ifattach(struct ifnet *ifp, uint8_t lla) ifp->if_xname, ifp->if_xname); } if_attach(ifp); - if_set_sadl(ifp, &lla, sizeof(lla)); + if_set_sadl(ifp, &lla, sizeof(lla), true); ifp->if_broadcastaddr = &arcbroadcastaddr; diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index f972e94ae61d..c75466b5c7ff 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_bridge.c,v 1.62 2008/06/15 16:37:21 christos Exp $ */ +/* $NetBSD: if_bridge.c,v 1.63 2008/11/07 00:20:13 dyoung Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -80,7 +80,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.62 2008/06/15 16:37:21 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.63 2008/11/07 00:20:13 dyoung Exp $"); #include "opt_bridge_ipf.h" #include "opt_inet.h" @@ -488,23 +488,30 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, void *data) break; case SIOCSIFFLAGS: - if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) == IFF_RUNNING) { + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { + case IFF_RUNNING: /* * If interface is marked down and it is running, * then stop and disable it. */ (*ifp->if_stop)(ifp, 1); - } else if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) == IFF_UP) { + break; + case IFF_UP: /* * If interface is marked up and it is stopped, then * start it. */ error = (*ifp->if_init)(ifp); + break; + default: + break; } break; default: - error = ENOTTY; + error = ifioctl_common(ifp, cmd, data); break; } diff --git a/sys/net/if_ecosubr.c b/sys/net/if_ecosubr.c index fc924adb1403..f8e4797b6ce3 100644 --- a/sys/net/if_ecosubr.c +++ b/sys/net/if_ecosubr.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ecosubr.c,v 1.28 2008/03/12 18:22:24 dyoung Exp $ */ +/* $NetBSD: if_ecosubr.c,v 1.29 2008/11/07 00:20:13 dyoung Exp $ */ /*- * Copyright (c) 2001 Ben Harris @@ -58,7 +58,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ecosubr.c,v 1.28 2008/03/12 18:22:24 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ecosubr.c,v 1.29 2008/11/07 00:20:13 dyoung Exp $"); #include "bpfilter.h" #include "opt_inet.h" @@ -148,7 +148,8 @@ eco_ifattach(struct ifnet *ifp, const uint8_t *lla) } while (/*CONSTCOND*/0) int -eco_init(struct ifnet *ifp) { +eco_init(struct ifnet *ifp) +{ struct ecocom *ec = (struct ecocom *)ifp; if ((ifp->if_flags & IFF_RUNNING) == 0) @@ -525,20 +526,18 @@ eco_ioctl(struct ifnet *ifp, u_long cmd, void *data) int error; switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; + if ((ifp->if_flags & IFF_RUNNING) == 0 && + (error = (*ifp->if_init)(ifp)) != 0) + return error; switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: - if ((ifp->if_flags & IFF_RUNNING) == 0 && - (error = (*ifp->if_init)(ifp)) != 0) - return error; arp_ifinit(ifp, ifa); break; #endif default: - if ((ifp->if_flags & IFF_RUNNING) == 0) - return (*ifp->if_init)(ifp); break; } return 0; @@ -551,6 +550,8 @@ eco_ioctl(struct ifnet *ifp, u_long cmd, void *data) return 0; break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + return error; switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { case IFF_RUNNING: /* @@ -576,7 +577,7 @@ eco_ioctl(struct ifnet *ifp, u_long cmd, void *data) } break; default: - return ENOTTY; + return ifioctl_common(ifp, cmd, data); } return 0; diff --git a/sys/net/if_ether.h b/sys/net/if_ether.h index 3bf163f3a45f..787ea3e96373 100644 --- a/sys/net/if_ether.h +++ b/sys/net/if_ether.h @@ -1,4 +1,4 @@ -/* $NetBSD: if_ether.h,v 1.53 2008/07/25 20:04:50 dsl Exp $ */ +/* $NetBSD: if_ether.h,v 1.54 2008/11/07 00:20:13 dyoung Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -145,6 +145,10 @@ do { \ struct mii_data; +struct ethercom; + +typedef int (*ether_cb_t)(struct ethercom *); + /* * Structure shared between the ethernet driver modules and * the multicast list code. For example, each ec_softc or il_softc @@ -164,6 +168,11 @@ struct ethercom { int ec_nvlans; /* # VLANs on this interface */ /* The device handle for the MII bus child device. */ struct mii_data *ec_mii; + /* Called after a change to ec_if.if_flags. Returns + * ENETRESET if the device should be reinitialized with + * ec_if.if_init, 0 on success, not 0 on failure. + */ + ether_cb_t ec_ifflags_cb; #ifdef MBUFTRACE struct mowner ec_rx_mowner; /* mbufs received */ struct mowner ec_tx_mowner; /* mbufs transmitted */ @@ -180,6 +189,7 @@ extern const uint8_t ethermulticastaddr_slowprotocols[ETHER_ADDR_LEN]; extern const uint8_t ether_ipmulticast_min[ETHER_ADDR_LEN]; extern const uint8_t ether_ipmulticast_max[ETHER_ADDR_LEN]; +void ether_set_ifflags_cb(struct ethercom *, ether_cb_t); int ether_ioctl(struct ifnet *, u_long, void *); int ether_addmulti(const struct sockaddr *, struct ethercom *); int ether_delmulti(const struct sockaddr *, struct ethercom *); diff --git a/sys/net/if_etherip.c b/sys/net/if_etherip.c index a1e968607626..8d384db6cc09 100644 --- a/sys/net/if_etherip.c +++ b/sys/net/if_etherip.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_etherip.c,v 1.24 2008/11/03 00:52:07 hans Exp $ */ +/* $NetBSD: if_etherip.c,v 1.25 2008/11/07 00:20:13 dyoung Exp $ */ /* * Copyright (c) 2006, Hans Rosenfeld @@ -86,7 +86,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_etherip.c,v 1.24 2008/11/03 00:52:07 hans Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_etherip.c,v 1.25 2008/11/07 00:20:13 dyoung Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -700,7 +700,7 @@ etherip_sysctl_handler(SYSCTLFN_ARGS) if (ether_nonstatic_aton(enaddr, addr) != 0) return EINVAL; - if_set_sadl(ifp, enaddr, ETHER_ADDR_LEN); + if_set_sadl(ifp, enaddr, ETHER_ADDR_LEN, false); return error; } diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index bca0bbc5746f..1650ce26bbc4 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ethersubr.c,v 1.169 2008/07/23 06:34:31 dyoung Exp $ */ +/* $NetBSD: if_ethersubr.c,v 1.170 2008/11/07 00:20:13 dyoung Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.169 2008/07/23 06:34:31 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.170 2008/11/07 00:20:13 dyoung Exp $"); #include "opt_inet.h" #include "opt_atalk.h" @@ -1077,7 +1077,7 @@ ether_ifattach(struct ifnet *ifp, const uint8_t *lla) if (ifp->if_baudrate == 0) ifp->if_baudrate = IF_Mbps(10); /* just a default */ - if_set_sadl(ifp, lla, ETHER_ADDR_LEN); + if_set_sadl(ifp, lla, ETHER_ADDR_LEN, !ETHER_IS_LOCAL(lla)); LIST_INIT(&ec->ec_multiaddrs); ifp->if_broadcastaddr = etherbroadcastaddr; @@ -1433,6 +1433,12 @@ ether_delmulti(const struct sockaddr *sa, struct ethercom *ec) return (ENETRESET); } +void +ether_set_ifflags_cb(struct ethercom *ec, ether_cb_t cb) +{ + ec->ec_ifflags_cb = cb; +} + /* * Common ioctls for Ethernet interfaces. Note, we must be * called at splnet(). @@ -1443,30 +1449,23 @@ ether_ioctl(struct ifnet *ifp, u_long cmd, void *data) struct ethercom *ec = (void *) ifp; struct ifreq *ifr = (struct ifreq *)data; struct ifaddr *ifa = (struct ifaddr *)data; + struct if_laddrreq *iflr = data; + const struct sockaddr_dl *sdl; + static const uint8_t zero[ETHER_ADDR_LEN]; int error; switch (cmd) { - case SIOCSIFADDR: - ifp->if_flags |= IFF_UP; - switch (ifa->ifa_addr->sa_family) { -#ifdef INET - case AF_INET: - if ((ifp->if_flags & IFF_RUNNING) == 0 && - (error = (*ifp->if_init)(ifp)) != 0) + case SIOCINITIFADDR: + if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != + (IFF_UP|IFF_RUNNING)) { + ifp->if_flags |= IFF_UP; + if ((error = (*ifp->if_init)(ifp)) != 0) return error; - arp_ifinit(ifp, ifa); - break; -#endif /* INET */ - default: - if ((ifp->if_flags & IFF_RUNNING) == 0) - return (*ifp->if_init)(ifp); - break; } - return 0; - - case SIOCGIFADDR: - memcpy(((struct sockaddr *)&ifr->ifr_data)->sa_data, - CLLADDR(ifp->if_sadl), ETHER_ADDR_LEN); +#ifdef INET + if (ifa->ifa_addr->sa_family == AF_INET) + arp_ifinit(ifp, ifa); +#endif /* INET */ return 0; case SIOCSIFMTU: @@ -1490,6 +1489,8 @@ ether_ioctl(struct ifnet *ifp, u_long cmd, void *data) } case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + return error; switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) { case IFF_RUNNING: /* @@ -1505,11 +1506,17 @@ ether_ioctl(struct ifnet *ifp, u_long cmd, void *data) */ return (*ifp->if_init)(ifp); case IFF_UP|IFF_RUNNING: - /* - * Reset the interface to pick up changes in any other - * flags that affect the hardware state. - */ - return (*ifp->if_init)(ifp); + error = 0; + if (ec->ec_ifflags_cb == NULL || + (error = (*ec->ec_ifflags_cb)(ec)) == ENETRESET) { + /* + * Reset the interface to pick up + * changes in any other flags that + * affect the hardware state. + */ + return (*ifp->if_init)(ifp); + } else + return error; case 0: break; } @@ -1523,10 +1530,17 @@ ether_ioctl(struct ifnet *ifp, u_long cmd, void *data) if (ec->ec_mii == NULL) return ENOTTY; return ifmedia_ioctl(ifp, ifr, &ec->ec_mii->mii_media, cmd); - case SIOCSIFCAP: - return ifioctl_common(ifp, cmd, data); + case SIOCALIFADDR: + sdl = satocsdl(sstocsa(&iflr->addr)); + if (sdl->sdl_family != AF_LINK) + ; + else if (ETHER_IS_MULTICAST(CLLADDR(sdl))) + return EINVAL; + else if (memcmp(zero, CLLADDR(sdl), sizeof(zero)) == 0) + return EINVAL; + /*FALLTHROUGH*/ default: - return ENOTTY; + return ifioctl_common(ifp, cmd, data); } return 0; } diff --git a/sys/net/if_faith.c b/sys/net/if_faith.c index 519f06eed5c6..1edf5cdef73a 100644 --- a/sys/net/if_faith.c +++ b/sys/net/if_faith.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_faith.c,v 1.44 2008/10/24 17:07:33 dyoung Exp $ */ +/* $NetBSD: if_faith.c,v 1.45 2008/11/07 00:20:13 dyoung Exp $ */ /* $KAME: if_faith.c,v 1.21 2001/02/20 07:59:26 itojun Exp $ */ /* @@ -40,7 +40,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_faith.c,v 1.44 2008/10/24 17:07:33 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_faith.c,v 1.45 2008/11/07 00:20:13 dyoung Exp $"); #include "opt_inet.h" @@ -233,7 +233,7 @@ faithioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP | IFF_RUNNING; ifa = (struct ifaddr *)data; ifa->ifa_rtrequest = faithrtrequest; @@ -264,18 +264,10 @@ faithioctl(struct ifnet *ifp, u_long cmd, void *data) } break; -#ifdef SIOCSIFMTU - case SIOCSIFMTU: + default: if ((error = ifioctl_common(ifp, cmd, data)) == ENETRESET) error = 0; break; -#endif - - case SIOCSIFFLAGS: - break; - - default: - error = EINVAL; } return (error); } diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c index 987d23c119b1..2d1c2a6c0bfd 100644 --- a/sys/net/if_fddisubr.c +++ b/sys/net/if_fddisubr.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_fddisubr.c,v 1.76 2008/05/11 20:13:30 dyoung Exp $ */ +/* $NetBSD: if_fddisubr.c,v 1.77 2008/11/07 00:20:13 dyoung Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -96,7 +96,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_fddisubr.c,v 1.76 2008/05/11 20:13:30 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_fddisubr.c,v 1.77 2008/11/07 00:20:13 dyoung Exp $"); #include "opt_inet.h" #include "opt_atalk.h" @@ -521,7 +521,8 @@ fddi_output(struct ifnet *ifp0, struct mbuf *m0, const struct sockaddr *dst, #if NCARP > 0 if (ifp0 != ifp && ifp0->if_type == IFT_CARP) { - if_set_sadl(ifp0, fh->fddi_shost, sizeof(fh->fddi_shost)); + if_set_sadl(ifp0, fh->fddi_shost, sizeof(fh->fddi_shost), + false); } if (ifp != ifp0) @@ -786,7 +787,7 @@ fddi_ifattach(struct ifnet *ifp, void *lla) max_linkhdr = ALIGN(ifp->if_hdrlen); LIST_INIT(&ec->ec_multiaddrs); - if_set_sadl(ifp, lla, 6); + if_set_sadl(ifp, lla, 6, true); ifp->if_broadcastaddr = fddibroadcastaddr; #if NBPFILTER > 0 diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c index f022b2b805f2..34553be2eb8a 100644 --- a/sys/net/if_gif.c +++ b/sys/net/if_gif.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_gif.c,v 1.75 2008/06/15 16:37:21 christos Exp $ */ +/* $NetBSD: if_gif.c,v 1.76 2008/11/07 00:20:13 dyoung Exp $ */ /* $KAME: if_gif.c,v 1.76 2001/08/20 02:01:02 kjc Exp $ */ /* @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.75 2008/06/15 16:37:21 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.76 2008/11/07 00:20:13 dyoung Exp $"); #include "opt_inet.h" #include "opt_iso.h" @@ -157,6 +157,7 @@ gifattach0(struct gif_softc *sc) sc->gif_if.if_output = gif_output; sc->gif_if.if_type = IFT_GIF; sc->gif_if.if_dlt = DLT_NULL; + sc->gif_if.if_softc = sc; IFQ_SET_READY(&sc->gif_if.if_snd); if_attach(&sc->gif_if); if_alloc_sadl(&sc->gif_if); @@ -197,7 +198,7 @@ gif_encapcheck(struct mbuf *m, int off, int proto, void *arg) struct ip ip; struct gif_softc *sc; - sc = (struct gif_softc *)arg; + sc = arg; if (sc == NULL) return 0; @@ -230,7 +231,7 @@ gif_encapcheck(struct mbuf *m, int off, int proto, void *arg) if (m->m_pkthdr.len < sizeof(ip)) return 0; - m_copydata(m, 0, sizeof(ip), (void *)&ip); + m_copydata(m, 0, sizeof(ip), &ip); switch (ip.ip_v) { #ifdef INET @@ -259,7 +260,7 @@ int gif_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, struct rtentry *rt) { - struct gif_softc *sc = (struct gif_softc*)ifp; + struct gif_softc *sc = ifp->if_softc; int error = 0; static int called = 0; /* XXX: MUTEX */ ALTQ_DECL(struct altq_pktattr pktattr;) @@ -345,7 +346,7 @@ gifintr(void *arg) int s; int error; - sc = (struct gif_softc *)arg; + sc = arg; ifp = &sc->gif_if; /* output processing */ @@ -477,7 +478,7 @@ int gif_ioctl(struct ifnet *ifp, u_long cmd, void *data) { struct lwp *l = curlwp; /* XXX */ - struct gif_softc *sc = (struct gif_softc*)ifp; + struct gif_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq*)data; int error = 0, size; struct sockaddr *dst, *src; @@ -499,7 +500,7 @@ gif_ioctl(struct ifnet *ifp, u_long cmd, void *data) } switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; break; @@ -720,13 +721,8 @@ gif_ioctl(struct ifnet *ifp, u_long cmd, void *data) memcpy(dst, src, src->sa_len); break; - case SIOCSIFFLAGS: - /* if_ioctl() takes care of it */ - break; - default: - error = EINVAL; - break; + return ifioctl_common(ifp, cmd, data); } bad: return error; @@ -735,7 +731,7 @@ gif_ioctl(struct ifnet *ifp, u_long cmd, void *data) int gif_set_tunnel(struct ifnet *ifp, struct sockaddr *src, struct sockaddr *dst) { - struct gif_softc *sc = (struct gif_softc *)ifp; + struct gif_softc *sc = ifp->if_softc; struct gif_softc *sc2; struct sockaddr *osrc, *odst; int s; @@ -844,7 +840,7 @@ gif_set_tunnel(struct ifnet *ifp, struct sockaddr *src, struct sockaddr *dst) void gif_delete_tunnel(struct ifnet *ifp) { - struct gif_softc *sc = (struct gif_softc *)ifp; + struct gif_softc *sc = ifp->if_softc; int s; s = splsoftnet(); diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c index a3933b121c7d..62ed1dce7e1a 100644 --- a/sys/net/if_gre.c +++ b/sys/net/if_gre.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_gre.c,v 1.138 2008/08/06 15:01:23 plunky Exp $ */ +/* $NetBSD: if_gre.c,v 1.139 2008/11/07 00:20:13 dyoung Exp $ */ /* * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc. @@ -45,7 +45,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.138 2008/08/06 15:01:23 plunky Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.139 2008/11/07 00:20:13 dyoung Exp $"); #include "opt_gre.h" #include "opt_inet.h" @@ -1305,7 +1305,7 @@ gre_ioctl(struct ifnet *ifp, const u_long cmd, void *data) GRE_DPRINTF(sc, "\n"); switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: GRE_DPRINTF(sc, "\n"); if ((ifp->if_flags & IFF_UP) != 0) break; @@ -1315,6 +1315,8 @@ gre_ioctl(struct ifnet *ifp, const u_long cmd, void *data) case SIOCSIFDSTADDR: break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; oproto = sp->sp_proto; otype = sp->sp_type; switch (ifr->ifr_flags & (IFF_LINK0|IFF_LINK2)) { @@ -1525,7 +1527,7 @@ gre_ioctl(struct ifnet *ifp, const u_long cmd, void *data) GRE_DPRINTF(sc, "\n"); break; default: - error = EINVAL; + error = ifioctl_common(ifp, cmd, data); break; } out: diff --git a/sys/net/if_hippisubr.c b/sys/net/if_hippisubr.c index 90e76907b44f..d74ca6bac019 100644 --- a/sys/net/if_hippisubr.c +++ b/sys/net/if_hippisubr.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_hippisubr.c,v 1.34 2008/02/20 17:05:53 matt Exp $ */ +/* $NetBSD: if_hippisubr.c,v 1.35 2008/11/07 00:20:13 dyoung Exp $ */ /* * Copyright (c) 1982, 1989, 1993 @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_hippisubr.c,v 1.34 2008/02/20 17:05:53 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_hippisubr.c,v 1.35 2008/11/07 00:20:13 dyoung Exp $"); #include "opt_inet.h" @@ -339,7 +339,7 @@ hippi_ifattach(struct ifnet *ifp, void *lla) ifp->if_input = hippi_input; ifp->if_baudrate = IF_Mbps(800); /* XXX double-check */ - if_set_sadl(ifp, lla, 6); + if_set_sadl(ifp, lla, 6, true); #if NBPFILTER > 0 bpfattach(ifp, DLT_HIPPI, sizeof(struct hippi_header)); diff --git a/sys/net/if_ieee1394subr.c b/sys/net/if_ieee1394subr.c index 80072f79eddf..2392fbb43a6d 100644 --- a/sys/net/if_ieee1394subr.c +++ b/sys/net/if_ieee1394subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ieee1394subr.c,v 1.40 2008/04/28 20:24:09 martin Exp $ */ +/* $NetBSD: if_ieee1394subr.c,v 1.41 2008/11/07 00:20:13 dyoung Exp $ */ /* * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ieee1394subr.c,v 1.40 2008/04/28 20:24:09 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ieee1394subr.c,v 1.41 2008/11/07 00:20:13 dyoung Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -685,7 +685,7 @@ ieee1394_ifattach(struct ifnet *ifp, const struct ieee1394_hwaddr *hwaddr) if (ifp->if_baudrate == 0) ifp->if_baudrate = IF_Mbps(100); - if_set_sadl(ifp, hwaddr, sizeof(struct ieee1394_hwaddr)); + if_set_sadl(ifp, hwaddr, sizeof(struct ieee1394_hwaddr), true); baddr = malloc(ifp->if_addrlen, M_DEVBUF, M_WAITOK); memset(baddr->iha_uid, 0xff, IEEE1394_ADDR_LEN); @@ -720,41 +720,24 @@ ieee1394_ioctl(struct ifnet *ifp, u_long cmd, void *data) struct ifreq *ifr = (struct ifreq *)data; struct ifaddr *ifa = (struct ifaddr *)data; int error = 0; -#if __NetBSD_Version__ < 105080000 - int fw_init(struct ifnet *); - void fw_stop(struct ifnet *, int); -#endif switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: -#if __NetBSD_Version__ >= 105080000 if ((error = (*ifp->if_init)(ifp)) != 0) -#else - if ((error = fw_init(ifp)) != 0) -#endif break; arp_ifinit(ifp, ifa); break; #endif /* INET */ default: -#if __NetBSD_Version__ >= 105080000 error = (*ifp->if_init)(ifp); -#else - error = fw_init(ifp); -#endif break; } break; - case SIOCGIFADDR: - memcpy(((struct sockaddr *)&ifr->ifr_data)->sa_data, - CLLADDR(ifp->if_sadl), IEEE1394_ADDR_LEN); - break; - case SIOCSIFMTU: if (ifr->ifr_mtu > IEEE1394MTU) error = EINVAL; @@ -762,10 +745,8 @@ ieee1394_ioctl(struct ifnet *ifp, u_long cmd, void *data) error = 0; break; - case SIOCSIFCAP: - return ifioctl_common(ifp, cmd, data); default: - error = ENOTTY; + error = ifioctl_common(ifp, cmd, data); break; } diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c index ce22e76976e1..4943f29e0513 100644 --- a/sys/net/if_loop.c +++ b/sys/net/if_loop.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_loop.c,v 1.69 2008/10/24 17:07:33 dyoung Exp $ */ +/* $NetBSD: if_loop.c,v 1.70 2008/11/07 00:20:13 dyoung Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -65,7 +65,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.69 2008/10/24 17:07:33 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.70 2008/11/07 00:20:13 dyoung Exp $"); #include "opt_inet.h" #include "opt_atalk.h" @@ -417,7 +417,7 @@ loioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifp->if_flags |= IFF_UP; ifa = (struct ifaddr *)data; if (ifa != NULL /*&& ifa->ifa_addr->sa_family == AF_ISO*/) @@ -460,7 +460,7 @@ loioctl(struct ifnet *ifp, u_long cmd, void *data) break; default: - error = EINVAL; + error = ifioctl_common(ifp, cmd, data); } return (error); } diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c index 187844c4dba9..9900b3fc7d87 100644 --- a/sys/net/if_ppp.c +++ b/sys/net/if_ppp.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ppp.c,v 1.123 2008/06/15 16:37:21 christos Exp $ */ +/* $NetBSD: if_ppp.c,v 1.124 2008/11/07 00:20:13 dyoung Exp $ */ /* Id: if_ppp.c,v 1.6 1997/03/04 03:33:00 paulus Exp */ /* @@ -102,7 +102,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.123 2008/06/15 16:37:21 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.124 2008/11/07 00:20:13 dyoung Exp $"); #include "ppp.h" @@ -760,11 +760,13 @@ pppsioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; if ((ifp->if_flags & IFF_RUNNING) == 0) ifp->if_flags &= ~IFF_UP; break; - case SIOCSIFADDR: + case SIOCINITIFADDR: switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: @@ -796,17 +798,6 @@ pppsioctl(struct ifnet *ifp, u_long cmd, void *data) } break; - case SIOCSIFMTU: - if ((error = kauth_authorize_network(l->l_cred, - KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, - ifp, (void *)cmd, NULL) != 0)) - break; - /*FALLTHROUGH*/ - case SIOCGIFMTU: - if ((error = ifioctl_common(&sc->sc_if, cmd, data)) == ENETRESET) - error = 0; - break; - case SIOCADDMULTI: case SIOCDELMULTI: if (ifr == NULL) { @@ -857,8 +848,16 @@ pppsioctl(struct ifnet *ifp, u_long cmd, void *data) break; #endif /* PPP_COMPRESS */ + case SIOCSIFMTU: + if ((error = kauth_authorize_network(l->l_cred, + KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, + ifp, (void *)cmd, NULL) != 0)) + break; + /*FALLTHROUGH*/ default: - error = EINVAL; + if ((error = ifioctl_common(&sc->sc_if, cmd, data)) == ENETRESET) + error = 0; + break; } splx(s); return (error); diff --git a/sys/net/if_sl.c b/sys/net/if_sl.c index c1e4cafa2bcf..08295aa11351 100644 --- a/sys/net/if_sl.c +++ b/sys/net/if_sl.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_sl.c,v 1.112 2008/06/15 16:37:21 christos Exp $ */ +/* $NetBSD: if_sl.c,v 1.113 2008/11/07 00:20:13 dyoung Exp $ */ /* * Copyright (c) 1987, 1989, 1992, 1993 @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_sl.c,v 1.112 2008/06/15 16:37:21 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_sl.c,v 1.113 2008/11/07 00:20:13 dyoung Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -984,7 +984,7 @@ slioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: if (ifa->ifa_addr->sa_family == AF_INET) ifp->if_flags |= IFF_UP; else @@ -1053,7 +1053,8 @@ slioctl(struct ifnet *ifp, u_long cmd, void *data) break; default: - error = EINVAL; + error = ifioctl_common(ifp, cmd, data); + break; } splx(s); return error; diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c index 7978be02599b..0fca08957102 100644 --- a/sys/net/if_spppsubr.c +++ b/sys/net/if_spppsubr.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_spppsubr.c,v 1.114 2008/10/03 18:33:06 pooka Exp $ */ +/* $NetBSD: if_spppsubr.c,v 1.115 2008/11/07 00:20:13 dyoung Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.114 2008/10/03 18:33:06 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.115 2008/11/07 00:20:13 dyoung Exp $"); #include "opt_inet.h" #include "opt_ipx.h" @@ -1044,10 +1044,12 @@ sppp_ioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { case SIOCAIFADDR: case SIOCSIFDSTADDR: - case SIOCSIFADDR: + case SIOCINITIFADDR: break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; going_up = ifp->if_flags & IFF_UP && (ifp->if_flags & IFF_RUNNING) == 0; going_down = (ifp->if_flags & IFF_UP) == 0 && @@ -1125,7 +1127,8 @@ sppp_ioctl(struct ifnet *ifp, u_long cmd, void *data) break; default: - error = ENOTTY; + error = ifioctl_common(ifp, cmd, data); + break; } splx(s); return (error); diff --git a/sys/net/if_srt.c b/sys/net/if_srt.c index 2870ec6ee30a..318c35c7b02e 100644 --- a/sys/net/if_srt.c +++ b/sys/net/if_srt.c @@ -1,8 +1,8 @@ -/* $NetBSD: if_srt.c,v 1.8 2008/06/15 16:37:21 christos Exp $ */ +/* $NetBSD: if_srt.c,v 1.9 2008/11/07 00:20:13 dyoung Exp $ */ /* This file is in the public domain. */ #include -__KERNEL_RCSID(0, "$NetBSD: if_srt.c,v 1.8 2008/06/15 16:37:21 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_srt.c,v 1.9 2008/11/07 00:20:13 dyoung Exp $"); #include "opt_inet.h" @@ -140,7 +140,7 @@ static int srt_if_ioctl(struct ifnet *intf, u_long cmd, void *data) err = 0; s = splnet(); switch (cmd) - { case SIOCSIFADDR: + { case SIOCINITIFADDR: case SIOCSIFDSTADDR: ifa = (void *) data; switch (ifa->ifa_addr->sa_family) @@ -158,14 +158,10 @@ static int srt_if_ioctl(struct ifnet *intf, u_long cmd, void *data) } /* XXX do we need to do more here for either of these? */ break; - case SIOCSIFMTU: - case SIOCGIFMTU: + default: if ((err = ifioctl_common(intf, cmd, data)) == ENETRESET) err = 0; break; - default: - err = EINVAL; - break; } splx(s); return(err); diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c index ea493cbee726..e6f130e6716a 100644 --- a/sys/net/if_stf.c +++ b/sys/net/if_stf.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_stf.c,v 1.67 2008/10/24 17:07:33 dyoung Exp $ */ +/* $NetBSD: if_stf.c,v 1.68 2008/11/07 00:20:13 dyoung Exp $ */ /* $KAME: if_stf.c,v 1.62 2001/06/07 22:32:16 itojun Exp $ */ /* @@ -75,7 +75,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_stf.c,v 1.67 2008/10/24 17:07:33 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_stf.c,v 1.68 2008/11/07 00:20:13 dyoung Exp $"); #include "opt_inet.h" @@ -683,7 +683,7 @@ stf_ioctl(struct ifnet *ifp, u_long cmd, void *data) error = 0; switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: ifa = (struct ifaddr *)data; if (ifa == NULL || ifa->ifa_addr->sa_family != AF_INET6) { error = EAFNOSUPPORT; @@ -718,7 +718,7 @@ stf_ioctl(struct ifnet *ifp, u_long cmd, void *data) break; default: - error = EINVAL; + error = ifioctl_common(ifp, cmd, data); break; } diff --git a/sys/net/if_strip.c b/sys/net/if_strip.c index 1af328ea2060..46235e902a8d 100644 --- a/sys/net/if_strip.c +++ b/sys/net/if_strip.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_strip.c,v 1.87 2008/06/15 16:37:21 christos Exp $ */ +/* $NetBSD: if_strip.c,v 1.88 2008/11/07 00:20:13 dyoung Exp $ */ /* from: NetBSD: if_sl.c,v 1.38 1996/02/13 22:00:23 christos Exp $ */ /* @@ -87,7 +87,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_strip.c,v 1.87 2008/06/15 16:37:21 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_strip.c,v 1.88 2008/11/07 00:20:13 dyoung Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -1277,7 +1277,7 @@ stripioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: if (ifa->ifa_addr->sa_family == AF_INET) ifp->if_flags |= IFF_UP; else @@ -1310,7 +1310,7 @@ stripioctl(struct ifnet *ifp, u_long cmd, void *data) break; default: - error = EINVAL; + error = ifioctl_common(ifp, cmd, data); } splx(s); return (error); diff --git a/sys/net/if_tap.c b/sys/net/if_tap.c index 9635538a21e5..d4106d89ff6c 100644 --- a/sys/net/if_tap.c +++ b/sys/net/if_tap.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_tap.c,v 1.49 2008/11/03 00:52:07 hans Exp $ */ +/* $NetBSD: if_tap.c,v 1.50 2008/11/07 00:20:13 dyoung Exp $ */ /* * Copyright (c) 2003, 2004, 2008 The NetBSD Foundation. @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.49 2008/11/03 00:52:07 hans Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.50 2008/11/07 00:20:13 dyoung Exp $"); #if defined(_KERNEL_OPT) #include "bpfilter.h" @@ -548,7 +548,7 @@ tap_lifaddr(struct ifnet *ifp, u_long cmd, struct ifaliasreq *ifra) if (sdl->sdl_family != AF_LINK) return (EINVAL); - if_set_sadl(ifp, CLLADDR(sdl), ETHER_ADDR_LEN); + if_set_sadl(ifp, CLLADDR(sdl), ETHER_ADDR_LEN, false); return (0); } @@ -1344,6 +1344,6 @@ tap_sysctl_handler(SYSCTLFN_ARGS) /* Commit change */ if (ether_nonstatic_aton(enaddr, addr) != 0) return (EINVAL); - if_set_sadl(ifp, enaddr, ETHER_ADDR_LEN); + if_set_sadl(ifp, enaddr, ETHER_ADDR_LEN, false); return (error); } diff --git a/sys/net/if_tokensubr.c b/sys/net/if_tokensubr.c index b0659866c3c0..ec339bc2f900 100644 --- a/sys/net/if_tokensubr.c +++ b/sys/net/if_tokensubr.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_tokensubr.c,v 1.54 2008/04/28 20:24:09 martin Exp $ */ +/* $NetBSD: if_tokensubr.c,v 1.55 2008/11/07 00:20:13 dyoung Exp $ */ /* * Copyright (c) 1982, 1989, 1993 @@ -92,7 +92,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_tokensubr.c,v 1.54 2008/04/28 20:24:09 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_tokensubr.c,v 1.55 2008/11/07 00:20:13 dyoung Exp $"); #include "opt_inet.h" #include "opt_atalk.h" @@ -656,7 +656,7 @@ token_ifattach(struct ifnet *ifp, void *lla) ifp->if_flags |= IFF_NOTRAILERS; #endif - if_set_sadl(ifp, lla, ISO88025_ADDR_LEN); + if_set_sadl(ifp, lla, ISO88025_ADDR_LEN, true); #if NBPFILTER > 0 bpfattach(ifp, DLT_IEEE802, sizeof(struct token_header)); diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index af8ac9c93f99..2fb9467314de 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_tun.c,v 1.107 2008/06/15 16:37:21 christos Exp $ */ +/* $NetBSD: if_tun.c,v 1.108 2008/11/07 00:20:13 dyoung Exp $ */ /* * Copyright (c) 1988, Julian Onions @@ -15,7 +15,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.107 2008/06/15 16:37:21 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.108 2008/11/07 00:20:13 dyoung Exp $"); #include "opt_inet.h" @@ -443,7 +443,7 @@ tun_ioctl(struct ifnet *ifp, u_long cmd, void *data) simple_lock(&tp->tun_lock); switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: tuninit(tp); TUNDEBUG("%s: address set\n", ifp->if_xname); break; @@ -483,10 +483,8 @@ tun_ioctl(struct ifnet *ifp, u_long cmd, void *data) break; } break; - case SIOCSIFFLAGS: - break; default: - error = EINVAL; + error = ifioctl_common(ifp, cmd, data); } simple_unlock(&tp->tun_lock); diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index 34a0e290f39a..02bdc339bc10 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_vlan.c,v 1.60 2008/10/11 17:19:41 bouyer Exp $ */ +/* $NetBSD: if_vlan.c,v 1.61 2008/11/07 00:20:13 dyoung Exp $ */ /*- * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. @@ -78,7 +78,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.60 2008/10/11 17:19:41 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.61 2008/11/07 00:20:13 dyoung Exp $"); #include "opt_inet.h" #include "bpfilter.h" @@ -464,13 +464,12 @@ vlan_ioctl(struct ifnet *ifp, u_long cmd, void *data) struct ifnet *pr; struct ifcapreq *ifcr; struct vlanreq vlr; - struct sockaddr *sa; int s, error = 0; s = splnet(); switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: if (ifv->ifv_p != NULL) { ifp->if_flags |= IFF_UP; @@ -488,11 +487,6 @@ vlan_ioctl(struct ifnet *ifp, u_long cmd, void *data) } break; - case SIOCGIFADDR: - sa = (struct sockaddr *)&ifr->ifr_data; - memcpy(sa->sa_data, CLLADDR(ifp->if_sadl), ifp->if_addrlen); - break; - case SIOCSIFMTU: if (ifv->ifv_p == NULL) error = EINVAL; @@ -544,6 +538,8 @@ vlan_ioctl(struct ifnet *ifp, u_long cmd, void *data) break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; /* * For promiscuous mode, we enable promiscuous mode on * the parent if we need promiscuous on the VLAN interface. @@ -574,7 +570,7 @@ vlan_ioctl(struct ifnet *ifp, u_long cmd, void *data) error = 0; break; default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); } splx(s); diff --git a/sys/net/link_proto.c b/sys/net/link_proto.c index c11146f5aafe..f7f9f1641b5f 100644 --- a/sys/net/link_proto.c +++ b/sys/net/link_proto.c @@ -1,4 +1,4 @@ -/* $NetBSD: link_proto.c,v 1.4 2008/05/13 18:09:22 dyoung Exp $ */ +/* $NetBSD: link_proto.c,v 1.5 2008/11/07 00:20:13 dyoung Exp $ */ /*- * Copyright (c) 1982, 1986, 1993 @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: link_proto.c,v 1.4 2008/05/13 18:09:22 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: link_proto.c,v 1.5 2008/11/07 00:20:13 dyoung Exp $"); #include #include @@ -153,6 +153,9 @@ link_control(struct socket *so, unsigned long cmd, void *data, else iflr->flags = 0; + if (ifa == ifp->if_hwdl) + iflr->flags |= IFLR_FACTORY; + sockaddr_copy(sstosa(&iflr->addr), sizeof(iflr->addr), ifa->ifa_addr); @@ -160,7 +163,7 @@ link_control(struct socket *so, unsigned long cmd, void *data, case SIOCDLIFADDR: if (ifa == NULL) error = EADDRNOTAVAIL; - else if (ifa == ifp->if_dl) + else if (ifa == ifp->if_dl || ifa == ifp->if_hwdl) error = EBUSY; else { /* TBD routing socket */ diff --git a/sys/net/route.c b/sys/net/route.c index 069711a897a7..85aaab45f1b0 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $NetBSD: route.c,v 1.113 2008/10/04 00:09:34 pooka Exp $ */ +/* $NetBSD: route.c,v 1.114 2008/11/07 00:20:13 dyoung Exp $ */ /*- * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc. @@ -93,7 +93,7 @@ #include "opt_route.h" #include -__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.113 2008/10/04 00:09:34 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.114 2008/11/07 00:20:13 dyoung Exp $"); #include #include @@ -110,6 +110,7 @@ __KERNEL_RCSID(0, "$NetBSD: route.c,v 1.113 2008/10/04 00:09:34 pooka Exp $"); #include #include +#include #include #include @@ -249,6 +250,7 @@ rtcache(struct route *ro) { struct domain *dom; + rtcache_invariants(ro); KASSERT(ro->_ro_rt != NULL); KASSERT(ro->ro_invalid == false); KASSERT(rtcache_getdst(ro) != NULL); @@ -257,6 +259,7 @@ rtcache(struct route *ro) return; LIST_INSERT_HEAD(&dom->dom_rtcache, ro, ro_rtcache_next); + rtcache_invariants(ro); } /* @@ -874,6 +877,8 @@ rtinit(struct ifaddr *ifa, int cmd, int flags) struct rtentry *nrt = NULL; int error; struct rt_addrinfo info; + struct sockaddr_dl *sdl; + const struct sockaddr_dl *ifsdl; dst = flags & RTF_HOST ? ifa->ifa_dstaddr : ifa->ifa_addr; if (cmd == RTM_DELETE) { @@ -901,28 +906,56 @@ rtinit(struct ifaddr *ifa, int cmd, int flags) * variable) when RTF_HOST is 1. still not sure if i can safely * change it to meet bsdi4 behavior. */ - info.rti_info[RTAX_NETMASK] = ifa->ifa_netmask; - error = rtrequest1(cmd, &info, &nrt); - if (cmd == RTM_DELETE && error == 0 && (rt = nrt)) { + if (cmd != RTM_LLINFO_UPD) + info.rti_info[RTAX_NETMASK] = ifa->ifa_netmask; + error = rtrequest1((cmd == RTM_LLINFO_UPD) ? RTM_GET : cmd, &info, + &nrt); + if (error != 0 || (rt = nrt) == NULL) + ; + else switch (cmd) { + case RTM_DELETE: rt_newaddrmsg(cmd, ifa, error, nrt); if (rt->rt_refcnt <= 0) { rt->rt_refcnt++; rtfree(rt); } - } - if (cmd == RTM_ADD && error == 0 && (rt = nrt)) { + break; + case RTM_LLINFO_UPD: + rt->rt_refcnt--; + RT_DPRINTF("%s: updating%s\n", __func__, + ((rt->rt_flags & RTF_LLINFO) == 0) ? " (no llinfo)" : ""); + + ifsdl = ifa->ifa_ifp->if_sadl; + + if ((rt->rt_flags & RTF_LLINFO) != 0 && + (sdl = satosdl(rt->rt_gateway)) != NULL && + sdl->sdl_family == AF_LINK && + sockaddr_dl_setaddr(sdl, sdl->sdl_len, CLLADDR(ifsdl), + ifa->ifa_ifp->if_addrlen) == NULL) { + error = EINVAL; + break; + } + + if (cmd == RTM_LLINFO_UPD && ifa->ifa_rtrequest != NULL) + ifa->ifa_rtrequest(RTM_LLINFO_UPD, rt, &info); + rt_newaddrmsg(RTM_CHANGE, ifa, error, nrt); + break; + case RTM_ADD: rt->rt_refcnt--; if (rt->rt_ifa != ifa) { printf("rtinit: wrong ifa (%p) was (%p)\n", ifa, rt->rt_ifa); - if (rt->rt_ifa->ifa_rtrequest) - rt->rt_ifa->ifa_rtrequest(RTM_DELETE, rt, NULL); + if (rt->rt_ifa->ifa_rtrequest != NULL) { + rt->rt_ifa->ifa_rtrequest(RTM_DELETE, rt, + &info); + } rt_replace_ifa(rt, ifa); rt->rt_ifp = ifa->ifa_ifp; - if (ifa->ifa_rtrequest) - ifa->ifa_rtrequest(RTM_ADD, rt, NULL); + if (ifa->ifa_rtrequest != NULL) + ifa->ifa_rtrequest(RTM_ADD, rt, &info); } rt_newaddrmsg(cmd, ifa, error, nrt); + break; } return error; } @@ -1126,6 +1159,7 @@ rt_timer_timer(void *arg) static struct rtentry * _rtcache_init(struct route *ro, int flag) { + rtcache_invariants(ro); KASSERT(ro->_ro_rt == NULL); if (rtcache_getdst(ro) == NULL) @@ -1134,6 +1168,7 @@ _rtcache_init(struct route *ro, int flag) if ((ro->_ro_rt = rtalloc1(rtcache_getdst(ro), flag)) != NULL) rtcache(ro); + rtcache_invariants(ro); return ro->_ro_rt; } @@ -1162,6 +1197,8 @@ rtcache_copy(struct route *new_ro, const struct route *old_ro) struct rtentry *rt; KASSERT(new_ro != old_ro); + rtcache_invariants(new_ro); + rtcache_invariants(old_ro); if ((rt = rtcache_validate(old_ro)) != NULL) rt->rt_refcnt++; @@ -1173,6 +1210,7 @@ rtcache_copy(struct route *new_ro, const struct route *old_ro) new_ro->ro_invalid = false; if ((new_ro->_ro_rt = rt) != NULL) rtcache(new_ro); + rtcache_invariants(new_ro); } static struct dom_rtlist invalid_routes = LIST_HEAD_INITIALIZER(dom_rtlist); @@ -1183,25 +1221,28 @@ rtcache_invalidate(struct dom_rtlist *rtlist) struct route *ro; while ((ro = LIST_FIRST(rtlist)) != NULL) { + rtcache_invariants(ro); KASSERT(ro->_ro_rt != NULL); ro->ro_invalid = true; LIST_REMOVE(ro, ro_rtcache_next); LIST_INSERT_HEAD(&invalid_routes, ro, ro_rtcache_next); + rtcache_invariants(ro); } } void rtcache_clear(struct route *ro) { + rtcache_invariants(ro); if (ro->_ro_rt == NULL) return; - KASSERT(rtcache_getdst(ro) != NULL); - LIST_REMOVE(ro, ro_rtcache_next); RTFREE(ro->_ro_rt); ro->_ro_rt = NULL; + ro->ro_invalid = false; + rtcache_invariants(ro); } struct rtentry * @@ -1211,6 +1252,8 @@ rtcache_lookup2(struct route *ro, const struct sockaddr *dst, int clone, const struct sockaddr *odst; struct rtentry *rt = NULL; + rtcache_invariants(ro); + odst = rtcache_getdst(ro); if (odst == NULL) @@ -1227,6 +1270,8 @@ rtcache_lookup2(struct route *ro, const struct sockaddr *dst, int clone, } else *hitp = 1; + rtcache_invariants(ro); + return rt; } @@ -1237,8 +1282,8 @@ rtcache_free(struct route *ro) if (ro->ro_sa != NULL) { sockaddr_free(ro->ro_sa); ro->ro_sa = NULL; - KASSERT(ro->_ro_rt == NULL); } + rtcache_invariants(ro); } int @@ -1246,10 +1291,13 @@ rtcache_setdst(struct route *ro, const struct sockaddr *sa) { KASSERT(sa != NULL); + rtcache_invariants(ro); if (ro->ro_sa != NULL && ro->ro_sa->sa_family == sa->sa_family) { rtcache_clear(ro); - if (sockaddr_copy(ro->ro_sa, ro->ro_sa->sa_len, sa) != NULL) + if (sockaddr_copy(ro->ro_sa, ro->ro_sa->sa_len, sa) != NULL) { + rtcache_invariants(ro); return 0; + } sockaddr_free(ro->ro_sa); } else if (ro->ro_sa != NULL) rtcache_free(ro); /* free ro_sa, wrong family */ @@ -1257,8 +1305,10 @@ rtcache_setdst(struct route *ro, const struct sockaddr *sa) KASSERT(ro->_ro_rt == NULL); if ((ro->ro_sa = sockaddr_dup(sa, M_NOWAIT)) == NULL) { + rtcache_invariants(ro); return ENOMEM; } + rtcache_invariants(ro); return 0; } diff --git a/sys/net/route.h b/sys/net/route.h index 138c661d59c8..646ed5a272cf 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -1,4 +1,4 @@ -/* $NetBSD: route.h,v 1.70 2008/03/26 14:54:19 ad Exp $ */ +/* $NetBSD: route.h,v 1.71 2008/11/07 00:20:13 dyoung Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -205,6 +205,9 @@ struct rt_msghdr { #define RTM_SETGATE 0x12 /* set prototype gateway for clones * (see example in arp_rtrequest). */ +#define RTM_LLINFO_UPD 0x13 /* indication to ARP/NDP/etc. that link-layer + * address has changed + */ #define RTV_MTU 0x1 /* init or lock _mtu */ #define RTV_HOPCOUNT 0x2 /* init or lock _hopcount */ @@ -384,6 +387,13 @@ struct rtentry *rtcache_update(struct route *, int); void rtcache_free(struct route *); int rtcache_setdst(struct route *, const struct sockaddr *); +static inline void +rtcache_invariants(const struct route *ro) +{ + KASSERT(ro->ro_sa != NULL || ro->_ro_rt == NULL); + KASSERT(!ro->ro_invalid || ro->_ro_rt != NULL); +} + static inline struct rtentry * rtcache_lookup1(struct route *ro, const struct sockaddr *dst, int clone) { @@ -407,6 +417,7 @@ rtcache_lookup(struct route *ro, const struct sockaddr *dst) static inline const struct sockaddr * rtcache_getdst(const struct route *ro) { + rtcache_invariants(ro); return ro->ro_sa; } @@ -419,6 +430,8 @@ rtcache_validate(const struct route *ro) { struct rtentry *rt = ro->_ro_rt; + rtcache_invariants(ro); + if (ro->ro_invalid) return NULL; diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 0ab2b4ba13b7..246ad85a4235 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $NetBSD: rtsock.c,v 1.115 2008/10/28 11:41:23 christos Exp $ */ +/* $NetBSD: rtsock.c,v 1.116 2008/11/07 00:20:13 dyoung Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.115 2008/10/28 11:41:23 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.116 2008/11/07 00:20:13 dyoung Exp $"); #include "opt_inet.h" @@ -815,20 +815,28 @@ rt_ifmsg(struct ifnet *ifp) void rt_newaddrmsg(int cmd, struct ifaddr *ifa, int error, struct rtentry *rt) { +#define cmdpass(__cmd, __pass) (((__cmd) << 2) | (__pass)) struct rt_addrinfo info; - const struct sockaddr *sa = NULL; + const struct sockaddr *sa; int pass; - struct mbuf *m = NULL; + struct mbuf *m; struct ifnet *ifp = ifa->ifa_ifp; + struct rt_msghdr rtm; + struct ifa_msghdr ifam; + int ncmd; if (route_cb.any_count == 0) return; for (pass = 1; pass < 3; pass++) { memset(&info, 0, sizeof(info)); - if ((cmd == RTM_ADD && pass == 1) || - (cmd == RTM_DELETE && pass == 2)) { - struct ifa_msghdr ifam; - int ncmd = cmd == RTM_ADD ? RTM_NEWADDR : RTM_DELADDR; + switch (cmdpass(cmd, pass)) { + case cmdpass(RTM_ADD, 1): + case cmdpass(RTM_CHANGE, 1): + case cmdpass(RTM_DELETE, 2): + if (cmd == RTM_ADD) + ncmd = RTM_NEWADDR; + else + ncmd = RTM_DELADDR; info.rti_info[RTAX_IFA] = sa = ifa->ifa_addr; info.rti_info[RTAX_IFP] = ifp->if_dl->ifa_addr; @@ -843,11 +851,10 @@ rt_newaddrmsg(int cmd, struct ifaddr *ifa, int error, struct rtentry *rt) continue; mtod(m, struct ifa_msghdr *)->ifam_addrs = info.rti_addrs; - } - if ((cmd == RTM_ADD && pass == 2) || - (cmd == RTM_DELETE && pass == 1)) { - struct rt_msghdr rtm; - + break; + case cmdpass(RTM_ADD, 2): + case cmdpass(RTM_CHANGE, 2): + case cmdpass(RTM_DELETE, 1): if (rt == NULL) continue; info.rti_info[RTAX_NETMASK] = rt_mask(rt); @@ -861,6 +868,9 @@ rt_newaddrmsg(int cmd, struct ifaddr *ifa, int error, struct rtentry *rt) if (m == NULL) continue; mtod(m, struct rt_msghdr *)->rtm_addrs = info.rti_addrs; + break; + default: + continue; } #ifdef DIAGNOSTIC if (m == NULL) @@ -868,6 +878,7 @@ rt_newaddrmsg(int cmd, struct ifaddr *ifa, int error, struct rtentry *rt) #endif route_enqueue(m, sa ? sa->sa_family : 0); } +#undef cmdpass } static struct mbuf * diff --git a/sys/net80211/ieee80211_ioctl.c b/sys/net80211/ieee80211_ioctl.c index ac8c26ce332d..51e25b5ceb21 100644 --- a/sys/net80211/ieee80211_ioctl.c +++ b/sys/net80211/ieee80211_ioctl.c @@ -1,4 +1,4 @@ -/* $NetBSD: ieee80211_ioctl.c,v 1.49 2008/04/05 09:34:22 mlelstv Exp $ */ +/* $NetBSD: ieee80211_ioctl.c,v 1.50 2008/11/07 00:20:18 dyoung Exp $ */ /*- * Copyright (c) 2001 Atsushi Onoe * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting @@ -36,7 +36,7 @@ __FBSDID("$FreeBSD: src/sys/net80211/ieee80211_ioctl.c,v 1.35 2005/08/30 14:27:47 avatar Exp $"); #endif #ifdef __NetBSD__ -__KERNEL_RCSID(0, "$NetBSD: ieee80211_ioctl.c,v 1.49 2008/04/05 09:34:22 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ieee80211_ioctl.c,v 1.50 2008/11/07 00:20:18 dyoung Exp $"); #endif /* @@ -2548,51 +2548,6 @@ ieee80211_ioctl(struct ieee80211com *ic, u_long cmd, void *data) else ifp->if_mtu = ifr->ifr_mtu; break; - case SIOCSIFADDR: - /* - * XXX Handle this directly so we can supress if_init calls. - * XXX This should be done in ether_ioctl but for the moment - * XXX there are too many other parts of the system that - * XXX set IFF_UP and so supress if_init being called when - * XXX it should be. - */ - ifa = (struct ifaddr *) data; - switch (ifa->ifa_addr->sa_family) { -#ifdef INET - case AF_INET: - if ((ifp->if_flags & IFF_UP) == 0) { - ifp->if_flags |= IFF_UP; - ifp->if_init(ifp->if_softc); - } - arp_ifinit(ifp, ifa); - break; -#endif -#ifdef IPX - /* - * XXX - This code is probably wrong, - * but has been copied many times. - */ - case AF_IPX: { - struct ipx_addr *ina = &(IA_SIPX(ifa)->sipx_addr); - - if (ipx_nullhost(*ina)) - ina->x_host = *(union ipx_host *) - IFP2ENADDR(ifp); - else - bcopy((void *) ina->x_host.c_host, - (void *) IFP2ENADDR(ifp), - ETHER_ADDR_LEN); - /* fall thru... */ - } -#endif - default: - if ((ifp->if_flags & IFF_UP) == 0) { - ifp->if_flags |= IFF_UP; - ifp->if_init(ifp->if_softc); - } - break; - } - break; default: error = ether_ioctl(ifp, cmd, data); break; diff --git a/sys/netatalk/at_control.c b/sys/netatalk/at_control.c index e275cbaa3ee1..e50da1f157ad 100644 --- a/sys/netatalk/at_control.c +++ b/sys/netatalk/at_control.c @@ -1,4 +1,4 @@ -/* $NetBSD: at_control.c,v 1.26 2008/04/30 00:25:17 ad Exp $ */ +/* $NetBSD: at_control.c,v 1.27 2008/11/07 00:20:18 dyoung Exp $ */ /* * Copyright (c) 1990,1994 Regents of The University of Michigan. @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: at_control.c,v 1.26 2008/04/30 00:25:17 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: at_control.c,v 1.27 2008/11/07 00:20:18 dyoung Exp $"); #include #include @@ -318,9 +318,7 @@ at_control(cmd, data, ifp, l) break; default: - if (ifp == 0 || ifp->if_ioctl == 0) - return (EOPNOTSUPP); - return ((*ifp->if_ioctl) (ifp, cmd, data)); + return ENOTTY; } return (0); } @@ -586,8 +584,7 @@ at_ifinit(ifp, aa, sat) * Now that we have selected an address, we need to tell the * interface about it, just in case it needs to adjust something. */ - if (ifp->if_ioctl && - (error = (*ifp->if_ioctl) (ifp, SIOCSIFADDR, (void *) aa))) { + if ((error = (*ifp->if_ioctl)(ifp, SIOCINITIFADDR, aa)) != 0) { /* * of course this could mean that it objects violently * so if it does, we back out again.. diff --git a/sys/netinet/if_arp.c b/sys/netinet/if_arp.c index 1647fc330035..93ac4c7ad495 100644 --- a/sys/netinet/if_arp.c +++ b/sys/netinet/if_arp.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_arp.c,v 1.143 2008/10/24 17:07:33 dyoung Exp $ */ +/* $NetBSD: if_arp.c,v 1.144 2008/11/07 00:20:18 dyoung Exp $ */ /*- * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.143 2008/10/24 17:07:33 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.144 2008/11/07 00:20:18 dyoung Exp $"); #include "opt_ddb.h" #include "opt_inet.h" @@ -478,6 +478,19 @@ arp_rtrequest(int req, struct rtentry *rt, const struct rt_addrinfo *info) callout_reset(&arptimer_ch, hz, arptimer, NULL); } + if (req == RTM_LLINFO_UPD) { + struct in_addr *in; + + if ((ifa = info->rti_ifa) == NULL) + return; + + in = &ifatoia(ifa)->ia_addr.sin_addr; + + arprequest(ifa->ifa_ifp, in, in, + CLLADDR(ifa->ifa_ifp->if_sadl)); + return; + } + if ((rt->rt_flags & RTF_GATEWAY) != 0) { if (req != RTM_ADD) return; diff --git a/sys/netinet/in.c b/sys/netinet/in.c index 57e022542fd2..ef8d9c19081c 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -1,4 +1,4 @@ -/* $NetBSD: in.c,v 1.127 2008/09/25 15:48:57 pooka Exp $ */ +/* $NetBSD: in.c,v 1.128 2008/11/07 00:20:18 dyoung Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -91,7 +91,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.127 2008/09/25 15:48:57 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.128 2008/11/07 00:20:18 dyoung Exp $"); #include "opt_inet.h" #include "opt_inet_conf.h" @@ -466,9 +466,7 @@ in_control(struct socket *so, u_long cmd, void *data, struct ifnet *ifp, return (EINVAL); oldaddr = ia->ia_dstaddr; ia->ia_dstaddr = *satocsin(ifreq_getdstaddr(cmd, ifr)); - if (ifp->if_ioctl != NULL && - (error = (*ifp->if_ioctl)(ifp, SIOCSIFDSTADDR, - (void *)ia)) != 0) { + if ((error = (*ifp->if_ioctl)(ifp, SIOCSIFDSTADDR, ia)) != 0) { ia->ia_dstaddr = oldaddr; return error; } @@ -569,11 +567,7 @@ in_control(struct socket *so, u_long cmd, void *data, struct ifnet *ifp, #endif /* MROUTING */ default: - if (ifp == NULL || ifp->if_ioctl == NULL) - return EOPNOTSUPP; - error = (*ifp->if_ioctl)(ifp, cmd, data); - in_setmaxmtu(); - break; + return ENOTTY; } if (error != 0 && newifaddr) { @@ -891,8 +885,7 @@ in_ifinit(struct ifnet *ifp, struct in_ifaddr *ia, * if this is its first address, * and to validate the address if necessary. */ - if (ifp->if_ioctl && - (error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, (void *)ia))) + if ((error = (*ifp->if_ioctl)(ifp, SIOCINITIFADDR, ia)) != 0) goto bad; splx(s); if (scrub) { @@ -1152,8 +1145,7 @@ in_addmulti(struct in_addr *ap, struct ifnet *ifp) */ sockaddr_in_init(&sin, ap, 0); ifreq_setaddr(SIOCADDMULTI, &ifr, sintosa(&sin)); - if ((ifp->if_ioctl == NULL) || - (*ifp->if_ioctl)(ifp, SIOCADDMULTI,(void *)&ifr) != 0) { + if ((*ifp->if_ioctl)(ifp, SIOCADDMULTI, &ifr) != 0) { LIST_REMOVE(inm, inm_list); pool_put(&inmulti_pool, inm); splx(s); @@ -1201,8 +1193,7 @@ in_delmulti(struct in_multi *inm) */ sockaddr_in_init(&sin, &inm->inm_addr, 0); ifreq_setaddr(SIOCDELMULTI, &ifr, sintosa(&sin)); - (*inm->inm_ifp->if_ioctl)(inm->inm_ifp, SIOCDELMULTI, - (void *)&ifr); + (*inm->inm_ifp->if_ioctl)(inm->inm_ifp, SIOCDELMULTI, &ifr); pool_put(&inmulti_pool, inm); } splx(s); diff --git a/sys/netinet/in_gif.c b/sys/netinet/in_gif.c index 7ad8bd19758b..0d09b3d590ab 100644 --- a/sys/netinet/in_gif.c +++ b/sys/netinet/in_gif.c @@ -1,4 +1,4 @@ -/* $NetBSD: in_gif.c,v 1.59 2008/04/12 05:58:22 thorpej Exp $ */ +/* $NetBSD: in_gif.c,v 1.60 2008/11/07 00:20:18 dyoung Exp $ */ /* $KAME: in_gif.c,v 1.66 2001/07/29 04:46:09 itojun Exp $ */ /* @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: in_gif.c,v 1.59 2008/04/12 05:58:22 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in_gif.c,v 1.60 2008/11/07 00:20:18 dyoung Exp $"); #include "opt_inet.h" #include "opt_iso.h" @@ -91,7 +91,7 @@ int in_gif_output(struct ifnet *ifp, int family, struct mbuf *m) { struct rtentry *rt; - struct gif_softc *sc = (struct gif_softc*)ifp; + struct gif_softc *sc = ifp->if_softc; struct sockaddr_in *sin_src = (struct sockaddr_in *)sc->gif_psrc; struct sockaddr_in *sin_dst = (struct sockaddr_in *)sc->gif_pdst; struct ip iphdr; /* capsule IP header, host byte ordered */ @@ -156,7 +156,7 @@ in_gif_output(struct ifnet *ifp, int family, struct mbuf *m) return EAFNOSUPPORT; } - bzero(&iphdr, sizeof(iphdr)); + memset(&iphdr, 0, sizeof(iphdr)); iphdr.ip_src = sin_src->sin_addr; /* bidirectional configured tunnel mode */ if (sin_dst->sin_addr.s_addr != INADDR_ANY) @@ -225,7 +225,7 @@ in_gif_input(struct mbuf *m, ...) return; } #ifndef GIF_ENCAPCHECK - if (!gif_validate4(ip, (struct gif_softc *)gifp, m->m_pkthdr.rcvif)) { + if (!gif_validate4(ip, gifp->if_softc, m->m_pkthdr.rcvif)) { m_freem(m); ip_statinc(IP_STAT_NOGIF); return; @@ -322,21 +322,21 @@ gif_validate4(const struct ip *ip, struct gif_softc *sc, struct ifnet *ifp) /* ingress filters on outer source */ if ((sc->gif_if.if_flags & IFF_LINK2) == 0 && ifp) { - struct sockaddr_in sin; + union { + struct sockaddr sa; + struct sockaddr_in sin; + } u; struct rtentry *rt; - bzero(&sin, sizeof(sin)); - sin.sin_family = AF_INET; - sin.sin_len = sizeof(struct sockaddr_in); - sin.sin_addr = ip->ip_src; - rt = rtalloc1((struct sockaddr *)&sin, 0); - if (!rt || rt->rt_ifp != ifp) { + sockaddr_in_init(&u.sin, &ip->ip_src, 0); + rt = rtalloc1(&u.sa, 0); + if (rt == NULL || rt->rt_ifp != ifp) { #if 0 log(LOG_WARNING, "%s: packet from 0x%x dropped " "due to ingress filter\n", if_name(&sc->gif_if), - (u_int32_t)ntohl(sin.sin_addr.s_addr)); + (u_int32_t)ntohl(u.sin.sin_addr.s_addr)); #endif - if (rt) + if (rt != NULL) rtfree(rt); return 0; } @@ -359,9 +359,9 @@ gif_encapcheck4(struct mbuf *m, int off, int proto, void *arg) struct ifnet *ifp; /* sanity check done in caller */ - sc = (struct gif_softc *)arg; + sc = arg; - m_copydata(m, 0, sizeof(ip), (void *)&ip); + m_copydata(m, 0, sizeof(ip), &ip); ifp = ((m->m_flags & M_PKTHDR) != 0) ? m->m_pkthdr.rcvif : NULL; return gif_validate4(&ip, sc, ifp); @@ -374,7 +374,7 @@ in_gif_attach(struct gif_softc *sc) #ifndef GIF_ENCAPCHECK struct sockaddr_in mask4; - bzero(&mask4, sizeof(mask4)); + memset(&mask4, 0, sizeof(mask4)); mask4.sin_len = sizeof(struct sockaddr_in); mask4.sin_addr.s_addr = ~0; diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index d214ed20602e..84b258b8ce4c 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -1,4 +1,4 @@ -/* $NetBSD: ip_carp.c,v 1.26 2008/05/04 07:22:14 thorpej Exp $ */ +/* $NetBSD: ip_carp.c,v 1.27 2008/11/07 00:20:18 dyoung Exp $ */ /* $OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $ */ /* @@ -28,7 +28,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.26 2008/05/04 07:22:14 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.27 2008/11/07 00:20:18 dyoung Exp $"); /* * TODO: @@ -1610,7 +1610,7 @@ carp_set_enaddr(struct carp_softc *sc) enaddr[4] = 1; enaddr[5] = sc->sc_vhid; } - if_set_sadl(&sc->sc_if, enaddr, sizeof(enaddr)); + if_set_sadl(&sc->sc_if, enaddr, sizeof(enaddr), false); } void @@ -1861,7 +1861,7 @@ carp_join_multicast6(struct carp_softc *sc) #endif /* INET6 */ int -carp_ioctl(struct ifnet *ifp, u_long cmd, void *addr) +carp_ioctl(struct ifnet *ifp, u_long cmd, void *data) { struct lwp *l = curlwp; /* XXX */ struct carp_softc *sc = ifp->if_softc, *vr; @@ -1871,11 +1871,11 @@ carp_ioctl(struct ifnet *ifp, u_long cmd, void *addr) struct ifnet *cdev = NULL; int error = 0; - ifa = (struct ifaddr *)addr; - ifr = (struct ifreq *)addr; + ifa = (struct ifaddr *)data; + ifr = (struct ifreq *)data; switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: switch (ifa->ifa_addr->sa_family) { #ifdef INET case AF_INET: @@ -1898,6 +1898,8 @@ carp_ioctl(struct ifnet *ifp, u_long cmd, void *addr) break; case SIOCSIFFLAGS: + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; if (sc->sc_state != INIT && !(ifr->ifr_flags & IFF_UP)) { callout_stop(&sc->sc_ad_tmo); callout_stop(&sc->sc_md_tmo); @@ -2016,7 +2018,7 @@ carp_ioctl(struct ifnet *ifp, u_long cmd, void *addr) break; default: - error = EINVAL; + error = ether_ioctl(ifp, cmd, data); } carp_hmac_prepare(sc); @@ -2147,7 +2149,7 @@ carp_ether_addmulti(struct carp_softc *sc, struct ifreq *ifr) memcpy(&mc->mc_addr, sa, sa->sa_len); LIST_INSERT_HEAD(&sc->carp_mc_listhead, mc, mc_entries); - error = (*ifp->if_ioctl)(ifp, SIOCADDMULTI, (void *)ifr); + error = (*ifp->if_ioctl)(ifp, SIOCADDMULTI, ifr); if (error != 0) goto ioctl_failed; @@ -2199,7 +2201,7 @@ carp_ether_delmulti(struct carp_softc *sc, struct ifreq *ifr) return (error); /* We no longer use this multicast address. Tell parent so. */ - error = (*ifp->if_ioctl)(ifp, SIOCDELMULTI, (void *)ifr); + error = (*ifp->if_ioctl)(ifp, SIOCDELMULTI, ifr); if (error == 0) { /* And forget about this address. */ LIST_REMOVE(mc, mc_entries); @@ -2233,7 +2235,7 @@ carp_ether_purgemulti(struct carp_softc *sc) memcpy(ifr->ifr_name, ifp->if_xname, IFNAMSIZ); while ((mc = LIST_FIRST(&sc->carp_mc_listhead)) != NULL) { memcpy(&ifr->ifr_addr, &mc->mc_addr, mc->mc_addr.ss_len); - (void)(*ifp->if_ioctl)(ifp, SIOCDELMULTI, (void *)ifr); + (void)(*ifp->if_ioctl)(ifp, SIOCDELMULTI, ifr); LIST_REMOVE(mc, mc_entries); FREE(mc, M_DEVBUF); } diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index 5b61701da4fa..5af771f85f2b 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -1,4 +1,4 @@ -/* $NetBSD: in6.c,v 1.141 2008/07/31 18:24:07 matt Exp $ */ +/* $NetBSD: in6.c,v 1.142 2008/11/07 00:20:18 dyoung Exp $ */ /* $KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $ */ /* @@ -62,7 +62,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.141 2008/07/31 18:24:07 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.142 2008/11/07 00:20:18 dyoung Exp $"); #include "opt_inet.h" #include "opt_pfil_hooks.h" @@ -736,10 +736,7 @@ in6_control1(struct socket *so, u_long cmd, void *data, struct ifnet *ifp, } default: - if (ifp == NULL || ifp->if_ioctl == 0) - return EOPNOTSUPP; - error = ((*ifp->if_ioctl)(ifp, cmd, data)); - return error; + return ENOTTY; } return 0; @@ -1705,8 +1702,8 @@ in6_ifinit(struct ifnet *ifp, struct in6_ifaddr *ia, ia->ia_addr = *sin6; - if (ifacount <= 1 && ifp->if_ioctl && - (error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, (void *)ia))) { + if (ifacount <= 1 && + (error = (*ifp->if_ioctl)(ifp, SIOCINITIFADDR, ia)) != 0) { splx(s); return error; } diff --git a/sys/netinet6/in6_gif.c b/sys/netinet6/in6_gif.c index 9fc55040ecc6..d141410e8f22 100644 --- a/sys/netinet6/in6_gif.c +++ b/sys/netinet6/in6_gif.c @@ -1,4 +1,4 @@ -/* $NetBSD: in6_gif.c,v 1.56 2008/04/24 11:38:38 ad Exp $ */ +/* $NetBSD: in6_gif.c,v 1.57 2008/11/07 00:20:18 dyoung Exp $ */ /* $KAME: in6_gif.c,v 1.62 2001/07/29 04:27:25 itojun Exp $ */ /* @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: in6_gif.c,v 1.56 2008/04/24 11:38:38 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in6_gif.c,v 1.57 2008/11/07 00:20:18 dyoung Exp $"); #include "opt_inet.h" #include "opt_iso.h" @@ -88,7 +88,7 @@ int in6_gif_output(struct ifnet *ifp, int family, struct mbuf *m) { struct rtentry *rt; - struct gif_softc *sc = (struct gif_softc*)ifp; + struct gif_softc *sc = ifp->if_softc; struct sockaddr_in6 *sin6_src = (struct sockaddr_in6 *)sc->gif_psrc; struct sockaddr_in6 *sin6_dst = (struct sockaddr_in6 *)sc->gif_pdst; struct ip6_hdr *ip6; @@ -201,17 +201,16 @@ in6_gif_output(struct ifnet *ifp, int family, struct mbuf *m) * it is too painful to ask for resend of inner packet, to achieve * path MTU discovery for encapsulated packets. */ - error = ip6_output(m, 0, &sc->gif_ro, IPV6_MINMTU, - (struct ip6_moptions *)NULL, (struct socket *)NULL, NULL); + error = ip6_output(m, 0, &sc->gif_ro, IPV6_MINMTU, NULL, NULL, NULL); #else - error = ip6_output(m, 0, &sc->gif_ro, 0, - (struct ip6_moptions *)NULL, (struct socket *)NULL, NULL); + error = ip6_output(m, 0, &sc->gif_ro, 0, NULL, NULL, NULL); #endif return (error); } -int in6_gif_input(struct mbuf **mp, int *offp, int proto) +int +in6_gif_input(struct mbuf **mp, int *offp, int proto) { struct mbuf *m = *mp; struct ifnet *gifp = NULL; @@ -229,7 +228,7 @@ int in6_gif_input(struct mbuf **mp, int *offp, int proto) return IPPROTO_DONE; } #ifndef GIF_ENCAPCHECK - if (!gif_validate6(ip6, (struct gif_softc *)gifp, m->m_pkthdr.rcvif)) { + if (!gif_validate6(ip6, gifp->if_softc, m->m_pkthdr.rcvif)) { m_freem(m); IP6_STATINC(IP6_STAT_NOGIF); return IPPROTO_DONE; @@ -314,22 +313,22 @@ gif_validate6(const struct ip6_hdr *ip6, struct gif_softc *sc, /* ingress filters on outer source */ if ((sc->gif_if.if_flags & IFF_LINK2) == 0 && ifp) { - struct sockaddr_in6 sin6; + union { + struct sockaddr sa; + struct sockaddr_in6 sin6; + } u; struct rtentry *rt; - memset(&sin6, 0, sizeof(sin6)); - sin6.sin6_family = AF_INET6; - sin6.sin6_len = sizeof(struct sockaddr_in6); - sin6.sin6_addr = ip6->ip6_src; /* XXX scopeid */ - rt = rtalloc1((struct sockaddr *)&sin6, 0); - if (!rt || rt->rt_ifp != ifp) { + sockaddr_in6_init(&u.sin6, &ip6->ip6_src, 0, 0, 0); + rt = rtalloc1(&u.sa, 0); + if (rt == NULL || rt->rt_ifp != ifp) { #if 0 log(LOG_WARNING, "%s: packet from %s dropped " "due to ingress filter\n", if_name(&sc->gif_if), - ip6_sprintf(&sin6.sin6_addr)); + ip6_sprintf(&u.sin6.sin6_addr)); #endif - if (rt) + if (rt != NULL) rtfree(rt); return 0; } @@ -352,7 +351,7 @@ gif_encapcheck6(struct mbuf *m, int off, int proto, void *arg) struct ifnet *ifp; /* sanity check done in caller */ - sc = (struct gif_softc *)arg; + sc = arg; m_copydata(m, 0, sizeof(ip6), (void *)&ip6); ifp = ((m->m_flags & M_PKTHDR) != 0) ? m->m_pkthdr.rcvif : NULL; @@ -367,7 +366,7 @@ in6_gif_attach(struct gif_softc *sc) #ifndef GIF_ENCAPCHECK struct sockaddr_in6 mask6; - bzero(&mask6, sizeof(mask6)); + memset(&mask6, 0, sizeof(mask6)); mask6.sin6_len = sizeof(struct sockaddr_in6); mask6.sin6_addr.s6_addr32[0] = mask6.sin6_addr.s6_addr32[1] = mask6.sin6_addr.s6_addr32[2] = mask6.sin6_addr.s6_addr32[3] = ~0; diff --git a/sys/netinet6/in6_ifattach.c b/sys/netinet6/in6_ifattach.c index 779879e088cb..995646afcd78 100644 --- a/sys/netinet6/in6_ifattach.c +++ b/sys/netinet6/in6_ifattach.c @@ -1,4 +1,4 @@ -/* $NetBSD: in6_ifattach.c,v 1.80 2008/04/24 11:38:38 ad Exp $ */ +/* $NetBSD: in6_ifattach.c,v 1.81 2008/11/07 00:20:18 dyoung Exp $ */ /* $KAME: in6_ifattach.c,v 1.124 2001/07/18 08:32:51 jinmei Exp $ */ /* @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: in6_ifattach.c,v 1.80 2008/04/24 11:38:38 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in6_ifattach.c,v 1.81 2008/11/07 00:20:18 dyoung Exp $"); #include #include @@ -315,9 +315,9 @@ generate_tmp_ifid(u_int8_t *seed0, const u_int8_t *seed1, u_int8_t *ret) return 0; } + /* * Get interface identifier for the specified interface. - * XXX assumes single sockaddr_dl (AF_LINK address) per an interfacea * * in6 - upper 64bits are preserved */ @@ -325,7 +325,7 @@ int in6_get_hw_ifid(struct ifnet *ifp, struct in6_addr *in6) { struct ifaddr *ifa; - const struct sockaddr_dl *sdl; + const struct sockaddr_dl *sdl = NULL, *tsdl; const char *addr; size_t addrlen; static u_int8_t allzero[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -335,18 +335,18 @@ in6_get_hw_ifid(struct ifnet *ifp, struct in6_addr *in6) IFADDR_FOREACH(ifa, ifp) { if (ifa->ifa_addr->sa_family != AF_LINK) continue; - sdl = satocsdl(ifa->ifa_addr); - if (sdl == NULL) + tsdl = satocsdl(ifa->ifa_addr); + if (tsdl == NULL || tsdl->sdl_alen == 0) continue; - if (sdl->sdl_alen == 0) - continue; - - goto found; + if (sdl == NULL || ifa == ifp->if_dl || ifa == ifp->if_hwdl) + sdl = tsdl; + if (ifa == ifp->if_hwdl) + break; } - return -1; + if (sdl == NULL) + return -1; -found: addr = CLLADDR(sdl); addrlen = sdl->sdl_alen; diff --git a/sys/netinet6/mld6.c b/sys/netinet6/mld6.c index 57a2a9a8cd4a..733cab7f6846 100644 --- a/sys/netinet6/mld6.c +++ b/sys/netinet6/mld6.c @@ -1,4 +1,4 @@ -/* $NetBSD: mld6.c,v 1.47 2008/08/22 17:11:39 adrianp Exp $ */ +/* $NetBSD: mld6.c,v 1.48 2008/11/07 00:20:18 dyoung Exp $ */ /* $KAME: mld6.c,v 1.25 2001/01/16 14:14:18 itojun Exp $ */ /* @@ -102,7 +102,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: mld6.c,v 1.47 2008/08/22 17:11:39 adrianp Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mld6.c,v 1.48 2008/11/07 00:20:18 dyoung Exp $"); #include "opt_inet.h" @@ -665,10 +665,7 @@ in6_addmulti(struct in6_addr *maddr6, struct ifnet *ifp, * filter appropriately for the new address. */ sockaddr_in6_init(&ifr.ifr_addr, maddr6, 0, 0, 0); - if (ifp->if_ioctl == NULL) - *errorp = ENXIO; /* XXX: appropriate? */ - else - *errorp = (*ifp->if_ioctl)(ifp, SIOCADDMULTI, &ifr); + *errorp = (*ifp->if_ioctl)(ifp, SIOCADDMULTI, &ifr); if (*errorp) { LIST_REMOVE(in6m, in6m_entry); free(in6m, M_IPMADDR); diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index 8db6804e8895..ca8c974f71dd 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -1,4 +1,4 @@ -/* $NetBSD: nd6.c,v 1.130 2008/10/24 17:07:33 dyoung Exp $ */ +/* $NetBSD: nd6.c,v 1.131 2008/11/07 00:20:18 dyoung Exp $ */ /* $KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $ */ /* @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.130 2008/10/24 17:07:33 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.131 2008/11/07 00:20:18 dyoung Exp $"); #include "opt_ipsec.h" @@ -1126,6 +1126,35 @@ nd6_rtrequest(int req, struct rtentry *rt, const struct rt_addrinfo *info) RT_DPRINTF("rt->_rt_key = %p\n", (void *)rt->_rt_key); + if (req == RTM_LLINFO_UPD) { + int rc; + struct in6_addr *in6; + struct in6_addr in6_all; + int anycast; + + if ((ifa = info->rti_ifa) == NULL) + return; + + in6 = &ifatoia6(ifa)->ia_addr.sin6_addr; + anycast = ifatoia6(ifa)->ia6_flags & IN6_IFF_ANYCAST; + + in6_all = in6addr_linklocal_allnodes; + if ((rc = in6_setscope(&in6_all, ifa->ifa_ifp, NULL)) != 0) { + log(LOG_ERR, "%s: failed to set scope %s " + "(errno=%d)\n", __func__, if_name(ifp), rc); + return; + } + + /* XXX don't set Override for proxy addresses */ + nd6_na_output(ifa->ifa_ifp, &in6_all, in6, + (anycast ? 0 : ND_NA_FLAG_OVERRIDE) +#if 0 + | (ip6_forwarding ? ND_NA_FLAG_ROUTER : 0) +#endif + , 1, NULL); + return; + } + if ((rt->rt_flags & RTF_GATEWAY) != 0) return; diff --git a/sys/netisdn/i4b_ipr.c b/sys/netisdn/i4b_ipr.c index a22e73529435..d6a6b22048d0 100644 --- a/sys/netisdn/i4b_ipr.c +++ b/sys/netisdn/i4b_ipr.c @@ -27,7 +27,7 @@ * i4b_ipr.c - isdn4bsd IP over raw HDLC ISDN network driver * --------------------------------------------------------- * - * $Id: i4b_ipr.c,v 1.29 2008/02/07 01:22:03 dyoung Exp $ + * $Id: i4b_ipr.c,v 1.30 2008/11/07 00:20:18 dyoung Exp $ * * $FreeBSD$ * @@ -59,7 +59,7 @@ *---------------------------------------------------------------------------*/ #include -__KERNEL_RCSID(0, "$NetBSD: i4b_ipr.c,v 1.29 2008/02/07 01:22:03 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: i4b_ipr.c,v 1.30 2008/11/07 00:20:18 dyoung Exp $"); #include "irip.h" #include "opt_irip.h" @@ -560,19 +560,10 @@ iripoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, /*---------------------------------------------------------------------------* * process ioctl *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ -static int -iripioctl(struct ifnet *ifp, IOCTL_CMD_T cmd, void *data) -#else static int iripioctl(struct ifnet *ifp, u_long cmd, void *data) -#endif { -#if defined(__FreeBSD__) || defined(__bsdi__) - struct ipr_softc *sc = &ipr_softc[ifp->if_unit]; -#else struct ipr_softc *sc = ifp->if_softc; -#endif struct ifreq *ifr = (struct ifreq *)data; struct ifaddr *ifa = (struct ifaddr *)data; @@ -584,7 +575,7 @@ iripioctl(struct ifnet *ifp, u_long cmd, void *data) switch (cmd) { case SIOCAIFADDR: /* add interface address */ - case SIOCSIFADDR: /* set interface address */ + case SIOCINITIFADDR: /* set interface address */ case SIOCSIFDSTADDR: /* set interface destination address */ if(ifa->ifa_addr->sa_family != AF_INET) error = EAFNOSUPPORT; @@ -593,10 +584,10 @@ iripioctl(struct ifnet *ifp, u_long cmd, void *data) break; case SIOCSIFFLAGS: /* set interface flags */ - if(!(ifr->ifr_flags & IFF_UP)) - { - if(sc->sc_if.if_flags & IFF_RUNNING) - { + if ((error = ifioctl_common(ifp, cmd, data)) != 0) + break; + if ((ifr->ifr_flags & IFF_UP) == 0) { + if (sc->sc_if.if_flags & IFF_RUNNING) { /* disconnect ISDN line */ i4b_l4_drvrdisc(sc->sc_cdp->cdid); sc->sc_if.if_flags &= ~IFF_RUNNING; @@ -610,9 +601,7 @@ iripioctl(struct ifnet *ifp, u_long cmd, void *data) } if(ifr->ifr_flags & IFF_DEBUG) - { - /* enable debug messages */ - } + ; /* enable debug messages */ break; @@ -636,18 +625,12 @@ iripioctl(struct ifnet *ifp, u_long cmd, void *data) #ifdef IPR_VJ case IPRIOCSMAXCID: { -#if defined(__FreeBSD_version) && __FreeBSD_version >= 400005 - struct proc *p = curproc; /* XXX */ - - if((error = suser(p)) != 0) -#else struct lwp *l = curlwp; /* XXX */ if((error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_INTERFACE, KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, ifp, (void *)cmd, NULL)) != 0) -#endif break; sl_compress_setup(sc->sc_compr, *(int *)data); } @@ -655,7 +638,9 @@ iripioctl(struct ifnet *ifp, u_long cmd, void *data) #endif #endif default: - error = EINVAL; + error = ifioctl_common(ifp, cmd, data); + if (error == ENETRESET) + error = 0; break; } diff --git a/sys/netiso/if_eon.c b/sys/netiso/if_eon.c index 81a4bcd16198..3bf2b5306768 100644 --- a/sys/netiso/if_eon.c +++ b/sys/netiso/if_eon.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_eon.c,v 1.68 2008/10/24 17:07:33 dyoung Exp $ */ +/* $NetBSD: if_eon.c,v 1.69 2008/11/07 00:20:18 dyoung Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -67,7 +67,7 @@ SOFTWARE. */ #include -__KERNEL_RCSID(0, "$NetBSD: if_eon.c,v 1.68 2008/10/24 17:07:33 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_eon.c,v 1.69 2008/11/07 00:20:18 dyoung Exp $"); #include "opt_eon.h" @@ -154,7 +154,7 @@ eonattach(void) ifp->if_flags = IFF_BROADCAST; if_attach(ifp); if_alloc_sadl(ifp); - eonioctl(ifp, SIOCSIFADDR, ifp->if_dl); + eonioctl(ifp, SIOCINITIFADDR, ifp->if_dl); eon_llinfo.el_qhdr.link = eon_llinfo.el_qhdr.rlink = &(eon_llinfo.el_qhdr); @@ -190,7 +190,7 @@ eonioctl(struct ifnet *ifp, u_long cmd, void *data) #endif switch (cmd) { - case SIOCSIFADDR: + case SIOCINITIFADDR: if (ifa == NULL) break; ifp->if_flags |= IFF_UP; @@ -198,7 +198,7 @@ eonioctl(struct ifnet *ifp, u_long cmd, void *data) ifa->ifa_rtrequest = eonrtrequest; break; default: - error = EINVAL; + error = ifioctl_common(ifp, cmd, data); break; } splx(s); diff --git a/sys/netiso/iso.c b/sys/netiso/iso.c index cec3d182ae8f..c14770a2b5c0 100644 --- a/sys/netiso/iso.c +++ b/sys/netiso/iso.c @@ -1,4 +1,4 @@ -/* $NetBSD: iso.c,v 1.50 2008/04/28 20:24:10 martin Exp $ */ +/* $NetBSD: iso.c,v 1.51 2008/11/07 00:20:18 dyoung Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -88,7 +88,7 @@ SOFTWARE. */ #include -__KERNEL_RCSID(0, "$NetBSD: iso.c,v 1.50 2008/04/28 20:24:10 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: iso.c,v 1.51 2008/11/07 00:20:18 dyoung Exp $"); #include #include @@ -587,9 +587,7 @@ iso_control(struct socket *so, u_long cmd, void *data, struct ifnet *ifp, default: if (cmdbyte(cmd) == 'a') return (snpac_ioctl(so, cmd, data, l)); - if (ifp == 0 || ifp->if_ioctl == 0) - return (EOPNOTSUPP); - return ((*ifp->if_ioctl)(ifp, cmd, data)); + return ENOTTY; } return (0); } @@ -651,8 +649,7 @@ iso_ifinit(struct ifnet *ifp, struct iso_ifaddr *ia, struct sockaddr_iso *siso, * if this is its first address, * and to validate the address if necessary. */ - if (ifp->if_ioctl && - (error = (*ifp->if_ioctl) (ifp, SIOCSIFADDR, (void *) ia))) { + if ((error = (*ifp->if_ioctl)(ifp, SIOCINITIFADDR, ia)) != 0) { splx(s); ia->ia_addr = oldaddr; return (error); @@ -665,6 +662,10 @@ iso_ifinit(struct ifnet *ifp, struct iso_ifaddr *ia, struct sockaddr_iso *siso, /* * XXX -- The following is here temporarily out of laziness in not * changing every ethernet driver's if_ioctl routine + * + * XXX extract llc_ifinit() and call from ether_ioctl(), + * XXX fddi_ioctl(). --dyoung + * */ if (ifp->if_type == IFT_ETHER || ifp->if_type == IFT_FDDI) { ia->ia_ifa.ifa_rtrequest = llc_rtrequest; diff --git a/sys/netiso/iso_snpac.c b/sys/netiso/iso_snpac.c index 4b90b254bcde..90396a0324ad 100644 --- a/sys/netiso/iso_snpac.c +++ b/sys/netiso/iso_snpac.c @@ -1,4 +1,4 @@ -/* $NetBSD: iso_snpac.c,v 1.51 2008/10/24 21:50:08 dyoung Exp $ */ +/* $NetBSD: iso_snpac.c,v 1.52 2008/11/07 00:20:18 dyoung Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -59,7 +59,7 @@ SOFTWARE. */ #include -__KERNEL_RCSID(0, "$NetBSD: iso_snpac.c,v 1.51 2008/10/24 21:50:08 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: iso_snpac.c,v 1.52 2008/11/07 00:20:18 dyoung Exp $"); #include "opt_iso.h" #ifdef ISO @@ -281,12 +281,12 @@ iso_setmcasts(struct ifnet *ifp, int req) (void)memset(&ifr, 0, sizeof(ifr)); for (cpp = addrlist; *cpp; cpp++) { (void)memcpy(ifr.ifr_addr.sa_data, *cpp, 6); - if (req == RTM_ADD && (ifp->if_ioctl == NULL || - (*ifp->if_ioctl)(ifp, SIOCADDMULTI, &ifr) != 0)) + if (req == RTM_ADD && + (*ifp->if_ioctl)(ifp, SIOCADDMULTI, &ifr) != 0) printf("iso_setmcasts: %s unable to add mcast\n", ifp->if_xname); - else if (req == RTM_DELETE && (ifp->if_ioctl == NULL || - (*ifp->if_ioctl)(ifp, SIOCDELMULTI, &ifr) != 0)) + else if (req == RTM_DELETE && + (*ifp->if_ioctl)(ifp, SIOCDELMULTI, &ifr) != 0) printf("iso_setmcasts: %s unable to delete mcast\n", ifp->if_xname); } diff --git a/sys/netnatm/natm.c b/sys/netnatm/natm.c index b3890a89fad8..aef858083d77 100644 --- a/sys/netnatm/natm.c +++ b/sys/netnatm/natm.c @@ -1,4 +1,4 @@ -/* $NetBSD: natm.c,v 1.16 2008/05/22 00:59:19 dyoung Exp $ */ +/* $NetBSD: natm.c,v 1.17 2008/11/07 00:20:18 dyoung Exp $ */ /* * @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: natm.c,v 1.16 2008/05/22 00:59:19 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: natm.c,v 1.17 2008/11/07 00:20:18 dyoung Exp $"); #include #include @@ -200,7 +200,7 @@ struct proc *p; ATM_PH_SETVCI(&api.aph, npcb->npcb_vci); api.rxhand = npcb; s2 = splnet(); - if (ifp->if_ioctl == NULL || ifp->if_ioctl(ifp, SIOCATMENA, &api) != 0) { + if (ifp->if_ioctl(ifp, SIOCATMENA, &api) != 0) { splx(s2); npcb_free(npcb, NPCB_REMOVE); error = EIO; @@ -230,8 +230,7 @@ struct proc *p; ATM_PH_SETVCI(&api.aph, npcb->npcb_vci); api.rxhand = npcb; s2 = splnet(); - if (ifp->if_ioctl != NULL) - ifp->if_ioctl(ifp, SIOCATMDIS, &api); + ifp->if_ioctl(ifp, SIOCATMDIS, &api); splx(s); npcb_free(npcb, NPCB_REMOVE);