From 3d976872ed4642f1a00375a063dd87fe989f2675 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Thu, 1 Aug 2002 07:37:52 +0000 Subject: [PATCH] Don't set the IFF_PROMISC bit when in hostap mode like the previous commit bogusly did. Instead, don't set PROMSIC in the hardware if we're in hostap mode. This matches more closely what openbsd did as well. --- sys/dev/wi/if_wi.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/sys/dev/wi/if_wi.c b/sys/dev/wi/if_wi.c index ae364fd5a272..ba18f2ed67b6 100644 --- a/sys/dev/wi/if_wi.c +++ b/sys/dev/wi/if_wi.c @@ -1655,19 +1655,22 @@ wi_ioctl(ifp, command, data) break; case SIOCSIFFLAGS: /* - * Can't do promisc and hostap at the same time. + * 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 + * wi_init() by just setting PROMISC in the hardware. */ - if (sc->wi_ptype == WI_PORTTYPE_AP) - ifp->if_flags &= ~IFF_PROMISC; if (ifp->if_flags & IFF_UP) { - if (ifp->if_flags & IFF_RUNNING && - ifp->if_flags & IFF_PROMISC && - !(sc->wi_if_flags & IFF_PROMISC)) { - WI_SETVAL(WI_RID_PROMISC, 1); - } else if (ifp->if_flags & IFF_RUNNING && - !(ifp->if_flags & IFF_PROMISC) && - sc->wi_if_flags & IFF_PROMISC) { - WI_SETVAL(WI_RID_PROMISC, 0); + if (sc->wi_ptype != WI_PORTTYPE_AP && + ifp->if_flags & IFF_RUNNING) { + if (ifp->if_flags & IFF_PROMISC && + !(sc->wi_if_flags & IFF_PROMISC)) { + WI_SETVAL(WI_RID_PROMISC, 1); + } else if (!(ifp->if_flags & IFF_PROMISC) && + sc->wi_if_flags & IFF_PROMISC) { + WI_SETVAL(WI_RID_PROMISC, 0); + } else { + wi_init(sc); + } } else { wi_init(sc); } @@ -2091,12 +2094,7 @@ wi_init(xsc) * and always reset promisc mode in Host-AP regime, * it shows us all the packets anyway. */ - /* - * Can't do promisc and hostap at the same time. - */ - if (sc->wi_ptype == WI_PORTTYPE_AP) - ifp->if_flags &= ~IFF_PROMISC; - if (ifp->if_flags & IFF_PROMISC) + if (sc->wi_ptype != WI_PORTTYPE_AP && ifp->if_flags & IFF_PROMISC) WI_SETVAL(WI_RID_PROMISC, 1); else WI_SETVAL(WI_RID_PROMISC, 0);