From patchwork Tue Jun 21 22:26:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bob Copeland X-Patchwork-Id: 9191495 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 385466075A for ; Tue, 21 Jun 2016 22:27:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27ECB281DB for ; Tue, 21 Jun 2016 22:27:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C8E828319; Tue, 21 Jun 2016 22:27:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0DB9728324 for ; Tue, 21 Jun 2016 22:27:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752049AbcFUW1M (ORCPT ); Tue, 21 Jun 2016 18:27:12 -0400 Received: from mail-io0-f193.google.com ([209.85.223.193]:36540 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751099AbcFUW0x (ORCPT ); Tue, 21 Jun 2016 18:26:53 -0400 Received: by mail-io0-f193.google.com with SMTP id s63so4411406ioi.3 for ; Tue, 21 Jun 2016 15:26:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bobcopeland-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=4+0qYitXSHSx3NIiybbP8TqOxStEhxaaT0pX6I+fpPw=; b=ZCSvzNFh6PfGo2/bR1TcmWJTe9BY4Bulh4AihHgypGH7UNBhUbgj2Ry4//KBbPfs+U XusXg1/C96/t4knmYGwqUohnLx1OtM5Ytda5ekq3Yt7X5eAdg+npQOpsILRfMZlHwlQq Lgc1GExD/PXpMB5wu661yUpjt0MnLZ4CEkTT+/BHtSzd6jSandK21igvuoe5/lYaXUrB oA5OiTm2Or1TjsyEIcwnu7anRJoBkKFpVW8EwNBrzEPRWrg9Smas3C0sWEoaDN5QxD7U fRruuO07LTdeW9eg4aWu0nyqCnndcS0o/j+khe4sAwpWdvTJ3YzbMcmN3mXEj7R3EMCz 7VmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=4+0qYitXSHSx3NIiybbP8TqOxStEhxaaT0pX6I+fpPw=; b=P/EJuEpVXMcfRujYewOyrY7VchY5iIOfU9Hbt4XML8bqpxbml0ph3404/CgKJv0ZlE C8Aew7OnrtL/Su9is9aYvLqe1UmMY96WNDmbwPCuS9LZxNcK19Y+IyyxrqNK8xbO1X0v l11DwlR+uk5MFqqFjg+vG0Z14fvC58jIfp+BHuXApb5njd6lMhAqHzQOAxJuyC8mxgOD 9hbN/Rrc0cSfLiT3rEBaqXpZt/Qy2Ia0BopBtLI6t8SaWUSrmHvs0mkor5fhdtcLIjHl 1D8due8+ViLMghbBHlb8ar8qCJyQU+byYy0c7ZvH/ibFJeAiqjDytf9EVV8lyoFKzmiS azLw== X-Gm-Message-State: ALyK8tJbWo9UTIKL5+kR/Z5dDzWlbFLz/Txr2axkJ82kYacuS0vZbqd1hEDzaaZCpXUVDA== X-Received: by 10.107.143.131 with SMTP id r125mr35550212iod.54.1466547964221; Tue, 21 Jun 2016 15:26:04 -0700 (PDT) Received: from hash (CPE0018e7fe5281-CM18593342f28f.cpe.net.cable.rogers.com. [99.254.238.186]) by smtp.gmail.com with ESMTPSA id w78sm2382773ita.3.2016.06.21.15.26.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Jun 2016 15:26:03 -0700 (PDT) Received: from bob by hash with local (Exim 4.84_2) (envelope-from ) id 1bFU7O-0007Qt-EN; Tue, 21 Jun 2016 18:26:02 -0400 Date: Tue, 21 Jun 2016 18:26:02 -0400 From: Bob Copeland To: Johannes Berg Cc: Jouni Malinen , linux-wireless@vger.kernel.org Subject: Re: [PATCH] mac80211: Fix mesh estab_plinks counting in STA removal case Message-ID: <20160621222602.GA7271@localhost> References: <20160619205102.GA28350@w1.fi> <1466536150.18972.1.camel@sipsolutions.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1466536150.18972.1.camel@sipsolutions.net> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, Jun 21, 2016 at 09:09:10PM +0200, Johannes Berg wrote: > > >    */ > > - changed = mesh_accept_plinks_update(sdata); > > + if (sdata->u.mesh.user_mpm && > > +     sta->mesh->plink_state == NL80211_PLINK_ESTAB) > > + changed |= mesh_plink_dec_estab_count(sdata); > > + changed |= mesh_accept_plinks_update(sdata); > >   if (!sdata->u.mesh.user_mpm) { > >   changed |= mesh_plink_deactivate(sta); > >   del_timer_sync(&sta->mesh->plink_timer); > > > > Does it have to be done before the mesh_accept_plinks_update()? > > If not, you should put it with the existing u.mesh.user_mpm check. If > yes, then the code is further buggy since only mesh_plink_deactivate() > will call it when the kernel MPM is used. Looks further buggy, so perhaps this untested patch would work, i.e. move the accepting-plinks change closer to the decrement, and push the user_mpm check down into mesh_plink_deactivate to just avoid sending the peering frames. [There's also a bit there for power saving that we likely want to keep for secure networks.] Then again maybe accepting_plinks flag should just be computed when used instead of tracking the state separately. --- net/mac80211/mesh.c | 18 ++---------------- net/mac80211/mesh_plink.c | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index 21b1fdf..3c150f8 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c @@ -148,22 +148,8 @@ u32 mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata) void mesh_sta_cleanup(struct sta_info *sta) { struct ieee80211_sub_if_data *sdata = sta->sdata; - u32 changed; - - /* - * maybe userspace handles peer allocation and peering, but in either - * case the beacon is still generated by the kernel and we might need - * an update. - */ - changed = mesh_accept_plinks_update(sdata); - if (!sdata->u.mesh.user_mpm) { - changed |= mesh_plink_deactivate(sta); - del_timer_sync(&sta->mesh->plink_timer); - } - - /* make sure no readers can access nexthop sta from here on */ - mesh_path_flush_by_nexthop(sta); - synchronize_net(); + u32 changed = mesh_plink_deactivate(sta); + del_timer_sync(&sta->mesh->plink_timer); if (changed) ieee80211_mbss_info_change_notify(sdata, changed); diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c index 79f2a0a..69ac7a8 100644 --- a/net/mac80211/mesh_plink.c +++ b/net/mac80211/mesh_plink.c @@ -349,6 +349,8 @@ static u32 __mesh_plink_deactivate(struct sta_info *sta) changed = mesh_plink_dec_estab_count(sdata); sta->mesh->plink_state = NL80211_PLINK_BLOCKED; + changed |= mesh_accept_plinks_update(sdata); + ieee80211_mps_sta_status_update(sta); changed |= ieee80211_mps_set_sta_local_pm(sta, NL80211_MESH_POWER_UNKNOWN); @@ -370,13 +372,19 @@ u32 mesh_plink_deactivate(struct sta_info *sta) spin_lock_bh(&sta->mesh->plink_lock); changed = __mesh_plink_deactivate(sta); - sta->mesh->reason = WLAN_REASON_MESH_PEER_CANCELED; - mesh_plink_frame_tx(sdata, sta, WLAN_SP_MESH_PEERING_CLOSE, - sta->sta.addr, sta->mesh->llid, sta->mesh->plid, - sta->mesh->reason); + + if (sdata->u.mesh.user_mpm) { + sta->mesh->reason = WLAN_REASON_MESH_PEER_CANCELED; + mesh_plink_frame_tx(sdata, sta, WLAN_SP_MESH_PEERING_CLOSE, + sta->sta.addr, sta->mesh->llid, sta->mesh->plid, + sta->mesh->reason); + } spin_unlock_bh(&sta->mesh->plink_lock); mesh_path_flush_by_nexthop(sta); + /* make sure no readers can access nexthop sta from here on */ + synchronize_net(); + return changed; }