hostapd: backport ignoring 4addr mode enabling error
[openwrt/openwrt.git] / package / network / services / hostapd / patches / 020-ignore-4addr-mode-enabling-error.patch
1 From c7cca9b08f3e1e49c4a4a59ec66c47d91448e6ae Mon Sep 17 00:00:00 2001
2 From: Jouni Malinen <j@w1.fi>
3 Date: Sat, 13 Feb 2021 23:59:28 +0200
4 Subject: [PATCH] nl80211: Ignore 4addr mode enabling error if it was already
5 enabled
6
7 nl80211_set_4addr_mode() could fail when trying to enable 4addr mode on
8 an interface that is in a bridge and has 4addr mode already enabled.
9 This operation would not have been necessary in the first place and this
10 failure results in disconnecting, e.g., when roaming from one backhaul
11 BSS to another BSS with Multi AP.
12
13 Avoid this issue by ignoring the nl80211 command failure in the case
14 where 4addr mode is being enabled while it has already been enabled.
15
16 Signed-off-by: Jouni Malinen <j@w1.fi>
17 ---
18 src/drivers/driver_nl80211.c | 23 +++++++++++++++++++++++
19 1 file changed, 23 insertions(+)
20
21 diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
22 index 72189da24..011a15e68 100644
23 --- a/src/drivers/driver_nl80211.c
24 +++ b/src/drivers/driver_nl80211.c
25 @@ -617,6 +617,7 @@ struct wiphy_idx_data {
26 int wiphy_idx;
27 enum nl80211_iftype nlmode;
28 u8 *macaddr;
29 + u8 use_4addr;
30 };
31
32
33 @@ -639,6 +640,9 @@ static int netdev_info_handler(struct nl_msg *msg, void *arg)
34 os_memcpy(info->macaddr, nla_data(tb[NL80211_ATTR_MAC]),
35 ETH_ALEN);
36
37 + if (tb[NL80211_ATTR_4ADDR])
38 + info->use_4addr = nla_get_u8(tb[NL80211_ATTR_4ADDR]);
39 +
40 return NL_SKIP;
41 }
42
43 @@ -691,6 +695,20 @@ static int nl80211_get_macaddr(struct i802_bss *bss)
44 }
45
46
47 +static int nl80211_get_4addr(struct i802_bss *bss)
48 +{
49 + struct nl_msg *msg;
50 + struct wiphy_idx_data data = {
51 + .use_4addr = 0,
52 + };
53 +
54 + if (!(msg = nl80211_cmd_msg(bss, 0, NL80211_CMD_GET_INTERFACE)) ||
55 + send_and_recv_msgs(bss->drv, msg, netdev_info_handler, &data))
56 + return -1;
57 + return data.use_4addr;
58 +}
59 +
60 +
61 static int nl80211_register_beacons(struct wpa_driver_nl80211_data *drv,
62 struct nl80211_wiphy_data *w)
63 {
64 @@ -11482,6 +11500,11 @@ static int nl80211_set_4addr_mode(void *priv, const char *bridge_ifname,
65
66 ret = send_and_recv_msgs(drv, msg, NULL, NULL);
67 msg = NULL;
68 + if (ret && val && nl80211_get_4addr(bss) == 1) {
69 + wpa_printf(MSG_DEBUG,
70 + "nl80211: 4addr mode was already enabled");
71 + ret = 0;
72 + }
73 if (!ret) {
74 if (bridge_ifname[0] && val &&
75 i802_check_bridge(drv, bss, bridge_ifname, bss->ifname) < 0)
76 --
77 2.29.2
78