aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorDenis V. Lunev <den@openvz.org>2008-07-05 22:04:09 -0400
committerDavid S. Miller <davem@davemloft.net>2008-07-05 22:04:09 -0400
commitb00180defdeeac8e07e3dc02e53e7395d42bbd19 (patch)
tree3e3343c81ae0a09b8baa9e2d3b42c9c73d16ad6d /net
parent86c657f6b5bbf2f3ec2213eca528998134a9b344 (diff)
ipv4: pass current value of rt_genid into rt_hash
Basically, there is no difference to atomic_read internally or pass it as a parameter as rt_hash is inline. Signed-off-by: Denis V. Lunev <den@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/route.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 9725223ffe9d..e4e37edbad60 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -256,11 +256,12 @@ static DEFINE_PER_CPU(struct rt_cache_stat, rt_cache_stat);
256#define RT_CACHE_STAT_INC(field) \ 256#define RT_CACHE_STAT_INC(field) \
257 (__raw_get_cpu_var(rt_cache_stat).field++) 257 (__raw_get_cpu_var(rt_cache_stat).field++)
258 258
259static inline unsigned int rt_hash(__be32 daddr, __be32 saddr, int idx) 259static inline unsigned int rt_hash(__be32 daddr, __be32 saddr, int idx,
260 int genid)
260{ 261{
261 return jhash_3words((__force u32)(__be32)(daddr), 262 return jhash_3words((__force u32)(__be32)(daddr),
262 (__force u32)(__be32)(saddr), 263 (__force u32)(__be32)(saddr),
263 idx, atomic_read(&rt_genid)) 264 idx, genid)
264 & rt_hash_mask; 265 & rt_hash_mask;
265} 266}
266 267
@@ -1180,7 +1181,8 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
1180 1181
1181 for (i = 0; i < 2; i++) { 1182 for (i = 0; i < 2; i++) {
1182 for (k = 0; k < 2; k++) { 1183 for (k = 0; k < 2; k++) {
1183 unsigned hash = rt_hash(daddr, skeys[i], ikeys[k]); 1184 unsigned hash = rt_hash(daddr, skeys[i], ikeys[k],
1185 atomic_read(&rt_genid));
1184 1186
1185 rthp=&rt_hash_table[hash].chain; 1187 rthp=&rt_hash_table[hash].chain;
1186 1188
@@ -1295,7 +1297,8 @@ static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst)
1295 } else if ((rt->rt_flags & RTCF_REDIRECTED) || 1297 } else if ((rt->rt_flags & RTCF_REDIRECTED) ||
1296 rt->u.dst.expires) { 1298 rt->u.dst.expires) {
1297 unsigned hash = rt_hash(rt->fl.fl4_dst, rt->fl.fl4_src, 1299 unsigned hash = rt_hash(rt->fl.fl4_dst, rt->fl.fl4_src,
1298 rt->fl.oif); 1300 rt->fl.oif,
1301 atomic_read(&rt_genid));
1299#if RT_CACHE_DEBUG >= 1 1302#if RT_CACHE_DEBUG >= 1
1300 printk(KERN_DEBUG "ipv4_negative_advice: redirect to " 1303 printk(KERN_DEBUG "ipv4_negative_advice: redirect to "
1301 NIPQUAD_FMT "/%02x dropped\n", 1304 NIPQUAD_FMT "/%02x dropped\n",
@@ -1444,7 +1447,8 @@ unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph,
1444 1447
1445 for (k = 0; k < 2; k++) { 1448 for (k = 0; k < 2; k++) {
1446 for (i = 0; i < 2; i++) { 1449 for (i = 0; i < 2; i++) {
1447 unsigned hash = rt_hash(daddr, skeys[i], ikeys[k]); 1450 unsigned hash = rt_hash(daddr, skeys[i], ikeys[k],
1451 atomic_read(&rt_genid));
1448 1452
1449 rcu_read_lock(); 1453 rcu_read_lock();
1450 for (rth = rcu_dereference(rt_hash_table[hash].chain); rth; 1454 for (rth = rcu_dereference(rt_hash_table[hash].chain); rth;
@@ -1709,7 +1713,7 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
1709 RT_CACHE_STAT_INC(in_slow_mc); 1713 RT_CACHE_STAT_INC(in_slow_mc);
1710 1714
1711 in_dev_put(in_dev); 1715 in_dev_put(in_dev);
1712 hash = rt_hash(daddr, saddr, dev->ifindex); 1716 hash = rt_hash(daddr, saddr, dev->ifindex, atomic_read(&rt_genid));
1713 return rt_intern_hash(hash, rth, &skb->rtable); 1717 return rt_intern_hash(hash, rth, &skb->rtable);
1714 1718
1715e_nobufs: 1719e_nobufs:
@@ -1870,7 +1874,7 @@ static int ip_mkroute_input(struct sk_buff *skb,
1870 return err; 1874 return err;
1871 1875
1872 /* put it into the cache */ 1876 /* put it into the cache */
1873 hash = rt_hash(daddr, saddr, fl->iif); 1877 hash = rt_hash(daddr, saddr, fl->iif, atomic_read(&rt_genid));
1874 return rt_intern_hash(hash, rth, &skb->rtable); 1878 return rt_intern_hash(hash, rth, &skb->rtable);
1875} 1879}
1876 1880
@@ -2026,7 +2030,7 @@ local_input:
2026 rth->rt_flags &= ~RTCF_LOCAL; 2030 rth->rt_flags &= ~RTCF_LOCAL;
2027 } 2031 }
2028 rth->rt_type = res.type; 2032 rth->rt_type = res.type;
2029 hash = rt_hash(daddr, saddr, fl.iif); 2033 hash = rt_hash(daddr, saddr, fl.iif, atomic_read(&rt_genid));
2030 err = rt_intern_hash(hash, rth, &skb->rtable); 2034 err = rt_intern_hash(hash, rth, &skb->rtable);
2031 goto done; 2035 goto done;
2032 2036
@@ -2077,7 +2081,7 @@ int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr,
2077 2081
2078 net = dev_net(dev); 2082 net = dev_net(dev);
2079 tos &= IPTOS_RT_MASK; 2083 tos &= IPTOS_RT_MASK;
2080 hash = rt_hash(daddr, saddr, iif); 2084 hash = rt_hash(daddr, saddr, iif, atomic_read(&rt_genid));
2081 2085
2082 rcu_read_lock(); 2086 rcu_read_lock();
2083 for (rth = rcu_dereference(rt_hash_table[hash].chain); rth; 2087 for (rth = rcu_dereference(rt_hash_table[hash].chain); rth;
@@ -2266,7 +2270,8 @@ static int ip_mkroute_output(struct rtable **rp,
2266 int err = __mkroute_output(&rth, res, fl, oldflp, dev_out, flags); 2270 int err = __mkroute_output(&rth, res, fl, oldflp, dev_out, flags);
2267 unsigned hash; 2271 unsigned hash;
2268 if (err == 0) { 2272 if (err == 0) {
2269 hash = rt_hash(oldflp->fl4_dst, oldflp->fl4_src, oldflp->oif); 2273 hash = rt_hash(oldflp->fl4_dst, oldflp->fl4_src, oldflp->oif,
2274 atomic_read(&rt_genid));
2270 err = rt_intern_hash(hash, rth, rp); 2275 err = rt_intern_hash(hash, rth, rp);
2271 } 2276 }
2272 2277
@@ -2478,7 +2483,8 @@ int __ip_route_output_key(struct net *net, struct rtable **rp,
2478 unsigned hash; 2483 unsigned hash;
2479 struct rtable *rth; 2484 struct rtable *rth;
2480 2485
2481 hash = rt_hash(flp->fl4_dst, flp->fl4_src, flp->oif); 2486 hash = rt_hash(flp->fl4_dst, flp->fl4_src, flp->oif,
2487 atomic_read(&rt_genid));
2482 2488
2483 rcu_read_lock_bh(); 2489 rcu_read_lock_bh();
2484 for (rth = rcu_dereference(rt_hash_table[hash].chain); rth; 2490 for (rth = rcu_dereference(rt_hash_table[hash].chain); rth;