Skip to content

Commit

Permalink
[IPV4] IP_GRE: Unify code path to get hash array index.
Browse files Browse the repository at this point in the history
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
  • Loading branch information
YOSHIFUJI Hideaki authored and David S. Miller committed Apr 26, 2007
1 parent 87d1a16 commit 5056a1e
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions net/ipv4/ip_gre.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,11 @@ static struct ip_tunnel * ipgre_tunnel_lookup(__be32 remote, __be32 local, __be3
return NULL;
}

static struct ip_tunnel **ipgre_bucket(struct ip_tunnel *t)
static struct ip_tunnel **__ipgre_bucket(struct ip_tunnel_parm *parms)
{
__be32 remote = t->parms.iph.daddr;
__be32 local = t->parms.iph.saddr;
__be32 key = t->parms.i_key;
__be32 remote = parms->iph.daddr;
__be32 local = parms->iph.saddr;
__be32 key = parms->i_key;
unsigned h = HASH(key);
int prio = 0;

Expand All @@ -209,6 +209,11 @@ static struct ip_tunnel **ipgre_bucket(struct ip_tunnel *t)
return &tunnels[prio][h];
}

static inline struct ip_tunnel **ipgre_bucket(struct ip_tunnel *t)
{
return __ipgre_bucket(&t->parms);
}

static void ipgre_tunnel_link(struct ip_tunnel *t)
{
struct ip_tunnel **tp = ipgre_bucket(t);
Expand Down Expand Up @@ -240,17 +245,9 @@ static struct ip_tunnel * ipgre_tunnel_locate(struct ip_tunnel_parm *parms, int
__be32 key = parms->i_key;
struct ip_tunnel *t, **tp, *nt;
struct net_device *dev;
unsigned h = HASH(key);
int prio = 0;
char name[IFNAMSIZ];

if (local)
prio |= 1;
if (remote && !MULTICAST(remote)) {
prio |= 2;
h ^= HASH(remote);
}
for (tp = &tunnels[prio][h]; (t = *tp) != NULL; tp = &t->next) {
for (tp = __ipgre_bucket(parms); (t = *tp) != NULL; tp = &t->next) {
if (local == t->parms.iph.saddr && remote == t->parms.iph.daddr) {
if (key == t->parms.i_key)
return t;
Expand Down

0 comments on commit 5056a1e

Please sign in to comment.