* [PATCH net-next 1/8] ipv6: add sysctl_ipv6_flowlabel group
2026-01-15 9:41 [PATCH net-next 0/8] ipv6: more data-race annotations Eric Dumazet
@ 2026-01-15 9:41 ` Eric Dumazet
2026-01-15 9:41 ` [PATCH net-next 2/8] ipv6: annotate data-races from ip6_make_flowlabel() Eric Dumazet
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Eric Dumazet @ 2026-01-15 9:41 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, David Ahern, netdev, eric.dumazet, Eric Dumazet
Group together following struct netns_sysctl_ipv6 fields:
- flowlabel_consistency
- auto_flowlabels
- flowlabel_state_ranges
After this patch, ip6_make_flowlabel() uses a single cache line to fetch
auto_flowlabels and flowlabel_state_ranges (instead of two before the patch).
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
include/net/netns/ipv6.h | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
index 08d2ecc96e2b43901af6d91ae06d555b5ae9298d..34bdb1308e8ff85f04130ed25f40a4f8a24db083 100644
--- a/include/net/netns/ipv6.h
+++ b/include/net/netns/ipv6.h
@@ -30,19 +30,23 @@ struct netns_sysctl_ipv6 {
int ip6_rt_min_advmss;
u32 multipath_hash_fields;
u8 multipath_hash_policy;
- u8 bindv6only;
+
+ __cacheline_group_begin(sysctl_ipv6_flowlabel);
u8 flowlabel_consistency;
u8 auto_flowlabels;
- int icmpv6_time;
+ u8 flowlabel_state_ranges;
+ __cacheline_group_end(sysctl_ipv6_flowlabel);
+
u8 icmpv6_echo_ignore_all;
u8 icmpv6_echo_ignore_multicast;
u8 icmpv6_echo_ignore_anycast;
+ int icmpv6_time;
DECLARE_BITMAP(icmpv6_ratemask, ICMPV6_MSG_MAX + 1);
unsigned long *icmpv6_ratemask_ptr;
u8 anycast_src_echo_reply;
+ u8 bindv6only;
u8 ip_nonlocal_bind;
u8 fwmark_reflect;
- u8 flowlabel_state_ranges;
int idgen_retries;
int idgen_delay;
int flowlabel_reflect;
--
2.52.0.457.g6b5491de43-goog
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH net-next 2/8] ipv6: annotate data-races from ip6_make_flowlabel()
2026-01-15 9:41 [PATCH net-next 0/8] ipv6: more data-race annotations Eric Dumazet
2026-01-15 9:41 ` [PATCH net-next 1/8] ipv6: add sysctl_ipv6_flowlabel group Eric Dumazet
@ 2026-01-15 9:41 ` Eric Dumazet
2026-01-15 9:41 ` [PATCH net-next 3/8] ipv6: annotate date-race in ipv6_can_nonlocal_bind() Eric Dumazet
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Eric Dumazet @ 2026-01-15 9:41 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, David Ahern, netdev, eric.dumazet, Eric Dumazet
Use READ_ONCE() to read sysctl values in ip6_make_flowlabel()
and ip6_make_flowlabel()
Add a const qualifier to 'struct net' parameters.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
include/net/ipv6.h | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 74fbf1ad8065a6596487b72af70131919a26c5a2..7873b34181d9bbf18cc61522967e6db5d646813c 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -949,10 +949,12 @@ static inline bool ipv6_can_nonlocal_bind(struct net *net,
#define IP6_DEFAULT_AUTO_FLOW_LABELS IP6_AUTO_FLOW_LABEL_OPTOUT
-static inline __be32 ip6_make_flowlabel(struct net *net, struct sk_buff *skb,
+static inline __be32 ip6_make_flowlabel(const struct net *net,
+ struct sk_buff *skb,
__be32 flowlabel, bool autolabel,
struct flowi6 *fl6)
{
+ u8 auto_flowlabels;
u32 hash;
/* @flowlabel may include more than a flow label, eg, the traffic class.
@@ -960,10 +962,12 @@ static inline __be32 ip6_make_flowlabel(struct net *net, struct sk_buff *skb,
*/
flowlabel &= IPV6_FLOWLABEL_MASK;
- if (flowlabel ||
- net->ipv6.sysctl.auto_flowlabels == IP6_AUTO_FLOW_LABEL_OFF ||
- (!autolabel &&
- net->ipv6.sysctl.auto_flowlabels != IP6_AUTO_FLOW_LABEL_FORCED))
+ if (flowlabel)
+ return flowlabel;
+
+ auto_flowlabels = READ_ONCE(net->ipv6.sysctl.auto_flowlabels);
+ if (auto_flowlabels == IP6_AUTO_FLOW_LABEL_OFF ||
+ (!autolabel && auto_flowlabels != IP6_AUTO_FLOW_LABEL_FORCED))
return flowlabel;
hash = skb_get_hash_flowi6(skb, fl6);
@@ -976,15 +980,15 @@ static inline __be32 ip6_make_flowlabel(struct net *net, struct sk_buff *skb,
flowlabel = (__force __be32)hash & IPV6_FLOWLABEL_MASK;
- if (net->ipv6.sysctl.flowlabel_state_ranges)
+ if (READ_ONCE(net->ipv6.sysctl.flowlabel_state_ranges))
flowlabel |= IPV6_FLOWLABEL_STATELESS_FLAG;
return flowlabel;
}
-static inline int ip6_default_np_autolabel(struct net *net)
+static inline int ip6_default_np_autolabel(const struct net *net)
{
- switch (net->ipv6.sysctl.auto_flowlabels) {
+ switch (READ_ONCE(net->ipv6.sysctl.auto_flowlabels)) {
case IP6_AUTO_FLOW_LABEL_OFF:
case IP6_AUTO_FLOW_LABEL_OPTIN:
default:
@@ -995,13 +999,13 @@ static inline int ip6_default_np_autolabel(struct net *net)
}
}
#else
-static inline __be32 ip6_make_flowlabel(struct net *net, struct sk_buff *skb,
+static inline __be32 ip6_make_flowlabel(const struct net *net, struct sk_buff *skb,
__be32 flowlabel, bool autolabel,
struct flowi6 *fl6)
{
return flowlabel;
}
-static inline int ip6_default_np_autolabel(struct net *net)
+static inline int ip6_default_np_autolabel(const struct net *net)
{
return 0;
}
--
2.52.0.457.g6b5491de43-goog
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH net-next 3/8] ipv6: annotate date-race in ipv6_can_nonlocal_bind()
2026-01-15 9:41 [PATCH net-next 0/8] ipv6: more data-race annotations Eric Dumazet
2026-01-15 9:41 ` [PATCH net-next 1/8] ipv6: add sysctl_ipv6_flowlabel group Eric Dumazet
2026-01-15 9:41 ` [PATCH net-next 2/8] ipv6: annotate data-races from ip6_make_flowlabel() Eric Dumazet
@ 2026-01-15 9:41 ` Eric Dumazet
2026-01-15 9:41 ` [PATCH net-next 4/8] ipv6: annotate data-races in ip6_multipath_hash_{policy,fields}() Eric Dumazet
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Eric Dumazet @ 2026-01-15 9:41 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, David Ahern, netdev, eric.dumazet, Eric Dumazet
Add a missing READ_ONCE(), and add const qualifiers to the two parameters.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
include/net/ipv6.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 7873b34181d9bbf18cc61522967e6db5d646813c..f39cd85e89123a06f7660868ef42c8050d693fbf 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -931,10 +931,10 @@ static inline void iph_to_flow_copy_v6addrs(struct flow_keys *flow,
#if IS_ENABLED(CONFIG_IPV6)
-static inline bool ipv6_can_nonlocal_bind(struct net *net,
- struct inet_sock *inet)
+static inline bool ipv6_can_nonlocal_bind(const struct net *net,
+ const struct inet_sock *inet)
{
- return net->ipv6.sysctl.ip_nonlocal_bind ||
+ return READ_ONCE(net->ipv6.sysctl.ip_nonlocal_bind) ||
test_bit(INET_FLAGS_FREEBIND, &inet->inet_flags) ||
test_bit(INET_FLAGS_TRANSPARENT, &inet->inet_flags);
}
--
2.52.0.457.g6b5491de43-goog
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH net-next 4/8] ipv6: annotate data-races in ip6_multipath_hash_{policy,fields}()
2026-01-15 9:41 [PATCH net-next 0/8] ipv6: more data-race annotations Eric Dumazet
` (2 preceding siblings ...)
2026-01-15 9:41 ` [PATCH net-next 3/8] ipv6: annotate date-race in ipv6_can_nonlocal_bind() Eric Dumazet
@ 2026-01-15 9:41 ` Eric Dumazet
2026-01-15 9:41 ` [PATCH net-next 5/8] ipv6: annotate data-races over sysctl.flowlabel_reflect Eric Dumazet
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Eric Dumazet @ 2026-01-15 9:41 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, David Ahern, netdev, eric.dumazet, Eric Dumazet
Add missing READ_ONCE() when reading sysctl values.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
include/net/ipv6.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index f39cd85e89123a06f7660868ef42c8050d693fbf..c7f597da01cd92293b9ffbd9e692dea75fd581b8 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -1014,11 +1014,11 @@ static inline int ip6_default_np_autolabel(const struct net *net)
#if IS_ENABLED(CONFIG_IPV6)
static inline int ip6_multipath_hash_policy(const struct net *net)
{
- return net->ipv6.sysctl.multipath_hash_policy;
+ return READ_ONCE(net->ipv6.sysctl.multipath_hash_policy);
}
static inline u32 ip6_multipath_hash_fields(const struct net *net)
{
- return net->ipv6.sysctl.multipath_hash_fields;
+ return READ_ONCE(net->ipv6.sysctl.multipath_hash_fields);
}
#else
static inline int ip6_multipath_hash_policy(const struct net *net)
--
2.52.0.457.g6b5491de43-goog
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH net-next 5/8] ipv6: annotate data-races over sysctl.flowlabel_reflect
2026-01-15 9:41 [PATCH net-next 0/8] ipv6: more data-race annotations Eric Dumazet
` (3 preceding siblings ...)
2026-01-15 9:41 ` [PATCH net-next 4/8] ipv6: annotate data-races in ip6_multipath_hash_{policy,fields}() Eric Dumazet
@ 2026-01-15 9:41 ` Eric Dumazet
2026-01-15 9:41 ` [PATCH net-next 6/8] ipv6: annotate data-races around sysctl.ip6_rt_gc_interval Eric Dumazet
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Eric Dumazet @ 2026-01-15 9:41 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, David Ahern, netdev, eric.dumazet, Eric Dumazet
Add missing READ_ONCE() when reading ipv6.sysctl.flowlabel_reflect,
as its value can be changed under us.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/ipv6/af_inet6.c | 4 ++--
net/ipv6/icmp.c | 3 ++-
net/ipv6/tcp_ipv6.c | 3 ++-
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index b705751eb73c6b784b74f40ab3d7c0933f8259f0..bd29840659f34b5754a182303d2871c5f884dfce 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -224,8 +224,8 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol,
inet6_set_bit(MC6_LOOP, sk);
inet6_set_bit(MC6_ALL, sk);
np->pmtudisc = IPV6_PMTUDISC_WANT;
- inet6_assign_bit(REPFLOW, sk, net->ipv6.sysctl.flowlabel_reflect &
- FLOWLABEL_REFLECT_ESTABLISHED);
+ inet6_assign_bit(REPFLOW, sk, READ_ONCE(net->ipv6.sysctl.flowlabel_reflect) &
+ FLOWLABEL_REFLECT_ESTABLISHED);
sk->sk_ipv6only = net->ipv6.sysctl.bindv6only;
sk->sk_txrehash = READ_ONCE(net->core.sysctl_txrehash);
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index 5d2f90babaa5f14ea6bd712127e31e891e284130..c72270582d9c507f00464d7dc1c57248f8679f72 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -958,7 +958,8 @@ static enum skb_drop_reason icmpv6_echo_reply(struct sk_buff *skb)
tmp_hdr.icmp6_type = type;
memset(&fl6, 0, sizeof(fl6));
- if (net->ipv6.sysctl.flowlabel_reflect & FLOWLABEL_REFLECT_ICMPV6_ECHO_REPLIES)
+ if (READ_ONCE(net->ipv6.sysctl.flowlabel_reflect) &
+ FLOWLABEL_REFLECT_ICMPV6_ECHO_REPLIES)
fl6.flowlabel = ip6_flowlabel(ipv6_hdr(skb));
fl6.flowi6_proto = IPPROTO_ICMPV6;
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 280fe59785598e269183bf90f962ea8d58632b9a..4ae664b05fa9171ed996bf8f3b6e7b2aaa63d5c9 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1085,7 +1085,8 @@ static void tcp_v6_send_reset(const struct sock *sk, struct sk_buff *skb,
txhash = inet_twsk(sk)->tw_txhash;
}
} else {
- if (net->ipv6.sysctl.flowlabel_reflect & FLOWLABEL_REFLECT_TCP_RESET)
+ if (READ_ONCE(net->ipv6.sysctl.flowlabel_reflect) &
+ FLOWLABEL_REFLECT_TCP_RESET)
label = ip6_flowlabel(ipv6h);
}
--
2.52.0.457.g6b5491de43-goog
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH net-next 6/8] ipv6: annotate data-races around sysctl.ip6_rt_gc_interval
2026-01-15 9:41 [PATCH net-next 0/8] ipv6: more data-race annotations Eric Dumazet
` (4 preceding siblings ...)
2026-01-15 9:41 ` [PATCH net-next 5/8] ipv6: annotate data-races over sysctl.flowlabel_reflect Eric Dumazet
@ 2026-01-15 9:41 ` Eric Dumazet
2026-01-15 9:41 ` [PATCH net-next 7/8] ipv6: exthdrs: annotate data-race over multiple sysctl Eric Dumazet
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Eric Dumazet @ 2026-01-15 9:41 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, David Ahern, netdev, eric.dumazet, Eric Dumazet
Add READ_ONCE() on lockless reads of net->ipv6.sysctl.ip6_rt_gc_interval
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/ipv6/ip6_fib.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 2111af022d946d0b9e1a35abdcbac39cbe00f921..174d38c70ac454ac4bd2399a4567862e887150e3 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -1374,14 +1374,14 @@ static void fib6_start_gc(struct net *net, struct fib6_info *rt)
if (!timer_pending(&net->ipv6.ip6_fib_timer) &&
(rt->fib6_flags & RTF_EXPIRES))
mod_timer(&net->ipv6.ip6_fib_timer,
- jiffies + net->ipv6.sysctl.ip6_rt_gc_interval);
+ jiffies + READ_ONCE(net->ipv6.sysctl.ip6_rt_gc_interval));
}
void fib6_force_start_gc(struct net *net)
{
if (!timer_pending(&net->ipv6.ip6_fib_timer))
mod_timer(&net->ipv6.ip6_fib_timer,
- jiffies + net->ipv6.sysctl.ip6_rt_gc_interval);
+ jiffies + READ_ONCE(net->ipv6.sysctl.ip6_rt_gc_interval));
}
static void __fib6_update_sernum_upto_root(struct fib6_info *rt,
@@ -2413,6 +2413,7 @@ static void fib6_gc_all(struct net *net, struct fib6_gc_args *gc_args)
void fib6_run_gc(unsigned long expires, struct net *net, bool force)
{
struct fib6_gc_args gc_args;
+ int ip6_rt_gc_interval;
unsigned long now;
if (force) {
@@ -2421,8 +2422,8 @@ void fib6_run_gc(unsigned long expires, struct net *net, bool force)
mod_timer(&net->ipv6.ip6_fib_timer, jiffies + HZ);
return;
}
- gc_args.timeout = expires ? (int)expires :
- net->ipv6.sysctl.ip6_rt_gc_interval;
+ ip6_rt_gc_interval = READ_ONCE(net->ipv6.sysctl.ip6_rt_gc_interval);
+ gc_args.timeout = expires ? (int)expires : ip6_rt_gc_interval;
gc_args.more = 0;
fib6_gc_all(net, &gc_args);
@@ -2431,8 +2432,7 @@ void fib6_run_gc(unsigned long expires, struct net *net, bool force)
if (gc_args.more)
mod_timer(&net->ipv6.ip6_fib_timer,
- round_jiffies(now
- + net->ipv6.sysctl.ip6_rt_gc_interval));
+ round_jiffies(now + ip6_rt_gc_interval));
else
timer_delete(&net->ipv6.ip6_fib_timer);
spin_unlock_bh(&net->ipv6.fib6_gc_lock);
--
2.52.0.457.g6b5491de43-goog
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH net-next 7/8] ipv6: exthdrs: annotate data-race over multiple sysctl
2026-01-15 9:41 [PATCH net-next 0/8] ipv6: more data-race annotations Eric Dumazet
` (5 preceding siblings ...)
2026-01-15 9:41 ` [PATCH net-next 6/8] ipv6: annotate data-races around sysctl.ip6_rt_gc_interval Eric Dumazet
@ 2026-01-15 9:41 ` Eric Dumazet
2026-01-15 9:41 ` [PATCH net-next 8/8] ipv6: annotate data-races in net/ipv6/route.c Eric Dumazet
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Eric Dumazet @ 2026-01-15 9:41 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, David Ahern, netdev, eric.dumazet, Eric Dumazet
Following four sysctls can change under us, add missing READ_ONCE().
- ipv6.sysctl.max_dst_opts_len
- ipv6.sysctl.max_dst_opts_cnt
- ipv6.sysctl.max_hbh_opts_len
- ipv6.sysctl.max_hbh_opts_cnt
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/ipv6/exthdrs.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index a23eb8734e151dac46a2d03d15de10ce6e45af54..54088fa0c09d068d35779e3cafd721cd24e00ea8 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -314,7 +314,7 @@ static int ipv6_destopt_rcv(struct sk_buff *skb)
}
extlen = (skb_transport_header(skb)[1] + 1) << 3;
- if (extlen > net->ipv6.sysctl.max_dst_opts_len)
+ if (extlen > READ_ONCE(net->ipv6.sysctl.max_dst_opts_len))
goto fail_and_free;
opt->lastopt = opt->dst1 = skb_network_header_len(skb);
@@ -322,7 +322,8 @@ static int ipv6_destopt_rcv(struct sk_buff *skb)
dstbuf = opt->dst1;
#endif
- if (ip6_parse_tlv(false, skb, net->ipv6.sysctl.max_dst_opts_cnt)) {
+ if (ip6_parse_tlv(false, skb,
+ READ_ONCE(net->ipv6.sysctl.max_dst_opts_cnt))) {
skb->transport_header += extlen;
opt = IP6CB(skb);
#if IS_ENABLED(CONFIG_IPV6_MIP6)
@@ -1049,11 +1050,12 @@ int ipv6_parse_hopopts(struct sk_buff *skb)
}
extlen = (skb_transport_header(skb)[1] + 1) << 3;
- if (extlen > net->ipv6.sysctl.max_hbh_opts_len)
+ if (extlen > READ_ONCE(net->ipv6.sysctl.max_hbh_opts_len))
goto fail_and_free;
opt->flags |= IP6SKB_HOPBYHOP;
- if (ip6_parse_tlv(true, skb, net->ipv6.sysctl.max_hbh_opts_cnt)) {
+ if (ip6_parse_tlv(true, skb,
+ READ_ONCE(net->ipv6.sysctl.max_hbh_opts_cnt))) {
skb->transport_header += extlen;
opt = IP6CB(skb);
opt->nhoff = sizeof(struct ipv6hdr);
--
2.52.0.457.g6b5491de43-goog
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH net-next 8/8] ipv6: annotate data-races in net/ipv6/route.c
2026-01-15 9:41 [PATCH net-next 0/8] ipv6: more data-race annotations Eric Dumazet
` (6 preceding siblings ...)
2026-01-15 9:41 ` [PATCH net-next 7/8] ipv6: exthdrs: annotate data-race over multiple sysctl Eric Dumazet
@ 2026-01-15 9:41 ` Eric Dumazet
2026-01-19 16:59 ` [PATCH net-next 0/8] ipv6: more data-race annotations Simon Horman
2026-01-19 18:10 ` patchwork-bot+netdevbpf
9 siblings, 0 replies; 11+ messages in thread
From: Eric Dumazet @ 2026-01-15 9:41 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, David Ahern, netdev, eric.dumazet, Eric Dumazet
sysctls are read while their values can change,
add READ_ONCE() annotations.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/ipv6/route.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 00a8318f33a7be7e09806e19522d5a120d4200af..032061d46bff786f787109443fd7c18e9361841c 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2895,7 +2895,7 @@ static void rt6_do_update_pmtu(struct rt6_info *rt, u32 mtu)
dst_metric_set(&rt->dst, RTAX_MTU, mtu);
rt->rt6i_flags |= RTF_MODIFIED;
- rt6_update_expires(rt, net->ipv6.sysctl.ip6_rt_mtu_expires);
+ rt6_update_expires(rt, READ_ONCE(net->ipv6.sysctl.ip6_rt_mtu_expires));
}
static bool rt6_cache_allowed_for_pmtu(const struct rt6_info *rt)
@@ -3256,8 +3256,8 @@ static unsigned int ip6_default_advmss(const struct dst_entry *dst)
rcu_read_lock();
net = dst_dev_net_rcu(dst);
- if (mtu < net->ipv6.sysctl.ip6_rt_min_advmss)
- mtu = net->ipv6.sysctl.ip6_rt_min_advmss;
+ mtu = max_t(unsigned int, mtu,
+ READ_ONCE(net->ipv6.sysctl.ip6_rt_min_advmss));
rcu_read_unlock();
@@ -3359,10 +3359,10 @@ struct dst_entry *icmp6_dst_alloc(struct net_device *dev,
static void ip6_dst_gc(struct dst_ops *ops)
{
struct net *net = container_of(ops, struct net, ipv6.ip6_dst_ops);
- int rt_min_interval = net->ipv6.sysctl.ip6_rt_gc_min_interval;
- int rt_elasticity = net->ipv6.sysctl.ip6_rt_gc_elasticity;
- int rt_gc_timeout = net->ipv6.sysctl.ip6_rt_gc_timeout;
- unsigned long rt_last_gc = net->ipv6.ip6_rt_last_gc;
+ int rt_min_interval = READ_ONCE(net->ipv6.sysctl.ip6_rt_gc_min_interval);
+ int rt_elasticity = READ_ONCE(net->ipv6.sysctl.ip6_rt_gc_elasticity);
+ int rt_gc_timeout = READ_ONCE(net->ipv6.sysctl.ip6_rt_gc_timeout);
+ unsigned long rt_last_gc = READ_ONCE(net->ipv6.ip6_rt_last_gc);
unsigned int val;
int entries;
@@ -5005,7 +5005,7 @@ void rt6_sync_down_dev(struct net_device *dev, unsigned long event)
};
struct net *net = dev_net(dev);
- if (net->ipv6.sysctl.skip_notify_on_dev_down)
+ if (READ_ONCE(net->ipv6.sysctl.skip_notify_on_dev_down))
fib6_clean_all_skip_notify(net, fib6_ifdown, &arg);
else
fib6_clean_all(net, fib6_ifdown, &arg);
@@ -6405,6 +6405,7 @@ void fib6_rt_update(struct net *net, struct fib6_info *rt,
void fib6_info_hw_flags_set(struct net *net, struct fib6_info *f6i,
bool offload, bool trap, bool offload_failed)
{
+ u8 fib_notify_on_flag_change;
struct sk_buff *skb;
int err;
@@ -6416,8 +6417,9 @@ void fib6_info_hw_flags_set(struct net *net, struct fib6_info *f6i,
WRITE_ONCE(f6i->offload, offload);
WRITE_ONCE(f6i->trap, trap);
+ fib_notify_on_flag_change = READ_ONCE(net->ipv6.sysctl.fib_notify_on_flag_change);
/* 2 means send notifications only if offload_failed was changed. */
- if (net->ipv6.sysctl.fib_notify_on_flag_change == 2 &&
+ if (fib_notify_on_flag_change == 2 &&
READ_ONCE(f6i->offload_failed) == offload_failed)
return;
@@ -6429,7 +6431,7 @@ void fib6_info_hw_flags_set(struct net *net, struct fib6_info *f6i,
*/
return;
- if (!net->ipv6.sysctl.fib_notify_on_flag_change)
+ if (!fib_notify_on_flag_change)
return;
skb = nlmsg_new(rt6_nlmsg_size(f6i), GFP_KERNEL);
@@ -6526,7 +6528,7 @@ static int ipv6_sysctl_rtcache_flush(const struct ctl_table *ctl, int write,
return ret;
net = (struct net *)ctl->extra1;
- delay = net->ipv6.sysctl.flush_delay;
+ delay = READ_ONCE(net->ipv6.sysctl.flush_delay);
fib6_run_gc(delay <= 0 ? 0 : (unsigned long)delay, net, delay > 0);
return 0;
}
--
2.52.0.457.g6b5491de43-goog
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH net-next 0/8] ipv6: more data-race annotations
2026-01-15 9:41 [PATCH net-next 0/8] ipv6: more data-race annotations Eric Dumazet
` (7 preceding siblings ...)
2026-01-15 9:41 ` [PATCH net-next 8/8] ipv6: annotate data-races in net/ipv6/route.c Eric Dumazet
@ 2026-01-19 16:59 ` Simon Horman
2026-01-19 18:10 ` patchwork-bot+netdevbpf
9 siblings, 0 replies; 11+ messages in thread
From: Simon Horman @ 2026-01-19 16:59 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S. Miller, Jakub Kicinski, Paolo Abeni, David Ahern, netdev,
eric.dumazet
On Thu, Jan 15, 2026 at 09:41:33AM +0000, Eric Dumazet wrote:
> Inspired by one unrelated syzbot report.
>
> This series adds missing (and boring) data-race annotations in IPv6.
>
> Only the first patch adds sysctl_ipv6_flowlabel group
> to speedup ip6_make_flowlabel() a bit.
Thanks Eric,
This all looks good to me.
And thanks for including the const updates.
For the series:
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH net-next 0/8] ipv6: more data-race annotations
2026-01-15 9:41 [PATCH net-next 0/8] ipv6: more data-race annotations Eric Dumazet
` (8 preceding siblings ...)
2026-01-19 16:59 ` [PATCH net-next 0/8] ipv6: more data-race annotations Simon Horman
@ 2026-01-19 18:10 ` patchwork-bot+netdevbpf
9 siblings, 0 replies; 11+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-01-19 18:10 UTC (permalink / raw)
To: Eric Dumazet; +Cc: davem, kuba, pabeni, horms, dsahern, netdev, eric.dumazet
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 15 Jan 2026 09:41:33 +0000 you wrote:
> Inspired by one unrelated syzbot report.
>
> This series adds missing (and boring) data-race annotations in IPv6.
>
> Only the first patch adds sysctl_ipv6_flowlabel group
> to speedup ip6_make_flowlabel() a bit.
>
> [...]
Here is the summary with links:
- [net-next,1/8] ipv6: add sysctl_ipv6_flowlabel group
https://git.kernel.org/netdev/net-next/c/e82a347d92d1
- [net-next,2/8] ipv6: annotate data-races from ip6_make_flowlabel()
https://git.kernel.org/netdev/net-next/c/ded139b59b5d
- [net-next,3/8] ipv6: annotate date-race in ipv6_can_nonlocal_bind()
https://git.kernel.org/netdev/net-next/c/3681282530e6
- [net-next,4/8] ipv6: annotate data-races in ip6_multipath_hash_{policy,fields}()
https://git.kernel.org/netdev/net-next/c/03e9d91dd64e
- [net-next,5/8] ipv6: annotate data-races over sysctl.flowlabel_reflect
https://git.kernel.org/netdev/net-next/c/5ade47c974b4
- [net-next,6/8] ipv6: annotate data-races around sysctl.ip6_rt_gc_interval
https://git.kernel.org/netdev/net-next/c/12eddc685744
- [net-next,7/8] ipv6: exthdrs: annotate data-race over multiple sysctl
https://git.kernel.org/netdev/net-next/c/978b67d28358
- [net-next,8/8] ipv6: annotate data-races in net/ipv6/route.c
https://git.kernel.org/netdev/net-next/c/f062e8e25102
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 11+ messages in thread