All of lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-wired-lan] [PATCH net v1] ice: Fix VF not able to send tagged traffic with no VLAN filters
@ 2022-08-01 16:12 Mateusz Palczewski
  2022-08-02 22:33 ` Tony Nguyen
  0 siblings, 1 reply; 2+ messages in thread
From: Mateusz Palczewski @ 2022-08-01 16:12 UTC (permalink / raw)
  To: intel-wired-lan; +Cc: Sylwester Dziedziuch

From: Sylwester Dziedziuch <sylwesterx.dziedziuch@intel.com>

VF was not able to send tagged traffic when it didn't
have any VLAN interfaces and VLAN anti-spoofing was enabled.
Fix this by allowing VFs with no VLAN filters to send tagged
traffic. After VF adds a VLAN interface it will be able to
send tagged traffic matching VLAN filters only.

Testing hints:
1. Spawn VF
2. Send tagged packet from a VF
3. The packet should be sent out and not dropped
4. Add a VLAN interface on VF
5. Send tagged packet on that VLAN interface
6. Packet should be sent out and not dropped
7. Send tagged packet with id different than VLAN interface
8. Packet should be dropped

Fixes: daf4dd16438b ("ice: Refactor spoofcheck configuration functions")
Signed-off-by: Sylwester Dziedziuch <sylwesterx.dziedziuch@intel.com>
Signed-off-by: Mateusz Palczewski <mateusz.palczewski@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_vf_lib.c   |  7 ++-
 drivers/net/ethernet/intel/ice/ice_virtchnl.c | 57 ++++++++++++++++---
 2 files changed, 55 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib.c b/drivers/net/ethernet/intel/ice/ice_vf_lib.c
index 2d6130af1d40..2e1bcd44f32b 100644
--- a/drivers/net/ethernet/intel/ice/ice_vf_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.c
@@ -707,11 +707,14 @@ static int ice_cfg_mac_antispoof(struct ice_vsi *vsi, bool enable)
 static int ice_vsi_ena_spoofchk(struct ice_vsi *vsi)
 {
 	struct ice_vsi_vlan_ops *vlan_ops;
-	int err;
+	int err = 0;
 
 	vlan_ops = ice_get_compat_vsi_vlan_ops(vsi);
 
-	err = vlan_ops->ena_tx_filtering(vsi);
+	/* Allow VF with VLAN 0 only to send all tagged traffic */
+	if ((vsi->type != ICE_VSI_VF) || ice_vsi_has_non_zero_vlans(vsi))
+		err = vlan_ops->ena_tx_filtering(vsi);
+	
 	if (err)
 		return err;
 
diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl.c b/drivers/net/ethernet/intel/ice/ice_virtchnl.c
index 24188ec594d5..a241c0bdc150 100644
--- a/drivers/net/ethernet/intel/ice/ice_virtchnl.c
+++ b/drivers/net/ethernet/intel/ice/ice_virtchnl.c
@@ -2264,6 +2264,15 @@ static int ice_vc_process_vlan_msg(struct ice_vf *vf, u8 *msg, bool add_v)
 
 			/* Enable VLAN filtering on first non-zero VLAN */
 			if (!vlan_promisc && vid && !ice_is_dvm_ena(&pf->hw)) {
+				if (vf->spoofchk) {
+					status = vsi->inner_vlan_ops.ena_tx_filtering(vsi);
+					if (status) {
+						v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+						dev_err(dev, "Enable VLAN anti-spoofing on VLAN ID: %d failed error-%d\n",
+							vid, status);
+						goto error_param;
+					}
+				}
 				if (vsi->inner_vlan_ops.ena_rx_filtering(vsi)) {
 					v_ret = VIRTCHNL_STATUS_ERR_PARAM;
 					dev_err(dev, "Enable VLAN pruning on VLAN ID: %d failed error-%d\n",
@@ -2309,8 +2318,10 @@ static int ice_vc_process_vlan_msg(struct ice_vf *vf, u8 *msg, bool add_v)
 			}
 
 			/* Disable VLAN filtering when only VLAN 0 is left */
-			if (!ice_vsi_has_non_zero_vlans(vsi))
+			if (!ice_vsi_has_non_zero_vlans(vsi)) {
+				vsi->inner_vlan_ops.dis_tx_filtering(vsi);
 				vsi->inner_vlan_ops.dis_rx_filtering(vsi);
+			}
 
 			if (vlan_promisc)
 				ice_vf_dis_vlan_promisc(vsi, &vlan);
@@ -2814,6 +2825,13 @@ ice_vc_del_vlans(struct ice_vf *vf, struct ice_vsi *vsi,
 
 			if (vlan_promisc)
 				ice_vf_dis_vlan_promisc(vsi, &vlan);
+
+			/* Disable VLAN filtering when only VLAN 0 is left */
+			if (!ice_vsi_has_non_zero_vlans(vsi) && ice_is_dvm_ena(&vsi->back->hw)) {
+				err = vsi->outer_vlan_ops.dis_tx_filtering(vsi);
+				if (err)
+					return err;
+			}
 		}
 
 		vc_vlan = &vlan_fltr->inner;
@@ -2829,8 +2847,17 @@ ice_vc_del_vlans(struct ice_vf *vf, struct ice_vsi *vsi,
 			/* no support for VLAN promiscuous on inner VLAN unless
 			 * we are in Single VLAN Mode (SVM)
 			 */
-			if (!ice_is_dvm_ena(&vsi->back->hw) && vlan_promisc)
-				ice_vf_dis_vlan_promisc(vsi, &vlan);
+			if (!ice_is_dvm_ena(&vsi->back->hw)) {
+				if (vlan_promisc)
+					ice_vf_dis_vlan_promisc(vsi, &vlan);
+
+				/* Disable VLAN filtering when only VLAN 0 is left */
+				if (!ice_vsi_has_non_zero_vlans(vsi)) {
+					err = vsi->inner_vlan_ops.dis_tx_filtering(vsi);
+					if (err)
+						return err;
+				}
+			}
 		}
 	}
 
@@ -2907,6 +2934,13 @@ ice_vc_add_vlans(struct ice_vf *vf, struct ice_vsi *vsi,
 				if (err)
 					return err;
 			}
+
+			/* Enable VLAN filtering on first non-zero VLAN */
+			if (vf->spoofchk && vlan.vid && ice_is_dvm_ena(&vsi->back->hw)) {
+				err = vsi->outer_vlan_ops.ena_tx_filtering(vsi);
+				if (err)
+					return err;
+			}
 		}
 
 		vc_vlan = &vlan_fltr->inner;
@@ -2922,10 +2956,19 @@ ice_vc_add_vlans(struct ice_vf *vf, struct ice_vsi *vsi,
 			/* no support for VLAN promiscuous on inner VLAN unless
 			 * we are in Single VLAN Mode (SVM)
 			 */
-			if (!ice_is_dvm_ena(&vsi->back->hw) && vlan_promisc) {
-				err = ice_vf_ena_vlan_promisc(vsi, &vlan);
-				if (err)
-					return err;
+			if (!ice_is_dvm_ena(&vsi->back->hw)) {
+				if (vlan_promisc) {
+					err = ice_vf_ena_vlan_promisc(vsi, &vlan);
+					if (err)
+						return err;
+				}
+
+				/* Enable VLAN filtering on first non-zero VLAN */
+				if (vf->spoofchk && vlan.vid) {
+					err = vsi->inner_vlan_ops.ena_tx_filtering(vsi);
+					if (err)
+						return err;
+				}
 			}
 		}
 	}
-- 
2.25.1

_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Intel-wired-lan] [PATCH net v1] ice: Fix VF not able to send tagged traffic with no VLAN filters
  2022-08-01 16:12 [Intel-wired-lan] [PATCH net v1] ice: Fix VF not able to send tagged traffic with no VLAN filters Mateusz Palczewski
@ 2022-08-02 22:33 ` Tony Nguyen
  0 siblings, 0 replies; 2+ messages in thread
