PERFORCE change 44973 for review
Sam Leffler
sam at FreeBSD.org
Thu Jan 8 13:51:52 PST 2004
http://perforce.freebsd.org/chv.cgi?CH=44973
Change 44973 by sam at sam_ebb on 2004/01/08 13:51:11
Eliminate gratuitous calls to if_init when setting the interface
address. This is especially important for 802.11 devices where
the init method kicks the 802.11 state machine.
Affected files ...
.. //depot/projects/netperf+sockets/sys/net/if_ethersubr.c#3 edit
Differences ...
==== //depot/projects/netperf+sockets/sys/net/if_ethersubr.c#3 (text+ko) ====
@@ -873,12 +873,21 @@
switch (command) {
case SIOCSIFADDR:
- ifp->if_flags |= IFF_UP;
-
+ /*
+ * NB: don't reset the interface unless it's
+ * being marked up for the first time. Calling
+ * the init method unncessarily can cause some
+ * devices to do lots of work (e.g. 802.11 where
+ * the station may reassociate).
+ */
switch (ifa->ifa_addr->sa_family) {
#ifdef INET
case AF_INET:
- ifp->if_init(ifp->if_softc); /* before arpwhohas */
+ if ((ifp->if_flags & IFF_UP) == 0) {
+ /* bring the interface up before arpwhohas */
+ ifp->if_flags |= IFF_UP;
+ ifp->if_init(ifp->if_softc);
+ }
arp_ifinit(ifp, ifa);
break;
#endif
@@ -886,8 +895,7 @@
/*
* XXX - This code is probably wrong
*/
- case AF_IPX:
- {
+ case AF_IPX: {
struct ipx_addr *ina = &(IA_SIPX(ifa)->sipx_addr);
struct arpcom *ac = IFP2AC(ifp);
@@ -900,16 +908,14 @@
(caddr_t) ac->ac_enaddr,
sizeof(ac->ac_enaddr));
}
-
- /*
- * Set new address
- */
- ifp->if_init(ifp->if_softc);
- break;
- }
+ /* fall thru... */
+ }
#endif
default:
- ifp->if_init(ifp->if_softc);
+ if ((ifp->if_flags & IFF_UP) == 0) {
+ ifp->if_flags |= IFF_UP;
+ ifp->if_init(ifp->if_softc);
+ }
break;
}
break;
More information about the p4-projects
mailing list