Commit e1aafe5a authored by Hideaki Yoshifuji's avatar Hideaki Yoshifuji

[IPV6] Don't use expired default routes.

Signed-off-by: default avatarHideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
parent 62343f76
...@@ -167,6 +167,12 @@ static void ip6_dst_ifdown(struct dst_entry *dst, int how) ...@@ -167,6 +167,12 @@ static void ip6_dst_ifdown(struct dst_entry *dst, int how)
} }
} }
static __inline__ int rt6_check_expired(const struct rt6_info *rt)
{
return (rt->rt6i_flags & RTF_EXPIRES &&
time_after(jiffies, rt->rt6i_expires));
}
/* /*
* Route lookup. Any rt6_lock is implied. * Route lookup. Any rt6_lock is implied.
*/ */
...@@ -237,8 +243,7 @@ static struct rt6_info *rt6_best_dflt(struct rt6_info *rt, int oif) ...@@ -237,8 +243,7 @@ static struct rt6_info *rt6_best_dflt(struct rt6_info *rt, int oif)
sprt->rt6i_dev->ifindex == oif)) sprt->rt6i_dev->ifindex == oif))
m += 8; m += 8;
if ((sprt->rt6i_flags & RTF_EXPIRES) && if (rt6_check_expired(sprt))
time_after(jiffies, sprt->rt6i_expires))
continue; continue;
if (sprt == rt6_dflt_pointer) if (sprt == rt6_dflt_pointer)
...@@ -296,7 +301,8 @@ static struct rt6_info *rt6_best_dflt(struct rt6_info *rt, int oif) ...@@ -296,7 +301,8 @@ static struct rt6_info *rt6_best_dflt(struct rt6_info *rt, int oif)
for (sprt = rt6_dflt_pointer->u.next; for (sprt = rt6_dflt_pointer->u.next;
sprt; sprt = sprt->u.next) { sprt; sprt = sprt->u.next) {
if (sprt->u.dst.obsolete <= 0 && if (sprt->u.dst.obsolete <= 0 &&
sprt->u.dst.error == 0) { sprt->u.dst.error == 0 &&
!rt6_check_expired(sprt)) {
match = sprt; match = sprt;
break; break;
} }
...@@ -305,7 +311,8 @@ static struct rt6_info *rt6_best_dflt(struct rt6_info *rt, int oif) ...@@ -305,7 +311,8 @@ static struct rt6_info *rt6_best_dflt(struct rt6_info *rt, int oif)
!match && sprt; !match && sprt;
sprt = sprt->u.next) { sprt = sprt->u.next) {
if (sprt->u.dst.obsolete <= 0 && if (sprt->u.dst.obsolete <= 0 &&
sprt->u.dst.error == 0) { sprt->u.dst.error == 0 &&
!rt6_check_expired(sprt)) {
match = sprt; match = sprt;
break; break;
} }
...@@ -331,7 +338,8 @@ static struct rt6_info *rt6_best_dflt(struct rt6_info *rt, int oif) ...@@ -331,7 +338,8 @@ static struct rt6_info *rt6_best_dflt(struct rt6_info *rt, int oif)
*/ */
for (sprt = ip6_routing_table.leaf; for (sprt = ip6_routing_table.leaf;
sprt; sprt = sprt->u.next) { sprt; sprt = sprt->u.next) {
if ((sprt->rt6i_flags & RTF_DEFAULT) && if (!rt6_check_expired(sprt) &&
(sprt->rt6i_flags & RTF_DEFAULT) &&
(!oif || (!oif ||
(sprt->rt6i_dev && (sprt->rt6i_dev &&
sprt->rt6i_dev->ifindex == oif))) { sprt->rt6i_dev->ifindex == oif))) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment