diff options
author | YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> | 2007-04-24 07:44:48 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 01:29:56 -0400 |
commit | 5056a1ef9e2597cff7b15904fbc74193f316fc40 (patch) | |
tree | 9acec59c0ee92a7285d680592fc1da37fd8977af /net/ipv4/ip_gre.c | |
parent | 87d1a164df0b5e297cda698724ea7984d8392b06 (diff) |
[IPV4] IP_GRE: Unify code path to get hash array index.
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Diffstat (limited to 'net/ipv4/ip_gre.c')
-rw-r--r-- | net/ipv4/ip_gre.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index f49afaa81298..63282934725e 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c | |||
@@ -191,11 +191,11 @@ static struct ip_tunnel * ipgre_tunnel_lookup(__be32 remote, __be32 local, __be3 | |||
191 | return NULL; | 191 | return NULL; |
192 | } | 192 | } |
193 | 193 | ||
194 | static struct ip_tunnel **ipgre_bucket(struct ip_tunnel *t) | 194 | static struct ip_tunnel **__ipgre_bucket(struct ip_tunnel_parm *parms) |
195 | { | 195 | { |
196 | __be32 remote = t->parms.iph.daddr; | 196 | __be32 remote = parms->iph.daddr; |
197 | __be32 local = t->parms.iph.saddr; | 197 | __be32 local = parms->iph.saddr; |
198 | __be32 key = t->parms.i_key; | 198 | __be32 key = parms->i_key; |
199 | unsigned h = HASH(key); | 199 | unsigned h = HASH(key); |
200 | int prio = 0; | 200 | int prio = 0; |
201 | 201 | ||
@@ -209,6 +209,11 @@ static struct ip_tunnel **ipgre_bucket(struct ip_tunnel *t) | |||
209 | return &tunnels[prio][h]; | 209 | return &tunnels[prio][h]; |
210 | } | 210 | } |
211 | 211 | ||
212 | static inline struct ip_tunnel **ipgre_bucket(struct ip_tunnel *t) | ||
213 | { | ||
214 | return __ipgre_bucket(&t->parms); | ||
215 | } | ||
216 | |||
212 | static void ipgre_tunnel_link(struct ip_tunnel *t) | 217 | static void ipgre_tunnel_link(struct ip_tunnel *t) |
213 | { | 218 | { |
214 | struct ip_tunnel **tp = ipgre_bucket(t); | 219 | struct ip_tunnel **tp = ipgre_bucket(t); |
@@ -240,17 +245,9 @@ static struct ip_tunnel * ipgre_tunnel_locate(struct ip_tunnel_parm *parms, int | |||
240 | __be32 key = parms->i_key; | 245 | __be32 key = parms->i_key; |
241 | struct ip_tunnel *t, **tp, *nt; | 246 | struct ip_tunnel *t, **tp, *nt; |
242 | struct net_device *dev; | 247 | struct net_device *dev; |
243 | unsigned h = HASH(key); | ||
244 | int prio = 0; | ||
245 | char name[IFNAMSIZ]; | 248 | char name[IFNAMSIZ]; |
246 | 249 | ||
247 | if (local) | 250 | for (tp = __ipgre_bucket(parms); (t = *tp) != NULL; tp = &t->next) { |
248 | prio |= 1; | ||
249 | if (remote && !MULTICAST(remote)) { | ||
250 | prio |= 2; | ||
251 | h ^= HASH(remote); | ||
252 | } | ||
253 | for (tp = &tunnels[prio][h]; (t = *tp) != NULL; tp = &t->next) { | ||
254 | if (local == t->parms.iph.saddr && remote == t->parms.iph.daddr) { | 251 | if (local == t->parms.iph.saddr && remote == t->parms.iph.daddr) { |
255 | if (key == t->parms.i_key) | 252 | if (key == t->parms.i_key) |
256 | return t; | 253 | return t; |