diff options
author | Johannes Berg <johannes.berg@intel.com> | 2021-01-22 16:19:42 +0100 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2021-01-22 16:28:39 +0100 |
commit | 2fe8ef106238b274c505c480ecf00d8765abf0d8 (patch) | |
tree | cd0531c336c1c5de84ba8e21bc51921a6e08936f /net/mac80211 | |
parent | 347c2989a8ba8a231f2ffc0635f2f36fedd30bde (diff) |
cfg80211: change netdev registration/unregistration semantics
We used to not require anything in terms of registering netdevs
with cfg80211, using a netdev notifier instead. However, in the
next patch reducing RTNL locking, this causes big problems, and
the simplest way is to just require drivers to do things better.
Change the registration/unregistration semantics to require the
drivers to call cfg80211_(un)register_netdevice() when this is
happening due to a cfg80211 request, i.e. add_virtual_intf() or
del_virtual_intf() (or if it somehow has to happen in any other
cfg80211 callback).
Otherwise, in other contexts, drivers may continue to use the
normal netdev (un)registration functions as usual.
Internally, we still use the netdev notifier and track (by the
new wdev->registered bool) if the wdev had already been added
to cfg80211 or not.
Link: https://lore.kernel.org/r/20210122161942.cf2f4b65e4e9.Ida8234e50da13eb675b557bac52a713ad4eddf71@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211')
-rw-r--r-- | net/mac80211/iface.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 1b44690823aa..fcaf4d20cabf 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c @@ -1976,7 +1976,7 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name, ndev->min_mtu = 256; ndev->max_mtu = local->hw.max_mtu; - ret = register_netdevice(ndev); + ret = cfg80211_register_netdevice(ndev); if (ret) { free_netdev(ndev); return ret; @@ -2006,10 +2006,9 @@ void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata) synchronize_rcu(); - if (sdata->dev) { - unregister_netdevice(sdata->dev); - } else { - cfg80211_unregister_wdev(&sdata->wdev); + cfg80211_unregister_wdev(&sdata->wdev); + + if (!sdata->dev) { ieee80211_teardown_sdata(sdata); kfree(sdata); } |