@@ -97,7 +97,7 @@ static void tcpm_suck_dst(struct tcp_metrics_block *tm,
97
97
u32 msval ;
98
98
u32 val ;
99
99
100
- tm -> tcpm_stamp = jiffies ;
100
+ WRITE_ONCE ( tm -> tcpm_stamp , jiffies ) ;
101
101
102
102
val = 0 ;
103
103
if (dst_metric_locked (dst , RTAX_RTT ))
@@ -131,9 +131,15 @@ static void tcpm_suck_dst(struct tcp_metrics_block *tm,
131
131
132
132
#define TCP_METRICS_TIMEOUT (60 * 60 * HZ)
133
133
134
- static void tcpm_check_stamp (struct tcp_metrics_block * tm , struct dst_entry * dst )
134
+ static void tcpm_check_stamp (struct tcp_metrics_block * tm ,
135
+ const struct dst_entry * dst )
135
136
{
136
- if (tm && unlikely (time_after (jiffies , tm -> tcpm_stamp + TCP_METRICS_TIMEOUT )))
137
+ unsigned long limit ;
138
+
139
+ if (!tm )
140
+ return ;
141
+ limit = READ_ONCE (tm -> tcpm_stamp ) + TCP_METRICS_TIMEOUT ;
142
+ if (unlikely (time_after (jiffies , limit )))
137
143
tcpm_suck_dst (tm , dst , false);
138
144
}
139
145
@@ -174,7 +180,8 @@ static struct tcp_metrics_block *tcpm_new(struct dst_entry *dst,
174
180
oldest = deref_locked (tcp_metrics_hash [hash ].chain );
175
181
for (tm = deref_locked (oldest -> tcpm_next ); tm ;
176
182
tm = deref_locked (tm -> tcpm_next )) {
177
- if (time_before (tm -> tcpm_stamp , oldest -> tcpm_stamp ))
183
+ if (time_before (READ_ONCE (tm -> tcpm_stamp ),
184
+ READ_ONCE (oldest -> tcpm_stamp )))
178
185
oldest = tm ;
179
186
}
180
187
tm = oldest ;
@@ -434,7 +441,7 @@ void tcp_update_metrics(struct sock *sk)
434
441
tp -> reordering );
435
442
}
436
443
}
437
- tm -> tcpm_stamp = jiffies ;
444
+ WRITE_ONCE ( tm -> tcpm_stamp , jiffies ) ;
438
445
out_unlock :
439
446
rcu_read_unlock ();
440
447
}
@@ -647,7 +654,7 @@ static int tcp_metrics_fill_info(struct sk_buff *msg,
647
654
}
648
655
649
656
if (nla_put_msecs (msg , TCP_METRICS_ATTR_AGE ,
650
- jiffies - tm -> tcpm_stamp ,
657
+ jiffies - READ_ONCE ( tm -> tcpm_stamp ) ,
651
658
TCP_METRICS_ATTR_PAD ) < 0 )
652
659
goto nla_put_failure ;
653
660
0 commit comments