aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJulian Anastasov <ja@ssi.bg>2011-08-08 01:20:20 -0400
committerDavid S. Miller <davem@davemloft.net>2011-08-08 01:20:20 -0400
commitd547f727df86059104af2234804fdd538e112015 (patch)
treebe54058b51ae121709242553e4aefde5662f734c /net
parent025890b4ed433b9c9e0f221bb806d42d049c87fe (diff)
ipv4: fix the reusing of routing cache entries
compare_keys and ip_route_input_common rely on rt_oif for distinguishing of input and output routes with same keys values. But sometimes the input route has also same hash chain (keyed by iif != 0) with the output routes (keyed by orig_oif=0). Problem visible if running with small number of rhash_entries. Fix them to use rt_route_iif instead. By this way input route can not be returned to users that request output route. The patch fixes the ip_rt_bug errors that were reported in ip_local_out context, mostly for 255.255.255.255 destinations. Signed-off-by: Julian Anastasov <ja@ssi.bg> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/route.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index e3dec1c9f09d..cb7efe0567f0 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -731,6 +731,7 @@ static inline int compare_keys(struct rtable *rt1, struct rtable *rt2)
731 ((__force u32)rt1->rt_key_src ^ (__force u32)rt2->rt_key_src) | 731 ((__force u32)rt1->rt_key_src ^ (__force u32)rt2->rt_key_src) |
732 (rt1->rt_mark ^ rt2->rt_mark) | 732 (rt1->rt_mark ^ rt2->rt_mark) |
733 (rt1->rt_key_tos ^ rt2->rt_key_tos) | 733 (rt1->rt_key_tos ^ rt2->rt_key_tos) |
734 (rt1->rt_route_iif ^ rt2->rt_route_iif) |
734 (rt1->rt_oif ^ rt2->rt_oif) | 735 (rt1->rt_oif ^ rt2->rt_oif) |
735 (rt1->rt_iif ^ rt2->rt_iif)) == 0; 736 (rt1->rt_iif ^ rt2->rt_iif)) == 0;
736} 737}
@@ -2321,8 +2322,8 @@ int ip_route_input_common(struct sk_buff *skb, __be32 daddr, __be32 saddr,
2321 if ((((__force u32)rth->rt_key_dst ^ (__force u32)daddr) | 2322 if ((((__force u32)rth->rt_key_dst ^ (__force u32)daddr) |
2322 ((__force u32)rth->rt_key_src ^ (__force u32)saddr) | 2323 ((__force u32)rth->rt_key_src ^ (__force u32)saddr) |
2323 (rth->rt_iif ^ iif) | 2324 (rth->rt_iif ^ iif) |
2324 rth->rt_oif |
2325 (rth->rt_key_tos ^ tos)) == 0 && 2325 (rth->rt_key_tos ^ tos)) == 0 &&
2326 rt_is_input_route(rth) &&
2326 rth->rt_mark == skb->mark && 2327 rth->rt_mark == skb->mark &&
2327 net_eq(dev_net(rth->dst.dev), net) && 2328 net_eq(dev_net(rth->dst.dev), net) &&
2328 !rt_is_expired(rth)) { 2329 !rt_is_expired(rth)) {