Blame SOURCES/0234-netdrv-net-mlx5e-Disallow-inserting-vxlan-vlan-egres.patch

d8f823
From ac5bd9adb75cdce1a63983928583ca614781f712 Mon Sep 17 00:00:00 2001
d8f823
From: Alaa Hleihel <ahleihel@redhat.com>
d8f823
Date: Tue, 19 May 2020 07:48:56 -0400
d8f823
Subject: [PATCH 234/312] [netdrv] net/mlx5e: Disallow inserting vxlan/vlan
d8f823
 egress rules without decap/pop
d8f823
d8f823
Message-id: <20200519074934.6303-26-ahleihel@redhat.com>
d8f823
Patchwork-id: 310528
d8f823
Patchwork-instance: patchwork
d8f823
O-Subject: [RHEL8.3 BZ 1663246 25/63] net/mlx5e: Disallow inserting vxlan/vlan egress rules without decap/pop
d8f823
Bugzilla: 1790219 1790218 1663246
d8f823
RH-Acked-by: Marcelo Leitner <mleitner@redhat.com>
d8f823
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
d8f823
RH-Acked-by: John Linville <linville@redhat.com>
d8f823
RH-Acked-by: Ivan Vecera <ivecera@redhat.com>
d8f823
RH-Acked-by: Tony Camuso <tcamuso@redhat.com>
d8f823
RH-Acked-by: Kamal Heib <kheib@redhat.com>
d8f823
d8f823
Bugzilla: http://bugzilla.redhat.com/1663246
d8f823
Bugzilla: http://bugzilla.redhat.com/1790219
d8f823
Bugzilla: http://bugzilla.redhat.com/1790218
d8f823
Upstream: v5.7-rc1
d8f823
d8f823
commit 7f2fd0a5f8d859d71e710a664a113c4a2620dc4f
d8f823
Author: Paul Blakey <paulb@mellanox.com>
d8f823
Date:   Sun Feb 16 12:01:33 2020 +0200
d8f823
d8f823
    net/mlx5e: Disallow inserting vxlan/vlan egress rules without decap/pop
d8f823
d8f823
    Currently, rules on tunnel devices can be offloaded without decap action
d8f823
    when a vlan pop action exists. Similarly, the driver will offload rules
d8f823
    on vlan interfaces with no pop action when a decap action exists.
d8f823
d8f823
    Disallow the faulty behavior by checking that vlan egress rules do pop or
d8f823
    drop and vxlan egress rules do decap, as intended.
d8f823
d8f823
    Signed-off-by: Paul Blakey <paulb@mellanox.com>
d8f823
    Reviewed-by: Oz Shlomo <ozsh@mellanox.com>
d8f823
    Reviewed-by: Mark Bloch <markb@mellanox.com>
d8f823
    Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
d8f823
d8f823
Signed-off-by: Alaa Hleihel <ahleihel@redhat.com>
d8f823
Signed-off-by: Frantisek Hrbata <fhrbata@redhat.com>
d8f823
---
d8f823
 drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 20 +++++++++++++++-----
d8f823
 1 file changed, 15 insertions(+), 5 deletions(-)
d8f823
d8f823
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
d8f823
index 3d0a5c63d083..b3b006230b89 100644
d8f823
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
d8f823
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
d8f823
@@ -2673,6 +2673,8 @@ static bool actions_match_supported(struct mlx5e_priv *priv,
d8f823
 				    struct mlx5e_tc_flow *flow,
d8f823
 				    struct netlink_ext_ack *extack)
d8f823
 {
d8f823
+	struct net_device *filter_dev = parse_attr->filter_dev;
d8f823
+	bool drop_action, decap_action, pop_action;
d8f823
 	u32 actions;
d8f823
 
d8f823
 	if (mlx5e_is_eswitch_flow(flow))
d8f823
@@ -2680,11 +2682,19 @@ static bool actions_match_supported(struct mlx5e_priv *priv,
d8f823
 	else
d8f823
 		actions = flow->nic_attr->action;
d8f823
 
d8f823
-	if (flow_flag_test(flow, EGRESS) &&
d8f823
-	    !((actions & MLX5_FLOW_CONTEXT_ACTION_DECAP) ||
d8f823
-	      (actions & MLX5_FLOW_CONTEXT_ACTION_VLAN_POP) ||
d8f823
-	      (actions & MLX5_FLOW_CONTEXT_ACTION_DROP)))
d8f823
-		return false;
d8f823
+	drop_action = actions & MLX5_FLOW_CONTEXT_ACTION_DROP;
d8f823
+	decap_action = actions & MLX5_FLOW_CONTEXT_ACTION_DECAP;
d8f823
+	pop_action = actions & MLX5_FLOW_CONTEXT_ACTION_VLAN_POP;
d8f823
+
d8f823
+	if (flow_flag_test(flow, EGRESS) && !drop_action) {
d8f823
+		/* If no drop, we must decap (vxlan) or pop (vlan) */
d8f823
+		if (mlx5e_get_tc_tun(filter_dev) && !decap_action)
d8f823
+			return false;
d8f823
+		else if (is_vlan_dev(filter_dev) && !pop_action)
d8f823
+			return false;
d8f823
+		else
d8f823
+			return false; /* Sanity */
d8f823
+	}
d8f823
 
d8f823
 	if (actions & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR)
d8f823
 		return modify_header_match_supported(&parse_attr->spec,
d8f823
-- 
d8f823
2.13.6
d8f823