diff options
author | Paul Irofti <pirofti@cvs.openbsd.org> | 2018-04-26 12:50:08 +0000 |
---|---|---|
committer | Paul Irofti <pirofti@cvs.openbsd.org> | 2018-04-26 12:50:08 +0000 |
commit | b5e621a41798b95e9539225bae33e087fcebc12d (patch) | |
tree | f682d47a097afc9b760402d0835a6924f179f01a /sbin | |
parent | dd64a9bb6b48cd5481a54a4814304303c0100f01 (diff) |
net80211: stub SIOCS80211SCAN, make ifconfig scan instant.
The following removes the functionality of the SIOCS80211SCAN ioctl.
After long discussions with stps@, mpi@, and deraadt@ we decided that
this was the correct way of fixing ifconfig scan from blocking the
network stack.
The kernel will continue scanning in the background and filling the
nodes array, but ifconfig scan commands will now basically do just a
SIOCG80211ALLNODES and pretty print the array. So the output stays the
same but is instant.
In fact, when the interface is freshly brought up, if you type fast
enough, you can see the array being filled by running multiple ifconfig
scans in sequence.
The SIOCS80211SCAN ioctl stays for now as wi(4), pgt(4) and malo(4)
still need it around. But not for long...
Another change that this introduces is the fact that ifconfig scan no
longer plays with UP and DOWN. If the interface is down it complains and
exits. This is needed in order to maintain the nodes list.
Works on iwm(4), iwn(4), urtwn(4), run(4) and athn(4).
Tested by mpi@, landry@, florian@, thanks!
OK mpi@.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index f426e615ef9..a76a90c71fe 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.364 2018/04/26 12:23:56 schwarze Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.365 2018/04/26 12:50:07 pirofti Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -2257,11 +2257,11 @@ ieee80211_listnodes(void) struct ieee80211_nodereq_all na; struct ieee80211_nodereq nr[512]; struct ifreq ifr; - int i, down = 0; + int i; if ((flags & IFF_UP) == 0) { - down = 1; - setifflags("up", IFF_UP); + printf("\t\tcannot scan, interface is down\n"); + return; } bzero(&ifr, sizeof(ifr)); @@ -2270,7 +2270,7 @@ ieee80211_listnodes(void) if (ioctl(s, SIOCS80211SCAN, (caddr_t)&ifr) != 0) { if (errno == EPERM) printf("\t\tno permission to scan\n"); - goto done; + return; } bzero(&na, sizeof(na)); @@ -2281,7 +2281,7 @@ ieee80211_listnodes(void) if (ioctl(s, SIOCG80211ALLNODES, &na) != 0) { warn("SIOCG80211ALLNODES"); - goto done; + return; } if (!na.na_nodes) @@ -2294,10 +2294,6 @@ ieee80211_listnodes(void) ieee80211_printnode(&nr[i]); putchar('\n'); } - - done: - if (down) - setifflags("restore", -IFF_UP); } void |