From patchwork Thu Jan 25 01:16:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Oh X-Patchwork-Id: 10183457 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 B9ABB60383 for ; Thu, 25 Jan 2018 01:16:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9945228753 for ; Thu, 25 Jan 2018 01:16:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8CB06289C4; Thu, 25 Jan 2018 01:16:32 +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, 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 A1C1328753 for ; Thu, 25 Jan 2018 01:16:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751278AbeAYBQ3 (ORCPT ); Wed, 24 Jan 2018 20:16:29 -0500 Received: from mail-he1eur01on0084.outbound.protection.outlook.com ([104.47.0.84]:49365 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751109AbeAYBQ1 (ORCPT ); Wed, 24 Jan 2018 20:16:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bowerswilkins.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=uLMcKzXTepiCzr9GphR+KEIRojnUbJT5qJHOEPHD59A=; b=ivhxvXz7w48VKptykIb4qoGCrNR1KDacEvCFSGODGVyrUBI7OYmklnjgE0HkEJU/G9tbQ+AQska2ZBO+m65zkgbLxE+oBZw997Ed70PRomCB2uq0wrPdlICVxnsKfNoz11u5alJ2jKGD4hD/2lacMxoLF30sMTIIL/+6kQwukO8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peter.oh@bowerswilkins.com; Received: from smtp.office365.com (2001:1900:2200:85:c44:fbd3:e970:4565) by DB5PR04MB1654.eurprd04.prod.outlook.com (2a01:111:e400:5995::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.428.17; Thu, 25 Jan 2018 01:16:23 +0000 From: peter.oh@bowerswilkins.com To: linux-wireless@vger.kernel.org, johannes@sipsolutions.net Cc: Peter Oh , johannes.berg@intel.com Subject: [PATCH v3] mac80211: mesh: fix wrong mesh TTL offset calculation Date: Wed, 24 Jan 2018 17:16:10 -0800 Message-Id: <8582518b7f032acfa598faf7d26c765b09149e90.1516842930.git.peter.oh@bowerswilkins.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [2001:1900:2200:85:c44:fbd3:e970:4565] X-ClientProxiedBy: MWHPR19CA0049.namprd19.prod.outlook.com (2603:10b6:300:94::11) To DB5PR04MB1654.eurprd04.prod.outlook.com (2a01:111:e400:5995::12) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eb6b00e4-daa3-4df6-97d4-08d56391408f X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:DB5PR04MB1654; X-Microsoft-Exchange-Diagnostics: 1; DB5PR04MB1654; 3:3f8ptqfVM5SGR0GecE6nyU65Zfqib85BkD/A0nEYMWBup7QK+v7GMlulCC5CMJZJ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asFz5RmnvdIQXd3QbZXJi7ERQqgSfuiudEimsUSYkKCz6chTPRlDg3IjaGnWf3+0/OJbf2e/PJ214gzPRpBSD4TzmoHwqSdRHHGkoiQpQlx3HbMYsjKyN+mk99rYJc/5MPhCtw8lPdie46ZhmV9I7a3CZkjXJ0UENs47H4GNic91yOzQCUcmmgcr30iMsSpXPRPhz/CituLTrHil8KCKboTUH+N/E5GC4ja3Onx8UbM1ji+cICaxM1x0B/aFiFZMK6JoCA7bvrSJptvhvsvf6Bv; 4:j4MfB2H4LTMbWjUyQHU6r8KW9tSHSS5cHaUtgrmX8+A9+YRlVdKMwfMKqCsRsttocTzuEefEpjKVLvP6aowBGf9mKkmF+QjagdCjESwUdjzUe/4hbFnMbOrpvFcxWReojN0fZO6hqlycCKOsKL8i8F3CBzoRo9txom6B6OPGKYI+0NhlVChqylqo2HKvSHoO61uzM7sP2P5Rc50EMOjry48MwJrmHuO4imJuGgGEjPy4hxyu+6WAJHfvrQsR+xU87wQjg90slo4Xx9xgzOwEmg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(3231023)(2400081)(944501161)(93006095)(93001095)(10201501046)(3002001)(6041288)(20161123560045)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(6072148)(201708071742011); SRVR:DB5PR04MB1654; BCL:0; PCL:0; RULEID:; SRVR:DB5PR04MB1654; X-Forefront-PRVS: 0563F2E8B7 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(39850400004)(396003)(346002)(366004)(39380400002)(189003)(199004)(2906002)(118296001)(68736007)(8936002)(50226002)(47776003)(25786009)(16810700005)(16586007)(7736002)(33896004)(53416004)(305945005)(106356001)(4326008)(52116002)(105586002)(50466002)(48376002)(52396003)(51416003)(6116002)(386003)(6506007)(316002)(36756003)(5660300001)(6486002)(86362001)(69596002)(6512007)(9686003)(478600001)(85782001)(81156014)(81166006)(8676002)(53936002)(6666003)(97736004)(186003)(85772001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR04MB1654; H:smtp.office365.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: bowerswilkins.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB5PR04MB1654; 23:OYueoqLOahHEeQD8x4Hw+Q1rA3CfQ0EMWilYXCnWt?= =?us-ascii?Q?cETQYol6K3oK+kO8eNc8KyHOxE4r1pIKCyXWnYgTwmdFmUSv9M6l0xqFAjC7?= =?us-ascii?Q?cnvHizPzE5u0slPlaXruUW6qSZenJ8frP2ODpSRqNidCeNM7rZAswBooqkpG?= =?us-ascii?Q?2/GVIb9FcW8kNF5qN9ZsKLdE6s8HdeY7CMCY3kIq4ah58vPzup6kpcaCURBB?= =?us-ascii?Q?n5hffmganKTMsfWOr/XeIDa6MLc7ZUSo0Cui66LGl/PktBcnC0yK5IWokwTb?= =?us-ascii?Q?wdmvi+g+92bI4u7FH0qK2pVGJ9XIoy5ZhoaLrXyPWad6NZJf0S+kNsIk8f3G?= =?us-ascii?Q?mX9qHzc1KFCwzhsQQqwt4GAiiRfe05bMyMGaCl9/tpzPwP27C63h/ASHWJ6G?= =?us-ascii?Q?+3mTE9/EOpJWfprJD5tsndy5KEfKys9TuOy34lWQpS3NUScUIGXst800ivTk?= =?us-ascii?Q?0QiZwn2WqPZNNIjS0GYb7Dka8OR2ZhisQrR4RPfeQvtevRme77nYJsHee/04?= =?us-ascii?Q?4xl4+nJNTSN/iPr7NWrtO55CODCrnU4h+V9ea0U0H3DVNTgp7OIvaNRKWE+w?= =?us-ascii?Q?md3kocpXElqfX1GHLPfVvQw8Hhbt6JGJVPFYwuwtG3ZaYIKUcQ+DyFGM4EZw?= =?us-ascii?Q?uW3JAADST3aYBuZLuP7PpeK8711LQgrt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xn5mj9Nv6oOVzhPLwbyccW/Z2UFCfFvvlaPnTtKJQpenZjrcbq8hzXCbMX6wojIs96J7JzTZqmhfuzCzu1YYmxD/+voUO/wvf6wxc17ECfB71KZXa9gPkQWU=; 24:NxgYW6roRa/7Qe2fTrLh8LDTbym92aoPNqyGXYq1SbBYV0eEA24N7gsqu3ZghaDwrVBEN7ZMc3grw4vYYEuXPyIr8IjG3uIXnJoqALZHj6Y=; 7:meKrH3Sm2vPaP/IMb6BQoJ3Y+ZPDfUDFeuQ5bEJqWxLKwAb1SdxBMx4UYyVEFFZdTYj8Ja8nWH7FL0QuPRCPmqyU6b5Q92nI4KTThXJa2QSKhhbugm+cOJuQsu76OJr5TqPCYJgCYDlIB2IFAfLbuuc8kg+a4EQFeIwogGjACaOmibw7OjgLgpD78UFDDnP2WWucxqQwdJnf8Tfqij2NJPJHHghrh9si03gJ5IUP+RfeV4QMMpbb7E0h01UshGox SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: bowerswilkins.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2018 01:16:23.7665 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eb6b00e4-daa3-4df6-97d4-08d56391408f X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a75a45bb-4772-448f-a2c6-9d2413d86410 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR04MB1654 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 From: Peter Oh mesh TTL offset in Mesh Channel Switch Parameters element depends on not only Secondary Channel Offset element, but also affected by HT Control field and Wide Bandwidth Channel Switch element. Use element structure to correct the miscalculation. Signed-off-by: Peter Oh --- net/mac80211/mesh.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index 73ac607..6a381cb 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c @@ -1255,13 +1255,12 @@ int ieee80211_mesh_csa_beacon(struct ieee80211_sub_if_data *sdata, } static int mesh_fwd_csa_frame(struct ieee80211_sub_if_data *sdata, - struct ieee80211_mgmt *mgmt, size_t len) + struct ieee80211_mgmt *mgmt, size_t len, + struct ieee802_11_elems *elems) { struct ieee80211_mgmt *mgmt_fwd; struct sk_buff *skb; struct ieee80211_local *local = sdata->local; - u8 *pos = mgmt->u.action.u.chan_switch.variable; - size_t offset_ttl; skb = dev_alloc_skb(local->tx_headroom + len); if (!skb) @@ -1269,13 +1268,9 @@ static int mesh_fwd_csa_frame(struct ieee80211_sub_if_data *sdata, skb_reserve(skb, local->tx_headroom); mgmt_fwd = skb_put(skb, len); - /* offset_ttl is based on whether the secondary channel - * offset is available or not. Subtract 1 from the mesh TTL - * and disable the initiator flag before forwarding. - */ - offset_ttl = (len < 42) ? 7 : 10; - *(pos + offset_ttl) -= 1; - *(pos + offset_ttl + 1) &= ~WLAN_EID_CHAN_SWITCH_PARAM_INITIATOR; + elems->mesh_chansw_params_ie->mesh_ttl--; + elems->mesh_chansw_params_ie->mesh_flags &= + ~WLAN_EID_CHAN_SWITCH_PARAM_INITIATOR; memcpy(mgmt_fwd, mgmt, len); eth_broadcast_addr(mgmt_fwd->da); @@ -1323,7 +1318,7 @@ static void mesh_rx_csa_frame(struct ieee80211_sub_if_data *sdata, /* forward or re-broadcast the CSA frame */ if (fwd_csa) { - if (mesh_fwd_csa_frame(sdata, mgmt, len) < 0) + if (mesh_fwd_csa_frame(sdata, mgmt, len, &elems) < 0) mcsa_dbg(sdata, "Failed to forward the CSA frame"); } }