diff options
| author | dyoung <dyoung@NetBSD.org> | 2008-11-07 00:20:01 +0000 |
|---|---|---|
| committer | dyoung <dyoung@NetBSD.org> | 2008-11-07 00:20:01 +0000 |
| commit | de87fe677d8a6a5550686a03f180df394da699dc (patch) | |
| tree | 5e781f3364b7131f35f9647c107b6bc403752ba2 /sys/dev/ic | |
| parent | f455f7ee91e885925403e221d2f303a56ef60395 (diff) | |
*** Summary ***
When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.
Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)
Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.
Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.
Return consistent, appropriate error codes from network drivers.
Improve readability. KNF.
*** Details ***
In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.
In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.
Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.
In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.
Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:
switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}
Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,
switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}
unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).
In ipw(4), remove an if_set_sadl() call that is out of place.
In nfe(4), reuse the jumbo MTU logic in ether_ioctl().
Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.
Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.
Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.
Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.
In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.
Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.
In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.
Let ifioctl_common() handle SIOCGIFADDR.
Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.
In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.
bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
Diffstat (limited to 'sys/dev/ic')
| -rw-r--r-- | sys/dev/ic/an.c | 6 | ||||
| -rw-r--r-- | sys/dev/ic/ath.c | 6 | ||||
| -rw-r--r-- | sys/dev/ic/atw.c | 6 | ||||
| -rw-r--r-- | sys/dev/ic/awi.c | 6 | ||||
| -rw-r--r-- | sys/dev/ic/dp8390.c | 13 | ||||
| -rw-r--r-- | sys/dev/ic/elinkxl.c | 37 | ||||
| -rw-r--r-- | sys/dev/ic/gem.c | 45 | ||||
| -rw-r--r-- | sys/dev/ic/hd64570.c | 18 | ||||
| -rw-r--r-- | sys/dev/ic/hme.c | 33 | ||||
| -rw-r--r-- | sys/dev/ic/i82586.c | 11 | ||||
| -rw-r--r-- | sys/dev/ic/lance.c | 32 | ||||
| -rw-r--r-- | sys/dev/ic/lemac.c | 10 | ||||
| -rw-r--r-- | sys/dev/ic/mb86950.c | 42 | ||||
| -rw-r--r-- | sys/dev/ic/mb86960.c | 28 | ||||
| -rw-r--r-- | sys/dev/ic/midway.c | 25 | ||||
| -rw-r--r-- | sys/dev/ic/pdq_ifsubr.c | 43 | ||||
| -rw-r--r-- | sys/dev/ic/rrunner.c | 10 | ||||
| -rw-r--r-- | sys/dev/ic/rt2560.c | 6 | ||||
| -rw-r--r-- | sys/dev/ic/rt2661.c | 6 | ||||
| -rw-r--r-- | sys/dev/ic/rtw.c | 8 | ||||
| -rw-r--r-- | sys/dev/ic/sgec.c | 25 | ||||
| -rw-r--r-- | sys/dev/ic/smc90cx6.c | 25 | ||||
| -rw-r--r-- | sys/dev/ic/smc91cxx.c | 32 | ||||
| -rw-r--r-- | sys/dev/ic/tropic.c | 50 | ||||
| -rw-r--r-- | sys/dev/ic/tulip.c | 41 | ||||
| -rw-r--r-- | sys/dev/ic/wi.c | 9 |
26 files changed, 290 insertions, 283 deletions
diff --git a/sys/dev/ic/an.c b/sys/dev/ic/an.c index 9bc8f9fc793..e5b78b5092c 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 <wpaul@ctr.columbia.edu>. All rights reserved. @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__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 c85bfc4a53c..63f30cdc348 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 ae30c5a42e3..1f55bae6353 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 <sys/cdefs.h> -__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 e0cfe0ae529..220e548f204 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 <sys/cdefs.h> #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 2b468f38cdd..034ea777ce6 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 <sys/cdefs.h> -__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 c515d60e4b2..8448e86e1da 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 <sys/cdefs.h> -__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 9682f371762..c29b5b4c0a9 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 <sys/cdefs.h> -__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 d2cff14f78c..b78b8fd7e2e 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 <sys/cdefs.h> -__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 513009435bb..d693c863078 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 <sys/cdefs.h> -__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 cab9d284a19..882c3e91663 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 <sys/cdefs.h> -__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 55e8dd8257b..ece98f58cd2 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 <sys/cdefs.h> -__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); + case SIOCGIFMEDIA: + case SIOCSIFMEDIA: + error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd); break; - case SIOCADDMULTI: - case SIOCDELMULTI: - if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) { + default: + 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. */ - if (ifp->if_flags & IFF_RUNNING) - lance_reset(sc); - error = 0; + lance_reset(sc); } break; - case SIOCGIFMEDIA: - case SIOCSIFMEDIA: - error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd); - break; - - default: - error = EINVAL; - break; } splx(s); diff --git a/sys/dev/ic/lemac.c b/sys/dev/ic/lemac.c index e79ceffe234..dd8cce73a46 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 <matt@3am-software.com> @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__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 b70b4f26539..62081069c0a 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 <sys/cdefs.h> -__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 36e3dbda67e..6e1284ebadd 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 <sys/cdefs.h> -__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 ece0ddd7bdf..15bd91356c9 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 <sys/cdefs.h> -__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 2a713b97b33..ee57a6a2c8c 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 <matt@3am-software.com> @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__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 b2f10476cd5..64da888621b 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 <sys/cdefs.h> -__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 b4546e4ec16..98ed35f74fa 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 <sys/cdefs.h> -__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 c418b30300a..6c0fad757cb 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 <sys/cdefs.h> -__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 46b549e52d5..bcad107b9c8 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 <sys/cdefs.h> -__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 afcaa429a31..91dde6b6a4a 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 <sys/cdefs.h> -__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 0b028bd86d2..f114dadf3c6 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 <sys/cdefs.h> -__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 20111bed330..dfa14a4b8e0 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 <sys/cdefs.h> -__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 ed056137874..7711758a8d2 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 <sys/cdefs.h> -__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 8de88c536d1..3b73c5f6ff6 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 <sys/cdefs.h> -__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 4df8bd8e229..e58e248c09d 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 <sys/cdefs.h> -__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; |
