net/mlx5e: MPLSoUDP decap, fix check for unsupported matches
authorMaor Dickman <maord@nvidia.com>
Thu, 6 Jan 2022 12:46:24 +0000 (14:46 +0200)
committerSaeed Mahameed <saeedm@nvidia.com>
Thu, 24 Feb 2022 00:08:19 +0000 (16:08 -0800)
Currently offload of rule on bareudp device require tunnel key
in order to match on mpls fields and without it the mpls fields
are ignored, this is incorrect due to the fact udp tunnel doesn't
have key to match on.

Fix by returning error in case flow is matching on tunnel key.

Fixes: 72046a91d134 ("net/mlx5e: Allow to match on mpls parameters")
Signed-off-by: Maor Dickman <maord@nvidia.com>
Reviewed-by: Roi Dayan <roid@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_mplsoudp.c

index f40dbfc..c5b1617 100644 (file)
@@ -59,37 +59,31 @@ static int parse_tunnel(struct mlx5e_priv *priv,
                        void *headers_v)
 {
        struct flow_rule *rule = flow_cls_offload_flow_rule(f);
-       struct flow_match_enc_keyid enc_keyid;
        struct flow_match_mpls match;
        void *misc2_c;
        void *misc2_v;
 
-       misc2_c = MLX5_ADDR_OF(fte_match_param, spec->match_criteria,
-                              misc_parameters_2);
-       misc2_v = MLX5_ADDR_OF(fte_match_param, spec->match_value,
-                              misc_parameters_2);
-
-       if (!flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_MPLS))
-               return 0;
-
-       if (!flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ENC_KEYID))
-               return 0;
-
-       flow_rule_match_enc_keyid(rule, &enc_keyid);
-
-       if (!enc_keyid.mask->keyid)
-               return 0;
-
        if (!MLX5_CAP_ETH(priv->mdev, tunnel_stateless_mpls_over_udp) &&
            !(MLX5_CAP_GEN(priv->mdev, flex_parser_protocols) & MLX5_FLEX_PROTO_CW_MPLS_UDP))
                return -EOPNOTSUPP;
 
+       if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ENC_KEYID))
+               return -EOPNOTSUPP;
+
+       if (!flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_MPLS))
+               return 0;
+
        flow_rule_match_mpls(rule, &match);
 
        /* Only support matching the first LSE */
        if (match.mask->used_lses != 1)
                return -EOPNOTSUPP;
 
+       misc2_c = MLX5_ADDR_OF(fte_match_param, spec->match_criteria,
+                              misc_parameters_2);
+       misc2_v = MLX5_ADDR_OF(fte_match_param, spec->match_value,
+                              misc_parameters_2);
+
        MLX5_SET(fte_match_set_misc2, misc2_c,
                 outer_first_mpls_over_udp.mpls_label,
                 match.mask->ls[0].mpls_label);