Commit 2e68ea92 authored by Ido Schimmel's avatar Ido Schimmel Committed by David S. Miller

ipv4: Calculate multipath hash inside switch statement

A subsequent patch will add another multipath hash policy where the
multipath hash is calculated directly by the policy specific code and
not outside of the switch statement.

Prepare for this change by moving the multipath hash calculation inside
the switch statement.

No functional changes intended.
Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 06b38e23
...@@ -1912,7 +1912,7 @@ int fib_multipath_hash(const struct net *net, const struct flowi4 *fl4, ...@@ -1912,7 +1912,7 @@ int fib_multipath_hash(const struct net *net, const struct flowi4 *fl4,
{ {
u32 multipath_hash = fl4 ? fl4->flowi4_multipath_hash : 0; u32 multipath_hash = fl4 ? fl4->flowi4_multipath_hash : 0;
struct flow_keys hash_keys; struct flow_keys hash_keys;
u32 mhash; u32 mhash = 0;
switch (net->ipv4.sysctl_fib_multipath_hash_policy) { switch (net->ipv4.sysctl_fib_multipath_hash_policy) {
case 0: case 0:
...@@ -1924,6 +1924,7 @@ int fib_multipath_hash(const struct net *net, const struct flowi4 *fl4, ...@@ -1924,6 +1924,7 @@ int fib_multipath_hash(const struct net *net, const struct flowi4 *fl4,
hash_keys.addrs.v4addrs.src = fl4->saddr; hash_keys.addrs.v4addrs.src = fl4->saddr;
hash_keys.addrs.v4addrs.dst = fl4->daddr; hash_keys.addrs.v4addrs.dst = fl4->daddr;
} }
mhash = flow_hash_from_keys(&hash_keys);
break; break;
case 1: case 1:
/* skb is currently provided only when forwarding */ /* skb is currently provided only when forwarding */
...@@ -1957,6 +1958,7 @@ int fib_multipath_hash(const struct net *net, const struct flowi4 *fl4, ...@@ -1957,6 +1958,7 @@ int fib_multipath_hash(const struct net *net, const struct flowi4 *fl4,
hash_keys.ports.dst = fl4->fl4_dport; hash_keys.ports.dst = fl4->fl4_dport;
hash_keys.basic.ip_proto = fl4->flowi4_proto; hash_keys.basic.ip_proto = fl4->flowi4_proto;
} }
mhash = flow_hash_from_keys(&hash_keys);
break; break;
case 2: case 2:
memset(&hash_keys, 0, sizeof(hash_keys)); memset(&hash_keys, 0, sizeof(hash_keys));
...@@ -1987,9 +1989,9 @@ int fib_multipath_hash(const struct net *net, const struct flowi4 *fl4, ...@@ -1987,9 +1989,9 @@ int fib_multipath_hash(const struct net *net, const struct flowi4 *fl4,
hash_keys.addrs.v4addrs.src = fl4->saddr; hash_keys.addrs.v4addrs.src = fl4->saddr;
hash_keys.addrs.v4addrs.dst = fl4->daddr; hash_keys.addrs.v4addrs.dst = fl4->daddr;
} }
mhash = flow_hash_from_keys(&hash_keys);
break; break;
} }
mhash = flow_hash_from_keys(&hash_keys);
if (multipath_hash) if (multipath_hash)
mhash = jhash_2words(mhash, multipath_hash, 0); mhash = jhash_2words(mhash, multipath_hash, 0);
......
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