From patchwork Fri Jun 17 19:29:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 12885935 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CA24C433EF for ; Fri, 17 Jun 2022 19:29:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231909AbiFQT3V (ORCPT ); Fri, 17 Jun 2022 15:29:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229952AbiFQT3U (ORCPT ); Fri, 17 Jun 2022 15:29:20 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D445454030; Fri, 17 Jun 2022 12:29:18 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 6E1B9E000A; Fri, 17 Jun 2022 19:29:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1655494157; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HLZNoK3s6nGQbPR4WYJoo22e0BgrLaurywMR0f3XiRU=; b=RFBKLTkSkRbxUcE00q4igckhaY+ioKOl0NBKqvVmMjWN44rkgSxUQBJBNq3CSOiU13dcxl F5qgN4A5q+e2f7xbzNga48dJi59vlDbAvphQS6Y3JrQbcinWI5PlALlN4jSHyRqKG1GHys C4taqRpyaDyWxJRqAwpkoB3oO3GAQDV9QtKGghhW/bJQiZnA5XHi0ytfNOaB0csOQaDlEs w+kh4KQqclj24B4nwZyeDdteCBaoMM4bwnrzOyGCghHRXPmHi8uvDvg+vHP1CHIcbE36YJ 2H5OFarmOPfV55AruGDEtTAONQ8Y3A0DKlJvAaZxS94I/pmNszpIvx8Db6mA6g== From: Miquel Raynal To: Alexander Aring , Stefan Schmidt , linux-wpan@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, David Girault , Romuald Despres , Frederic Blain , Nicolas Schodet , Thomas Petazzoni , Miquel Raynal Subject: [PATCH] net: mac802154: Fix a Tx warning check Date: Fri, 17 Jun 2022 21:29:14 +0200 Message-Id: <20220617192914.1275611-1-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org The purpose of the netif_is_down() helper was to ensure that the network interface used was still up when performing the transmission. What it actually did was to check if _all_ interfaces were up. This was not noticed at that time because I did not use interfaces at all before discussing with Alexander Aring about how to handle coordinators properly. Drop the helper and call netif_running() on the right sub interface object directly. Fixes: 4f790184139b ("net: mac802154: Add a warning in the slow path") Signed-off-by: Miquel Raynal Acked-by: Alexander Aring --- net/mac802154/ieee802154_i.h | 8 ++++++-- net/mac802154/tx.c | 31 ++++++++----------------------- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/net/mac802154/ieee802154_i.h b/net/mac802154/ieee802154_i.h index 8a4816ae71e7..010365a6364e 100644 --- a/net/mac802154/ieee802154_i.h +++ b/net/mac802154/ieee802154_i.h @@ -126,9 +126,13 @@ void ieee802154_rx(struct ieee802154_local *local, struct sk_buff *skb); void ieee802154_xmit_sync_worker(struct work_struct *work); int ieee802154_sync_and_hold_queue(struct ieee802154_local *local); int ieee802154_mlme_op_pre(struct ieee802154_local *local); -int ieee802154_mlme_tx(struct ieee802154_local *local, struct sk_buff *skb); +int ieee802154_mlme_tx(struct ieee802154_local *local, + struct ieee802154_sub_if_data *sdata, + struct sk_buff *skb); void ieee802154_mlme_op_post(struct ieee802154_local *local); -int ieee802154_mlme_tx_one(struct ieee802154_local *local, struct sk_buff *skb); +int ieee802154_mlme_tx_one(struct ieee802154_local *local, + struct ieee802154_sub_if_data *sdata, + struct sk_buff *skb); netdev_tx_t ieee802154_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev); netdev_tx_t diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c index 8ddcd2e841ca..9d8d43cf1e64 100644 --- a/net/mac802154/tx.c +++ b/net/mac802154/tx.c @@ -132,31 +132,14 @@ int ieee802154_sync_and_hold_queue(struct ieee802154_local *local) return ret; } -static bool ieee802154_netif_is_down(struct ieee802154_local *local) -{ - struct ieee802154_sub_if_data *sdata; - bool is_down = true; - - rcu_read_lock(); - list_for_each_entry_rcu(sdata, &local->interfaces, list) { - if (!sdata->dev) - continue; - - is_down = !netif_running(sdata->dev); - if (is_down) - break; - } - rcu_read_unlock(); - - return is_down; -} - int ieee802154_mlme_op_pre(struct ieee802154_local *local) { return ieee802154_sync_and_hold_queue(local); } -int ieee802154_mlme_tx(struct ieee802154_local *local, struct sk_buff *skb) +int ieee802154_mlme_tx(struct ieee802154_local *local, + struct ieee802154_sub_if_data *sdata, + struct sk_buff *skb) { int ret; @@ -174,7 +157,7 @@ int ieee802154_mlme_tx(struct ieee802154_local *local, struct sk_buff *skb) /* Warn if the ieee802154 core thinks MLME frames can be sent while the * net interface expects this cannot happen. */ - if (WARN_ON_ONCE(ieee802154_netif_is_down(local))) { + if (WARN_ON_ONCE(!netif_running(sdata->dev))) { rtnl_unlock(); return -ENETDOWN; } @@ -192,12 +175,14 @@ void ieee802154_mlme_op_post(struct ieee802154_local *local) ieee802154_release_queue(local); } -int ieee802154_mlme_tx_one(struct ieee802154_local *local, struct sk_buff *skb) +int ieee802154_mlme_tx_one(struct ieee802154_local *local, + struct ieee802154_sub_if_data *sdata, + struct sk_buff *skb) { int ret; ieee802154_mlme_op_pre(local); - ret = ieee802154_mlme_tx(local, skb); + ret = ieee802154_mlme_tx(local, sdata, skb); ieee802154_mlme_op_post(local); return ret;