All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: mac802154: Fix a Tx warning check
@ 2022-06-17 19:29 Miquel Raynal
  2022-06-20  0:33 ` Alexander Aring
  2022-06-27  9:04 ` Stefan Schmidt
  0 siblings, 2 replies; 3+ messages in thread
From: Miquel Raynal @ 2022-06-17 19:29 UTC (permalink / raw)
  To: Alexander Aring, Stefan Schmidt, linux-wpan
  Cc: David S. Miller, Jakub Kicinski, Paolo Abeni, netdev,
	David Girault, Romuald Despres, Frederic Blain, Nicolas Schodet,
	Thomas Petazzoni, Miquel Raynal

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 <miquel.raynal@bootlin.com>
---
 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;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: mac802154: Fix a Tx warning check
  2022-06-17 19:29 [PATCH] net: mac802154: Fix a Tx warning check Miquel Raynal
@ 2022-06-20  0:33 ` Alexander Aring
  2022-06-27  9:04 ` Stefan Schmidt
  1 sibling, 0 replies; 3+ messages in thread
From: Alexander Aring @ 2022-06-20  0:33 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Alexander Aring, Stefan Schmidt, linux-wpan - ML,
	David S. Miller, Jakub Kicinski, Paolo Abeni,
	Network Development, David Girault, Romuald Despres,
	Frederic Blain, Nicolas Schodet, Thomas Petazzoni

Hi,

On Fri, Jun 17, 2022 at 3:30 PM Miquel Raynal <miquel.raynal@bootlin.com> wrote:
>
> 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")

Acked-by: Alexander Aring <aahringo@redhat.com>

- Alex


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: mac802154: Fix a Tx warning check
  2022-06-17 19:29 [PATCH] net: mac802154: Fix a Tx warning check Miquel Raynal
  2022-06-20  0:33 ` Alexander Aring
@ 2022-06-27  9:04 ` Stefan Schmidt
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Schmidt @ 2022-06-27  9:04 UTC (permalink / raw)
  To: Miquel Raynal, Alexander Aring, linux-wpan
  Cc: David S. Miller, Jakub Kicinski, Paolo Abeni, netdev,
	David Girault, Romuald Despres, Frederic Blain, Nicolas Schodet,
	Thomas Petazzoni

Hello.

On 17.06.22 21:29, Miquel Raynal wrote:
> 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 <miquel.raynal@bootlin.com>
> ---
>   net/mac802154/ieee802154_i.h |  8 ++++++--
>   net/mac802154/tx.c           | 31 ++++++++-----------------------
>   2 files changed, 14 insertions(+), 25 deletions(-)


This patch has been applied to the wpan-next tree and will be
part of the next pull request to net-next. Thanks!

regards
Stefan Schmidt

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-27  9:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-17 19:29 [PATCH] net: mac802154: Fix a Tx warning check Miquel Raynal
2022-06-20  0:33 ` Alexander Aring
2022-06-27  9:04 ` Stefan Schmidt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.