Commit 87490f6db38999fee7f6d3dbecc5b94730c7e010
Committed by
John W. Linville
1 parent
bf533e0bfd
Exists in
master
and in
7 other branches
mac80211: split out concurrent vif checks
Split the concurrent virtual interface checks into a new function that can be used to check for any given new interface type. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Showing 1 changed file with 29 additions and 14 deletions Side-by-side Diff
net/mac80211/iface.c
... | ... | @@ -94,20 +94,14 @@ |
94 | 94 | type2 == NL80211_IFTYPE_AP_VLAN)); |
95 | 95 | } |
96 | 96 | |
97 | -static int ieee80211_open(struct net_device *dev) | |
97 | +static int ieee80211_check_concurrent_iface(struct ieee80211_sub_if_data *sdata, | |
98 | + enum nl80211_iftype iftype) | |
98 | 99 | { |
99 | - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
100 | - struct ieee80211_sub_if_data *nsdata; | |
101 | 100 | struct ieee80211_local *local = sdata->local; |
102 | - struct sta_info *sta; | |
103 | - u32 changed = 0; | |
104 | - int res; | |
105 | - u32 hw_reconf_flags = 0; | |
101 | + struct ieee80211_sub_if_data *nsdata; | |
102 | + struct net_device *dev = sdata->dev; | |
106 | 103 | |
107 | - /* fail early if user set an invalid address */ | |
108 | - if (!is_zero_ether_addr(dev->dev_addr) && | |
109 | - !is_valid_ether_addr(dev->dev_addr)) | |
110 | - return -EADDRNOTAVAIL; | |
104 | + ASSERT_RTNL(); | |
111 | 105 | |
112 | 106 | /* we hold the RTNL here so can safely walk the list */ |
113 | 107 | list_for_each_entry(nsdata, &local->interfaces, list) { |
... | ... | @@ -124,7 +118,7 @@ |
124 | 118 | * belonging to the same hardware. Then, however, we're |
125 | 119 | * faced with having to adopt two different TSF timers... |
126 | 120 | */ |
127 | - if (sdata->vif.type == NL80211_IFTYPE_ADHOC && | |
121 | + if (iftype == NL80211_IFTYPE_ADHOC && | |
128 | 122 | nsdata->vif.type == NL80211_IFTYPE_ADHOC) |
129 | 123 | return -EBUSY; |
130 | 124 | |
131 | 125 | |
132 | 126 | |
... | ... | @@ -138,18 +132,39 @@ |
138 | 132 | /* |
139 | 133 | * check whether it may have the same address |
140 | 134 | */ |
141 | - if (!identical_mac_addr_allowed(sdata->vif.type, | |
135 | + if (!identical_mac_addr_allowed(iftype, | |
142 | 136 | nsdata->vif.type)) |
143 | 137 | return -ENOTUNIQ; |
144 | 138 | |
145 | 139 | /* |
146 | 140 | * can only add VLANs to enabled APs |
147 | 141 | */ |
148 | - if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN && | |
142 | + if (iftype == NL80211_IFTYPE_AP_VLAN && | |
149 | 143 | nsdata->vif.type == NL80211_IFTYPE_AP) |
150 | 144 | sdata->bss = &nsdata->u.ap; |
151 | 145 | } |
152 | 146 | } |
147 | + | |
148 | + return 0; | |
149 | +} | |
150 | + | |
151 | +static int ieee80211_open(struct net_device *dev) | |
152 | +{ | |
153 | + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | |
154 | + struct ieee80211_local *local = sdata->local; | |
155 | + struct sta_info *sta; | |
156 | + u32 changed = 0; | |
157 | + int res; | |
158 | + u32 hw_reconf_flags = 0; | |
159 | + | |
160 | + /* fail early if user set an invalid address */ | |
161 | + if (!is_zero_ether_addr(dev->dev_addr) && | |
162 | + !is_valid_ether_addr(dev->dev_addr)) | |
163 | + return -EADDRNOTAVAIL; | |
164 | + | |
165 | + res = ieee80211_check_concurrent_iface(sdata, sdata->vif.type); | |
166 | + if (res) | |
167 | + return res; | |
153 | 168 | |
154 | 169 | switch (sdata->vif.type) { |
155 | 170 | case NL80211_IFTYPE_WDS: |