Skip to content

Commit 31afeb4

Browse files
tracywwnjdavem330
authored andcommitted
ipv6: change route cache aging logic
In current route cache aging logic, if a route has both RTF_EXPIRE and RTF_GATEWAY set, the route will only be removed if the neighbor cache has no NTF_ROUTER flag. Otherwise, even if the route has expired, it won't get deleted. Fix this logic to always check if the route has expired first and then do the gateway neighbor cache check if previous check decide to not remove the exception entry. Fixes: 1859bac ("ipv6: remove from fib tree aged out RTF_CACHE dst") Signed-off-by: Wei Wang <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Acked-by: Martin KaFai Lau <[email protected]> Acked-by: Paolo Abeni <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0a797db commit 31afeb4

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

net/ipv6/route.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,12 +1585,19 @@ static void rt6_age_examine_exception(struct rt6_exception_bucket *bucket,
15851585
* EXPIRES exceptions - e.g. pmtu-generated ones are pruned when
15861586
* expired, independently from their aging, as per RFC 8201 section 4
15871587
*/
1588-
if (!(rt->rt6i_flags & RTF_EXPIRES) &&
1589-
time_after_eq(now, rt->dst.lastuse + gc_args->timeout)) {
1590-
RT6_TRACE("aging clone %p\n", rt);
1588+
if (!(rt->rt6i_flags & RTF_EXPIRES)) {
1589+
if (time_after_eq(now, rt->dst.lastuse + gc_args->timeout)) {
1590+
RT6_TRACE("aging clone %p\n", rt);
1591+
rt6_remove_exception(bucket, rt6_ex);
1592+
return;
1593+
}
1594+
} else if (time_after(jiffies, rt->dst.expires)) {
1595+
RT6_TRACE("purging expired route %p\n", rt);
15911596
rt6_remove_exception(bucket, rt6_ex);
15921597
return;
1593-
} else if (rt->rt6i_flags & RTF_GATEWAY) {
1598+
}
1599+
1600+
if (rt->rt6i_flags & RTF_GATEWAY) {
15941601
struct neighbour *neigh;
15951602
__u8 neigh_flags = 0;
15961603

@@ -1605,11 +1612,8 @@ static void rt6_age_examine_exception(struct rt6_exception_bucket *bucket,
16051612
rt6_remove_exception(bucket, rt6_ex);
16061613
return;
16071614
}
1608-
} else if (__rt6_check_expired(rt)) {
1609-
RT6_TRACE("purging expired route %p\n", rt);
1610-
rt6_remove_exception(bucket, rt6_ex);
1611-
return;
16121615
}
1616+
16131617
gc_args->more++;
16141618
}
16151619

0 commit comments

Comments
 (0)