Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mac80211: clean up mesh code

There's various code with strange indentation,
questionable loop and locking constructs, etc.

The bigger change is moving the "sdata" argument
to the first argument of all functions, like all
other mac80211 functions that have one.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>

+252 -263
+7 -7
net/mac80211/cfg.c
··· 1500 1500 return -ENOENT; 1501 1501 } 1502 1502 1503 - err = mesh_path_add(dst, sdata); 1503 + err = mesh_path_add(sdata, dst); 1504 1504 if (err) { 1505 1505 rcu_read_unlock(); 1506 1506 return err; 1507 1507 } 1508 1508 1509 - mpath = mesh_path_lookup(dst, sdata); 1509 + mpath = mesh_path_lookup(sdata, dst); 1510 1510 if (!mpath) { 1511 1511 rcu_read_unlock(); 1512 1512 return -ENXIO; ··· 1518 1518 } 1519 1519 1520 1520 static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev, 1521 - u8 *dst) 1521 + u8 *dst) 1522 1522 { 1523 1523 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1524 1524 1525 1525 if (dst) 1526 - return mesh_path_del(dst, sdata); 1526 + return mesh_path_del(sdata, dst); 1527 1527 1528 1528 mesh_path_flush_by_iface(sdata); 1529 1529 return 0; ··· 1547 1547 return -ENOENT; 1548 1548 } 1549 1549 1550 - mpath = mesh_path_lookup(dst, sdata); 1550 + mpath = mesh_path_lookup(sdata, dst); 1551 1551 if (!mpath) { 1552 1552 rcu_read_unlock(); 1553 1553 return -ENOENT; ··· 1611 1611 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1612 1612 1613 1613 rcu_read_lock(); 1614 - mpath = mesh_path_lookup(dst, sdata); 1614 + mpath = mesh_path_lookup(sdata, dst); 1615 1615 if (!mpath) { 1616 1616 rcu_read_unlock(); 1617 1617 return -ENOENT; ··· 1632 1632 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1633 1633 1634 1634 rcu_read_lock(); 1635 - mpath = mesh_path_lookup_by_idx(idx, sdata); 1635 + mpath = mesh_path_lookup_by_idx(sdata, idx); 1636 1636 if (!mpath) { 1637 1637 rcu_read_unlock(); 1638 1638 return -ENOENT;
+1 -2
net/mac80211/main.c
··· 1173 1173 rc80211_minstrel_ht_exit(); 1174 1174 rc80211_minstrel_exit(); 1175 1175 1176 - if (mesh_allocated) 1177 - ieee80211s_stop(); 1176 + ieee80211s_stop(); 1178 1177 1179 1178 ieee80211_iface_exit(); 1180 1179
+61 -54
net/mac80211/mesh.c
··· 17 17 #define TMR_RUNNING_MP 1 18 18 #define TMR_RUNNING_MPR 2 19 19 20 - int mesh_allocated; 20 + static int mesh_allocated; 21 21 static struct kmem_cache *rm_cache; 22 22 23 23 bool mesh_action_is_path_sel(struct ieee80211_mgmt *mgmt) ··· 36 36 37 37 void ieee80211s_stop(void) 38 38 { 39 + if (!mesh_allocated) 40 + return; 39 41 mesh_pathtbl_unregister(); 40 42 kmem_cache_destroy(rm_cache); 41 43 } ··· 92 90 (ifmsh->mesh_cc_id == ie->mesh_config->meshconf_congest) && 93 91 (ifmsh->mesh_sp_id == ie->mesh_config->meshconf_synch) && 94 92 (ifmsh->mesh_auth_id == ie->mesh_config->meshconf_auth))) 95 - goto mismatch; 93 + return false; 96 94 97 95 ieee80211_sta_get_rates(local, ie, ieee80211_get_sdata_band(sdata), 98 96 &basic_rates); 99 97 100 98 if (sdata->vif.bss_conf.basic_rates != basic_rates) 101 - goto mismatch; 99 + return false; 102 100 103 101 ieee80211_ht_oper_to_chandef(sdata->vif.bss_conf.chandef.chan, 104 102 ie->ht_operation, &sta_chan_def); 105 103 106 104 if (!cfg80211_chandef_compatible(&sdata->vif.bss_conf.chandef, 107 105 &sta_chan_def)) 108 - goto mismatch; 106 + return false; 109 107 110 108 return true; 111 - mismatch: 112 - return false; 113 109 } 114 110 115 111 /** ··· 118 118 bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie) 119 119 { 120 120 return (ie->mesh_config->meshconf_cap & 121 - IEEE80211_MESHCONF_CAPAB_ACCEPT_PLINKS) != 0; 121 + IEEE80211_MESHCONF_CAPAB_ACCEPT_PLINKS) != 0; 122 122 } 123 123 124 124 /** ··· 196 196 if (!sdata->u.mesh.rmc) 197 197 return; 198 198 199 - for (i = 0; i < RMC_BUCKETS; i++) 199 + for (i = 0; i < RMC_BUCKETS; i++) { 200 200 list_for_each_entry_safe(p, n, &rmc->bucket[i], list) { 201 201 list_del(&p->list); 202 202 kmem_cache_free(rm_cache, p); 203 203 } 204 + } 204 205 205 206 kfree(rmc); 206 207 sdata->u.mesh.rmc = NULL; ··· 210 209 /** 211 210 * mesh_rmc_check - Check frame in recent multicast cache and add if absent. 212 211 * 212 + * @sdata: interface 213 213 * @sa: source address 214 214 * @mesh_hdr: mesh_header 215 215 * ··· 220 218 * received this frame lately. If the frame is not in the cache, it is added to 221 219 * it. 222 220 */ 223 - int mesh_rmc_check(u8 *sa, struct ieee80211s_hdr *mesh_hdr, 224 - struct ieee80211_sub_if_data *sdata) 221 + int mesh_rmc_check(struct ieee80211_sub_if_data *sdata, 222 + const u8 *sa, struct ieee80211s_hdr *mesh_hdr) 225 223 { 226 224 struct mesh_rmc *rmc = sdata->u.mesh.rmc; 227 225 u32 seqnum = 0; ··· 235 233 list_for_each_entry_safe(p, n, &rmc->bucket[idx], list) { 236 234 ++entries; 237 235 if (time_after(jiffies, p->exp_time) || 238 - (entries == RMC_QUEUE_MAX_LEN)) { 236 + entries == RMC_QUEUE_MAX_LEN) { 239 237 list_del(&p->list); 240 238 kmem_cache_free(rm_cache, p); 241 239 --entries; 242 - } else if ((seqnum == p->seqnum) && 243 - (ether_addr_equal(sa, p->sa))) 240 + } else if ((seqnum == p->seqnum) && ether_addr_equal(sa, p->sa)) 244 241 return -1; 245 242 } 246 243 ··· 254 253 return 0; 255 254 } 256 255 257 - int 258 - mesh_add_meshconf_ie(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata) 256 + int mesh_add_meshconf_ie(struct ieee80211_sub_if_data *sdata, 257 + struct sk_buff *skb) 259 258 { 260 259 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 261 260 u8 *pos, neighbors; ··· 286 285 /* Mesh capability */ 287 286 *pos = IEEE80211_MESHCONF_CAPAB_FORWARDING; 288 287 *pos |= ifmsh->accepting_plinks ? 289 - IEEE80211_MESHCONF_CAPAB_ACCEPT_PLINKS : 0x00; 288 + IEEE80211_MESHCONF_CAPAB_ACCEPT_PLINKS : 0x00; 290 289 /* Mesh PS mode. See IEEE802.11-2012 8.4.2.100.8 */ 291 290 *pos |= ifmsh->ps_peers_deep_sleep ? 292 - IEEE80211_MESHCONF_CAPAB_POWER_SAVE_LEVEL : 0x00; 291 + IEEE80211_MESHCONF_CAPAB_POWER_SAVE_LEVEL : 0x00; 293 292 *pos++ |= ifmsh->adjusting_tbtt ? 294 - IEEE80211_MESHCONF_CAPAB_TBTT_ADJUSTING : 0x00; 293 + IEEE80211_MESHCONF_CAPAB_TBTT_ADJUSTING : 0x00; 295 294 *pos++ = 0x00; 296 295 297 296 return 0; 298 297 } 299 298 300 - int 301 - mesh_add_meshid_ie(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata) 299 + int mesh_add_meshid_ie(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb) 302 300 { 303 301 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 304 302 u8 *pos; ··· 314 314 return 0; 315 315 } 316 316 317 - int mesh_add_awake_window_ie(struct sk_buff *skb, 318 - struct ieee80211_sub_if_data *sdata) 317 + static int mesh_add_awake_window_ie(struct ieee80211_sub_if_data *sdata, 318 + struct sk_buff *skb) 319 319 { 320 320 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 321 321 u8 *pos; ··· 337 337 return 0; 338 338 } 339 339 340 - int 341 - mesh_add_vendor_ies(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata) 340 + int mesh_add_vendor_ies(struct ieee80211_sub_if_data *sdata, 341 + struct sk_buff *skb) 342 342 { 343 343 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 344 344 u8 offset, len; ··· 361 361 return 0; 362 362 } 363 363 364 - int 365 - mesh_add_rsn_ie(struct sk_buff *skb, struct ieee80211_sub_if_data *sdata) 364 + int mesh_add_rsn_ie(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb) 366 365 { 367 366 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 368 367 u8 len = 0; ··· 389 390 return 0; 390 391 } 391 392 392 - int mesh_add_ds_params_ie(struct sk_buff *skb, 393 - struct ieee80211_sub_if_data *sdata) 393 + static int mesh_add_ds_params_ie(struct ieee80211_sub_if_data *sdata, 394 + struct sk_buff *skb) 394 395 { 395 396 struct ieee80211_chanctx_conf *chanctx_conf; 396 397 struct ieee80211_channel *chan; ··· 416 417 return 0; 417 418 } 418 419 419 - int mesh_add_ht_cap_ie(struct sk_buff *skb, 420 - struct ieee80211_sub_if_data *sdata) 420 + int mesh_add_ht_cap_ie(struct ieee80211_sub_if_data *sdata, 421 + struct sk_buff *skb) 421 422 { 422 423 struct ieee80211_local *local = sdata->local; 423 424 enum ieee80211_band band = ieee80211_get_sdata_band(sdata); ··· 438 439 return 0; 439 440 } 440 441 441 - int mesh_add_ht_oper_ie(struct sk_buff *skb, 442 - struct ieee80211_sub_if_data *sdata) 442 + int mesh_add_ht_oper_ie(struct ieee80211_sub_if_data *sdata, 443 + struct sk_buff *skb) 443 444 { 444 445 struct ieee80211_local *local = sdata->local; 445 446 struct ieee80211_chanctx_conf *chanctx_conf; ··· 474 475 475 476 return 0; 476 477 } 478 + 477 479 static void ieee80211_mesh_path_timer(unsigned long data) 478 480 { 479 481 struct ieee80211_sub_if_data *sdata = ··· 520 520 521 521 /** 522 522 * ieee80211_fill_mesh_addresses - fill addresses of a locally originated mesh frame 523 - * @hdr: 802.11 frame header 523 + * @hdr: 802.11 frame header 524 524 * @fc: frame control field 525 525 * @meshda: destination address in the mesh 526 526 * @meshsa: source address address in the mesh. Same as TA, as frame is ··· 551 551 552 552 /** 553 553 * ieee80211_new_mesh_header - create a new mesh header 554 - * @meshhdr: uninitialized mesh header 555 554 * @sdata: mesh interface to be used 555 + * @meshhdr: uninitialized mesh header 556 556 * @addr4or5: 1st address in the ae header, which may correspond to address 4 557 557 * (if addr6 is NULL) or address 5 (if addr6 is present). It may 558 558 * be NULL. ··· 561 561 * 562 562 * Return the header length. 563 563 */ 564 - int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr, 565 - struct ieee80211_sub_if_data *sdata, char *addr4or5, 566 - char *addr6) 564 + int ieee80211_new_mesh_header(struct ieee80211_sub_if_data *sdata, 565 + struct ieee80211s_hdr *meshhdr, 566 + const char *addr4or5, const char *addr6) 567 567 { 568 - int aelen = 0; 569 - BUG_ON(!addr4or5 && addr6); 568 + if (WARN_ON(!addr4or5 && addr6)) 569 + return 0; 570 + 570 571 memset(meshhdr, 0, sizeof(*meshhdr)); 572 + 571 573 meshhdr->ttl = sdata->u.mesh.mshcfg.dot11MeshTTL; 574 + 575 + /* FIXME: racy -- TX on multiple queues can be concurrent */ 572 576 put_unaligned(cpu_to_le32(sdata->u.mesh.mesh_seqnum), &meshhdr->seqnum); 573 577 sdata->u.mesh.mesh_seqnum++; 578 + 574 579 if (addr4or5 && !addr6) { 575 580 meshhdr->flags |= MESH_FLAGS_AE_A4; 576 - aelen += ETH_ALEN; 577 581 memcpy(meshhdr->eaddr1, addr4or5, ETH_ALEN); 582 + return 2 * ETH_ALEN; 578 583 } else if (addr4or5 && addr6) { 579 584 meshhdr->flags |= MESH_FLAGS_AE_A5_A6; 580 - aelen += 2 * ETH_ALEN; 581 585 memcpy(meshhdr->eaddr1, addr4or5, ETH_ALEN); 582 586 memcpy(meshhdr->eaddr2, addr6, ETH_ALEN); 587 + return 3 * ETH_ALEN; 583 588 } 584 - return 6 + aelen; 589 + 590 + return ETH_ALEN; 585 591 } 586 592 587 - static void ieee80211_mesh_housekeeping(struct ieee80211_sub_if_data *sdata, 588 - struct ieee80211_if_mesh *ifmsh) 593 + static void ieee80211_mesh_housekeeping(struct ieee80211_sub_if_data *sdata) 589 594 { 595 + struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 590 596 u32 changed; 591 597 592 598 ieee80211_sta_expire(sdata, IEEE80211_MESH_PEER_INACTIVITY_LIMIT); ··· 602 596 ieee80211_mbss_info_change_notify(sdata, changed); 603 597 604 598 mod_timer(&ifmsh->housekeeping_timer, 605 - round_jiffies(jiffies + IEEE80211_MESH_HOUSEKEEPING_INTERVAL)); 599 + round_jiffies(jiffies + 600 + IEEE80211_MESH_HOUSEKEEPING_INTERVAL)); 606 601 } 607 602 608 603 static void ieee80211_mesh_rootpath(struct ieee80211_sub_if_data *sdata) ··· 715 708 *pos++ = 0x0; 716 709 717 710 if (ieee80211_add_srates_ie(sdata, skb, true, band) || 718 - mesh_add_ds_params_ie(skb, sdata)) 711 + mesh_add_ds_params_ie(sdata, skb)) 719 712 goto out_free; 720 713 721 714 bcn->head_len = skb->len; ··· 726 719 bcn->tail = bcn->head + bcn->head_len; 727 720 728 721 if (ieee80211_add_ext_srates_ie(sdata, skb, true, band) || 729 - mesh_add_rsn_ie(skb, sdata) || 730 - mesh_add_ht_cap_ie(skb, sdata) || 731 - mesh_add_ht_oper_ie(skb, sdata) || 732 - mesh_add_meshid_ie(skb, sdata) || 733 - mesh_add_meshconf_ie(skb, sdata) || 734 - mesh_add_awake_window_ie(skb, sdata) || 735 - mesh_add_vendor_ies(skb, sdata)) 722 + mesh_add_rsn_ie(sdata, skb) || 723 + mesh_add_ht_cap_ie(sdata, skb) || 724 + mesh_add_ht_oper_ie(sdata, skb) || 725 + mesh_add_meshid_ie(sdata, skb) || 726 + mesh_add_meshconf_ie(sdata, skb) || 727 + mesh_add_awake_window_ie(sdata, skb) || 728 + mesh_add_vendor_ies(sdata, skb)) 736 729 goto out_free; 737 730 738 731 bcn->tail_len = skb->len; ··· 1046 1039 mesh_mpp_table_grow(); 1047 1040 1048 1041 if (test_and_clear_bit(MESH_WORK_HOUSEKEEPING, &ifmsh->wrkq_flags)) 1049 - ieee80211_mesh_housekeeping(sdata, ifmsh); 1042 + ieee80211_mesh_housekeeping(sdata); 1050 1043 1051 1044 if (test_and_clear_bit(MESH_WORK_ROOT, &ifmsh->wrkq_flags)) 1052 1045 ieee80211_mesh_rootpath(sdata);
+50 -55
net/mac80211/mesh.h
··· 26 26 * @MESH_PATH_ACTIVE: the mesh path can be used for forwarding 27 27 * @MESH_PATH_RESOLVING: the discovery process is running for this mesh path 28 28 * @MESH_PATH_SN_VALID: the mesh path contains a valid destination sequence 29 - * number 29 + * number 30 30 * @MESH_PATH_FIXED: the mesh path has been manually set and should not be 31 - * modified 31 + * modified 32 32 * @MESH_PATH_RESOLVED: the mesh path can has been resolved 33 33 * @MESH_PATH_REQ_QUEUED: there is an unsent path request for this destination 34 - * already queued up, waiting for the discovery process to start. 34 + * already queued up, waiting for the discovery process to start. 35 35 * 36 36 * MESH_PATH_RESOLVED is used by the mesh path timer to 37 37 * decide when to stop or cancel the mesh path discovery. ··· 73 73 * @dst: mesh path destination mac address 74 74 * @sdata: mesh subif 75 75 * @next_hop: mesh neighbor to which frames for this destination will be 76 - * forwarded 76 + * forwarded 77 77 * @timer: mesh path discovery timer 78 78 * @frame_queue: pending queue for frames sent to this destination while the 79 - * path is unresolved 79 + * path is unresolved 80 80 * @sn: target sequence number 81 81 * @metric: current metric to this destination 82 82 * @hop_count: hops to destination 83 83 * @exp_time: in jiffies, when the path will expire or when it expired 84 84 * @discovery_timeout: timeout (lapse in jiffies) used for the last discovery 85 - * retry 85 + * retry 86 86 * @discovery_retries: number of discovery retries 87 87 * @flags: mesh path flags, as specified on &enum mesh_path_flags 88 88 * @state_lock: mesh path state lock used to protect changes to the ··· 206 206 /* Various */ 207 207 int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc, 208 208 const u8 *da, const u8 *sa); 209 - int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr, 210 - struct ieee80211_sub_if_data *sdata, char *addr4or5, 211 - char *addr6); 212 - int mesh_rmc_check(u8 *addr, struct ieee80211s_hdr *mesh_hdr, 213 - struct ieee80211_sub_if_data *sdata); 209 + int ieee80211_new_mesh_header(struct ieee80211_sub_if_data *sdata, 210 + struct ieee80211s_hdr *meshhdr, 211 + const char *addr4or5, const char *addr6); 212 + int mesh_rmc_check(struct ieee80211_sub_if_data *sdata, 213 + const u8 *addr, struct ieee80211s_hdr *mesh_hdr); 214 214 bool mesh_matches_local(struct ieee80211_sub_if_data *sdata, 215 215 struct ieee802_11_elems *ie); 216 216 void mesh_ids_set_default(struct ieee80211_if_mesh *mesh); 217 - void mesh_mgmt_ies_add(struct sk_buff *skb, 218 - struct ieee80211_sub_if_data *sdata); 219 - int mesh_add_meshconf_ie(struct sk_buff *skb, 220 - struct ieee80211_sub_if_data *sdata); 221 - int mesh_add_meshid_ie(struct sk_buff *skb, 222 - struct ieee80211_sub_if_data *sdata); 223 - int mesh_add_rsn_ie(struct sk_buff *skb, 224 - struct ieee80211_sub_if_data *sdata); 225 - int mesh_add_awake_window_ie(struct sk_buff *skb, 226 - struct ieee80211_sub_if_data *sdata); 227 - int mesh_add_vendor_ies(struct sk_buff *skb, 228 - struct ieee80211_sub_if_data *sdata); 229 - int mesh_add_ds_params_ie(struct sk_buff *skb, 230 - struct ieee80211_sub_if_data *sdata); 231 - int mesh_add_ht_cap_ie(struct sk_buff *skb, 232 - struct ieee80211_sub_if_data *sdata); 233 - int mesh_add_ht_oper_ie(struct sk_buff *skb, 234 - struct ieee80211_sub_if_data *sdata); 217 + void mesh_mgmt_ies_add(struct ieee80211_sub_if_data *sdata, 218 + struct sk_buff *skb); 219 + int mesh_add_meshconf_ie(struct ieee80211_sub_if_data *sdata, 220 + struct sk_buff *skb); 221 + int mesh_add_meshid_ie(struct ieee80211_sub_if_data *sdata, 222 + struct sk_buff *skb); 223 + int mesh_add_rsn_ie(struct ieee80211_sub_if_data *sdata, 224 + struct sk_buff *skb); 225 + int mesh_add_vendor_ies(struct ieee80211_sub_if_data *sdata, 226 + struct sk_buff *skb); 227 + int mesh_add_ht_cap_ie(struct ieee80211_sub_if_data *sdata, 228 + struct sk_buff *skb); 229 + int mesh_add_ht_oper_ie(struct ieee80211_sub_if_data *sdata, 230 + struct sk_buff *skb); 235 231 void mesh_rmc_free(struct ieee80211_sub_if_data *sdata); 236 232 int mesh_rmc_init(struct ieee80211_sub_if_data *sdata); 237 233 void ieee80211s_init(void); 238 234 void ieee80211s_update_metric(struct ieee80211_local *local, 239 - struct sta_info *sta, struct sk_buff *skb); 240 - void ieee80211s_stop(void); 235 + struct sta_info *sta, struct sk_buff *skb); 241 236 void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata); 242 237 int ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata); 243 238 void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata); ··· 258 263 struct ieee802_11_elems *elems); 259 264 260 265 /* Mesh paths */ 261 - int mesh_nexthop_lookup(struct sk_buff *skb, 262 - struct ieee80211_sub_if_data *sdata); 263 - int mesh_nexthop_resolve(struct sk_buff *skb, 264 - struct ieee80211_sub_if_data *sdata); 266 + int mesh_nexthop_lookup(struct ieee80211_sub_if_data *sdata, 267 + struct sk_buff *skb); 268 + int mesh_nexthop_resolve(struct ieee80211_sub_if_data *sdata, 269 + struct sk_buff *skb); 265 270 void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata); 266 - struct mesh_path *mesh_path_lookup(const u8 *dst, 267 - struct ieee80211_sub_if_data *sdata); 268 - struct mesh_path *mpp_path_lookup(u8 *dst, 269 - struct ieee80211_sub_if_data *sdata); 270 - int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata); 271 - struct mesh_path *mesh_path_lookup_by_idx(int idx, 272 - struct ieee80211_sub_if_data *sdata); 271 + struct mesh_path *mesh_path_lookup(struct ieee80211_sub_if_data *sdata, 272 + const u8 *dst); 273 + struct mesh_path *mpp_path_lookup(struct ieee80211_sub_if_data *sdata, 274 + const u8 *dst); 275 + int mpp_path_add(struct ieee80211_sub_if_data *sdata, 276 + const u8 *dst, const u8 *mpp); 277 + struct mesh_path * 278 + mesh_path_lookup_by_idx(struct ieee80211_sub_if_data *sdata, int idx); 273 279 void mesh_path_fix_nexthop(struct mesh_path *mpath, struct sta_info *next_hop); 274 280 void mesh_path_expire(struct ieee80211_sub_if_data *sdata); 275 281 void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata, 276 - struct ieee80211_mgmt *mgmt, size_t len); 277 - int mesh_path_add(const u8 *dst, struct ieee80211_sub_if_data *sdata); 282 + struct ieee80211_mgmt *mgmt, size_t len); 283 + int mesh_path_add(struct ieee80211_sub_if_data *sdata, const u8 *dst); 278 284 279 285 int mesh_path_add_gate(struct mesh_path *mpath); 280 286 int mesh_path_send_to_gates(struct mesh_path *mpath); 281 287 int mesh_gate_num(struct ieee80211_sub_if_data *sdata); 288 + 282 289 /* Mesh plinks */ 283 290 void mesh_neighbour_update(struct ieee80211_sub_if_data *sdata, 284 - u8 *hw_addr, 285 - struct ieee802_11_elems *ie); 291 + u8 *hw_addr, struct ieee802_11_elems *ie); 286 292 bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie); 287 293 u32 mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata); 288 294 void mesh_plink_broken(struct sta_info *sta); ··· 300 304 void mesh_mpath_table_grow(void); 301 305 void mesh_mpp_table_grow(void); 302 306 /* Mesh paths */ 303 - int mesh_path_error_tx(u8 ttl, const u8 *target, __le32 target_sn, 304 - __le16 target_rcode, const u8 *ra, 305 - struct ieee80211_sub_if_data *sdata); 307 + int mesh_path_error_tx(struct ieee80211_sub_if_data *sdata, 308 + u8 ttl, const u8 *target, __le32 target_sn, 309 + __le16 target_rcode, const u8 *ra); 306 310 void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta); 307 311 void mesh_path_flush_pending(struct mesh_path *mpath); 308 312 void mesh_path_tx_pending(struct mesh_path *mpath); 309 313 int mesh_pathtbl_init(void); 310 314 void mesh_pathtbl_unregister(void); 311 - int mesh_path_del(u8 *addr, struct ieee80211_sub_if_data *sdata); 315 + int mesh_path_del(struct ieee80211_sub_if_data *sdata, const u8 *addr); 312 316 void mesh_path_timer(unsigned long data); 313 317 void mesh_path_flush_by_nexthop(struct sta_info *sta); 314 - void mesh_path_discard_frame(struct sk_buff *skb, 315 - struct ieee80211_sub_if_data *sdata); 318 + void mesh_path_discard_frame(struct ieee80211_sub_if_data *sdata, 319 + struct sk_buff *skb); 316 320 void mesh_path_quiesce(struct ieee80211_sub_if_data *sdata); 317 321 void mesh_path_restart(struct ieee80211_sub_if_data *sdata); 318 322 void mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata); ··· 321 325 extern int mesh_paths_generation; 322 326 323 327 #ifdef CONFIG_MAC80211_MESH 324 - extern int mesh_allocated; 325 - 326 328 static inline 327 329 u32 mesh_plink_inc_estab_count(struct ieee80211_sub_if_data *sdata) 328 330 { ··· 365 371 void mesh_plink_restart(struct sta_info *sta); 366 372 void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata); 367 373 void mesh_sync_adjust_tbtt(struct ieee80211_sub_if_data *sdata); 374 + void ieee80211s_stop(void); 368 375 #else 369 - #define mesh_allocated 0 370 376 static inline void 371 377 ieee80211_mesh_notify_scan_completed(struct ieee80211_local *local) {} 372 378 static inline void ieee80211_mesh_quiesce(struct ieee80211_sub_if_data *sdata) ··· 379 385 { return false; } 380 386 static inline void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata) 381 387 {} 388 + static inline void ieee80211s_stop(void) {} 382 389 #endif 383 390 384 391 #endif /* IEEE80211S_H */
+34 -34
net/mac80211/mesh_hwmp.c
··· 238 238 * also acquires in the TX path. To avoid a deadlock we don't transmit the 239 239 * frame directly but add it to the pending queue instead. 240 240 */ 241 - int mesh_path_error_tx(u8 ttl, const u8 *target, __le32 target_sn, 242 - __le16 target_rcode, const u8 *ra, 243 - struct ieee80211_sub_if_data *sdata) 241 + int mesh_path_error_tx(struct ieee80211_sub_if_data *sdata, 242 + u8 ttl, const u8 *target, __le32 target_sn, 243 + __le16 target_rcode, const u8 *ra) 244 244 { 245 245 struct ieee80211_local *local = sdata->local; 246 246 struct sk_buff *skb; ··· 430 430 process = false; 431 431 fresh_info = false; 432 432 } else { 433 - mpath = mesh_path_lookup(orig_addr, sdata); 433 + mpath = mesh_path_lookup(sdata, orig_addr); 434 434 if (mpath) { 435 435 spin_lock_bh(&mpath->state_lock); 436 436 if (mpath->flags & MESH_PATH_FIXED) ··· 445 445 } 446 446 } 447 447 } else { 448 - mesh_path_add(orig_addr, sdata); 449 - mpath = mesh_path_lookup(orig_addr, sdata); 448 + mesh_path_add(sdata, orig_addr); 449 + mpath = mesh_path_lookup(sdata, orig_addr); 450 450 if (!mpath) { 451 451 rcu_read_unlock(); 452 452 return 0; ··· 478 478 else { 479 479 fresh_info = true; 480 480 481 - mpath = mesh_path_lookup(ta, sdata); 481 + mpath = mesh_path_lookup(sdata, ta); 482 482 if (mpath) { 483 483 spin_lock_bh(&mpath->state_lock); 484 484 if ((mpath->flags & MESH_PATH_FIXED) || ··· 486 486 (last_hop_metric > mpath->metric))) 487 487 fresh_info = false; 488 488 } else { 489 - mesh_path_add(ta, sdata); 490 - mpath = mesh_path_lookup(ta, sdata); 489 + mesh_path_add(sdata, ta); 490 + mpath = mesh_path_lookup(sdata, ta); 491 491 if (!mpath) { 492 492 rcu_read_unlock(); 493 493 return 0; ··· 553 553 } else if (is_broadcast_ether_addr(target_addr) && 554 554 (target_flags & IEEE80211_PREQ_TO_FLAG)) { 555 555 rcu_read_lock(); 556 - mpath = mesh_path_lookup(orig_addr, sdata); 556 + mpath = mesh_path_lookup(sdata, orig_addr); 557 557 if (mpath) { 558 558 if (flags & IEEE80211_PREQ_PROACTIVE_PREP_FLAG) { 559 559 reply = true; ··· 568 568 rcu_read_unlock(); 569 569 } else { 570 570 rcu_read_lock(); 571 - mpath = mesh_path_lookup(target_addr, sdata); 571 + mpath = mesh_path_lookup(sdata, target_addr); 572 572 if (mpath) { 573 573 if ((!(mpath->flags & MESH_PATH_SN_VALID)) || 574 574 SN_LT(mpath->sn, target_sn)) { ··· 678 678 } 679 679 680 680 rcu_read_lock(); 681 - mpath = mesh_path_lookup(orig_addr, sdata); 681 + mpath = mesh_path_lookup(sdata, orig_addr); 682 682 if (mpath) 683 683 spin_lock_bh(&mpath->state_lock); 684 684 else ··· 736 736 target_rcode = PERR_IE_TARGET_RCODE(perr_elem); 737 737 738 738 rcu_read_lock(); 739 - mpath = mesh_path_lookup(target_addr, sdata); 739 + mpath = mesh_path_lookup(sdata, target_addr); 740 740 if (mpath) { 741 741 struct sta_info *sta; 742 742 ··· 751 751 spin_unlock_bh(&mpath->state_lock); 752 752 if (!ifmsh->mshcfg.dot11MeshForwarding) 753 753 goto endperr; 754 - mesh_path_error_tx(ttl, target_addr, cpu_to_le32(target_sn), 754 + mesh_path_error_tx(sdata, ttl, target_addr, 755 + cpu_to_le32(target_sn), 755 756 cpu_to_le16(target_rcode), 756 - broadcast_addr, sdata); 757 + broadcast_addr); 757 758 } else 758 759 spin_unlock_bh(&mpath->state_lock); 759 760 } ··· 802 801 803 802 metric_txsta = airtime_link_metric_get(local, sta); 804 803 805 - mpath = mesh_path_lookup(orig_addr, sdata); 804 + mpath = mesh_path_lookup(sdata, orig_addr); 806 805 if (!mpath) { 807 - mesh_path_add(orig_addr, sdata); 808 - mpath = mesh_path_lookup(orig_addr, sdata); 806 + mesh_path_add(sdata, orig_addr); 807 + mpath = mesh_path_lookup(sdata, orig_addr); 809 808 if (!mpath) { 810 809 rcu_read_unlock(); 811 810 sdata->u.mesh.mshstats.dropped_frames_no_route++; ··· 862 861 863 862 864 863 void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata, 865 - struct ieee80211_mgmt *mgmt, 866 - size_t len) 864 + struct ieee80211_mgmt *mgmt, size_t len) 867 865 { 868 866 struct ieee802_11_elems elems; 869 867 size_t baselen; ··· 1006 1006 spin_unlock_bh(&ifmsh->mesh_preq_queue_lock); 1007 1007 1008 1008 rcu_read_lock(); 1009 - mpath = mesh_path_lookup(preq_node->dst, sdata); 1009 + mpath = mesh_path_lookup(sdata, preq_node->dst); 1010 1010 if (!mpath) 1011 1011 goto enddiscovery; 1012 1012 ··· 1076 1076 * Returns: 0 if the next hop was found and -ENOENT if the frame was queued. 1077 1077 * skb is freeed here if no mpath could be allocated. 1078 1078 */ 1079 - int mesh_nexthop_resolve(struct sk_buff *skb, 1080 - struct ieee80211_sub_if_data *sdata) 1079 + int mesh_nexthop_resolve(struct ieee80211_sub_if_data *sdata, 1080 + struct sk_buff *skb) 1081 1081 { 1082 1082 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 1083 1083 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); ··· 1091 1091 return 0; 1092 1092 1093 1093 rcu_read_lock(); 1094 - err = mesh_nexthop_lookup(skb, sdata); 1094 + err = mesh_nexthop_lookup(sdata, skb); 1095 1095 if (!err) 1096 1096 goto endlookup; 1097 1097 1098 1098 /* no nexthop found, start resolving */ 1099 - mpath = mesh_path_lookup(target_addr, sdata); 1099 + mpath = mesh_path_lookup(sdata, target_addr); 1100 1100 if (!mpath) { 1101 - mesh_path_add(target_addr, sdata); 1102 - mpath = mesh_path_lookup(target_addr, sdata); 1101 + mesh_path_add(sdata, target_addr); 1102 + mpath = mesh_path_lookup(sdata, target_addr); 1103 1103 if (!mpath) { 1104 - mesh_path_discard_frame(skb, sdata); 1104 + mesh_path_discard_frame(sdata, skb); 1105 1105 err = -ENOSPC; 1106 1106 goto endlookup; 1107 1107 } ··· 1118 1118 skb_queue_tail(&mpath->frame_queue, skb); 1119 1119 err = -ENOENT; 1120 1120 if (skb_to_free) 1121 - mesh_path_discard_frame(skb_to_free, sdata); 1121 + mesh_path_discard_frame(sdata, skb_to_free); 1122 1122 1123 1123 endlookup: 1124 1124 rcu_read_unlock(); 1125 1125 return err; 1126 1126 } 1127 + 1127 1128 /** 1128 1129 * mesh_nexthop_lookup - put the appropriate next hop on a mesh frame. Calling 1129 1130 * this function is considered "using" the associated mpath, so preempt a path ··· 1135 1134 * 1136 1135 * Returns: 0 if the next hop was found. Nonzero otherwise. 1137 1136 */ 1138 - int mesh_nexthop_lookup(struct sk_buff *skb, 1139 - struct ieee80211_sub_if_data *sdata) 1137 + int mesh_nexthop_lookup(struct ieee80211_sub_if_data *sdata, 1138 + struct sk_buff *skb) 1140 1139 { 1141 1140 struct mesh_path *mpath; 1142 1141 struct sta_info *next_hop; ··· 1145 1144 int err = -ENOENT; 1146 1145 1147 1146 rcu_read_lock(); 1148 - mpath = mesh_path_lookup(target_addr, sdata); 1147 + mpath = mesh_path_lookup(sdata, target_addr); 1149 1148 1150 1149 if (!mpath || !(mpath->flags & MESH_PATH_ACTIVE)) 1151 1150 goto endlookup; ··· 1204 1203 } 1205 1204 } 1206 1205 1207 - void 1208 - mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata) 1206 + void mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata) 1209 1207 { 1210 1208 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 1211 1209 u32 interval = ifmsh->mshcfg.dot11MeshHWMPRannInterval;
+46 -43
net/mac80211/mesh_pathtbl.c
··· 24 24 /* Keep the mean chain length below this constant */ 25 25 #define MEAN_CHAIN_LEN 2 26 26 27 - #define MPATH_EXPIRED(mpath) ((mpath->flags & MESH_PATH_ACTIVE) && \ 28 - time_after(jiffies, mpath->exp_time) && \ 29 - !(mpath->flags & MESH_PATH_FIXED)) 27 + static inline bool mpath_expired(struct mesh_path *mpath) 28 + { 29 + return (mpath->flags & MESH_PATH_ACTIVE) && 30 + time_after(jiffies, mpath->exp_time) && 31 + !(mpath->flags & MESH_PATH_FIXED); 32 + } 30 33 31 34 struct mpath_node { 32 35 struct hlist_node list; ··· 188 185 struct mesh_table *tbl) 189 186 { 190 187 /* Use last four bytes of hw addr and interface index as hash index */ 191 - return jhash_2words(*(u32 *)(addr+2), sdata->dev->ifindex, tbl->hash_rnd) 192 - & tbl->hash_mask; 188 + return jhash_2words(*(u32 *)(addr+2), sdata->dev->ifindex, 189 + tbl->hash_rnd) & tbl->hash_mask; 193 190 } 194 191 195 192 ··· 342 339 mpath = node->mpath; 343 340 if (mpath->sdata == sdata && 344 341 ether_addr_equal(dst, mpath->dst)) { 345 - if (MPATH_EXPIRED(mpath)) { 342 + if (mpath_expired(mpath)) { 346 343 spin_lock_bh(&mpath->state_lock); 347 344 mpath->flags &= ~MESH_PATH_ACTIVE; 348 345 spin_unlock_bh(&mpath->state_lock); ··· 355 352 356 353 /** 357 354 * mesh_path_lookup - look up a path in the mesh path table 358 - * @dst: hardware address (ETH_ALEN length) of destination 359 355 * @sdata: local subif 356 + * @dst: hardware address (ETH_ALEN length) of destination 360 357 * 361 358 * Returns: pointer to the mesh path structure, or NULL if not found 362 359 * 363 360 * Locking: must be called within a read rcu section. 364 361 */ 365 - struct mesh_path *mesh_path_lookup(const u8 *dst, 366 - struct ieee80211_sub_if_data *sdata) 362 + struct mesh_path * 363 + mesh_path_lookup(struct ieee80211_sub_if_data *sdata, const u8 *dst) 367 364 { 368 365 return mpath_lookup(rcu_dereference(mesh_paths), dst, sdata); 369 366 } 370 367 371 - struct mesh_path *mpp_path_lookup(u8 *dst, struct ieee80211_sub_if_data *sdata) 368 + struct mesh_path * 369 + mpp_path_lookup(struct ieee80211_sub_if_data *sdata, const u8 *dst) 372 370 { 373 371 return mpath_lookup(rcu_dereference(mpp_paths), dst, sdata); 374 372 } ··· 384 380 * 385 381 * Locking: must be called within a read rcu section. 386 382 */ 387 - struct mesh_path *mesh_path_lookup_by_idx(int idx, struct ieee80211_sub_if_data *sdata) 383 + struct mesh_path * 384 + mesh_path_lookup_by_idx(struct ieee80211_sub_if_data *sdata, int idx) 388 385 { 389 386 struct mesh_table *tbl = rcu_dereference(mesh_paths); 390 387 struct mpath_node *node; ··· 397 392 if (sdata && node->mpath->sdata != sdata) 398 393 continue; 399 394 if (j++ == idx) { 400 - if (MPATH_EXPIRED(node->mpath)) { 395 + if (mpath_expired(node->mpath)) { 401 396 spin_lock_bh(&node->mpath->state_lock); 402 397 node->mpath->flags &= ~MESH_PATH_ACTIVE; 403 398 spin_unlock_bh(&node->mpath->state_lock); ··· 441 436 spin_lock_bh(&tbl->gates_lock); 442 437 hlist_add_head_rcu(&new_gate->list, tbl->known_gates); 443 438 spin_unlock_bh(&tbl->gates_lock); 444 - rcu_read_unlock(); 445 439 mpath_dbg(mpath->sdata, 446 440 "Mesh path: Recorded new gate: %pM. %d known gates\n", 447 441 mpath->dst, mpath->sdata->u.mesh.num_gates); 448 - return 0; 442 + err = 0; 449 443 err_rcu: 450 444 rcu_read_unlock(); 451 445 return err; ··· 455 451 * @tbl: table which holds our list of known gates 456 452 * @mpath: gate mpath 457 453 * 458 - * Returns: 0 on success 459 - * 460 454 * Locking: must be called inside rcu_read_lock() section 461 455 */ 462 - static int mesh_gate_del(struct mesh_table *tbl, struct mesh_path *mpath) 456 + static void mesh_gate_del(struct mesh_table *tbl, struct mesh_path *mpath) 463 457 { 464 458 struct mpath_node *gate; 465 459 struct hlist_node *p, *q; 466 460 467 - hlist_for_each_entry_safe(gate, p, q, tbl->known_gates, list) 468 - if (gate->mpath == mpath) { 469 - spin_lock_bh(&tbl->gates_lock); 470 - hlist_del_rcu(&gate->list); 471 - kfree_rcu(gate, rcu); 472 - spin_unlock_bh(&tbl->gates_lock); 473 - mpath->sdata->u.mesh.num_gates--; 474 - mpath->is_gate = false; 475 - mpath_dbg(mpath->sdata, 476 - "Mesh path: Deleted gate: %pM. %d known gates\n", 477 - mpath->dst, mpath->sdata->u.mesh.num_gates); 478 - break; 479 - } 480 - 481 - return 0; 461 + hlist_for_each_entry_safe(gate, p, q, tbl->known_gates, list) { 462 + if (gate->mpath != mpath) 463 + continue; 464 + spin_lock_bh(&tbl->gates_lock); 465 + hlist_del_rcu(&gate->list); 466 + kfree_rcu(gate, rcu); 467 + spin_unlock_bh(&tbl->gates_lock); 468 + mpath->sdata->u.mesh.num_gates--; 469 + mpath->is_gate = false; 470 + mpath_dbg(mpath->sdata, 471 + "Mesh path: Deleted gate: %pM. %d known gates\n", 472 + mpath->dst, mpath->sdata->u.mesh.num_gates); 473 + break; 474 + } 482 475 } 483 476 484 477 /** ··· 489 488 490 489 /** 491 490 * mesh_path_add - allocate and add a new path to the mesh path table 492 - * @addr: destination address of the path (ETH_ALEN length) 491 + * @dst: destination address of the path (ETH_ALEN length) 493 492 * @sdata: local subif 494 493 * 495 494 * Returns: 0 on success 496 495 * 497 496 * State: the initial state of the new path is set to 0 498 497 */ 499 - int mesh_path_add(const u8 *dst, struct ieee80211_sub_if_data *sdata) 498 + int mesh_path_add(struct ieee80211_sub_if_data *sdata, const u8 *dst) 500 499 { 501 500 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 502 501 struct ieee80211_local *local = sdata->local; ··· 631 630 write_unlock_bh(&pathtbl_resize_lock); 632 631 } 633 632 634 - int mpp_path_add(u8 *dst, u8 *mpp, struct ieee80211_sub_if_data *sdata) 633 + int mpp_path_add(struct ieee80211_sub_if_data *sdata, 634 + const u8 *dst, const u8 *mpp) 635 635 { 636 636 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 637 637 struct ieee80211_local *local = sdata->local; ··· 741 739 mpath->flags &= ~MESH_PATH_ACTIVE; 742 740 ++mpath->sn; 743 741 spin_unlock_bh(&mpath->state_lock); 744 - mesh_path_error_tx(sdata->u.mesh.mshcfg.element_ttl, 745 - mpath->dst, cpu_to_le32(mpath->sn), 746 - reason, bcast, sdata); 742 + mesh_path_error_tx(sdata, 743 + sdata->u.mesh.mshcfg.element_ttl, 744 + mpath->dst, cpu_to_le32(mpath->sn), 745 + reason, bcast); 747 746 } 748 747 } 749 748 rcu_read_unlock(); ··· 859 856 * 860 857 * Returns: 0 if successful 861 858 */ 862 - int mesh_path_del(u8 *addr, struct ieee80211_sub_if_data *sdata) 859 + int mesh_path_del(struct ieee80211_sub_if_data *sdata, const u8 *addr) 863 860 { 864 861 struct mesh_table *tbl; 865 862 struct mesh_path *mpath; ··· 968 965 * 969 966 * Locking: the function must me called within a rcu_read_lock region 970 967 */ 971 - void mesh_path_discard_frame(struct sk_buff *skb, 972 - struct ieee80211_sub_if_data *sdata) 968 + void mesh_path_discard_frame(struct ieee80211_sub_if_data *sdata, 969 + struct sk_buff *skb) 973 970 { 974 971 kfree_skb(skb); 975 972 sdata->u.mesh.mshstats.dropped_frames_no_route++; ··· 987 984 struct sk_buff *skb; 988 985 989 986 while ((skb = skb_dequeue(&mpath->frame_queue)) != NULL) 990 - mesh_path_discard_frame(skb, mpath->sdata); 987 + mesh_path_discard_frame(mpath->sdata, skb); 991 988 } 992 989 993 990 /** ··· 1108 1105 if ((!(mpath->flags & MESH_PATH_RESOLVING)) && 1109 1106 (!(mpath->flags & MESH_PATH_FIXED)) && 1110 1107 time_after(jiffies, mpath->exp_time + MESH_PATH_EXPIRE)) 1111 - mesh_path_del(mpath->dst, mpath->sdata); 1108 + mesh_path_del(mpath->sdata, mpath->dst); 1112 1109 } 1113 1110 rcu_read_unlock(); 1114 1111 }
+20 -16
net/mac80211/mesh_plink.c
··· 38 38 }; 39 39 40 40 static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata, 41 - enum ieee80211_self_protected_actioncode action, 42 - u8 *da, __le16 llid, __le16 plid, __le16 reason); 41 + enum ieee80211_self_protected_actioncode action, 42 + u8 *da, __le16 llid, __le16 plid, __le16 reason); 43 43 44 44 /** 45 45 * mesh_plink_fsm_restart - restart a mesh peer link finite state machine ··· 231 231 } 232 232 233 233 static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata, 234 - enum ieee80211_self_protected_actioncode action, 235 - u8 *da, __le16 llid, __le16 plid, __le16 reason) { 234 + enum ieee80211_self_protected_actioncode action, 235 + u8 *da, __le16 llid, __le16 plid, __le16 reason) 236 + { 236 237 struct ieee80211_local *local = sdata->local; 237 238 struct sk_buff *skb; 238 239 struct ieee80211_tx_info *info; ··· 284 283 } 285 284 if (ieee80211_add_srates_ie(sdata, skb, true, band) || 286 285 ieee80211_add_ext_srates_ie(sdata, skb, true, band) || 287 - mesh_add_rsn_ie(skb, sdata) || 288 - mesh_add_meshid_ie(skb, sdata) || 289 - mesh_add_meshconf_ie(skb, sdata)) 286 + mesh_add_rsn_ie(sdata, skb) || 287 + mesh_add_meshid_ie(sdata, skb) || 288 + mesh_add_meshconf_ie(sdata, skb)) 290 289 goto free; 291 290 } else { /* WLAN_SP_MESH_PEERING_CLOSE */ 292 291 info->flags |= IEEE80211_TX_CTL_NO_ACK; 293 - if (mesh_add_meshid_ie(skb, sdata)) 292 + if (mesh_add_meshid_ie(sdata, skb)) 294 293 goto free; 295 294 } 296 295 ··· 334 333 } 335 334 336 335 if (action != WLAN_SP_MESH_PEERING_CLOSE) { 337 - if (mesh_add_ht_cap_ie(skb, sdata) || 338 - mesh_add_ht_oper_ie(skb, sdata)) 336 + if (mesh_add_ht_cap_ie(sdata, skb) || 337 + mesh_add_ht_oper_ie(sdata, skb)) 339 338 goto free; 340 339 } 341 340 342 - if (mesh_add_vendor_ies(skb, sdata)) 341 + if (mesh_add_vendor_ies(sdata, skb)) 343 342 goto free; 344 343 345 344 ieee80211_tx_skb(sdata, skb); ··· 667 666 } 668 667 669 668 670 - void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_mgmt *mgmt, 671 - size_t len, struct ieee80211_rx_status *rx_status) 669 + void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, 670 + struct ieee80211_mgmt *mgmt, size_t len, 671 + struct ieee80211_rx_status *rx_status) 672 672 { 673 673 struct mesh_config *mshcfg = &sdata->u.mesh.mshcfg; 674 674 struct ieee802_11_elems elems; ··· 682 680 u8 *baseaddr; 683 681 u32 changed = 0; 684 682 __le16 plid, llid, reason; 685 - static const char *mplstates[] = { 683 + static const char * const mplstates[] = { 686 684 [NL80211_PLINK_LISTEN] = "LISTEN", 687 685 [NL80211_PLINK_OPN_SNT] = "OPN-SNT", 688 686 [NL80211_PLINK_OPN_RCVD] = "OPN-RCVD", ··· 710 708 baselen += 4; 711 709 } 712 710 ieee802_11_parse_elems(baseaddr, len - baselen, &elems); 711 + 713 712 if (!elems.peering) { 714 713 mpl_dbg(sdata, 715 714 "Mesh plink: missing necessary peer link ie\n"); 716 715 return; 717 716 } 717 + 718 718 if (elems.rsn_len && 719 - sdata->u.mesh.security == IEEE80211_MESH_SEC_NONE) { 719 + sdata->u.mesh.security == IEEE80211_MESH_SEC_NONE) { 720 720 mpl_dbg(sdata, 721 721 "Mesh plink: can't establish link with secure peer\n"); 722 722 return; ··· 737 733 } 738 734 739 735 if (ftype != WLAN_SP_MESH_PEERING_CLOSE && 740 - (!elems.mesh_id || !elems.mesh_config)) { 736 + (!elems.mesh_id || !elems.mesh_config)) { 741 737 mpl_dbg(sdata, "Mesh plink: missing necessary ie\n"); 742 738 return; 743 739 }
+16 -31
net/mac80211/mesh_sync.c
··· 43 43 static bool mesh_peer_tbtt_adjusting(struct ieee802_11_elems *ie) 44 44 { 45 45 return (ie->mesh_config->meshconf_cap & 46 - IEEE80211_MESHCONF_CAPAB_TBTT_ADJUSTING) != 0; 46 + IEEE80211_MESHCONF_CAPAB_TBTT_ADJUSTING) != 0; 47 47 } 48 48 49 49 void mesh_sync_adjust_tbtt(struct ieee80211_sub_if_data *sdata) ··· 112 112 113 113 if (elems->mesh_config && mesh_peer_tbtt_adjusting(elems)) { 114 114 clear_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN); 115 - msync_dbg(sdata, "STA %pM : is adjusting TBTT\n", sta->sta.addr); 115 + msync_dbg(sdata, "STA %pM : is adjusting TBTT\n", 116 + sta->sta.addr); 116 117 goto no_sync; 117 118 } 118 119 ··· 130 129 sta->t_offset = t_t - t_r; 131 130 132 131 if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) { 133 - s64 t_clockdrift = sta->t_offset_setpoint 134 - - sta->t_offset; 132 + s64 t_clockdrift = sta->t_offset_setpoint - sta->t_offset; 135 133 msync_dbg(sdata, 136 134 "STA %pM : sta->t_offset=%lld, sta->t_offset_setpoint=%lld, t_clockdrift=%lld\n", 137 - sta->sta.addr, 138 - (long long) sta->t_offset, 139 - (long long) 140 - sta->t_offset_setpoint, 135 + sta->sta.addr, (long long) sta->t_offset, 136 + (long long) sta->t_offset_setpoint, 141 137 (long long) t_clockdrift); 142 138 143 139 if (t_clockdrift > TOFFSET_MAXIMUM_ADJUSTMENT || 144 - t_clockdrift < -TOFFSET_MAXIMUM_ADJUSTMENT) { 140 + t_clockdrift < -TOFFSET_MAXIMUM_ADJUSTMENT) { 145 141 msync_dbg(sdata, 146 142 "STA %pM : t_clockdrift=%lld too large, setpoint reset\n", 147 143 sta->sta.addr, ··· 147 149 goto no_sync; 148 150 } 149 151 150 - rcu_read_unlock(); 151 - 152 152 spin_lock_bh(&ifmsh->sync_offset_lock); 153 - if (t_clockdrift > 154 - ifmsh->sync_offset_clockdrift_max) 155 - ifmsh->sync_offset_clockdrift_max 156 - = t_clockdrift; 153 + if (t_clockdrift > ifmsh->sync_offset_clockdrift_max) 154 + ifmsh->sync_offset_clockdrift_max = t_clockdrift; 157 155 spin_unlock_bh(&ifmsh->sync_offset_lock); 158 - 159 156 } else { 160 157 sta->t_offset_setpoint = sta->t_offset - TOFFSET_SET_MARGIN; 161 158 set_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN); ··· 158 165 "STA %pM : offset was invalid, sta->t_offset=%lld\n", 159 166 sta->sta.addr, 160 167 (long long) sta->t_offset); 161 - rcu_read_unlock(); 162 168 } 163 - return; 164 169 165 170 no_sync: 166 171 rcu_read_unlock(); ··· 168 177 { 169 178 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 170 179 171 - WARN_ON(ifmsh->mesh_sp_id 172 - != IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET); 180 + WARN_ON(ifmsh->mesh_sp_id != IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET); 173 181 BUG_ON(!rcu_read_lock_held()); 174 182 175 183 spin_lock_bh(&ifmsh->sync_offset_lock); 176 184 177 - if (ifmsh->sync_offset_clockdrift_max > 178 - TOFFSET_MINIMUM_ADJUSTMENT) { 185 + if (ifmsh->sync_offset_clockdrift_max > TOFFSET_MINIMUM_ADJUSTMENT) { 179 186 /* Since ajusting the tsf here would 180 187 * require a possibly blocking call 181 188 * to the driver tsf setter, we punt ··· 182 193 msync_dbg(sdata, 183 194 "TBTT : kicking off TBTT adjustment with clockdrift_max=%lld\n", 184 195 ifmsh->sync_offset_clockdrift_max); 185 - set_bit(MESH_WORK_DRIFT_ADJUST, 186 - &ifmsh->wrkq_flags); 196 + set_bit(MESH_WORK_DRIFT_ADJUST, &ifmsh->wrkq_flags); 187 197 188 198 ifmsh->adjusting_tbtt = true; 189 199 } else { ··· 208 220 209 221 const struct ieee80211_mesh_sync_ops *ieee80211_mesh_sync_ops_get(u8 method) 210 222 { 211 - const struct ieee80211_mesh_sync_ops *ops = NULL; 212 - u8 i; 223 + int i; 213 224 214 225 for (i = 0 ; i < ARRAY_SIZE(sync_methods); ++i) { 215 - if (sync_methods[i].method == method) { 216 - ops = &sync_methods[i].ops; 217 - break; 218 - } 226 + if (sync_methods[i].method == method) 227 + return &sync_methods[i].ops; 219 228 } 220 - return ops; 229 + return NULL; 221 230 }
+6 -6
net/mac80211/rx.c
··· 2027 2027 /* frame is in RMC, don't forward */ 2028 2028 if (ieee80211_is_data(hdr->frame_control) && 2029 2029 is_multicast_ether_addr(hdr->addr1) && 2030 - mesh_rmc_check(hdr->addr3, mesh_hdr, rx->sdata)) 2030 + mesh_rmc_check(rx->sdata, hdr->addr3, mesh_hdr)) 2031 2031 return RX_DROP_MONITOR; 2032 2032 2033 2033 if (!ieee80211_is_data(hdr->frame_control) || ··· 2054 2054 } 2055 2055 2056 2056 rcu_read_lock(); 2057 - mppath = mpp_path_lookup(proxied_addr, sdata); 2057 + mppath = mpp_path_lookup(sdata, proxied_addr); 2058 2058 if (!mppath) { 2059 - mpp_path_add(proxied_addr, mpp_addr, sdata); 2059 + mpp_path_add(sdata, proxied_addr, mpp_addr); 2060 2060 } else { 2061 2061 spin_lock_bh(&mppath->state_lock); 2062 2062 if (!ether_addr_equal(mppath->mpp, mpp_addr)) ··· 2104 2104 memcpy(fwd_hdr->addr2, sdata->vif.addr, ETH_ALEN); 2105 2105 /* update power mode indication when forwarding */ 2106 2106 ieee80211_mps_set_frame_flags(sdata, NULL, fwd_hdr); 2107 - } else if (!mesh_nexthop_lookup(fwd_skb, sdata)) { 2107 + } else if (!mesh_nexthop_lookup(sdata, fwd_skb)) { 2108 2108 /* mesh power mode flags updated in mesh_nexthop_lookup */ 2109 2109 IEEE80211_IFSTA_MESH_CTR_INC(ifmsh, fwded_unicast); 2110 2110 } else { 2111 2111 /* unable to resolve next hop */ 2112 - mesh_path_error_tx(ifmsh->mshcfg.element_ttl, fwd_hdr->addr3, 2113 - 0, reason, fwd_hdr->addr2, sdata); 2112 + mesh_path_error_tx(sdata, ifmsh->mshcfg.element_ttl, 2113 + fwd_hdr->addr3, 0, reason, fwd_hdr->addr2); 2114 2114 IEEE80211_IFSTA_MESH_CTR_INC(ifmsh, dropped_frames_no_route); 2115 2115 kfree_skb(fwd_skb); 2116 2116 return RX_DROP_MONITOR;
+11 -15
net/mac80211/tx.c
··· 1495 1495 if (ieee80211_vif_is_mesh(&sdata->vif)) { 1496 1496 if (ieee80211_is_data(hdr->frame_control) && 1497 1497 is_unicast_ether_addr(hdr->addr1)) { 1498 - if (mesh_nexthop_resolve(skb, sdata)) 1498 + if (mesh_nexthop_resolve(sdata, skb)) 1499 1499 return; /* skb queued: don't free */ 1500 1500 } else { 1501 1501 ieee80211_mps_set_frame_flags(sdata, NULL, hdr); ··· 1844 1844 } 1845 1845 1846 1846 if (!is_multicast_ether_addr(skb->data)) { 1847 - mpath = mesh_path_lookup(skb->data, sdata); 1847 + mpath = mesh_path_lookup(sdata, skb->data); 1848 1848 if (!mpath) 1849 - mppath = mpp_path_lookup(skb->data, sdata); 1849 + mppath = mpp_path_lookup(sdata, skb->data); 1850 1850 } 1851 1851 1852 1852 /* ··· 1859 1859 !(mppath && !ether_addr_equal(mppath->mpp, skb->data))) { 1860 1860 hdrlen = ieee80211_fill_mesh_addresses(&hdr, &fc, 1861 1861 skb->data, skb->data + ETH_ALEN); 1862 - meshhdrlen = ieee80211_new_mesh_header(&mesh_hdr, 1863 - sdata, NULL, NULL); 1862 + meshhdrlen = ieee80211_new_mesh_header(sdata, &mesh_hdr, 1863 + NULL, NULL); 1864 1864 } else { 1865 1865 /* DS -> MBSS (802.11-2012 13.11.3.3). 1866 1866 * For unicast with unknown forwarding information, ··· 1879 1879 mesh_da, sdata->vif.addr); 1880 1880 if (is_multicast_ether_addr(mesh_da)) 1881 1881 /* DA TA mSA AE:SA */ 1882 - meshhdrlen = 1883 - ieee80211_new_mesh_header(&mesh_hdr, 1884 - sdata, 1885 - skb->data + ETH_ALEN, 1886 - NULL); 1882 + meshhdrlen = ieee80211_new_mesh_header( 1883 + sdata, &mesh_hdr, 1884 + skb->data + ETH_ALEN, NULL); 1887 1885 else 1888 1886 /* RA TA mDA mSA AE:DA SA */ 1889 - meshhdrlen = 1890 - ieee80211_new_mesh_header(&mesh_hdr, 1891 - sdata, 1892 - skb->data, 1893 - skb->data + ETH_ALEN); 1887 + meshhdrlen = ieee80211_new_mesh_header( 1888 + sdata, &mesh_hdr, skb->data, 1889 + skb->data + ETH_ALEN); 1894 1890 1895 1891 } 1896 1892 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);