diff options
| -rw-r--r-- | net/ipv4/route.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index e14df8ec5082..32fcb77295f0 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
| @@ -261,6 +261,10 @@ static unsigned int rt_hash_code(u32 daddr, u32 saddr) | |||
| 261 | & rt_hash_mask); | 261 | & rt_hash_mask); |
| 262 | } | 262 | } |
| 263 | 263 | ||
| 264 | #define rt_hash(daddr, saddr, idx) \ | ||
| 265 | rt_hash_code((__force u32)(__be32)(daddr),\ | ||
| 266 | (__force u32)(__be32)(saddr) ^ ((idx) << 5)) | ||
| 267 | |||
| 264 | #ifdef CONFIG_PROC_FS | 268 | #ifdef CONFIG_PROC_FS |
| 265 | struct rt_cache_iter_state { | 269 | struct rt_cache_iter_state { |
| 266 | int bucket; | 270 | int bucket; |
| @@ -1147,8 +1151,7 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw, | |||
| 1147 | 1151 | ||
| 1148 | for (i = 0; i < 2; i++) { | 1152 | for (i = 0; i < 2; i++) { |
| 1149 | for (k = 0; k < 2; k++) { | 1153 | for (k = 0; k < 2; k++) { |
| 1150 | unsigned hash = rt_hash_code(daddr, | 1154 | unsigned hash = rt_hash(daddr, skeys[i], ikeys[k]); |
| 1151 | skeys[i] ^ (ikeys[k] << 5)); | ||
| 1152 | 1155 | ||
| 1153 | rthp=&rt_hash_table[hash].chain; | 1156 | rthp=&rt_hash_table[hash].chain; |
| 1154 | 1157 | ||
| @@ -1260,9 +1263,8 @@ static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst) | |||
| 1260 | ret = NULL; | 1263 | ret = NULL; |
| 1261 | } else if ((rt->rt_flags & RTCF_REDIRECTED) || | 1264 | } else if ((rt->rt_flags & RTCF_REDIRECTED) || |
| 1262 | rt->u.dst.expires) { | 1265 | rt->u.dst.expires) { |
| 1263 | unsigned hash = rt_hash_code(rt->fl.fl4_dst, | 1266 | unsigned hash = rt_hash(rt->fl.fl4_dst, rt->fl.fl4_src, |
| 1264 | rt->fl.fl4_src ^ | 1267 | rt->fl.oif); |
| 1265 | (rt->fl.oif << 5)); | ||
| 1266 | #if RT_CACHE_DEBUG >= 1 | 1268 | #if RT_CACHE_DEBUG >= 1 |
| 1267 | printk(KERN_DEBUG "ip_rt_advice: redirect to " | 1269 | printk(KERN_DEBUG "ip_rt_advice: redirect to " |
| 1268 | "%u.%u.%u.%u/%02x dropped\n", | 1270 | "%u.%u.%u.%u/%02x dropped\n", |
| @@ -1405,7 +1407,7 @@ unsigned short ip_rt_frag_needed(struct iphdr *iph, unsigned short new_mtu) | |||
| 1405 | return 0; | 1407 | return 0; |
| 1406 | 1408 | ||
| 1407 | for (i = 0; i < 2; i++) { | 1409 | for (i = 0; i < 2; i++) { |
| 1408 | unsigned hash = rt_hash_code(daddr, skeys[i]); | 1410 | unsigned hash = rt_hash(daddr, skeys[i], 0); |
| 1409 | 1411 | ||
| 1410 | rcu_read_lock(); | 1412 | rcu_read_lock(); |
| 1411 | for (rth = rcu_dereference(rt_hash_table[hash].chain); rth; | 1413 | for (rth = rcu_dereference(rt_hash_table[hash].chain); rth; |
| @@ -1665,7 +1667,7 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr, | |||
| 1665 | RT_CACHE_STAT_INC(in_slow_mc); | 1667 | RT_CACHE_STAT_INC(in_slow_mc); |
| 1666 | 1668 | ||
| 1667 | in_dev_put(in_dev); | 1669 | in_dev_put(in_dev); |
| 1668 | hash = rt_hash_code(daddr, saddr ^ (dev->ifindex << 5)); | 1670 | hash = rt_hash(daddr, saddr, dev->ifindex); |
| 1669 | return rt_intern_hash(hash, rth, (struct rtable**) &skb->dst); | 1671 | return rt_intern_hash(hash, rth, (struct rtable**) &skb->dst); |
| 1670 | 1672 | ||
| 1671 | e_nobufs: | 1673 | e_nobufs: |
| @@ -1830,7 +1832,7 @@ static inline int ip_mkroute_input_def(struct sk_buff *skb, | |||
| 1830 | return err; | 1832 | return err; |
| 1831 | 1833 | ||
| 1832 | /* put it into the cache */ | 1834 | /* put it into the cache */ |
| 1833 | hash = rt_hash_code(daddr, saddr ^ (fl->iif << 5)); | 1835 | hash = rt_hash(daddr, saddr, fl->iif); |
| 1834 | return rt_intern_hash(hash, rth, (struct rtable**)&skb->dst); | 1836 | return rt_intern_hash(hash, rth, (struct rtable**)&skb->dst); |
| 1835 | } | 1837 | } |
| 1836 | 1838 | ||
| @@ -1871,7 +1873,7 @@ static inline int ip_mkroute_input(struct sk_buff *skb, | |||
| 1871 | return err; | 1873 | return err; |
| 1872 | 1874 | ||
| 1873 | /* put it into the cache */ | 1875 | /* put it into the cache */ |
| 1874 | hash = rt_hash_code(daddr, saddr ^ (fl->iif << 5)); | 1876 | hash = rt_hash(daddr, saddr, fl->iif); |
| 1875 | err = rt_intern_hash(hash, rth, &rtres); | 1877 | err = rt_intern_hash(hash, rth, &rtres); |
| 1876 | if (err) | 1878 | if (err) |
| 1877 | return err; | 1879 | return err; |
| @@ -2048,7 +2050,7 @@ local_input: | |||
| 2048 | rth->rt_flags &= ~RTCF_LOCAL; | 2050 | rth->rt_flags &= ~RTCF_LOCAL; |
| 2049 | } | 2051 | } |
| 2050 | rth->rt_type = res.type; | 2052 | rth->rt_type = res.type; |
| 2051 | hash = rt_hash_code(daddr, saddr ^ (fl.iif << 5)); | 2053 | hash = rt_hash(daddr, saddr, fl.iif); |
| 2052 | err = rt_intern_hash(hash, rth, (struct rtable**)&skb->dst); | 2054 | err = rt_intern_hash(hash, rth, (struct rtable**)&skb->dst); |
| 2053 | goto done; | 2055 | goto done; |
| 2054 | 2056 | ||
| @@ -2095,7 +2097,7 @@ int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr, | |||
| 2095 | int iif = dev->ifindex; | 2097 | int iif = dev->ifindex; |
| 2096 | 2098 | ||
| 2097 | tos &= IPTOS_RT_MASK; | 2099 | tos &= IPTOS_RT_MASK; |
| 2098 | hash = rt_hash_code(daddr, saddr ^ (iif << 5)); | 2100 | hash = rt_hash(daddr, saddr, iif); |
| 2099 | 2101 | ||
| 2100 | rcu_read_lock(); | 2102 | rcu_read_lock(); |
| 2101 | for (rth = rcu_dereference(rt_hash_table[hash].chain); rth; | 2103 | for (rth = rcu_dereference(rt_hash_table[hash].chain); rth; |
| @@ -2293,8 +2295,7 @@ static inline int ip_mkroute_output_def(struct rtable **rp, | |||
| 2293 | int err = __mkroute_output(&rth, res, fl, oldflp, dev_out, flags); | 2295 | int err = __mkroute_output(&rth, res, fl, oldflp, dev_out, flags); |
| 2294 | unsigned hash; | 2296 | unsigned hash; |
| 2295 | if (err == 0) { | 2297 | if (err == 0) { |
| 2296 | hash = rt_hash_code(oldflp->fl4_dst, | 2298 | hash = rt_hash(oldflp->fl4_dst, oldflp->fl4_src, oldflp->oif); |
| 2297 | oldflp->fl4_src ^ (oldflp->oif << 5)); | ||
| 2298 | err = rt_intern_hash(hash, rth, rp); | 2299 | err = rt_intern_hash(hash, rth, rp); |
| 2299 | } | 2300 | } |
| 2300 | 2301 | ||
| @@ -2336,9 +2337,8 @@ static inline int ip_mkroute_output(struct rtable** rp, | |||
| 2336 | if (err != 0) | 2337 | if (err != 0) |
| 2337 | goto cleanup; | 2338 | goto cleanup; |
| 2338 | 2339 | ||
| 2339 | hash = rt_hash_code(oldflp->fl4_dst, | 2340 | hash = rt_hash(oldflp->fl4_dst, oldflp->fl4_src, |
| 2340 | oldflp->fl4_src ^ | 2341 | oldflp->oif); |
| 2341 | (oldflp->oif << 5)); | ||
| 2342 | err = rt_intern_hash(hash, rth, rp); | 2342 | err = rt_intern_hash(hash, rth, rp); |
| 2343 | 2343 | ||
| 2344 | /* forward hop information to multipath impl. */ | 2344 | /* forward hop information to multipath impl. */ |
| @@ -2567,7 +2567,7 @@ int __ip_route_output_key(struct rtable **rp, const struct flowi *flp) | |||
| 2567 | unsigned hash; | 2567 | unsigned hash; |
| 2568 | struct rtable *rth; | 2568 | struct rtable *rth; |
| 2569 | 2569 | ||
| 2570 | hash = rt_hash_code(flp->fl4_dst, flp->fl4_src ^ (flp->oif << 5)); | 2570 | hash = rt_hash(flp->fl4_dst, flp->fl4_src, flp->oif); |
| 2571 | 2571 | ||
| 2572 | rcu_read_lock_bh(); | 2572 | rcu_read_lock_bh(); |
| 2573 | for (rth = rcu_dereference(rt_hash_table[hash].chain); rth; | 2573 | for (rth = rcu_dereference(rt_hash_table[hash].chain); rth; |
