Re: [PATCH 1/2] ipv4: igmp: annotate data-races around in_dev->mc_count
From: Paolo Abeni
Date: Thu Jun 04 2026 - 05:19:05 EST
On 5/31/26 5:07 AM, Yuyang Huang wrote:
> @@ -1922,7 +1923,7 @@ void ip_mc_destroy_dev(struct in_device *in_dev)
>
> while ((i = rtnl_dereference(in_dev->mc_list)) != NULL) {
> in_dev->mc_list = i->next_rcu;
> - in_dev->mc_count--;
> + WRITE_ONCE(in_dev->mc_count, in_dev->mc_count - 1);
> ip_mc_clear_src(i);
> ip_ma_put(i);
The patch LGTM, but note that sashiko has identified a pre-existing
issue which could deserve a follow-up:
https://sashiko.dev/#/patchset/20260531030705.3754389-1-yuyanghuang%40google.com
/P
> }
> @@ -2974,7 +2975,9 @@ static int igmp_mc_seq_show(struct seq_file *seq, void *v)
>
> if (rcu_access_pointer(state->in_dev->mc_list) == im) {
> seq_printf(seq, "%d\t%-10s: %5d %7s\n",
> - state->dev->ifindex, state->dev->name, state->in_dev->mc_count, querier);
> + state->dev->ifindex, state->dev->name,
> + READ_ONCE(state->in_dev->mc_count),
> + querier);
> }
>
> delta = im->timer.expires - jiffies;