1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Fri, 2 Jul 2021 06:57:53 +0200
3 Subject: [PATCH] mac80211: fix enabling 4-address mode on a sta vif after
6 Notify the driver about the 4-address mode change and also send a nulldata
7 packet to the AP to notify it about the change
9 Fixes: 1ff4e8f2dec8 ("mac80211: notify the driver when a sta uses 4-address mode")
10 Signed-off-by: Felix Fietkau <nbd@nbd.name>
13 --- a/net/mac80211/cfg.c
14 +++ b/net/mac80211/cfg.c
15 @@ -152,6 +152,8 @@ static int ieee80211_change_iface(struct
16 struct vif_params *params)
18 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
19 + struct ieee80211_local *local = sdata->local;
20 + struct sta_info *sta;
23 ret = ieee80211_if_change_type(sdata, type);
24 @@ -162,7 +164,24 @@ static int ieee80211_change_iface(struct
25 RCU_INIT_POINTER(sdata->u.vlan.sta, NULL);
26 ieee80211_check_fast_rx_iface(sdata);
27 } else if (type == NL80211_IFTYPE_STATION && params->use_4addr >= 0) {
28 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
30 + if (params->use_4addr == ifmgd->use_4addr)
33 sdata->u.mgd.use_4addr = params->use_4addr;
34 + if (!ifmgd->associated)
37 + mutex_lock(&local->sta_mtx);
38 + sta = sta_info_get(sdata, ifmgd->bssid);
40 + drv_sta_set_4addr(local, sdata, &sta->sta,
42 + mutex_unlock(&local->sta_mtx);
44 + if (params->use_4addr)
45 + ieee80211_send_4addr_nullfunc(local, sdata);
48 if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {
49 --- a/net/mac80211/ieee80211_i.h
50 +++ b/net/mac80211/ieee80211_i.h
51 @@ -2215,6 +2215,8 @@ void ieee80211_dynamic_ps_timer(struct t
52 void ieee80211_send_nullfunc(struct ieee80211_local *local,
53 struct ieee80211_sub_if_data *sdata,
55 +void ieee80211_send_4addr_nullfunc(struct ieee80211_local *local,
56 + struct ieee80211_sub_if_data *sdata);
57 void ieee80211_sta_tx_notify(struct ieee80211_sub_if_data *sdata,
58 struct ieee80211_hdr *hdr, bool ack, u16 tx_time);
60 --- a/net/mac80211/mlme.c
61 +++ b/net/mac80211/mlme.c
62 @@ -1115,8 +1115,8 @@ void ieee80211_send_nullfunc(struct ieee
63 ieee80211_tx_skb(sdata, skb);
66 -static void ieee80211_send_4addr_nullfunc(struct ieee80211_local *local,
67 - struct ieee80211_sub_if_data *sdata)
68 +void ieee80211_send_4addr_nullfunc(struct ieee80211_local *local,
69 + struct ieee80211_sub_if_data *sdata)
72 struct ieee80211_hdr *nullfunc;