All of lore.kernel.org
 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: David Ahern <dsahern@kernel.org>,
	netdev@vger.kernel.org, eric.dumazet@gmail.com,
	 Eric Dumazet <edumazet@google.com>
Subject: [PATCH net-next 07/13] ipv6: annotate data-races around idev->cnf.ignore_routes_with_linkdown
Date: Mon, 26 Feb 2024 15:50:49 +0000	[thread overview]
Message-ID: <20240226155055.1141336-8-edumazet@google.com> (raw)
In-Reply-To: <20240226155055.1141336-1-edumazet@google.com>

idev->cnf.ignore_routes_with_linkdown can be used without any locks,
add appropriate annotations.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 include/net/addrconf.h | 2 +-
 net/ipv6/addrconf.c    | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/net/addrconf.h b/include/net/addrconf.h
index 30d6f1e84e465e06a88bbbffaee70fdbd4ec5dd3..9d06eb945509ecfcf01bec1ffa8481262931c5bd 100644
--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -417,7 +417,7 @@ static inline bool ip6_ignore_linkdown(const struct net_device *dev)
 	if (unlikely(!idev))
 		return true;
 
-	return !!idev->cnf.ignore_routes_with_linkdown;
+	return !!READ_ONCE(idev->cnf.ignore_routes_with_linkdown);
 }
 
 void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp);
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index e5e40a37af18e18ceeef75248b205d1ad575802a..86992c1701485834662ec1a11d78576b211fdfab 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -566,7 +566,7 @@ static int inet6_netconf_fill_devconf(struct sk_buff *skb, int ifindex,
 
 	if ((all || type == NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN) &&
 	    nla_put_s32(skb, NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN,
-			devconf->ignore_routes_with_linkdown) < 0)
+			READ_ONCE(devconf->ignore_routes_with_linkdown)) < 0)
 		goto nla_put_failure;
 
 out:
@@ -935,7 +935,7 @@ static void addrconf_linkdown_change(struct net *net, __s32 newf)
 		if (idev) {
 			int changed = (!idev->cnf.ignore_routes_with_linkdown) ^ (!newf);
 
-			idev->cnf.ignore_routes_with_linkdown = newf;
+			WRITE_ONCE(idev->cnf.ignore_routes_with_linkdown, newf);
 			if (changed)
 				inet6_netconf_notify_devconf(dev_net(dev),
 							     RTM_NEWNETCONF,
@@ -956,7 +956,7 @@ static int addrconf_fixup_linkdown(struct ctl_table *table, int *p, int newf)
 
 	net = (struct net *)table->extra2;
 	old = *p;
-	*p = newf;
+	WRITE_ONCE(*p, newf);
 
 	if (p == &net->ipv6.devconf_dflt->ignore_routes_with_linkdown) {
 		if ((!newf) ^ (!old))
@@ -970,7 +970,7 @@ static int addrconf_fixup_linkdown(struct ctl_table *table, int *p, int newf)
 	}
 
 	if (p == &net->ipv6.devconf_all->ignore_routes_with_linkdown) {
-		net->ipv6.devconf_dflt->ignore_routes_with_linkdown = newf;
+		WRITE_ONCE(net->ipv6.devconf_dflt->ignore_routes_with_linkdown, newf);
 		addrconf_linkdown_change(net, newf);
 		if ((!newf) ^ (!old))
 			inet6_netconf_notify_devconf(net,
-- 
2.44.0.rc1.240.g4c46232300-goog


  parent reply	other threads:[~2024-02-26 15:51 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-26 15:50 [PATCH net-next 00/13] ipv6: lockless accesses to devconf Eric Dumazet
2024-02-26 15:50 ` [PATCH net-next 01/13] ipv6: add ipv6_devconf_read_txrx cacheline_group Eric Dumazet
2024-02-26 15:50 ` [PATCH net-next 02/13] ipv6: annotate data-races around cnf.disable_ipv6 Eric Dumazet
2024-02-26 16:09   ` Jiri Pirko
2024-02-26 16:14     ` Eric Dumazet
2024-02-26 16:18       ` Jiri Pirko
2024-02-26 16:24         ` Eric Dumazet
2024-02-26 16:46           ` Jiri Pirko
2024-02-26 15:50 ` [PATCH net-next 03/13] ipv6: annotate data-races around cnf.mtu6 Eric Dumazet
2024-02-26 15:50 ` [PATCH net-next 04/13] ipv6: annotate data-races around cnf.hop_limit Eric Dumazet
2024-02-26 15:50 ` [PATCH net-next 05/13] ipv6: annotate data-races around cnf.forwarding Eric Dumazet
2024-02-26 15:50 ` [PATCH net-next 06/13] ipv6: annotate data-races in ndisc_router_discovery() Eric Dumazet
2024-02-26 15:50 ` Eric Dumazet [this message]
2024-02-26 15:50 ` [PATCH net-next 08/13] ipv6: annotate data-races in rt6_probe() Eric Dumazet
2024-02-26 15:50 ` [PATCH net-next 09/13] ipv6: annotate data-races around devconf->proxy_ndp Eric Dumazet
2024-02-26 15:50 ` [PATCH net-next 10/13] ipv6: annotate data-races around devconf->disable_policy Eric Dumazet
2024-02-26 15:50 ` [PATCH net-next 11/13] ipv6/addrconf: annotate data-races around devconf fields (I) Eric Dumazet
2024-02-26 15:50 ` [PATCH net-next 12/13] ipv6/addrconf: annotate data-races around devconf fields (II) Eric Dumazet
2024-02-26 15:50 ` [PATCH net-next 13/13] ipv6: use xa_array iterator to implement inet6_netconf_dump_devconf() Eric Dumazet
2024-02-26 16:55   ` Jiri Pirko
2024-02-27 11:49     ` Eric Dumazet

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=20240226155055.1141336-8-edumazet@google.com \
    --to=edumazet@google.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --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 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.