OSDN Git Service

mlxsw: spectrum_nve_vxlan: Make VxLAN flags check per address family
authorAmit Cohen <amcohen@nvidia.com>
Tue, 14 Dec 2021 14:25:46 +0000 (16:25 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 15 Dec 2021 15:05:44 +0000 (15:05 +0000)
As part of 'can_offload' checks, there is a check of VxLAN flags.

The supported flags for IPv6 VxLAN will be different from the existing
flags because of some limitations.

As preparation for IPv6 underlay support, make this check per address
family.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_nve_vxlan.c

index d018d2d..766a20e 100644 (file)
 #include "spectrum.h"
 #include "spectrum_nve.h"
 
-#define MLXSW_SP_NVE_VXLAN_SUPPORTED_FLAGS     (VXLAN_F_UDP_ZERO_CSUM_TX | \
+#define MLXSW_SP_NVE_VXLAN_IPV4_SUPPORTED_FLAGS (VXLAN_F_UDP_ZERO_CSUM_TX | \
                                                 VXLAN_F_LEARN)
 
+static bool mlxsw_sp_nve_vxlan_ipv4_flags_check(const struct vxlan_config *cfg,
+                                               struct netlink_ext_ack *extack)
+{
+       if (!(cfg->flags & VXLAN_F_UDP_ZERO_CSUM_TX)) {
+               NL_SET_ERR_MSG_MOD(extack, "VxLAN: Zero UDP checksum must be allowed for TX");
+               return false;
+       }
+
+       if (cfg->flags & ~MLXSW_SP_NVE_VXLAN_IPV4_SUPPORTED_FLAGS) {
+               NL_SET_ERR_MSG_MOD(extack, "VxLAN: Unsupported flag");
+               return false;
+       }
+
+       return true;
+}
+
 static bool mlxsw_sp_nve_vxlan_can_offload(const struct mlxsw_sp_nve *nve,
                                           const struct mlxsw_sp_nve_params *params,
                                           struct netlink_ext_ack *extack)
@@ -55,14 +71,11 @@ static bool mlxsw_sp_nve_vxlan_can_offload(const struct mlxsw_sp_nve *nve,
                return false;
        }
 
-       if (!(cfg->flags & VXLAN_F_UDP_ZERO_CSUM_TX)) {
-               NL_SET_ERR_MSG_MOD(extack, "VxLAN: UDP checksum is not supported");
-               return false;
-       }
-
-       if (cfg->flags & ~MLXSW_SP_NVE_VXLAN_SUPPORTED_FLAGS) {
-               NL_SET_ERR_MSG_MOD(extack, "VxLAN: Unsupported flag");
-               return false;
+       switch (cfg->saddr.sa.sa_family) {
+       case AF_INET:
+               if (!mlxsw_sp_nve_vxlan_ipv4_flags_check(cfg, extack))
+                       return false;
+               break;
        }
 
        if (cfg->ttl == 0) {