Fix BUG of ip_rt_send_redirect()
Subsystems (2)
Quoted 6 lines · Herbert Xu
I think there are two problems here:
1)The first time we hit the check
rate_lastis zero. We should simply proceed with the redirect rather than treating this as a jiffies value.
Quoted 6 lines
2)When a dst is so old that the jiffies have wrapped around. I'm not sure whether this is worth solving as it should be extremely rare unless your HZ is sufficiently large and you're on a 32-bit platform.
One solution would be to periodically reset the
rate_lastfields to their original states. Perhaps we can combine that with the GC.
Mr Herbert Xu:
According to your advice, I have made another patch for the redirect bug.
This patch does not think of the jiffies wraparound any more. Because if the router sends a redirect packet for the first time, the redirect route cache entry will be created in the route cache. If this entry is used frequently(This should be extremely rare), the rate_last will be update to the current jiffies when it sends the redirect packet. So we don't concern about the jiffies wraparound. If this entry does not be used for a long time, the GC will remove it from route cache. Next time if we want to use this entry, the redirect entry will be created in the route cache again, and the rate_last will be initialized to 0. So we don't care of the jiffies wraparound too.
Following is my patch:
--- linux-2.6.19/net/ipv4/route.c.org 2006-12-05 10:47:02.402147160 +0800
+++ linux-2.6.19/net/ipv4/route.c 2006-12-05 10:48:26.339386760 +0800 @@ -1327,7 +1327,8 @@ void ip_rt_send_redirect(struct sk_buff
/* Check for load limit; set rate_last to the latest sent
* redirect.
*/
- if (time_after(jiffies,
+ if (rt->u.dst.rate_last == 0 ||
+ time_after(jiffies,
(rt->u.dst.rate_last +
(ip_rt_redirect_load << rt->u.dst.rate_tokens)))) { icmp_send(skb, ICMP_REDIRECT, ICMP_REDIR_HOST, rt->rt_gateway);
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 5 lines · Li Yewang
--- linux-2.6.19/net/ipv4/route.c.org 2006-12-05 10:47:02.402147160 +0800
+++linux-2.6.19/net/ipv4/route.c2006-12-05 10:48:26.339386760 +0800
Review void ip_rt_send_redirect(struct sk_buff · line 1334
Quoted 9 lines
(quoted diff) +2
-1@@ -1327,7 +1327,8 @@ void ip_rt_send_redirect(struct sk_buff /* Check for load limit; set rate_last to the latest sent * redirect. */ - if (time_after(jiffies, + if (rt->u.dst.rate_last == 0 || + time_after(jiffies, (rt->u.dst.rate_last + (ip_rt_redirect_load << rt->u.dst.rate_tokens)))) { icmp_send(skb, ICMP_REDIRECT, ICMP_REDIR_HOST, rt->rt_gateway);
Since rate_last can also be zero if jiffies == 0 (OK that's extremely unlikely but I'm feeling picky today :), how about checking rate_tokens instead? The value of rate_last can only be relevant if rate_tokens is non-zero.
BTW, please also check the other spots where rate_last/rate_token is used. They might need a similar fix.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt