From f89c56f5dafc295759205abca0d8eca269035828 Mon Sep 17 00:00:00 2001 From: Ksawlii Date: Sun, 24 Nov 2024 00:23:47 +0100 Subject: [PATCH] Revert "wifi: cfg80211: make hash table duplicates more survivable" This reverts commit 7f8f7aa2eb1df53bef293b7f6ddbe24558f3c8a1. --- net/wireless/scan.c | 46 ++++++++++++--------------------------------- 1 file changed, 12 insertions(+), 34 deletions(-) diff --git a/net/wireless/scan.c b/net/wireless/scan.c index 95000853e..dfa1680ac 100755 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -1510,7 +1510,7 @@ struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy, } EXPORT_SYMBOL(cfg80211_get_bss); -static bool rb_insert_bss(struct cfg80211_registered_device *rdev, +static void rb_insert_bss(struct cfg80211_registered_device *rdev, struct cfg80211_internal_bss *bss) { struct rb_node **p = &rdev->bss_tree.rb_node; @@ -1526,7 +1526,7 @@ static bool rb_insert_bss(struct cfg80211_registered_device *rdev, if (WARN_ON(!cmp)) { /* will sort of leak this BSS */ - return false; + return; } if (cmp < 0) @@ -1537,7 +1537,6 @@ static bool rb_insert_bss(struct cfg80211_registered_device *rdev, rb_link_node(&bss->rbn, parent, p); rb_insert_color(&bss->rbn, &rdev->bss_tree); - return true; } static struct cfg80211_internal_bss * @@ -1564,34 +1563,6 @@ rb_find_bss(struct cfg80211_registered_device *rdev, return NULL; } -static void cfg80211_insert_bss(struct cfg80211_registered_device *rdev, - struct cfg80211_internal_bss *bss) -{ - lockdep_assert_held(&rdev->bss_lock); - - if (!rb_insert_bss(rdev, bss)) - return; - list_add_tail(&bss->list, &rdev->bss_list); - rdev->bss_entries++; -} - -static void cfg80211_rehash_bss(struct cfg80211_registered_device *rdev, - struct cfg80211_internal_bss *bss) -{ - lockdep_assert_held(&rdev->bss_lock); - - rb_erase(&bss->rbn, &rdev->bss_tree); - if (!rb_insert_bss(rdev, bss)) { - list_del(&bss->list); - if (!list_empty(&bss->hidden_list)) - list_del_init(&bss->hidden_list); - if (!list_empty(&bss->pub.nontrans_list)) - list_del_init(&bss->pub.nontrans_list); - rdev->bss_entries--; - } - rdev->bss_generation++; -} - static bool cfg80211_combine_bsses(struct cfg80211_registered_device *rdev, struct cfg80211_internal_bss *new) { @@ -1866,7 +1837,9 @@ cfg80211_bss_update(struct cfg80211_registered_device *rdev, bss_ref_get(rdev, pbss); } - cfg80211_insert_bss(rdev, new); + list_add_tail(&new->list, &rdev->bss_list); + rdev->bss_entries++; + rb_insert_bss(rdev, new); found = new; } @@ -2728,7 +2701,10 @@ void cfg80211_update_assoc_bss_entry(struct wireless_dev *wdev, if (!WARN_ON(!__cfg80211_unlink_bss(rdev, new))) rdev->bss_generation++; } - cfg80211_rehash_bss(rdev, cbss); + + rb_erase(&cbss->rbn, &rdev->bss_tree); + rb_insert_bss(rdev, cbss); + rdev->bss_generation++; list_for_each_entry_safe(nontrans_bss, tmp, &cbss->pub.nontrans_list, @@ -2736,7 +2712,9 @@ void cfg80211_update_assoc_bss_entry(struct wireless_dev *wdev, bss = container_of(nontrans_bss, struct cfg80211_internal_bss, pub); bss->pub.channel = chan; - cfg80211_rehash_bss(rdev, bss); + rb_erase(&bss->rbn, &rdev->bss_tree); + rb_insert_bss(rdev, bss); + rdev->bss_generation++; } done: