[RFC PATCH] nl80211: re-add interface into bridge on interface re-creation

Dominique Martinet dominique.martinet at atmark-techno.com
Thu Dec 18 00:20:59 PST 2025


When using the nl80211 driver with a bridge, the driver properly detects
when the interface is re-created ("nl80211: Update ifindex for a removed
interface") and wpa_driver_nl80211_finish_drv_init() reinits it, but if
the interface was part of a bridge nothing adds it back there.

This adds the interface to the bridge in this function if the initial
init setup a bridge in the first place:
- the first time wpa_driver_nl80211_finish_drv_init() is called,
i802_init() has not yet setup the bridge (i802_check_bridge()), so
this flag is false and nothing changes
- when the interface is re-added the flag is only set if
i802_check_bridge() went to the end, which also ensures the bss->bridge
variable is sensible.

Signed-off-by: Dominique Martinet <dominique.martinet at atmark-techno.com>
---
Hello,

I searched the list but couldn't find any discussion about this, so
opening discussion with a patch but I'm happy to think of another way of
doing it (e.g. udev rule?) -- it just makes more sense to me to have
hostapd do this given hostapd added the interface to the bridge in the
first place.

I've tested this on our board which has a driver which allows "crashing"
the interface arbitrarily, as far as I can tell this works fine.

Anyway, thank you for hostap! Please let me konw if I can fix anything,
I went this way because it was the least intrusive but will be happy to
try another approach.

 src/drivers/driver_nl80211.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 24516637ee15..7d8c72bbf0a2 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -3366,6 +3366,15 @@ wpa_driver_nl80211_finish_drv_init(struct i802_bss *bss, const u8 *set_addr,
 	if (drv->vendor_cmd_test_avail)
 		qca_vendor_test(drv);
 
+	if (bss->added_if_into_bridge) {
+		if (linux_br_add_if(drv->global->ioctl_sock, bss->brname,
+				    bss->ifname) < 0) {
+			wpa_printf(MSG_WARNING,
+				   "nl80211: Failed to add interface %s into bridge %s: %s",
+				   bss->ifname, bss->brname, strerror(errno));
+		}
+	}
+
 	return 0;
 }
 
-- 
2.47.3





More information about the Hostap mailing list