public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] ipv4: igmp: annotate data-races around idev->mr_maxdelay
@ 2026-01-22 17:22 Eric Dumazet
  2026-01-22 20:05 ` David Ahern
  2026-01-25 22:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2026-01-22 17:22 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: Simon Horman, David Ahern, netdev, eric.dumazet, Eric Dumazet

idev->mr_maxdelay is read and written locklessly,
add READ_ONCE()/WRITE_ONCE() annotations.

While we are at it, make this field an u32.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 include/linux/inetdevice.h | 2 +-
 net/ipv4/igmp.c            | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h
index 5730ba6b1cfaff25f2b9d206722662e1e62b88fc..dccbeb25f70141982160c776f3cc727296def2b7 100644
--- a/include/linux/inetdevice.h
+++ b/include/linux/inetdevice.h
@@ -38,11 +38,11 @@ struct in_device {
 	struct ip_mc_list	*mc_tomb;
 	unsigned long		mr_v1_seen;
 	unsigned long		mr_v2_seen;
-	unsigned long		mr_maxdelay;
 	unsigned long		mr_qi;		/* Query Interval */
 	unsigned long		mr_qri;		/* Query Response Interval */
 	unsigned char		mr_qrv;		/* Query Robustness Variable */
 	unsigned char		mr_gq_running;
+	u32			mr_maxdelay;
 	u32			mr_ifc_count;
 	struct timer_list	mr_gq_timer;	/* general query timer */
 	struct timer_list	mr_ifc_timer;	/* interface change timer */
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 7182f1419c2a4d4ea1e90ef6857f6af895dd2770..0adc993c211d7a3901f9a0e9ee816e7fddc598cd 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -227,7 +227,7 @@ static void igmp_start_timer(struct ip_mc_list *im, int max_delay)
 
 static void igmp_gq_start_timer(struct in_device *in_dev)
 {
-	int tv = get_random_u32_below(in_dev->mr_maxdelay);
+	int tv = get_random_u32_below(READ_ONCE(in_dev->mr_maxdelay));
 	unsigned long exp = jiffies + tv + 2;
 
 	if (in_dev->mr_gq_running &&
@@ -1009,7 +1009,7 @@ static bool igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb,
 		max_delay = IGMPV3_MRC(ih3->code)*(HZ/IGMP_TIMER_SCALE);
 		if (!max_delay)
 			max_delay = 1;	/* can't mod w/ 0 */
-		in_dev->mr_maxdelay = max_delay;
+		WRITE_ONCE(in_dev->mr_maxdelay, max_delay);
 
 		/* RFC3376, 4.1.6. QRV and 4.1.7. QQIC, when the most recently
 		 * received value was zero, use the default or statically
-- 
2.52.0.457.g6b5491de43-goog


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

* Re: [PATCH net-next] ipv4: igmp: annotate data-races around idev->mr_maxdelay
  2026-01-22 17:22 [PATCH net-next] ipv4: igmp: annotate data-races around idev->mr_maxdelay Eric Dumazet
@ 2026-01-22 20:05 ` David Ahern
  2026-01-25 22:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: David Ahern @ 2026-01-22 20:05 UTC (permalink / raw)
  To: Eric Dumazet, David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: Simon Horman, netdev, eric.dumazet

On 1/22/26 10:22 AM, Eric Dumazet wrote:
> idev->mr_maxdelay is read and written locklessly,
> add READ_ONCE()/WRITE_ONCE() annotations.
> 
> While we are at it, make this field an u32.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> ---
>  include/linux/inetdevice.h | 2 +-
>  net/ipv4/igmp.c            | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h
> index 5730ba6b1cfaff25f2b9d206722662e1e62b88fc..dccbeb25f70141982160c776f3cc727296def2b7 100644
> --- a/include/linux/inetdevice.h
> +++ b/include/linux/inetdevice.h
> @@ -38,11 +38,11 @@ struct in_device {
>  	struct ip_mc_list	*mc_tomb;
>  	unsigned long		mr_v1_seen;
>  	unsigned long		mr_v2_seen;
> -	unsigned long		mr_maxdelay;
>  	unsigned long		mr_qi;		/* Query Interval */
>  	unsigned long		mr_qri;		/* Query Response Interval */
>  	unsigned char		mr_qrv;		/* Query Robustness Variable */
>  	unsigned char		mr_gq_running;
> +	u32			mr_maxdelay;
>  	u32			mr_ifc_count;
>  	struct timer_list	mr_gq_timer;	/* general query timer */
>  	struct timer_list	mr_ifc_timer;	/* interface change timer */
> diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
> index 7182f1419c2a4d4ea1e90ef6857f6af895dd2770..0adc993c211d7a3901f9a0e9ee816e7fddc598cd 100644
> --- a/net/ipv4/igmp.c
> +++ b/net/ipv4/igmp.c
> @@ -227,7 +227,7 @@ static void igmp_start_timer(struct ip_mc_list *im, int max_delay)
>  
>  static void igmp_gq_start_timer(struct in_device *in_dev)
>  {
> -	int tv = get_random_u32_below(in_dev->mr_maxdelay);
> +	int tv = get_random_u32_below(READ_ONCE(in_dev->mr_maxdelay));

u32 tv? fix that type while at it.

>  	unsigned long exp = jiffies + tv + 2;
>  
>  	if (in_dev->mr_gq_running &&
> @@ -1009,7 +1009,7 @@ static bool igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb,
>  		max_delay = IGMPV3_MRC(ih3->code)*(HZ/IGMP_TIMER_SCALE);
>  		if (!max_delay)
>  			max_delay = 1;	/* can't mod w/ 0 */
> -		in_dev->mr_maxdelay = max_delay;
> +		WRITE_ONCE(in_dev->mr_maxdelay, max_delay);

max_delay can also be u32; only scope creep with this patch set is
fixing up igmp_mod_timer to take u32.


>  
>  		/* RFC3376, 4.1.6. QRV and 4.1.7. QQIC, when the most recently
>  		 * received value was zero, use the default or statically

Reviewed-by: David Ahern <dsahern@kernel.org>


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

* Re: [PATCH net-next] ipv4: igmp: annotate data-races around idev->mr_maxdelay
  2026-01-22 17:22 [PATCH net-next] ipv4: igmp: annotate data-races around idev->mr_maxdelay Eric Dumazet
  2026-01-22 20:05 ` David Ahern
@ 2026-01-25 22:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-01-25 22:50 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: davem, kuba, pabeni, horms, dsahern, netdev, eric.dumazet

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 22 Jan 2026 17:22:47 +0000 you wrote:
> idev->mr_maxdelay is read and written locklessly,
> add READ_ONCE()/WRITE_ONCE() annotations.
> 
> While we are at it, make this field an u32.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> 
> [...]

Here is the summary with links:
  - [net-next] ipv4: igmp: annotate data-races around idev->mr_maxdelay
    https://git.kernel.org/netdev/net-next/c/e4faaf65a75f

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] 3+ messages in thread

end of thread, other threads:[~2026-01-25 22:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-22 17:22 [PATCH net-next] ipv4: igmp: annotate data-races around idev->mr_maxdelay Eric Dumazet
2026-01-22 20:05 ` David Ahern
2026-01-25 22:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox