diff options
author | Javier Cardona <javier@cozybit.com> | 2011-08-29 16:23:08 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-09-13 15:42:33 -0400 |
commit | cd72e817480bd3a1d2cdf03b65a1f3920c1c88a0 (patch) | |
tree | 29e58b9aaea480515d944a0ad3b090c9b6c1933b /net/mac80211/mesh_pathtbl.c | |
parent | 19c50b3dc530278a0d07dceebff1683f3bdc4a2b (diff) |
mac80211: Consolidate {mesh,mpp}_path_flush into one function
Signed-off-by: Javier Cardona <javier@cozybit.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/mesh_pathtbl.c')
-rw-r--r-- | net/mac80211/mesh_pathtbl.c | 65 |
1 files changed, 26 insertions, 39 deletions
diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c index 4a3053b09e31..7797f55eec46 100644 --- a/net/mac80211/mesh_pathtbl.c +++ b/net/mac80211/mesh_pathtbl.c | |||
@@ -790,35 +790,6 @@ void mesh_plink_broken(struct sta_info *sta) | |||
790 | rcu_read_unlock(); | 790 | rcu_read_unlock(); |
791 | } | 791 | } |
792 | 792 | ||
793 | /** | ||
794 | * mesh_path_flush_by_nexthop - Deletes mesh paths if their next hop matches | ||
795 | * | ||
796 | * @sta - mesh peer to match | ||
797 | * | ||
798 | * RCU notes: this function is called when a mesh plink transitions from | ||
799 | * PLINK_ESTAB to any other state, since PLINK_ESTAB state is the only one that | ||
800 | * allows path creation. This will happen before the sta can be freed (because | ||
801 | * sta_info_destroy() calls this) so any reader in a rcu read block will be | ||
802 | * protected against the plink disappearing. | ||
803 | */ | ||
804 | void mesh_path_flush_by_nexthop(struct sta_info *sta) | ||
805 | { | ||
806 | struct mesh_table *tbl; | ||
807 | struct mesh_path *mpath; | ||
808 | struct mpath_node *node; | ||
809 | struct hlist_node *p; | ||
810 | int i; | ||
811 | |||
812 | rcu_read_lock(); | ||
813 | tbl = rcu_dereference(mesh_paths); | ||
814 | for_each_mesh_entry(tbl, p, node, i) { | ||
815 | mpath = node->mpath; | ||
816 | if (rcu_dereference(mpath->next_hop) == sta) | ||
817 | mesh_path_del(mpath->dst, mpath->sdata); | ||
818 | } | ||
819 | rcu_read_unlock(); | ||
820 | } | ||
821 | |||
822 | static void mesh_path_node_reclaim(struct rcu_head *rp) | 793 | static void mesh_path_node_reclaim(struct rcu_head *rp) |
823 | { | 794 | { |
824 | struct mpath_node *node = container_of(rp, struct mpath_node, rcu); | 795 | struct mpath_node *node = container_of(rp, struct mpath_node, rcu); |
@@ -845,7 +816,18 @@ static void __mesh_path_del(struct mesh_table *tbl, struct mpath_node *node) | |||
845 | atomic_dec(&tbl->entries); | 816 | atomic_dec(&tbl->entries); |
846 | } | 817 | } |
847 | 818 | ||
848 | static void mesh_path_flush(struct ieee80211_sub_if_data *sdata) | 819 | /** |
820 | * mesh_path_flush_by_nexthop - Deletes mesh paths if their next hop matches | ||
821 | * | ||
822 | * @sta - mesh peer to match | ||
823 | * | ||
824 | * RCU notes: this function is called when a mesh plink transitions from | ||
825 | * PLINK_ESTAB to any other state, since PLINK_ESTAB state is the only one that | ||
826 | * allows path creation. This will happen before the sta can be freed (because | ||
827 | * sta_info_destroy() calls this) so any reader in a rcu read block will be | ||
828 | * protected against the plink disappearing. | ||
829 | */ | ||
830 | void mesh_path_flush_by_nexthop(struct sta_info *sta) | ||
849 | { | 831 | { |
850 | struct mesh_table *tbl; | 832 | struct mesh_table *tbl; |
851 | struct mesh_path *mpath; | 833 | struct mesh_path *mpath; |
@@ -857,7 +839,7 @@ static void mesh_path_flush(struct ieee80211_sub_if_data *sdata) | |||
857 | tbl = rcu_dereference(mesh_paths); | 839 | tbl = rcu_dereference(mesh_paths); |
858 | for_each_mesh_entry(tbl, p, node, i) { | 840 | for_each_mesh_entry(tbl, p, node, i) { |
859 | mpath = node->mpath; | 841 | mpath = node->mpath; |
860 | if (mpath->sdata == sdata) { | 842 | if (rcu_dereference(mpath->next_hop) == sta) { |
861 | spin_lock_bh(&tbl->hashwlock[i]); | 843 | spin_lock_bh(&tbl->hashwlock[i]); |
862 | __mesh_path_del(tbl, node); | 844 | __mesh_path_del(tbl, node); |
863 | spin_unlock_bh(&tbl->hashwlock[i]); | 845 | spin_unlock_bh(&tbl->hashwlock[i]); |
@@ -866,24 +848,23 @@ static void mesh_path_flush(struct ieee80211_sub_if_data *sdata) | |||
866 | rcu_read_unlock(); | 848 | rcu_read_unlock(); |
867 | } | 849 | } |
868 | 850 | ||
869 | static void mpp_path_flush(struct ieee80211_sub_if_data *sdata) | 851 | static void table_flush_by_iface(struct mesh_table *tbl, |
852 | struct ieee80211_sub_if_data *sdata) | ||
870 | { | 853 | { |
871 | struct mesh_table *tbl; | ||
872 | struct mesh_path *mpath; | 854 | struct mesh_path *mpath; |
873 | struct mpath_node *node; | 855 | struct mpath_node *node; |
874 | struct hlist_node *p; | 856 | struct hlist_node *p; |
875 | int i; | 857 | int i; |
876 | 858 | ||
877 | read_lock_bh(&pathtbl_resize_lock); | 859 | WARN_ON(!rcu_read_lock_held()); |
878 | tbl = rcu_dereference_protected(mpp_paths, | ||
879 | lockdep_is_held(pathtbl_resize_lock)); | ||
880 | for_each_mesh_entry(tbl, p, node, i) { | 860 | for_each_mesh_entry(tbl, p, node, i) { |
881 | mpath = node->mpath; | 861 | mpath = node->mpath; |
862 | if (mpath->sdata != sdata) | ||
863 | continue; | ||
882 | spin_lock_bh(&tbl->hashwlock[i]); | 864 | spin_lock_bh(&tbl->hashwlock[i]); |
883 | __mesh_path_del(tbl, node); | 865 | __mesh_path_del(tbl, node); |
884 | spin_unlock_bh(&tbl->hashwlock[i]); | 866 | spin_unlock_bh(&tbl->hashwlock[i]); |
885 | } | 867 | } |
886 | read_unlock_bh(&pathtbl_resize_lock); | ||
887 | } | 868 | } |
888 | 869 | ||
889 | /** | 870 | /** |
@@ -896,8 +877,14 @@ static void mpp_path_flush(struct ieee80211_sub_if_data *sdata) | |||
896 | */ | 877 | */ |
897 | void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata) | 878 | void mesh_path_flush_by_iface(struct ieee80211_sub_if_data *sdata) |
898 | { | 879 | { |
899 | mesh_path_flush(sdata); | 880 | struct mesh_table *tbl; |
900 | mpp_path_flush(sdata); | 881 | |
882 | rcu_read_lock(); | ||
883 | tbl = rcu_dereference(mesh_paths); | ||
884 | table_flush_by_iface(tbl, sdata); | ||
885 | tbl = rcu_dereference(mpp_paths); | ||
886 | table_flush_by_iface(tbl, sdata); | ||
887 | rcu_read_unlock(); | ||
901 | } | 888 | } |
902 | 889 | ||
903 | /** | 890 | /** |