[PATCH] nl80211: Send RTM_SETLINK to the correct interface for extra BSSs

Rafał Miłecki zajec5 at gmail.com
Wed Jul 23 04:48:02 PDT 2025


From: Rafał Miłecki <rafal at milecki.pl>

Modify wpa_driver_nl80211_set_operstate() to use BSS's ifindex instead
of the main one. This results in calling RTM_SETLINK for interface that
is actually used for a given BSS. It helps kernel to maintain proper
"operstate" values.

I noticed this "operstate" issue when working with wireless driver that
doesn't happen to call netif helpers (like netif_carrier_on()). In such
cases kernel doesn't update "operstate" properly on its own and hostapd
can be helpful there.

Before:
$ grep . /sys/class/net/wlan*/operstate
/sys/class/net/wlan0-1/operstate:unknown
/sys/class/net/wlan0/operstate:up
/sys/class/net/wlan1-1/operstate:unknown
/sys/class/net/wlan1/operstate:up

After:
$ grep . /sys/class/net/wlan*/operstate
/sys/class/net/wlan0-1/operstate:up
/sys/class/net/wlan0/operstate:up
/sys/class/net/wlan1-1/operstate:up
/sys/class/net/wlan1/operstate:up

Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
---
 src/drivers/driver_nl80211.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 0cc5b4b0e..ebd93d856 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -7808,7 +7808,7 @@ static int wpa_driver_nl80211_set_operstate(void *priv, int state)
 		   bss->ifname, drv->operstate, state,
 		   state ? "UP" : "DORMANT");
 	drv->operstate = state;
-	return netlink_send_oper_ifla(drv->global->netlink, drv->ifindex, -1,
+	return netlink_send_oper_ifla(drv->global->netlink, bss->ifindex, -1,
 				      state ? IF_OPER_UP : IF_OPER_DORMANT);
 }
 
-- 
2.43.0




More information about the Hostap mailing list