Skip to content

Commit ee9a8f7

Browse files
klassertdavem330
authored andcommitted
ipv4: Don't report stale pmtu values to userspace
We report cached pmtu values even if they are already expired. Change this to not report these values after they are expired and fix a race in the expire time calculation, as suggested by Eric Dumazet. Signed-off-by: Steffen Klassert <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7f92d33 commit ee9a8f7

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

net/ipv4/route.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2187,8 +2187,18 @@ static int rt_fill_info(struct net *net, __be32 dst, __be32 src,
21872187
nla_put_be32(skb, RTA_GATEWAY, rt->rt_gateway))
21882188
goto nla_put_failure;
21892189

2190+
expires = rt->dst.expires;
2191+
if (expires) {
2192+
unsigned long now = jiffies;
2193+
2194+
if (time_before(now, expires))
2195+
expires -= now;
2196+
else
2197+
expires = 0;
2198+
}
2199+
21902200
memcpy(metrics, dst_metrics_ptr(&rt->dst), sizeof(metrics));
2191-
if (rt->rt_pmtu)
2201+
if (rt->rt_pmtu && expires)
21922202
metrics[RTAX_MTU - 1] = rt->rt_pmtu;
21932203
if (rtnetlink_put_metrics(skb, metrics) < 0)
21942204
goto nla_put_failure;
@@ -2198,13 +2208,6 @@ static int rt_fill_info(struct net *net, __be32 dst, __be32 src,
21982208
goto nla_put_failure;
21992209

22002210
error = rt->dst.error;
2201-
expires = rt->dst.expires;
2202-
if (expires) {
2203-
if (time_before(jiffies, expires))
2204-
expires -= jiffies;
2205-
else
2206-
expires = 0;
2207-
}
22082211

22092212
if (rt_is_input_route(rt)) {
22102213
if (nla_put_u32(skb, RTA_IIF, rt->rt_iif))

0 commit comments

Comments
 (0)