netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <edumazet@google.com>
To: "David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, eric.dumazet@gmail.com,
	 Eric Dumazet <edumazet@google.com>
Subject: [PATCH net-next 1/8] rtnetlink: do not depend on RTNL for IFLA_QDISC output
Date: Fri,  3 May 2024 19:20:52 +0000	[thread overview]
Message-ID: <20240503192059.3884225-2-edumazet@google.com> (raw)
In-Reply-To: <20240503192059.3884225-1-edumazet@google.com>

dev->qdisc can be read using RCU protection.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/core/rtnetlink.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 283e42f48af68504af193ed5763d4e0fcd667d99..f4a87f89d5cde0cdd35c156d78ebe31511d4a31c 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1832,7 +1832,6 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb,
 	if (tgt_netnsid >= 0 && nla_put_s32(skb, IFLA_TARGET_NETNSID, tgt_netnsid))
 		goto nla_put_failure;
 
-	qdisc = rtnl_dereference(dev->qdisc);
 	if (nla_put_string(skb, IFLA_IFNAME, dev->name) ||
 	    nla_put_u32(skb, IFLA_TXQLEN, dev->tx_queue_len) ||
 	    nla_put_u8(skb, IFLA_OPERSTATE,
@@ -1857,8 +1856,6 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb,
 #endif
 	    put_master_ifindex(skb, dev) ||
 	    nla_put_u8(skb, IFLA_CARRIER, netif_carrier_ok(dev)) ||
-	    (qdisc &&
-	     nla_put_string(skb, IFLA_QDISC, qdisc->ops->id)) ||
 	    nla_put_ifalias(skb, dev) ||
 	    nla_put_u32(skb, IFLA_CARRIER_CHANGES,
 			atomic_read(&dev->carrier_up_count) +
@@ -1924,6 +1921,9 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb,
 		goto nla_put_failure;
 
 	rcu_read_lock();
+	qdisc = rcu_dereference(dev->qdisc);
+	if (qdisc && nla_put_string(skb, IFLA_QDISC, qdisc->ops->id))
+		goto nla_put_failure_rcu;
 	if (rtnl_fill_link_af(skb, dev, ext_filter_mask))
 		goto nla_put_failure_rcu;
 	if (rtnl_fill_link_ifmap(skb, dev))
-- 
2.45.0.rc1.225.g2a3ae87e7f-goog


  reply	other threads:[~2024-05-03 19:21 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-03 19:20 [PATCH net-next 0/8] rtnetlink: more rcu conversions for rtnl_fill_ifinfo() Eric Dumazet
2024-05-03 19:20 ` Eric Dumazet [this message]
2024-05-05 14:48   ` [PATCH net-next 1/8] rtnetlink: do not depend on RTNL for IFLA_QDISC output Simon Horman
2024-05-03 19:20 ` [PATCH net-next 2/8] rtnetlink: do not depend on RTNL for IFLA_IFNAME output Eric Dumazet
2024-05-05 14:49   ` Simon Horman
2024-05-03 19:20 ` [PATCH net-next 3/8] rtnetlink: do not depend on RTNL for IFLA_TXQLEN output Eric Dumazet
2024-05-05 14:43   ` Simon Horman
2024-05-07  9:26     ` Paolo Abeni
2024-05-07  9:35       ` Eric Dumazet
2024-05-07 16:32       ` Simon Horman
2024-05-03 19:20 ` [PATCH net-next 4/8] net: write once on dev->allmulti and dev->promiscuity Eric Dumazet
2024-05-05 14:54   ` Simon Horman
2024-05-03 19:20 ` [PATCH net-next 5/8] rtnetlink: do not depend on RTNL for many attributes Eric Dumazet
2024-05-05 14:46   ` Simon Horman
2024-05-05 15:00     ` Eric Dumazet
2024-05-05 15:06       ` Simon Horman
2024-05-05 15:14         ` Eric Dumazet
2024-05-07 16:38           ` Simon Horman
2024-05-07 16:39             ` Eric Dumazet
2024-05-07 16:55               ` Simon Horman
2024-05-03 19:20 ` [PATCH net-next 6/8] rtnetlink: do not depend on RTNL in rtnl_fill_proto_down() Eric Dumazet
2024-05-05 14:52   ` Simon Horman
2024-05-03 19:20 ` [PATCH net-next 7/8] rtnetlink: do not depend on RTNL in rtnl_xdp_prog_skb() Eric Dumazet
2024-05-05 14:53   ` Simon Horman
2024-05-03 19:20 ` [PATCH net-next 8/8] rtnetlink: allow rtnl_fill_link_netnsid() to run under RCU protection Eric Dumazet
2024-05-05 14:54   ` Simon Horman
2024-05-07  9:40 ` [PATCH net-next 0/8] rtnetlink: more rcu conversions for rtnl_fill_ifinfo() patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240503192059.3884225-2-edumazet@google.com \
    --to=edumazet@google.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).