Skip to content

Commit

Permalink
wifi: mac80211: RCU-ify link/link_conf pointers
Browse files Browse the repository at this point in the history
Since links can be added and removed dynamically, we need to
somehow protect the sdata->link[] and vif->link_conf[] array
pointers from disappearing when accessing them without locks.
RCU-ify the pointers to achieve this, which requires quite a
bit of rework.

Signed-off-by: Johannes Berg <[email protected]>
  • Loading branch information
jmberg-intel committed Jul 15, 2022
1 parent 3d1cc7c commit d8675a6
Show file tree
Hide file tree
Showing 22 changed files with 420 additions and 275 deletions.
14 changes: 9 additions & 5 deletions drivers/net/wireless/mac80211_hwsim.c
Original file line number Diff line number Diff line change
Expand Up @@ -1477,9 +1477,10 @@ static void mac80211_hwsim_tx_iter(void *_data, u8 *addr,
int i;

for (i = 0; i < ARRAY_SIZE(vif->link_conf); i++) {
struct ieee80211_bss_conf *conf = vif->link_conf[i];
struct ieee80211_bss_conf *conf;
struct ieee80211_chanctx_conf *chanctx;

conf = rcu_dereference(vif->link_conf[i]);
if (!conf)
continue;

Expand Down Expand Up @@ -1917,7 +1918,7 @@ static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac,
{
struct mac80211_hwsim_link_data *link_data = arg;
u32 link_id = link_data->link_id;
struct ieee80211_bss_conf *link_conf = vif->link_conf[link_id];
struct ieee80211_bss_conf *link_conf;
struct mac80211_hwsim_data *data =
container_of(link_data, struct mac80211_hwsim_data,
link_data[link_id]);
Expand All @@ -1931,6 +1932,10 @@ static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac,

hwsim_check_magic(vif);

link_conf = rcu_dereference(vif->link_conf[link_id]);
if (!link_conf)
return;

if (vif->type != NL80211_IFTYPE_AP &&
vif->type != NL80211_IFTYPE_MESH_POINT &&
vif->type != NL80211_IFTYPE_ADHOC &&
Expand Down Expand Up @@ -2155,12 +2160,11 @@ static void mac80211_hwsim_vif_info_changed(struct ieee80211_hw *hw,

static void mac80211_hwsim_link_info_changed(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
u32 link_id,
u64 changed)
struct ieee80211_bss_conf *info,
u32 link_id, u64 changed)
{
struct hwsim_vif_priv *vp = (void *)vif->drv_priv;
struct mac80211_hwsim_data *data = hw->priv;
struct ieee80211_bss_conf *info = vif->link_conf[link_id];
struct mac80211_hwsim_link_data *link_data = &data->link_data[link_id];

hwsim_check_magic(vif);
Expand Down
6 changes: 4 additions & 2 deletions include/net/mac80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,7 @@ struct ieee80211_vif {
enum nl80211_iftype type;
struct ieee80211_vif_cfg cfg;
struct ieee80211_bss_conf bss_conf;
struct ieee80211_bss_conf *link_conf[IEEE80211_MLD_MAX_NUM_LINKS];
struct ieee80211_bss_conf __rcu *link_conf[IEEE80211_MLD_MAX_NUM_LINKS];
u16 valid_links;
u8 addr[ETH_ALEN] __aligned(2);
bool p2p;
Expand Down Expand Up @@ -4082,7 +4082,9 @@ struct ieee80211_ops {
u64 changed);
void (*link_info_changed)(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
unsigned int link_id, u64 changed);
struct ieee80211_bss_conf *info,
unsigned int link_id,
u64 changed);

int (*start_ap)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
unsigned int link_id);
Expand Down
Loading

0 comments on commit d8675a6

Please sign in to comment.