netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: Eric Dumazet <edumazet@google.com>
Cc: "David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, Ido Schimmel <idosch@nvidia.com>,
	Jiri Pirko <jiri@nvidia.com>,
	eric.dumazet@gmail.com
Subject: Re: [PATCH v2 net-next 03/14] ipv6: prepare inet6_fill_ifinfo() for RCU protection
Date: Thu, 22 Feb 2024 17:36:45 +0100	[thread overview]
Message-ID: <Zdd4HbfO2Bn9dfuz@nanopsycho> (raw)
In-Reply-To: <20240222105021.1943116-4-edumazet@google.com>

Thu, Feb 22, 2024 at 11:50:10AM CET, edumazet@google.com wrote:
>We want to use RCU protection instead of RTNL

Is this a royal "We"? :)


>for inet6_fill_ifinfo().

This is a motivation for this patch, not what the patch does.

Would it be possible to maintain some sort of culture for the patch
descriptions, even of the patches which are small and simple?

https://www.kernel.org/doc/html/v6.6/process/submitting-patches.html#describe-your-changes

Your patch descriptions are usually hard to follow for me to understand
what the patch does :( Yes, I know you do it "to displease me" as you
wrote couple of months ago but maybe think about the others too, also
the ones looking in a git log/show and guessing.

Don't beat me.


>
>Signed-off-by: Eric Dumazet <edumazet@google.com>
>---
> include/linux/netdevice.h |  6 ++++--
> net/core/dev.c            |  4 ++--
> net/ipv6/addrconf.c       | 11 +++++++----
> 3 files changed, 13 insertions(+), 8 deletions(-)
>
>diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
>index f07c8374f29cb936fe11236fc63e06e741b1c965..09023e44db4e2c3a2133afc52ba5a335d6030646 100644
>--- a/include/linux/netdevice.h
>+++ b/include/linux/netdevice.h
>@@ -4354,8 +4354,10 @@ static inline bool netif_testing(const struct net_device *dev)
>  */
> static inline bool netif_oper_up(const struct net_device *dev)
> {
>-	return (dev->operstate == IF_OPER_UP ||
>-		dev->operstate == IF_OPER_UNKNOWN /* backward compat */);
>+	unsigned int operstate = READ_ONCE(dev->operstate);
>+
>+	return	operstate == IF_OPER_UP ||

double space  ^^


>+		operstate == IF_OPER_UNKNOWN /* backward compat */;
> }
> 
> /**
>diff --git a/net/core/dev.c b/net/core/dev.c
>index 0628d8ff1ed932efdd45ab7b79599dcfcca6c4eb..275fd5259a4a92d0bd2e145d66a716248b6c2804 100644
>--- a/net/core/dev.c
>+++ b/net/core/dev.c
>@@ -8632,12 +8632,12 @@ unsigned int dev_get_flags(const struct net_device *dev)
> {
> 	unsigned int flags;
> 
>-	flags = (dev->flags & ~(IFF_PROMISC |
>+	flags = (READ_ONCE(dev->flags) & ~(IFF_PROMISC |
> 				IFF_ALLMULTI |
> 				IFF_RUNNING |
> 				IFF_LOWER_UP |
> 				IFF_DORMANT)) |
>-		(dev->gflags & (IFF_PROMISC |
>+		(READ_ONCE(dev->gflags) & (IFF_PROMISC |
> 				IFF_ALLMULTI));
> 
> 	if (netif_running(dev)) {
>diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
>index 3c8bdad0105dc9542489b612890ba86de9c44bdc..df3c6feea74e2d95144140eceb6df5cef2dce1f4 100644
>--- a/net/ipv6/addrconf.c
>+++ b/net/ipv6/addrconf.c
>@@ -6047,6 +6047,7 @@ static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev,
> 	struct net_device *dev = idev->dev;
> 	struct ifinfomsg *hdr;
> 	struct nlmsghdr *nlh;
>+	int ifindex, iflink;
> 	void *protoinfo;
> 
> 	nlh = nlmsg_put(skb, portid, seq, event, sizeof(*hdr), flags);
>@@ -6057,16 +6058,18 @@ static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev,
> 	hdr->ifi_family = AF_INET6;
> 	hdr->__ifi_pad = 0;
> 	hdr->ifi_type = dev->type;
>-	hdr->ifi_index = dev->ifindex;
>+	ifindex = READ_ONCE(dev->ifindex);
>+	hdr->ifi_index = ifindex;
> 	hdr->ifi_flags = dev_get_flags(dev);
> 	hdr->ifi_change = 0;
> 
>+	iflink = dev_get_iflink(dev);
> 	if (nla_put_string(skb, IFLA_IFNAME, dev->name) ||
> 	    (dev->addr_len &&
> 	     nla_put(skb, IFLA_ADDRESS, dev->addr_len, dev->dev_addr)) ||
>-	    nla_put_u32(skb, IFLA_MTU, dev->mtu) ||
>-	    (dev->ifindex != dev_get_iflink(dev) &&
>-	     nla_put_u32(skb, IFLA_LINK, dev_get_iflink(dev))) ||
>+	    nla_put_u32(skb, IFLA_MTU, READ_ONCE(dev->mtu)) ||
>+	    (ifindex != iflink &&
>+	     nla_put_u32(skb, IFLA_LINK, iflink)) ||
> 	    nla_put_u8(skb, IFLA_OPERSTATE,
> 		       netif_running(dev) ? READ_ONCE(dev->operstate) : IF_OPER_DOWN))
> 		goto nla_put_failure;
>-- 
>2.44.0.rc1.240.g4c46232300-goog
>
>

  reply	other threads:[~2024-02-22 16:36 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-22 10:50 [PATCH v2 net-next 00/14] rtnetlink: reduce RTNL pressure for dumps Eric Dumazet
2024-02-22 10:50 ` [PATCH v2 net-next 01/14] rtnetlink: prepare nla_put_iflink() to run under RCU Eric Dumazet
2024-02-23 13:29   ` Donald Hunter
2024-02-24  8:21     ` Eric Dumazet
2024-02-24 10:46       ` Donald Hunter
2024-02-24 11:08         ` Eric Dumazet
2024-02-26  8:59           ` Donald Hunter
2024-02-22 10:50 ` [PATCH v2 net-next 02/14] ipv6: prepare inet6_fill_ifla6_attrs() for RCU Eric Dumazet
2024-02-23 14:35   ` Donald Hunter
2024-02-22 10:50 ` [PATCH v2 net-next 03/14] ipv6: prepare inet6_fill_ifinfo() for RCU protection Eric Dumazet
2024-02-22 16:36   ` Jiri Pirko [this message]
2024-02-22 16:43     ` Eric Dumazet
2024-02-23  7:19       ` Jiri Pirko
2024-02-22 16:45     ` Eric Dumazet
2024-02-23  7:16       ` Jiri Pirko
2024-02-22 10:50 ` [PATCH v2 net-next 04/14] ipv6: use xarray iterator to implement inet6_dump_ifinfo() Eric Dumazet
2024-02-23 14:42   ` Donald Hunter
2024-02-22 10:50 ` [PATCH v2 net-next 05/14] netlink: fix netlink_diag_dump() return value Eric Dumazet
2024-02-23 12:30   ` Donald Hunter
2024-02-22 10:50 ` [PATCH v2 net-next 06/14] netlink: hold nlk->cb_mutex longer in __netlink_dump_start() Eric Dumazet
2024-02-22 16:20   ` Jiri Pirko
2024-06-09  8:17     ` Tetsuo Handa
2024-06-09  8:29       ` Tetsuo Handa
2024-06-10 12:59         ` Eric Dumazet
2024-06-10 13:21           ` Tetsuo Handa
2024-02-22 10:50 ` [PATCH v2 net-next 07/14] rtnetlink: change nlk->cb_mutex role Eric Dumazet
2024-02-22 10:50 ` [PATCH v2 net-next 08/14] rtnetlink: add RTNL_FLAG_DUMP_UNLOCKED flag Eric Dumazet
2024-02-23 15:19   ` Donald Hunter
2024-02-22 10:50 ` [PATCH v2 net-next 09/14] ipv6: switch inet6_dump_ifinfo() to RCU protection Eric Dumazet
2024-02-23 15:19   ` Donald Hunter
2024-02-22 10:50 ` [PATCH v2 net-next 10/14] inet: allow ip_valid_fib_dump_req() to be called with RTNL or RCU Eric Dumazet
2024-02-23 15:22   ` Donald Hunter
2024-02-22 10:50 ` [PATCH v2 net-next 11/14] nexthop: allow nexthop_mpath_fill_node() to be called without RTNL Eric Dumazet
2024-02-23 15:21   ` Donald Hunter
2024-02-22 10:50 ` [PATCH v2 net-next 12/14] inet: switch inet_dump_fib() to RCU protection Eric Dumazet
2024-02-23 15:25   ` Donald Hunter
2024-02-22 10:50 ` [PATCH v2 net-next 13/14] rtnetlink: make rtnl_fill_link_ifmap() RCU ready Eric Dumazet
2024-02-23 13:03   ` Donald Hunter
2024-02-22 10:50 ` [PATCH v2 net-next 14/14] rtnetlink: provide RCU protection to rtnl_fill_prop_list() Eric Dumazet
2024-02-23 13:03   ` Donald Hunter
2024-02-26 11:50 ` [PATCH v2 net-next 00/14] rtnetlink: reduce RTNL pressure for dumps 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=Zdd4HbfO2Bn9dfuz@nanopsycho \
    --to=jiri@resnulli.us \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=idosch@nvidia.com \
    --cc=jiri@nvidia.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).