From: Tony Nguyen @ 2022-08-02 22:33 UTC (permalink / raw)
  To: Mateusz Palczewski, intel-wired-lan; +Cc: Sylwester Dziedziuch

On 8/1/2022 9:12 AM, Mateusz Palczewski wrote:
> From: Sylwester Dziedziuch <sylwesterx.dziedziuch@intel.com>
> 
> VF was not able to send tagged traffic when it didn't
> have any VLAN interfaces and VLAN anti-spoofing was enabled.
> Fix this by allowing VFs with no VLAN filters to send tagged
> traffic. After VF adds a VLAN interface it will be able to
> send tagged traffic matching VLAN filters only.
> 
> Testing hints:
> 1. Spawn VF
> 2. Send tagged packet from a VF
> 3. The packet should be sent out and not dropped
> 4. Add a VLAN interface on VF
> 5. Send tagged packet on that VLAN interface
> 6. Packet should be sent out and not dropped
> 7. Send tagged packet with id different than VLAN interface
> 8. Packet should be dropped

This has checkpatch issues:

CHECK: Unnecessary parentheses around 'vsi->type != ICE_VSI_VF'
ERROR: trailing whitespace

Also, if possible, would be nice to resolve these if it doesn't affect 
readability:

WARNING: line length of 82 exceeds 80 columns
WARNING: line length of 85 exceeds 80 columns
WARNING: line length of 88 exceeds 80 columns
WARNING: line length of 89 exceeds 80 columns
WARNING: line length of 91 exceeds 80 columns
WARNING: line length of 97 exceeds 80 columns

