From patchwork Thu Apr 23 12:26:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 6262041 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 056FEBF4A6 for ; Thu, 23 Apr 2015 12:26:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D58ED2038C for ; Thu, 23 Apr 2015 12:26:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D28AD20380 for ; Thu, 23 Apr 2015 12:26:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934402AbbDWM0X (ORCPT ); Thu, 23 Apr 2015 08:26:23 -0400 Received: from s3.sipsolutions.net ([5.9.151.49]:33987 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934298AbbDWM0V (ORCPT ); Thu, 23 Apr 2015 08:26:21 -0400 Received: by sipsolutions.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA256:128) (Exim 4.84) (envelope-from ) id 1YlGCu-0002BI-Ei; Thu, 23 Apr 2015 14:26:16 +0200 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg Subject: [PATCH] mac80211: fix rhashtable conversion Date: Thu, 23 Apr 2015 14:26:09 +0200 Message-Id: <1429791969-16194-1-git-send-email-johannes@sipsolutions.net> X-Mailer: git-send-email 2.1.4 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Johannes Berg My conversion of the mac80211 station hash table to rhashtable completely broke the lookup in two ways: 1) sta_info_get() no longer took into account the virtual interface 2) sta_info_get_bss() no longer compared the MAC address Fix both these issues. Fixes: 7bedd0cfad4e1 ("mac80211: use rhashtable for station table") Signed-off-by: Johannes Berg --- net/mac80211/sta_info.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index 737730abba6d..75d71f9f9435 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -157,8 +157,25 @@ struct sta_info *sta_info_get(struct ieee80211_sub_if_data *sdata, const u8 *addr) { struct ieee80211_local *local = sdata->local; + struct sta_info *sta; + struct rhash_head *tmp; + const struct bucket_table *tbl; + + rcu_read_lock(); + tbl = rht_dereference_rcu(local->sta_hash.tbl, &local->sta_hash); - return rhashtable_lookup_fast(&local->sta_hash, addr, sta_rht_params); + for_each_sta_info(local, tbl, addr, sta, tmp) { + if (ether_addr_equal(sta->sta.addr, addr) && + sta->sdata == sdata) { + rcu_read_unlock(); + /* this is safe as the caller must already hold + * another rcu read section or the mutex + */ + return sta; + } + } + rcu_read_unlock(); + return NULL; } /* @@ -177,8 +194,9 @@ struct sta_info *sta_info_get_bss(struct ieee80211_sub_if_data *sdata, tbl = rht_dereference_rcu(local->sta_hash.tbl, &local->sta_hash); for_each_sta_info(local, tbl, addr, sta, tmp) { - if (sta->sdata == sdata || - (sta->sdata->bss && sta->sdata->bss == sdata->bss)) { + if (ether_addr_equal(sta->sta.addr, addr) && + (sta->sdata == sdata || + (sta->sdata->bss && sta->sdata->bss == sdata->bss))) { rcu_read_unlock(); /* this is safe as the caller must already hold * another rcu read section or the mutex