cfg80211/mac80211: move more combination checks to mac80211
Get rid of the cfg80211_can_add_interface() and
cfg80211_can_change_interface() functions by moving that functionality
to mac80211. With this patch all interface combination checks are now
out of cfg80211 (except for the channel switch case which will be
addressed in a future commit).
Additionally, modify the ieee80211_check_combinations() function so
that an undefined chandef can be passed, in order to use it before a
channel is defined.
Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 436f988..5a6cc33 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -2808,7 +2808,7 @@
enum nl80211_iftype iftype = sdata->wdev.iftype;
int num[NUM_NL80211_IFTYPES];
struct ieee80211_chanctx *ctx;
- int num_different_channels = 1;
+ int num_different_channels = 0;
int total = 1;
lockdep_assert_held(&local->chanctx_mtx);
@@ -2816,9 +2816,13 @@
if (WARN_ON(hweight32(radar_detect) > 1))
return -EINVAL;
- if (WARN_ON(chanmode == IEEE80211_CHANCTX_SHARED && !chandef->chan))
+ if (WARN_ON(chandef && chanmode == IEEE80211_CHANCTX_SHARED &&
+ !chandef->chan))
return -EINVAL;
+ if (chandef)
+ num_different_channels = 1;
+
if (WARN_ON(iftype >= NUM_NL80211_IFTYPES))
return -EINVAL;
@@ -2841,7 +2845,7 @@
num_different_channels++;
continue;
}
- if ((chanmode == IEEE80211_CHANCTX_SHARED) &&
+ if (chandef && chanmode == IEEE80211_CHANCTX_SHARED &&
cfg80211_chandef_compatible(chandef,
&ctx->conf.def))
continue;