net: ipv6: Introduce ip6_multipath_hash_policy()
authorPetr Machata <petrm@mellanox.com>
Sun, 11 Mar 2018 07:45:47 +0000 (09:45 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 12 Mar 2018 15:07:15 +0000 (11:07 -0400)
In order to abstract away access to the
ipv6.sysctl.multipath_hash_policy variable, which is not available on
systems compiled without IPv6 support, introduce a wrapper function
ip6_multipath_hash_policy() that falls back to 0 on non-IPv6 systems.

Use this wrapper from mlxsw/spectrum_router instead of a direct
reference.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Acked-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
include/net/ipv6.h

index a8a578610a7bf7f7787711802cba6add891c6511..921bd1075edfff74241785779b39e3e8ada7e9ae 100644 (file)
@@ -7031,7 +7031,7 @@ static void mlxsw_sp_mp4_hash_init(char *recr2_pl)
 
 static void mlxsw_sp_mp6_hash_init(char *recr2_pl)
 {
-       bool only_l3 = !init_net.ipv6.sysctl.multipath_hash_policy;
+       bool only_l3 = !ip6_multipath_hash_policy(&init_net);
 
        mlxsw_sp_mp_hash_header_set(recr2_pl,
                                    MLXSW_REG_RECR2_IPV6_EN_NOT_TCP_NOT_UDP);
index cabd3cdd40154b4dc6ee9e31c44a1536c8648a68..50a6f0ddb8780f6c9169f4ae0b3b35af2d66cd4b 100644 (file)
@@ -888,6 +888,17 @@ static inline int ip6_default_np_autolabel(struct net *net)
 }
 #endif
 
+#if IS_ENABLED(CONFIG_IPV6)
+static inline int ip6_multipath_hash_policy(const struct net *net)
+{
+       return net->ipv6.sysctl.multipath_hash_policy;
+}
+#else
+static inline int ip6_multipath_hash_policy(const struct net *net)
+{
+       return 0;
+}
+#endif
 
 /*
  *     Header manipulation