Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net/ipv6: Make rt6_multipath_hash similar to fib_multipath_hash

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>

authored by

David Ahern and committed by
David S. Miller
9a2a537a ec7127a5

+10 -4
+10 -4
net/ipv6/route.c
··· 1833 1833 struct flow_keys *flkeys) 1834 1834 { 1835 1835 struct flow_keys hash_keys; 1836 + u32 mhash; 1836 1837 1838 + memset(&hash_keys, 0, sizeof(hash_keys)); 1839 + hash_keys.control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS; 1837 1840 if (skb) { 1838 - memset(&hash_keys, 0, sizeof(hash_keys)); 1839 - hash_keys.control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS; 1840 1841 ip6_multipath_l3_keys(skb, &hash_keys, flkeys); 1841 - return flow_hash_from_keys(&hash_keys) >> 1; 1842 + } else { 1843 + hash_keys.addrs.v6addrs.src = fl6->saddr; 1844 + hash_keys.addrs.v6addrs.dst = fl6->daddr; 1845 + hash_keys.tags.flow_label = (__force u32)fl6->flowlabel; 1846 + hash_keys.basic.ip_proto = fl6->flowi6_proto; 1842 1847 } 1848 + mhash = flow_hash_from_keys(&hash_keys); 1843 1849 1844 - return get_hash_from_flowi6(fl6) >> 1; 1850 + return mhash >> 1; 1845 1851 } 1846 1852 1847 1853 void ip6_route_input(struct sk_buff *skb)