Commit 8c7bc840 authored by Al Viro's avatar Al Viro Committed by David S. Miller

[IPV4]: annotate rt_hash_code() users

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f7655229
...@@ -261,6 +261,10 @@ static unsigned int rt_hash_code(u32 daddr, u32 saddr) ...@@ -261,6 +261,10 @@ static unsigned int rt_hash_code(u32 daddr, u32 saddr)
& rt_hash_mask); & rt_hash_mask);
} }
#define rt_hash(daddr, saddr, idx) \
rt_hash_code((__force u32)(__be32)(daddr),\
(__force u32)(__be32)(saddr) ^ ((idx) << 5))
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
struct rt_cache_iter_state { struct rt_cache_iter_state {
int bucket; int bucket;
...@@ -1147,8 +1151,7 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw, ...@@ -1147,8 +1151,7 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
for (k = 0; k < 2; k++) { for (k = 0; k < 2; k++) {
unsigned hash = rt_hash_code(daddr, unsigned hash = rt_hash(daddr, skeys[i], ikeys[k]);
skeys[i] ^ (ikeys[k] << 5));
rthp=&rt_hash_table[hash].chain; rthp=&rt_hash_table[hash].chain;
...@@ -1260,9 +1263,8 @@ static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst) ...@@ -1260,9 +1263,8 @@ static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst)
ret = NULL; ret = NULL;
} else if ((rt->rt_flags & RTCF_REDIRECTED) || } else if ((rt->rt_flags & RTCF_REDIRECTED) ||
rt->u.dst.expires) { rt->u.dst.expires) {
unsigned hash = rt_hash_code(rt->fl.fl4_dst, unsigned hash = rt_hash(rt->fl.fl4_dst, rt->fl.fl4_src,
rt->fl.fl4_src ^ rt->fl.oif);
(rt->fl.oif << 5));
#if RT_CACHE_DEBUG >= 1 #if RT_CACHE_DEBUG >= 1
printk(KERN_DEBUG "ip_rt_advice: redirect to " printk(KERN_DEBUG "ip_rt_advice: redirect to "
"%u.%u.%u.%u/%02x dropped\n", "%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,7 +1407,7 @@ unsigned short ip_rt_frag_needed(struct iphdr *iph, unsigned short new_mtu)
return 0; return 0;
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
unsigned hash = rt_hash_code(daddr, skeys[i]); unsigned hash = rt_hash(daddr, skeys[i], 0);
rcu_read_lock(); rcu_read_lock();
for (rth = rcu_dereference(rt_hash_table[hash].chain); rth; 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,7 +1667,7 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
RT_CACHE_STAT_INC(in_slow_mc); RT_CACHE_STAT_INC(in_slow_mc);
in_dev_put(in_dev); in_dev_put(in_dev);
hash = rt_hash_code(daddr, saddr ^ (dev->ifindex << 5)); hash = rt_hash(daddr, saddr, dev->ifindex);
return rt_intern_hash(hash, rth, (struct rtable**) &skb->dst); return rt_intern_hash(hash, rth, (struct rtable**) &skb->dst);
e_nobufs: e_nobufs:
...@@ -1830,7 +1832,7 @@ static inline int ip_mkroute_input_def(struct sk_buff *skb, ...@@ -1830,7 +1832,7 @@ static inline int ip_mkroute_input_def(struct sk_buff *skb,
return err; return err;
/* put it into the cache */ /* put it into the cache */
hash = rt_hash_code(daddr, saddr ^ (fl->iif << 5)); hash = rt_hash(daddr, saddr, fl->iif);
return rt_intern_hash(hash, rth, (struct rtable**)&skb->dst); return rt_intern_hash(hash, rth, (struct rtable**)&skb->dst);
} }
...@@ -1871,7 +1873,7 @@ static inline int ip_mkroute_input(struct sk_buff *skb, ...@@ -1871,7 +1873,7 @@ static inline int ip_mkroute_input(struct sk_buff *skb,
return err; return err;
/* put it into the cache */ /* put it into the cache */
hash = rt_hash_code(daddr, saddr ^ (fl->iif << 5)); hash = rt_hash(daddr, saddr, fl->iif);
err = rt_intern_hash(hash, rth, &rtres); err = rt_intern_hash(hash, rth, &rtres);
if (err) if (err)
return err; return err;
...@@ -2048,7 +2050,7 @@ local_input: ...@@ -2048,7 +2050,7 @@ local_input:
rth->rt_flags &= ~RTCF_LOCAL; rth->rt_flags &= ~RTCF_LOCAL;
} }
rth->rt_type = res.type; rth->rt_type = res.type;
hash = rt_hash_code(daddr, saddr ^ (fl.iif << 5)); hash = rt_hash(daddr, saddr, fl.iif);
err = rt_intern_hash(hash, rth, (struct rtable**)&skb->dst); err = rt_intern_hash(hash, rth, (struct rtable**)&skb->dst);
goto done; goto done;
...@@ -2095,7 +2097,7 @@ int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr, ...@@ -2095,7 +2097,7 @@ int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr,
int iif = dev->ifindex; int iif = dev->ifindex;
tos &= IPTOS_RT_MASK; tos &= IPTOS_RT_MASK;
hash = rt_hash_code(daddr, saddr ^ (iif << 5)); hash = rt_hash(daddr, saddr, iif);
rcu_read_lock(); rcu_read_lock();
for (rth = rcu_dereference(rt_hash_table[hash].chain); rth; 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,8 +2295,7 @@ static inline int ip_mkroute_output_def(struct rtable **rp,
int err = __mkroute_output(&rth, res, fl, oldflp, dev_out, flags); int err = __mkroute_output(&rth, res, fl, oldflp, dev_out, flags);
unsigned hash; unsigned hash;
if (err == 0) { if (err == 0) {
hash = rt_hash_code(oldflp->fl4_dst, hash = rt_hash(oldflp->fl4_dst, oldflp->fl4_src, oldflp->oif);
oldflp->fl4_src ^ (oldflp->oif << 5));
err = rt_intern_hash(hash, rth, rp); err = rt_intern_hash(hash, rth, rp);
} }
...@@ -2336,9 +2337,8 @@ static inline int ip_mkroute_output(struct rtable** rp, ...@@ -2336,9 +2337,8 @@ static inline int ip_mkroute_output(struct rtable** rp,
if (err != 0) if (err != 0)
goto cleanup; goto cleanup;
hash = rt_hash_code(oldflp->fl4_dst, hash = rt_hash(oldflp->fl4_dst, oldflp->fl4_src,
oldflp->fl4_src ^ oldflp->oif);
(oldflp->oif << 5));
err = rt_intern_hash(hash, rth, rp); err = rt_intern_hash(hash, rth, rp);
/* forward hop information to multipath impl. */ /* forward hop information to multipath impl. */
...@@ -2567,7 +2567,7 @@ int __ip_route_output_key(struct rtable **rp, const struct flowi *flp) ...@@ -2567,7 +2567,7 @@ int __ip_route_output_key(struct rtable **rp, const struct flowi *flp)
unsigned hash; unsigned hash;
struct rtable *rth; struct rtable *rth;
hash = rt_hash_code(flp->fl4_dst, flp->fl4_src ^ (flp->oif << 5)); hash = rt_hash(flp->fl4_dst, flp->fl4_src, flp->oif);
rcu_read_lock_bh(); rcu_read_lock_bh();
for (rth = rcu_dereference(rt_hash_table[hash].chain); rth; for (rth = rcu_dereference(rt_hash_table[hash].chain); rth;
......
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