Skip to content

Commit 1e2ea8a

Browse files
lxindavem330
authored andcommitted
ipv6: set dst.obsolete when a cached route has expired
Now it doesn't check for the cached route expiration in ipv6's dst_ops->check(), because it trusts dst_gc that would clean the cached route up when it's expired. The problem is in dst_gc, it would clean the cached route only when it's refcount is 1. If some other module (like xfrm) keeps holding it and the module only release it when dst_ops->check() fails. But without checking for the cached route expiration, .check() may always return true. Meanwhile, without releasing the cached route, dst_gc couldn't del it. It will cause this cached route never to expire. This patch is to set dst.obsolete with DST_OBSOLETE_KILL in .gc when it's expired, and check obsolete != DST_OBSOLETE_FORCE_CHK in .check. Note that this is even needed when ipv6 dst_gc timer is removed one day. It would set dst.obsolete in .redirect and .update_pmtu instead, and check for cached route expiration when getting it, just like what ipv4 route does. Reported-by: Jianlin Shi <[email protected]> Signed-off-by: Xin Long <[email protected]> Acked-by: Hannes Frederic Sowa <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4e587ea commit 1e2ea8a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

net/ipv6/ip6_fib.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1795,8 +1795,10 @@ static int fib6_age(struct rt6_info *rt, void *arg)
17951795
}
17961796
gc_args->more++;
17971797
} else if (rt->rt6i_flags & RTF_CACHE) {
1798+
if (time_after_eq(now, rt->dst.lastuse + gc_args->timeout))
1799+
rt->dst.obsolete = DST_OBSOLETE_KILL;
17981800
if (atomic_read(&rt->dst.__refcnt) == 1 &&
1799-
time_after_eq(now, rt->dst.lastuse + gc_args->timeout)) {
1801+
rt->dst.obsolete == DST_OBSOLETE_KILL) {
18001802
RT6_TRACE("aging clone %p\n", rt);
18011803
return -1;
18021804
} else if (rt->rt6i_flags & RTF_GATEWAY) {

net/ipv6/route.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,8 @@ static bool rt6_check_expired(const struct rt6_info *rt)
440440
if (time_after(jiffies, rt->dst.expires))
441441
return true;
442442
} else if (rt->dst.from) {
443-
return rt6_check_expired((struct rt6_info *) rt->dst.from);
443+
return rt->dst.obsolete != DST_OBSOLETE_FORCE_CHK ||
444+
rt6_check_expired((struct rt6_info *)rt->dst.from);
444445
}
445446
return false;
446447
}

0 commit comments

Comments
 (0)