.. | .. |
---|
47 | 47 | mesh_path_free_rcu(tbl, mpath); |
---|
48 | 48 | } |
---|
49 | 49 | |
---|
50 | | -static struct mesh_table *mesh_table_alloc(void) |
---|
| 50 | +static void mesh_table_init(struct mesh_table *tbl) |
---|
51 | 51 | { |
---|
52 | | - struct mesh_table *newtbl; |
---|
| 52 | + INIT_HLIST_HEAD(&tbl->known_gates); |
---|
| 53 | + INIT_HLIST_HEAD(&tbl->walk_head); |
---|
| 54 | + atomic_set(&tbl->entries, 0); |
---|
| 55 | + spin_lock_init(&tbl->gates_lock); |
---|
| 56 | + spin_lock_init(&tbl->walk_lock); |
---|
53 | 57 | |
---|
54 | | - newtbl = kmalloc(sizeof(struct mesh_table), GFP_ATOMIC); |
---|
55 | | - if (!newtbl) |
---|
56 | | - return NULL; |
---|
57 | | - |
---|
58 | | - INIT_HLIST_HEAD(&newtbl->known_gates); |
---|
59 | | - INIT_HLIST_HEAD(&newtbl->walk_head); |
---|
60 | | - atomic_set(&newtbl->entries, 0); |
---|
61 | | - spin_lock_init(&newtbl->gates_lock); |
---|
62 | | - spin_lock_init(&newtbl->walk_lock); |
---|
63 | | - if (rhashtable_init(&newtbl->rhead, &mesh_rht_params)) { |
---|
64 | | - kfree(newtbl); |
---|
65 | | - return NULL; |
---|
66 | | - } |
---|
67 | | - |
---|
68 | | - return newtbl; |
---|
| 58 | + /* rhashtable_init() may fail only in case of wrong |
---|
| 59 | + * mesh_rht_params |
---|
| 60 | + */ |
---|
| 61 | + WARN_ON(rhashtable_init(&tbl->rhead, &mesh_rht_params)); |
---|
69 | 62 | } |
---|
70 | 63 | |
---|
71 | 64 | static void mesh_table_free(struct mesh_table *tbl) |
---|
72 | 65 | { |
---|
73 | 66 | rhashtable_free_and_destroy(&tbl->rhead, |
---|
74 | 67 | mesh_path_rht_free, tbl); |
---|
75 | | - kfree(tbl); |
---|
76 | 68 | } |
---|
77 | 69 | |
---|
78 | 70 | /** |
---|
.. | .. |
---|
238 | 230 | struct mesh_path * |
---|
239 | 231 | mesh_path_lookup(struct ieee80211_sub_if_data *sdata, const u8 *dst) |
---|
240 | 232 | { |
---|
241 | | - return mpath_lookup(sdata->u.mesh.mesh_paths, dst, sdata); |
---|
| 233 | + return mpath_lookup(&sdata->u.mesh.mesh_paths, dst, sdata); |
---|
242 | 234 | } |
---|
243 | 235 | |
---|
244 | 236 | struct mesh_path * |
---|
245 | 237 | mpp_path_lookup(struct ieee80211_sub_if_data *sdata, const u8 *dst) |
---|
246 | 238 | { |
---|
247 | | - return mpath_lookup(sdata->u.mesh.mpp_paths, dst, sdata); |
---|
| 239 | + return mpath_lookup(&sdata->u.mesh.mpp_paths, dst, sdata); |
---|
248 | 240 | } |
---|
249 | 241 | |
---|
250 | 242 | static struct mesh_path * |
---|
.. | .. |
---|
281 | 273 | struct mesh_path * |
---|
282 | 274 | mesh_path_lookup_by_idx(struct ieee80211_sub_if_data *sdata, int idx) |
---|
283 | 275 | { |
---|
284 | | - return __mesh_path_lookup_by_idx(sdata->u.mesh.mesh_paths, idx); |
---|
| 276 | + return __mesh_path_lookup_by_idx(&sdata->u.mesh.mesh_paths, idx); |
---|
285 | 277 | } |
---|
286 | 278 | |
---|
287 | 279 | /** |
---|
.. | .. |
---|
296 | 288 | struct mesh_path * |
---|
297 | 289 | mpp_path_lookup_by_idx(struct ieee80211_sub_if_data *sdata, int idx) |
---|
298 | 290 | { |
---|
299 | | - return __mesh_path_lookup_by_idx(sdata->u.mesh.mpp_paths, idx); |
---|
| 291 | + return __mesh_path_lookup_by_idx(&sdata->u.mesh.mpp_paths, idx); |
---|
300 | 292 | } |
---|
301 | 293 | |
---|
302 | 294 | /** |
---|
.. | .. |
---|
309 | 301 | int err; |
---|
310 | 302 | |
---|
311 | 303 | rcu_read_lock(); |
---|
312 | | - tbl = mpath->sdata->u.mesh.mesh_paths; |
---|
| 304 | + tbl = &mpath->sdata->u.mesh.mesh_paths; |
---|
313 | 305 | |
---|
314 | 306 | spin_lock_bh(&mpath->state_lock); |
---|
315 | 307 | if (mpath->is_gate) { |
---|
.. | .. |
---|
418 | 410 | if (!new_mpath) |
---|
419 | 411 | return ERR_PTR(-ENOMEM); |
---|
420 | 412 | |
---|
421 | | - tbl = sdata->u.mesh.mesh_paths; |
---|
| 413 | + tbl = &sdata->u.mesh.mesh_paths; |
---|
422 | 414 | spin_lock_bh(&tbl->walk_lock); |
---|
423 | 415 | mpath = rhashtable_lookup_get_insert_fast(&tbl->rhead, |
---|
424 | 416 | &new_mpath->rhash, |
---|
.. | .. |
---|
460 | 452 | return -ENOMEM; |
---|
461 | 453 | |
---|
462 | 454 | memcpy(new_mpath->mpp, mpp, ETH_ALEN); |
---|
463 | | - tbl = sdata->u.mesh.mpp_paths; |
---|
| 455 | + tbl = &sdata->u.mesh.mpp_paths; |
---|
464 | 456 | |
---|
465 | 457 | spin_lock_bh(&tbl->walk_lock); |
---|
466 | 458 | ret = rhashtable_lookup_insert_fast(&tbl->rhead, |
---|
.. | .. |
---|
489 | 481 | void mesh_plink_broken(struct sta_info *sta) |
---|
490 | 482 | { |
---|
491 | 483 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
---|
492 | | - struct mesh_table *tbl = sdata->u.mesh.mesh_paths; |
---|
| 484 | + struct mesh_table *tbl = &sdata->u.mesh.mesh_paths; |
---|
493 | 485 | static const u8 bcast[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
---|
494 | 486 | struct mesh_path *mpath; |
---|
495 | 487 | |
---|
.. | .. |
---|
548 | 540 | void mesh_path_flush_by_nexthop(struct sta_info *sta) |
---|
549 | 541 | { |
---|
550 | 542 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
---|
551 | | - struct mesh_table *tbl = sdata->u.mesh.mesh_paths; |
---|
| 543 | + struct mesh_table *tbl = &sdata->u.mesh.mesh_paths; |
---|
552 | 544 | struct mesh_path *mpath; |
---|
553 | 545 | struct hlist_node *n; |
---|
554 | 546 | |
---|
.. | .. |
---|
563 | 555 | static void mpp_flush_by_proxy(struct ieee80211_sub_if_data *sdata, |
---|
564 | 556 | const u8 *proxy) |
---|
565 | 557 | { |
---|
566 | | - struct mesh_table *tbl = sdata->u.mesh.mpp_paths; |
---|
| 558 | + struct mesh_table *tbl = &sdata->u.mesh.mpp_paths; |
---|
567 | 559 | struct mesh_path *mpath; |
---|
568 | 560 | struct hlist_node *n; |
---|
569 | 561 | |
---|
.. | .. |
---|
597 | 589 | */ |
---|
598 | 590 | void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata) |
---|
599 | 591 | { |
---|
600 | | - table_flush_by_iface(sdata->u.mesh.mesh_paths); |
---|
601 | | - table_flush_by_iface(sdata->u.mesh.mpp_paths); |
---|
| 592 | + table_flush_by_iface(&sdata->u.mesh.mesh_paths); |
---|
| 593 | + table_flush_by_iface(&sdata->u.mesh.mpp_paths); |
---|
602 | 594 | } |
---|
603 | 595 | |
---|
604 | 596 | /** |
---|
.. | .. |
---|
644 | 636 | /* flush relevant mpp entries first */ |
---|
645 | 637 | mpp_flush_by_proxy(sdata, addr); |
---|
646 | 638 | |
---|
647 | | - err = table_path_del(sdata->u.mesh.mesh_paths, sdata, addr); |
---|
| 639 | + err = table_path_del(&sdata->u.mesh.mesh_paths, sdata, addr); |
---|
648 | 640 | sdata->u.mesh.mesh_paths_generation++; |
---|
649 | 641 | return err; |
---|
650 | 642 | } |
---|
.. | .. |
---|
682 | 674 | struct mesh_path *gate; |
---|
683 | 675 | bool copy = false; |
---|
684 | 676 | |
---|
685 | | - tbl = sdata->u.mesh.mesh_paths; |
---|
| 677 | + tbl = &sdata->u.mesh.mesh_paths; |
---|
686 | 678 | |
---|
687 | 679 | rcu_read_lock(); |
---|
688 | 680 | hlist_for_each_entry_rcu(gate, &tbl->known_gates, gate_list) { |
---|
.. | .. |
---|
762 | 754 | mesh_path_tx_pending(mpath); |
---|
763 | 755 | } |
---|
764 | 756 | |
---|
765 | | -int mesh_pathtbl_init(struct ieee80211_sub_if_data *sdata) |
---|
| 757 | +void mesh_pathtbl_init(struct ieee80211_sub_if_data *sdata) |
---|
766 | 758 | { |
---|
767 | | - struct mesh_table *tbl_path, *tbl_mpp; |
---|
768 | | - int ret; |
---|
769 | | - |
---|
770 | | - tbl_path = mesh_table_alloc(); |
---|
771 | | - if (!tbl_path) |
---|
772 | | - return -ENOMEM; |
---|
773 | | - |
---|
774 | | - tbl_mpp = mesh_table_alloc(); |
---|
775 | | - if (!tbl_mpp) { |
---|
776 | | - ret = -ENOMEM; |
---|
777 | | - goto free_path; |
---|
778 | | - } |
---|
779 | | - |
---|
780 | | - sdata->u.mesh.mesh_paths = tbl_path; |
---|
781 | | - sdata->u.mesh.mpp_paths = tbl_mpp; |
---|
782 | | - |
---|
783 | | - return 0; |
---|
784 | | - |
---|
785 | | -free_path: |
---|
786 | | - mesh_table_free(tbl_path); |
---|
787 | | - return ret; |
---|
| 759 | + mesh_table_init(&sdata->u.mesh.mesh_paths); |
---|
| 760 | + mesh_table_init(&sdata->u.mesh.mpp_paths); |
---|
788 | 761 | } |
---|
789 | 762 | |
---|
790 | 763 | static |
---|
.. | .. |
---|
806 | 779 | |
---|
807 | 780 | void mesh_path_expire(struct ieee80211_sub_if_data *sdata) |
---|
808 | 781 | { |
---|
809 | | - mesh_path_tbl_expire(sdata, sdata->u.mesh.mesh_paths); |
---|
810 | | - mesh_path_tbl_expire(sdata, sdata->u.mesh.mpp_paths); |
---|
| 782 | + mesh_path_tbl_expire(sdata, &sdata->u.mesh.mesh_paths); |
---|
| 783 | + mesh_path_tbl_expire(sdata, &sdata->u.mesh.mpp_paths); |
---|
811 | 784 | } |
---|
812 | 785 | |
---|
813 | 786 | void mesh_pathtbl_unregister(struct ieee80211_sub_if_data *sdata) |
---|
814 | 787 | { |
---|
815 | | - mesh_table_free(sdata->u.mesh.mesh_paths); |
---|
816 | | - mesh_table_free(sdata->u.mesh.mpp_paths); |
---|
| 788 | + mesh_table_free(&sdata->u.mesh.mesh_paths); |
---|
| 789 | + mesh_table_free(&sdata->u.mesh.mpp_paths); |
---|
817 | 790 | } |
---|