@@ -136,6 +136,29 @@ static struct ieee80211_supported_band band_5ghz = {
136
136
/* Assigned at module init. Guaranteed locally-administered and unicast. */
137
137
static u8 fake_router_bssid [ETH_ALEN ] __ro_after_init = {};
138
138
139
+ static void virt_wifi_inform_bss (struct wiphy * wiphy )
140
+ {
141
+ u64 tsf = div_u64 (ktime_get_boottime_ns (), 1000 );
142
+ struct cfg80211_bss * informed_bss ;
143
+ static const struct {
144
+ u8 tag ;
145
+ u8 len ;
146
+ u8 ssid [8 ];
147
+ } __packed ssid = {
148
+ .tag = WLAN_EID_SSID ,
149
+ .len = 8 ,
150
+ .ssid = "VirtWifi" ,
151
+ };
152
+
153
+ informed_bss = cfg80211_inform_bss (wiphy , & channel_5ghz ,
154
+ CFG80211_BSS_FTYPE_PRESP ,
155
+ fake_router_bssid , tsf ,
156
+ WLAN_CAPABILITY_ESS , 0 ,
157
+ (void * )& ssid , sizeof (ssid ),
158
+ DBM_TO_MBM (-50 ), GFP_KERNEL );
159
+ cfg80211_put_bss (wiphy , informed_bss );
160
+ }
161
+
139
162
/* Called with the rtnl lock held. */
140
163
static int virt_wifi_scan (struct wiphy * wiphy ,
141
164
struct cfg80211_scan_request * request )
@@ -156,28 +179,13 @@ static int virt_wifi_scan(struct wiphy *wiphy,
156
179
/* Acquires and releases the rdev BSS lock. */
157
180
static void virt_wifi_scan_result (struct work_struct * work )
158
181
{
159
- struct {
160
- u8 tag ;
161
- u8 len ;
162
- u8 ssid [8 ];
163
- } __packed ssid = {
164
- .tag = WLAN_EID_SSID , .len = 8 , .ssid = "VirtWifi" ,
165
- };
166
- struct cfg80211_bss * informed_bss ;
167
182
struct virt_wifi_wiphy_priv * priv =
168
183
container_of (work , struct virt_wifi_wiphy_priv ,
169
184
scan_result .work );
170
185
struct wiphy * wiphy = priv_to_wiphy (priv );
171
186
struct cfg80211_scan_info scan_info = { .aborted = false };
172
- u64 tsf = div_u64 (ktime_get_boottime_ns (), 1000 );
173
187
174
- informed_bss = cfg80211_inform_bss (wiphy , & channel_5ghz ,
175
- CFG80211_BSS_FTYPE_PRESP ,
176
- fake_router_bssid , tsf ,
177
- WLAN_CAPABILITY_ESS , 0 ,
178
- (void * )& ssid , sizeof (ssid ),
179
- DBM_TO_MBM (-50 ), GFP_KERNEL );
180
- cfg80211_put_bss (wiphy , informed_bss );
188
+ virt_wifi_inform_bss (wiphy );
181
189
182
190
/* Schedules work which acquires and releases the rtnl lock. */
183
191
cfg80211_scan_done (priv -> scan_request , & scan_info );
@@ -225,10 +233,12 @@ static int virt_wifi_connect(struct wiphy *wiphy, struct net_device *netdev,
225
233
if (!could_schedule )
226
234
return - EBUSY ;
227
235
228
- if (sme -> bssid )
236
+ if (sme -> bssid ) {
229
237
ether_addr_copy (priv -> connect_requested_bss , sme -> bssid );
230
- else
238
+ } else {
239
+ virt_wifi_inform_bss (wiphy );
231
240
eth_zero_addr (priv -> connect_requested_bss );
241
+ }
232
242
233
243
wiphy_debug (wiphy , "connect\n" );
234
244
@@ -241,11 +251,13 @@ static void virt_wifi_connect_complete(struct work_struct *work)
241
251
struct virt_wifi_netdev_priv * priv =
242
252
container_of (work , struct virt_wifi_netdev_priv , connect .work );
243
253
u8 * requested_bss = priv -> connect_requested_bss ;
244
- bool has_addr = !is_zero_ether_addr (requested_bss );
245
254
bool right_addr = ether_addr_equal (requested_bss , fake_router_bssid );
246
255
u16 status = WLAN_STATUS_SUCCESS ;
247
256
248
- if (!priv -> is_up || (has_addr && !right_addr ))
257
+ if (is_zero_ether_addr (requested_bss ))
258
+ requested_bss = NULL ;
259
+
260
+ if (!priv -> is_up || (requested_bss && !right_addr ))
249
261
status = WLAN_STATUS_UNSPECIFIED_FAILURE ;
250
262
else
251
263
priv -> is_connected = true;
0 commit comments