From patchwork Tue Nov 14 15:20:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chun-Yeow Yeoh X-Patchwork-Id: 10057843 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 A6AEB6023A for ; Tue, 14 Nov 2017 15:20:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C0D12961B for ; Tue, 14 Nov 2017 15:20:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 90BBB29687; Tue, 14 Nov 2017 15:20:24 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI 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 35B742961B for ; Tue, 14 Nov 2017 15:20:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755417AbdKNPUT (ORCPT ); Tue, 14 Nov 2017 10:20:19 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:48688 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755199AbdKNPUR (ORCPT ); Tue, 14 Nov 2017 10:20:17 -0500 Received: by mail-pf0-f194.google.com with SMTP id r62so2052638pfd.5 for ; Tue, 14 Nov 2017 07:20:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=dDr2cmA1F7frr+bSCjny+diP9dS+GrrIbGBcfUWvrIE=; b=hWxfW+Z+MlLniNOjZ9M7esMnEWmRvcdnTr5qmtqCUCTorNJ3RzDx4XlmYphXKnQhqa gOFSRqwuBEa0rb4dQNAj3Qf2/YZSqpx6lty2thHT4Ka8HlcWn5256uyseJjHUFqlK6MU DmmM8/gWzC0RPjR3uiHhU+NaZfHHmkvmpBQX4eLhyFQ47vxzjaWvSSNHL/Mw0AKDupNA H+akflCJ3GegCGP5gt+luq+l5AJA+55PKj+38No173CtEg2MXaePCBngyFovLdI5tHO5 hUUNGaDOcPkorfyXkITFmaoMlVhEt/2gpw/v7l850EL+DtXIX9R5kbnTZSDQImn6R7d+ oa8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=dDr2cmA1F7frr+bSCjny+diP9dS+GrrIbGBcfUWvrIE=; b=OZZ1hKmX4sY6c3mjcZmWBNEIiriotL3hxktS+yyyGWGlJ0PK8dDx36pCw5baVxLbPW lKZYkiUj+08RAno98GjBwoql9cY/z8yYD84X1ifyn1P60Lu6FJiP0q23TPGyP/UgYIU7 eZkOhW3p14gBKeM1088nQfREDEmWufaeHwPPNvjr0vCaEH/bdR9RXExlUg+zealFYBY1 9X32xqhzcQpYhhPHWZm/I38SmlX5mc7CAejljDOAIIChE5JgSnBNeRqq0cqeWviWmiIE 0LEvOpEp6d0Z5RMjNRrmEEQN2VEU3gjFANemwA4O4VsCVmQwJeSeyX4+66BWe8txz2tK iibw== X-Gm-Message-State: AJaThX7e46/EgPjTt+Oiqzw7PzwQcIe7GhVlsSjR2sdXpJXPXrgMdNrd yXcb8LPp7D/9uwxp+bXvUN4= X-Google-Smtp-Source: AGs4zMYaQQU7VV7jSDryJaSMrIvfW9g6+eRNwsVyYDTPjtSbs+xSYSZmxLqDmtxKVdZkAK3HgXI8DQ== X-Received: by 10.99.112.89 with SMTP id a25mr12382314pgn.2.1510672816930; Tue, 14 Nov 2017 07:20:16 -0800 (PST) Received: from nga.lan ([118.100.205.224]) by smtp.gmail.com with ESMTPSA id r77sm41326700pfk.93.2017.11.14.07.20.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Nov 2017 07:20:16 -0800 (PST) From: Chun-Yeow Yeoh To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Chun-Yeow Yeoh Subject: [PATCH] mac80211: fix the update of path metric for RANN frame Date: Tue, 14 Nov 2017 23:20:05 +0800 Message-Id: <1510672805-32594-1-git-send-email-yeohchunyeow@gmail.com> X-Mailer: git-send-email 2.3.0 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 The previous path metric update from RANN frame has not considered the own link metric toward the transmitting mesh STA. Fix this. Reported-by: Michael65535 Signed-off-by: Chun-Yeow Yeoh --- net/mac80211/mesh_hwmp.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c index c1d1b86..35ad398 100644 --- a/net/mac80211/mesh_hwmp.c +++ b/net/mac80211/mesh_hwmp.c @@ -797,7 +797,7 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata, struct mesh_path *mpath; u8 ttl, flags, hopcount; const u8 *orig_addr; - u32 orig_sn, metric, metric_txsta, interval; + u32 orig_sn, new_metric, orig_metric, last_hop_metric, interval; bool root_is_gate; ttl = rann->rann_ttl; @@ -808,7 +808,7 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata, interval = le32_to_cpu(rann->rann_interval); hopcount = rann->rann_hopcount; hopcount++; - metric = le32_to_cpu(rann->rann_metric); + orig_metric = le32_to_cpu(rann->rann_metric); /* Ignore our own RANNs */ if (ether_addr_equal(orig_addr, sdata->vif.addr)) @@ -825,7 +825,10 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata, return; } - metric_txsta = airtime_link_metric_get(local, sta); + last_hop_metric = airtime_link_metric_get(local, sta); + new_metric = orig_metric + last_hop_metric; + if (new_metric < orig_metric) + new_metric = MAX_METRIC; mpath = mesh_path_lookup(sdata, orig_addr); if (!mpath) { @@ -838,7 +841,7 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata, } if (!(SN_LT(mpath->sn, orig_sn)) && - !(mpath->sn == orig_sn && metric < mpath->rann_metric)) { + !(mpath->sn == orig_sn && new_metric < mpath->rann_metric)) { rcu_read_unlock(); return; } @@ -856,7 +859,7 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata, } mpath->sn = orig_sn; - mpath->rann_metric = metric + metric_txsta; + mpath->rann_metric = new_metric; mpath->is_root = true; /* Recording RANNs sender address to send individually * addressed PREQs destined for root mesh STA */ @@ -876,7 +879,7 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata, mesh_path_sel_frame_tx(MPATH_RANN, flags, orig_addr, orig_sn, 0, NULL, 0, broadcast_addr, hopcount, ttl, interval, - metric + metric_txsta, 0, sdata); + new_metric, 0, sdata); } rcu_read_unlock();