[PATCH] nl80211: Fix bridge option for non first-bss

Jouni Malinen j at w1.fi
Mon Nov 28 01:15:48 PST 2022


On Thu, Jul 21, 2022 at 03:01:19PM +0200, Mateusz Bajorski wrote:
> Bridge interface was not added to ifidx list on non first-bss configuration.
> This commit adapts solution from first bss where
> bridge field is handled in i802_init function
> 
> Issue occured when bridge interface already exist during adding bss.
> i802_check_bridge covers only scenario when bridge interface does not exist.

I was unable to reproduce any visible problem in that type of a
scenario. wpa_driver_nl80211_if_add() did not add the bridge ifindex
with add_ifidx(), but wpa_driver_nl80211_event_rtm_newlink() did this
when processing the RTM_NEWLINK message indicating that the BSS netdev
was added to a bridge.

Is there a sequence where the RTM_NEWLINK mechanism does not address
this? That would seem to require the netdev of the second BSS to already
exist and be in the bridge, but even when trying that kind of a
sequence, I saw the RTM_NEWLINK event taking care of this when hostapd
started operating the interface.

> diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
> @@ -7998,19 +7999,28 @@ static int wpa_driver_nl80211_if_add(void *priv, enum wpa_driver_if_type type,

> +		if (bridge) {
> +			br_ifindex = if_nametoindex(bridge);
> +			if (br_ifindex)
> +				add_ifidx(drv, br_ifindex, ifidx);
> +
> +			if (i802_check_bridge(drv, new_bss, bridge, ifname) < 0) {
> +				wpa_printf(MSG_ERROR, "nl80211: Failed to add the new "
> +					   "interface %s to a bridge %s",
> +					   ifname, bridge);
> +				if (br_ifindex)
> +					del_ifidx(drv, br_ifindex, ifidx);

Is that del_ifidx() correct thing to do? What if there had been some
other BSSs that were already in that bridge? Shouldn't they remain
functional even if something goes wrong with this new BSS addition?

>  		if (linux_set_iface_flags(drv->global->ioctl_sock, ifname, 1))
>  		{
> +			if (br_ifindex)
> +				del_ifidx(drv, br_ifindex, ifidx);

Same here..

-- 
Jouni Malinen                                            PGP id EFC895FA



More information about the Hostap mailing list