diff options
author | YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> | 2007-04-24 07:44:47 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 01:29:54 -0400 |
commit | 420fe234ad7adaa5a5445e5fab83b1485ed9e0f3 (patch) | |
tree | 8b4c16879eff9674615bd0de9ba87c72c285a9bd /net | |
parent | 30041e4af426bc9ab7a73440ce4a7c78881b6001 (diff) |
[IPV6] SIT: Unify code path to get hash array index.
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv6/sit.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c index 27fe10ffacb0..1efa95a99f45 100644 --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c | |||
@@ -99,10 +99,10 @@ static struct ip_tunnel * ipip6_tunnel_lookup(__be32 remote, __be32 local) | |||
99 | return NULL; | 99 | return NULL; |
100 | } | 100 | } |
101 | 101 | ||
102 | static struct ip_tunnel ** ipip6_bucket(struct ip_tunnel *t) | 102 | static struct ip_tunnel **__ipip6_bucket(struct ip_tunnel_parm *parms) |
103 | { | 103 | { |
104 | __be32 remote = t->parms.iph.daddr; | 104 | __be32 remote = parms->iph.daddr; |
105 | __be32 local = t->parms.iph.saddr; | 105 | __be32 local = parms->iph.saddr; |
106 | unsigned h = 0; | 106 | unsigned h = 0; |
107 | int prio = 0; | 107 | int prio = 0; |
108 | 108 | ||
@@ -117,6 +117,11 @@ static struct ip_tunnel ** ipip6_bucket(struct ip_tunnel *t) | |||
117 | return &tunnels[prio][h]; | 117 | return &tunnels[prio][h]; |
118 | } | 118 | } |
119 | 119 | ||
120 | static inline struct ip_tunnel **ipip6_bucket(struct ip_tunnel *t) | ||
121 | { | ||
122 | return __ipip6_bucket(&t->parms); | ||
123 | } | ||
124 | |||
120 | static void ipip6_tunnel_unlink(struct ip_tunnel *t) | 125 | static void ipip6_tunnel_unlink(struct ip_tunnel *t) |
121 | { | 126 | { |
122 | struct ip_tunnel **tp; | 127 | struct ip_tunnel **tp; |
@@ -147,19 +152,9 @@ static struct ip_tunnel * ipip6_tunnel_locate(struct ip_tunnel_parm *parms, int | |||
147 | __be32 local = parms->iph.saddr; | 152 | __be32 local = parms->iph.saddr; |
148 | struct ip_tunnel *t, **tp, *nt; | 153 | struct ip_tunnel *t, **tp, *nt; |
149 | struct net_device *dev; | 154 | struct net_device *dev; |
150 | unsigned h = 0; | ||
151 | int prio = 0; | ||
152 | char name[IFNAMSIZ]; | 155 | char name[IFNAMSIZ]; |
153 | 156 | ||
154 | if (remote) { | 157 | for (tp = __ipip6_bucket(parms); (t = *tp) != NULL; tp = &t->next) { |
155 | prio |= 2; | ||
156 | h ^= HASH(remote); | ||
157 | } | ||
158 | if (local) { | ||
159 | prio |= 1; | ||
160 | h ^= HASH(local); | ||
161 | } | ||
162 | for (tp = &tunnels[prio][h]; (t = *tp) != NULL; tp = &t->next) { | ||
163 | if (local == t->parms.iph.saddr && remote == t->parms.iph.daddr) | 158 | if (local == t->parms.iph.saddr && remote == t->parms.iph.daddr) |
164 | return t; | 159 | return t; |
165 | } | 160 | } |