From patchwork Fri Jan 26 22:02:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Oh X-Patchwork-Id: 10187119 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 0C66260383 for ; Fri, 26 Jan 2018 22:02:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDB962A3F9 for ; Fri, 26 Jan 2018 22:02:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E19F32A418; Fri, 26 Jan 2018 22:02:58 +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 1AE7F2A3F9 for ; Fri, 26 Jan 2018 22:02:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751394AbeAZWC4 (ORCPT ); Fri, 26 Jan 2018 17:02:56 -0500 Received: from mail-he1eur01on0088.outbound.protection.outlook.com ([104.47.0.88]:61248 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751257AbeAZWCz (ORCPT ); Fri, 26 Jan 2018 17:02:55 -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=mx7AwRFMnOsLZ+xaZhAIZMASX27mPr+PqDx/yb/t7/w=; b=otZjzIEoE59SXf0aP46ihawwY1KHjyWL99d2JO2I82mHIWBjzoUKJjbbw/PUsVFx5dLhH6LoO0OM5D8yoWPo2VH/aIZxXD5wRtcVoQXpwoIAxHehuqphv/2QafMtyt66tDluTuPJWyIJdN9zNqtxxq2sSDj7mfQQKN0QwuEIYxk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peter.oh@bowerswilkins.com; Received: from smtp.office365.com (2001:1900:2200:85:8493:3776:6cd:6788) by VI1PR04MB1662.eurprd04.prod.outlook.com (2a01:111:e400:596c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.444.14; Fri, 26 Jan 2018 22:02:50 +0000 From: peter.oh@bowerswilkins.com To: linux-wireless@vger.kernel.org, johannes@sipsolutions.net Cc: Peter Oh , johannes.berg@intel.com Subject: [PATCH v4] mac80211: mesh: fix wrong mesh TTL offset calculation Date: Fri, 26 Jan 2018 14:02:37 -0800 Message-Id: <5622ae154b32eab5fdba46fee9b0b7ca2e8fed23.1517004051.git.peter.oh@bowerswilkins.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [2001:1900:2200:85:8493:3776:6cd:6788] X-ClientProxiedBy: MWHPR12CA0070.namprd12.prod.outlook.com (2603:10b6:300:103::32) To VI1PR04MB1662.eurprd04.prod.outlook.com (2a01:111:e400:596c::12) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b77b7919-da98-4844-f605-08d565088b50 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:VI1PR04MB1662; X-Microsoft-Exchange-Diagnostics: 1; VI1PR04MB1662; 3:TNeg6Ud4K2yPDpNvDArfNL0s+DqoB0OvvJXdEfMWqD5Dqrf1N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T31B+RTEGhFAGCl7i/UKfh9mlvaU0vBdF4NnJIMb9lzH7G8ct3F02DpaRwOUnmn5jhqppu/nKkhkd4DhhaxOOe8PUYqUntGgmmQxuIza6s2bvOmy/pgCTqtZlfywLS29H49ur1Ktj2D1iiiJHNvtmwCVU/ZldlkvqjQV8zULRFjynWZM5Df4t1BYc6qjkmsChfrUZze2USgEQsngKBLIBp6zVW+9AT/OL2IZ2/Vva+Hr9nqwPhsHht+L6k3aswBEQ2w7rm+uB+1XPIMm+e036CNd6G+DZ8Tb4+; 4:EsEeT+uY4vEUTOdyKhpDJQ2KTSGC2M64x6ZBMlh+HCgQma2gX77G4/nsQpFuKb4hn1ZfgGprTJHqeZznWRZj+RbmPXc8WYzx6T3O4MWzsjR7VkzmTzMA7pHorntSc8qkFGxy/B6AQkL9pxH7KOyLVa18LMkmafRkyLlsfa7rcD1n4RKML6wTkpHksM/GaCfcobxYfNMBw8ZYH7sad4rEhJocYt5zz0JrEcD9WvYR1ah2iCSb+h2d/NVWUDo3fUsP/NW6gjr6Qk8CQ0Yz//HDEg== 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)(3002001)(93006095)(93001095)(10201501046)(3231077)(2400081)(944501161)(6041288)(20161123558120)(20161123562045)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:VI1PR04MB1662; BCL:0; PCL:0; RULEID:; SRVR:VI1PR04MB1662; X-Forefront-PRVS: 05641FD966 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(366004)(376002)(39380400002)(39850400004)(346002)(189003)(199004)(2906002)(5660300001)(6486002)(6116002)(97736004)(106356001)(6666003)(33896004)(68736007)(16526019)(36756003)(52396003)(48376002)(386003)(47776003)(51416003)(50466002)(6506007)(52116002)(69596002)(316002)(53416004)(105586002)(118296001)(50226002)(16586007)(8676002)(81166006)(85782001)(81156014)(25786009)(86362001)(8936002)(9686003)(7736002)(305945005)(478600001)(186003)(6512007)(4326008)(53936002)(16810700005)(85772001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR04MB1662; 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; VI1PR04MB1662; 23:jFsguDEoRpGd5omjvL+oZpeTQV0ULXBgwSkDONa7A?= =?us-ascii?Q?ohBXzZ1feXMUmjJ6qlSoyiP5PZB/DYFywJANMM7B0jIc3gRWRNL2GwvgoJXc?= =?us-ascii?Q?GURmD8kBhO6CxZUe614CC02ZbbVo6X8FLLafVjrnfkZL9FlOtpEuzlEUeush?= =?us-ascii?Q?fMY911PuUQJvTgUt6RRvR5gKwc0gcj2T4h5epmyCvupBi8YQwvzILoKhoqAl?= =?us-ascii?Q?Ks53uXc/WfdD78lqak9Hz9SldYg6mxWpTFuwi6OuXy7D3jYmyijqXCWhDb9H?= =?us-ascii?Q?mA16cLfIkEIMlQUpFvaH8CcZcbUEMkgYIEg+Rnt1KvLZT4Q/QXyKPKU6vqGL?= =?us-ascii?Q?p5EdZyJUJ/CDkKmJBBo0iOqXaqG3Fz6yUW8ee3HcMUNYHAXZdnHF8xm+O6SC?= =?us-ascii?Q?8zIQyXjm81zeBaJc+NU4vyhp39Pd3UITMh2Tx4ymbDPpbW3X/+e8IRVz42su?= =?us-ascii?Q?naaioommXm8H2vg4vmKB+xWASQKnSgmfilljNSkMO3oJUTFb3jvKCq7P3DY7?= =?us-ascii?Q?1rVULF6+P6QAttKwlaE2o0iQC8BEmmu+1vxURS8jXeRrO7mGtgwMAPKXFY1v?= =?us-ascii?Q?9iFFxUobPkpIiCFdoB+m3rQFRULcgFDr9FqujCCjOaseCwBd3qsw0zZ9DSh3?= =?us-ascii?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U2565XL3wZhVZipSk/nBFIIrY=; 5:faRhwvFv8kjHCpXf04dMDnhd/n8IKR9FnB1o7m6+raBULPOmhpG3gs7q+a75tEfVWCev0kOeFGPoFS6LrMv005YpwHpDpgm7tngV13YGiNpBh9Wb2dQMmKMdLxxaba+lpqRMPIQbP1bwtCnJQ+H5iWVuUzUn7TZtsO2bPSLKdhA=; 24:G1ygEfHTZCOq8gUVWMElgNgsRzu89tKzKOx7BXw9grw9wWL8OaC0RvbTOXYkuZ3866IXJVDcXUrMCikPe0S/3OHDrqy/gpCb25wm0CBU6sY=; 7:LzTdQXOdbAiCziYg3a5+qSOmHVQjdgOaZ0LPHBDk9eyCoxFFOXyi1GCs0UGbR7evmEt3hB648mswy77UHKQUEn5Z3g8+P+bafCiN0RHXZbUrp97Fq1VKFEkxojzGLjbH1cA/PQVbsSAkHg0V4+jdgmd2G19eWaZndkqoFQEP5B0KXIn4Vay3xp90q/9RrAN3KKit0+X8GO4aJIDWvFUfQ7BnTlFzcP9aXkt780UD1LVFjOpfFGiNPW5KdkiVoYiG SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: bowerswilkins.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2018 22:02:50.3006 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b77b7919-da98-4844-f605-08d565088b50 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a75a45bb-4772-448f-a2c6-9d2413d86410 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB1662 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. So use element structure to manipulate mesh channel swich param IE after removing its constant attribution to correct the miscalculation. Signed-off-by: Peter Oh --- net/mac80211/ieee80211_i.h | 2 +- net/mac80211/mesh.c | 17 ++++++----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index 2690002..ae9c33c 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h @@ -1467,7 +1467,7 @@ struct ieee802_11_elems { const struct ieee80211_timeout_interval_ie *timeout_int; const u8 *opmode_notif; const struct ieee80211_sec_chan_offs_ie *sec_chan_offs; - const struct ieee80211_mesh_chansw_params_ie *mesh_chansw_params_ie; + struct ieee80211_mesh_chansw_params_ie *mesh_chansw_params_ie; const struct ieee80211_bss_max_idle_period_ie *max_idle_period_ie; /* length of them, respectively */ 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"); } }