net/ipv6: Make rt6_multipath_hash similar to fib_multipath_hash
authorDavid Ahern <dsahern@gmail.com>
Fri, 2 Mar 2018 16:32:15 +0000 (08:32 -0800)
committerDavid S. Miller <davem@davemloft.net>
Sun, 4 Mar 2018 18:04:21 +0000 (13:04 -0500)
Make rt6_multipath_hash more of a direct parallel to fib_multipath_hash
and reduce stack and overhead in the process: get_hash_from_flowi6 is
just a wrapper around __get_hash_from_flowi6 with another stack
allocation for flow_keys. Move setting the addresses, protocol and
label into rt6_multipath_hash and allow it to make the call to
flow_hash_from_keys.

Signed-off-by: David Ahern <dsahern@gmail.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Reviewed-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/route.c

index 190d9690dfe0cf8d3ebf38b9ab7a6af1bf9dcb0a..5c89af2c54f47f371f2117ddfd850634b8c5caca 100644 (file)
@@ -1833,15 +1833,21 @@ u32 rt6_multipath_hash(const struct flowi6 *fl6, const struct sk_buff *skb,
                       struct flow_keys *flkeys)
 {
        struct flow_keys hash_keys;
+       u32 mhash;
 
+       memset(&hash_keys, 0, sizeof(hash_keys));
+       hash_keys.control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS;
        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);
-               return flow_hash_from_keys(&hash_keys) >> 1;
+       } else {
+               hash_keys.addrs.v6addrs.src = fl6->saddr;
+               hash_keys.addrs.v6addrs.dst = fl6->daddr;
+               hash_keys.tags.flow_label = (__force u32)fl6->flowlabel;
+               hash_keys.basic.ip_proto = fl6->flowi6_proto;
        }
+       mhash = flow_hash_from_keys(&hash_keys);
 
-       return get_hash_from_flowi6(fl6) >> 1;
+       return mhash >> 1;
 }
 
 void ip6_route_input(struct sk_buff *skb)