> Fixes: daf4dd16438b ("ice: Refactor spoofcheck configuration functions")
> Signed-off-by: Sylwester Dziedziuch <sylwesterx.dziedziuch@intel.com>
> Signed-off-by: Mateusz Palczewski <mateusz.palczewski@intel.com>
> ---
>   drivers/net/ethernet/intel/ice/ice_vf_lib.c   |  7 ++-
>   drivers/net/ethernet/intel/ice/ice_virtchnl.c | 57 ++++++++++++++++---
>   2 files changed, 55 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib.c b/drivers/net/ethernet/intel/ice/ice_vf_lib.c
> index 2d6130af1d40..2e1bcd44f32b 100644
> --- a/drivers/net/ethernet/intel/ice/ice_vf_lib.c
> +++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.c
> @@ -707,11 +707,14 @@ static int ice_cfg_mac_antispoof(struct ice_vsi *vsi, bool enable)
>   static int ice_vsi_ena_spoofchk(struct ice_vsi *vsi)
>   {
>   	struct ice_vsi_vlan_ops *vlan_ops;
> -	int err;
> +	int err = 0;
>   
>   	vlan_ops = ice_get_compat_vsi_vlan_ops(vsi);
>   
> -	err = vlan_ops->ena_tx_filtering(vsi);
> +	/* Allow VF with VLAN 0 only to send all tagged traffic */
> +	if ((vsi->type != ICE_VSI_VF) || ice_vsi_has_non_zero_vlans(vsi))
> +		err = vlan_ops->ena_tx_filtering(vsi);
> +	
>   	if (err)
>   		return err;

Should this be part of the above if as well?

>   
> diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl.c b/drivers/net/ethernet/intel/ice/ice_virtchnl.c
> index 24188ec594d5..a241c0bdc150 100644
> --- a/drivers/net/ethernet/intel/ice/ice_virtchnl.c
> +++ b/drivers/net/ethernet/intel/ice/ice_virtchnl.c
> @@ -2264,6 +2264,15 @@ static int ice_vc_process_vlan_msg(struct ice_vf *vf, u8 *msg, bool add_v)
>   
>   			/* Enable VLAN filtering on first non-zero VLAN */
>   			if (!vlan_promisc && vid && !ice_is_dvm_ena(&pf->hw)) {
> +				if (vf->spoofchk) {
> +					status = vsi->inner_vlan_ops.ena_tx_filtering(vsi);
> +					if (status) {
> +						v_ret = VIRTCHNL_STATUS_ERR_PARAM;
> +						dev_err(dev, "Enable VLAN anti-spoofing on VLAN ID: %d failed error-%d\n",
> +							vid, status);
> +						goto error_param;
> +					}
> +				}
>   				if (vsi->inner_vlan_ops.ena_rx_filtering(vsi)) {
>   					v_ret = VIRTCHNL_STATUS_ERR_PARAM;
>   					dev_err(dev, "Enable VLAN pruning on VLAN ID: %d failed error-%d\n",
> @@ -2309,8 +2318,10 @@ static int ice_vc_process_vlan_msg(struct ice_vf *vf, u8 *msg, bool add_v)
>   			}
>   
>   			/* Disable VLAN filtering when only VLAN 0 is left */
> -			if (!ice_vsi_has_non_zero_vlans(vsi))
> +			if (!ice_vsi_has_non_zero_vlans(vsi)) {
> +				vsi->inner_vlan_ops.dis_tx_filtering(vsi);
>   				vsi->inner_vlan_ops.dis_rx_filtering(vsi);
> +			}
>   
>   			if (vlan_promisc)
>   				ice_vf_dis_vlan_promisc(vsi, &vlan);
> @@ -2814,6 +2825,13 @@ ice_vc_del_vlans(struct ice_vf *vf, struct ice_vsi *vsi,
>   
>   			if (vlan_promisc)
>   				ice_vf_dis_vlan_promisc(vsi, &vlan);
> +
> +			/* Disable VLAN filtering when only VLAN 0 is left */
> +			if (!ice_vsi_has_non_zero_vlans(vsi) && ice_is_dvm_ena(&vsi->back->hw)) {
> +				err = vsi->outer_vlan_ops.dis_tx_filtering(vsi);
> +				if (err)
> +					return err;
> +			}
>   		}
>   
>   		vc_vlan = &vlan_fltr->inner;
> @@ -2829,8 +2847,17 @@ ice_vc_del_vlans(struct ice_vf *vf, struct ice_vsi *vsi,
>   			/* no support for VLAN promiscuous on inner VLAN unless
>   			 * we are in Single VLAN Mode (SVM)
>   			 */
> -			if (!ice_is_dvm_ena(&vsi->back->hw) && vlan_promisc)
> -				ice_vf_dis_vlan_promisc(vsi, &vlan);
> +			if (!ice_is_dvm_ena(&vsi->back->hw)) {
> +				if (vlan_promisc)
> +					ice_vf_dis_vlan_promisc(vsi, &vlan);
> +
> +				/* Disable VLAN filtering when only VLAN 0 is left */
> +				if (!ice_vsi_has_non_zero_vlans(vsi)) {
> +					err = vsi->inner_vlan_ops.dis_tx_filtering(vsi);
> +					if (err)
> +						return err;
> +				}
> +			}
>   		}
>   	}
>   
> @@ -2907,6 +2934,13 @@ ice_vc_add_vlans(struct ice_vf *vf, struct ice_vsi *vsi,
>   				if (err)
>   					return err;
>   			}
> +
> +			/* Enable VLAN filtering on first non-zero VLAN */
> +			if (vf->spoofchk && vlan.vid && ice_is_dvm_ena(&vsi->back->hw)) {
> +				err = vsi->outer_vlan_ops.ena_tx_filtering(vsi);
> +				if (err)
> +					return err;
> +			}
>   		}
>   
>   		vc_vlan = &vlan_fltr->inner;
> @@ -2922,10 +2956,19 @@ ice_vc_add_vlans(struct ice_vf *vf, struct ice_vsi *vsi,
>   			/* no support for VLAN promiscuous on inner VLAN unless
>   			 * we are in Single VLAN Mode (SVM)
>   			 */
> -			if (!ice_is_dvm_ena(&vsi->back->hw) && vlan_promisc) {
> -				err = ice_vf_ena_vlan_promisc(vsi, &vlan);
> -				if (err)
> -					return err;
> +			if (!ice_is_dvm_ena(&vsi->back->hw)) {
> +				if (vlan_promisc) {
> +					err = ice_vf_ena_vlan_promisc(vsi, &vlan);
> +					if (err)
> +						return err;
> +				}
> +
> +				/* Enable VLAN filtering on first non-zero VLAN */
> +				if (vf->spoofchk && vlan.vid) {
> +					err = vsi->inner_vlan_ops.ena_tx_filtering(vsi);
> +					if (err)
> +						return err;
> +				}
>   			}
>   		}
>   	}
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-02 22:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-01 16:12 [Intel-wired-lan] [PATCH net v1] ice: Fix VF not able to send tagged traffic with no VLAN filters Mateusz Palczewski
2022-08-02 22:33 ` Tony Nguyen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.