Commit 6f74b6c2 authored by David Ahern's avatar David Ahern Committed by David S. Miller

net: Align ip_multipath_l3_keys and ip6_multipath_l3_keys

Symmetry is good and allows easy comparison that ipv4 and ipv6 are
doing the same thing. To that end, change ip_multipath_l3_keys to
set addresses at the end after the icmp compares, and move the
initialization of ipv6 flow keys to rt6_multipath_hash.
Signed-off-by: default avatarDavid Ahern <dsahern@gmail.com>
Reviewed-by: default avatarIdo Schimmel <idosch@mellanox.com>
Reviewed-by: default avatarNikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7efc0b6b
...@@ -1748,37 +1748,39 @@ static void ip_multipath_l3_keys(const struct sk_buff *skb, ...@@ -1748,37 +1748,39 @@ static void ip_multipath_l3_keys(const struct sk_buff *skb,
struct flow_keys *hash_keys) struct flow_keys *hash_keys)
{ {
const struct iphdr *outer_iph = ip_hdr(skb); const struct iphdr *outer_iph = ip_hdr(skb);
const struct iphdr *key_iph = outer_iph;
const struct iphdr *inner_iph; const struct iphdr *inner_iph;
const struct icmphdr *icmph; const struct icmphdr *icmph;
struct iphdr _inner_iph; struct iphdr _inner_iph;
struct icmphdr _icmph; struct icmphdr _icmph;
hash_keys->addrs.v4addrs.src = outer_iph->saddr;
hash_keys->addrs.v4addrs.dst = outer_iph->daddr;
if (likely(outer_iph->protocol != IPPROTO_ICMP)) if (likely(outer_iph->protocol != IPPROTO_ICMP))
return; goto out;
if (unlikely((outer_iph->frag_off & htons(IP_OFFSET)) != 0)) if (unlikely((outer_iph->frag_off & htons(IP_OFFSET)) != 0))
return; goto out;
icmph = skb_header_pointer(skb, outer_iph->ihl * 4, sizeof(_icmph), icmph = skb_header_pointer(skb, outer_iph->ihl * 4, sizeof(_icmph),
&_icmph); &_icmph);
if (!icmph) if (!icmph)
return; goto out;
if (icmph->type != ICMP_DEST_UNREACH && if (icmph->type != ICMP_DEST_UNREACH &&
icmph->type != ICMP_REDIRECT && icmph->type != ICMP_REDIRECT &&
icmph->type != ICMP_TIME_EXCEEDED && icmph->type != ICMP_TIME_EXCEEDED &&
icmph->type != ICMP_PARAMETERPROB) icmph->type != ICMP_PARAMETERPROB)
return; goto out;
inner_iph = skb_header_pointer(skb, inner_iph = skb_header_pointer(skb,
outer_iph->ihl * 4 + sizeof(_icmph), outer_iph->ihl * 4 + sizeof(_icmph),
sizeof(_inner_iph), &_inner_iph); sizeof(_inner_iph), &_inner_iph);
if (!inner_iph) if (!inner_iph)
return; goto out;
hash_keys->addrs.v4addrs.src = inner_iph->saddr;
hash_keys->addrs.v4addrs.dst = inner_iph->daddr; key_iph = inner_iph;
out:
hash_keys->addrs.v4addrs.src = key_iph->saddr;
hash_keys->addrs.v4addrs.dst = key_iph->daddr;
} }
/* if skb is set it will be used and fl4 can be NULL */ /* if skb is set it will be used and fl4 can be NULL */
......
...@@ -1815,8 +1815,6 @@ static void ip6_multipath_l3_keys(const struct sk_buff *skb, ...@@ -1815,8 +1815,6 @@ static void ip6_multipath_l3_keys(const struct sk_buff *skb,
key_iph = inner_iph; key_iph = inner_iph;
_flkeys = NULL; _flkeys = NULL;
out: out:
memset(keys, 0, sizeof(*keys));
keys->control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS;
if (_flkeys) { if (_flkeys) {
keys->addrs.v6addrs.src = _flkeys->addrs.v6addrs.src; keys->addrs.v6addrs.src = _flkeys->addrs.v6addrs.src;
keys->addrs.v6addrs.dst = _flkeys->addrs.v6addrs.dst; keys->addrs.v6addrs.dst = _flkeys->addrs.v6addrs.dst;
...@@ -1837,6 +1835,8 @@ u32 rt6_multipath_hash(const struct flowi6 *fl6, const struct sk_buff *skb, ...@@ -1837,6 +1835,8 @@ u32 rt6_multipath_hash(const struct flowi6 *fl6, const struct sk_buff *skb,
struct flow_keys hash_keys; struct flow_keys hash_keys;
if (skb) { if (skb) {
memset(&hash_keys, 0, sizeof(hash_keys));
hash_keys.control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS;
ip6_multipath_l3_keys(skb, &hash_keys, flkeys); ip6_multipath_l3_keys(skb, &hash_keys, flkeys);
return flow_hash_from_keys(&hash_keys) >> 1; return flow_hash_from_keys(&hash_keys) >> 1;
} }
......
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