Skip to content

Commit e4faaf6

Browse files
edumazetkuba-moo
authored andcommitted
ipv4: igmp: annotate data-races around idev->mr_maxdelay
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 <[email protected]> Reviewed-by: David Ahern <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 0541302 commit e4faaf6

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

include/linux/inetdevice.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ struct in_device {
3838
struct ip_mc_list *mc_tomb;
3939
unsigned long mr_v1_seen;
4040
unsigned long mr_v2_seen;
41-
unsigned long mr_maxdelay;
4241
unsigned long mr_qi; /* Query Interval */
4342
unsigned long mr_qri; /* Query Response Interval */
4443
unsigned char mr_qrv; /* Query Robustness Variable */
4544
unsigned char mr_gq_running;
45+
u32 mr_maxdelay;
4646
u32 mr_ifc_count;
4747
struct timer_list mr_gq_timer; /* general query timer */
4848
struct timer_list mr_ifc_timer; /* interface change timer */

net/ipv4/igmp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ static void igmp_start_timer(struct ip_mc_list *im, int max_delay)
227227

228228
static void igmp_gq_start_timer(struct in_device *in_dev)
229229
{
230-
int tv = get_random_u32_below(in_dev->mr_maxdelay);
230+
int tv = get_random_u32_below(READ_ONCE(in_dev->mr_maxdelay));
231231
unsigned long exp = jiffies + tv + 2;
232232

233233
if (in_dev->mr_gq_running &&
@@ -1009,7 +1009,7 @@ static bool igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb,
10091009
max_delay = IGMPV3_MRC(ih3->code)*(HZ/IGMP_TIMER_SCALE);
10101010
if (!max_delay)
10111011
max_delay = 1; /* can't mod w/ 0 */
1012-
in_dev->mr_maxdelay = max_delay;
1012+
WRITE_ONCE(in_dev->mr_maxdelay, max_delay);
10131013

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

0 commit comments

Comments
 (0)