Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Jan 2004 11:39:48 -0800 (PST)
From:      Sam Leffler <sam@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 45026 for review
Message-ID:  <200401091939.i09JdmbV047970@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=45026

Change 45026 by sam@sam_ebb on 2004/01/09 11:39:01

	Do if_init suppression for SIOCSIFADDR. Setting the higher
	level address on an 802.11 interface should not have any effect
	in the driver. But since IFF_UP is set as a side-effect of this
	ioctl we need to call the driver at least once.
	
	This change eliminates 1-N channel scans when operating in station
	or ibss/adhoc mode as each call to if_init typically causes the
	driver to initiate a scan.  The 1-N number varies depending on
	how many address families are configured for use on the interface.

Affected files ...

.. //depot/projects/netperf+sockets/sys/net80211/ieee80211_ioctl.c#5 edit

Differences ...

==== //depot/projects/netperf+sockets/sys/net80211/ieee80211_ioctl.c#5 (text+ko) ====

@@ -38,6 +38,9 @@
  * IEEE 802.11 ioctl support (FreeBSD-specific)
  */
 
+#include "opt_inet.h"
+#include "opt_ipx.h"
+
 #include <sys/endian.h>
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -50,6 +53,16 @@
 #include <net/if_media.h>
 #include <net/ethernet.h>
 
+#ifdef INET
+#include <netinet/in.h>
+#include <netinet/if_ether.h>
+#endif
+
+#ifdef IPX
+#include <netipx/ipx.h>
+#include <netipx/ipx_if.h>
+#endif
+
 #include <net80211/ieee80211_var.h>
 #include <net80211/ieee80211_ioctl.h>
 
@@ -762,6 +775,7 @@
 	u_int8_t tmpkey[IEEE80211_KEYBUF_SIZE];
 	char tmpssid[IEEE80211_NWID_LEN];
 	struct ieee80211_channel *chan;
+	struct ifaddr *ifa;			/* XXX */
 
 	switch (cmd) {
 	case SIOCSIFMEDIA:
@@ -1037,6 +1051,51 @@
 		error = copyout(&ic->ic_stats, ifr->ifr_data,
 				sizeof (ic->ic_stats));
 		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);
+			struct arpcom *ac = (struct arpcom *)ifp;
+
+			if (ipx_nullhost(*ina))
+				ina->x_host = *(union ipx_host *) ac->ac_enaddr;
+			else
+				bcopy((caddr_t) ina->x_host.c_host,
+				      (caddr_t) ac->ac_enaddr,
+				      sizeof(ac->ac_enaddr));
+			/* fall thru... */
+		}
+#endif
+		default:
+			if ((ifp->if_flags & IFF_UP) == 0) {
+				ifp->if_flags |= IFF_UP;
+				ifp->if_init(ifp->if_softc);
+			}
+			break;
+		}
+		break;
 	case SIOCSIFMTU:
 		ifr = (struct ifreq *)data;
 		if (ifr->ifr_mtu > IEEE80211_MTU)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200401091939.i09JdmbV047970>