From nobody Thu Dec 18 12:46:28 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7EEA6C32796 for ; Tue, 23 Aug 2022 09:04:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347671AbiHWJEA (ORCPT ); Tue, 23 Aug 2022 05:04:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347638AbiHWJCm (ORCPT ); Tue, 23 Aug 2022 05:02:42 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98A622AE39; Tue, 23 Aug 2022 01:28:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4218361496; Tue, 23 Aug 2022 08:27:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3AF5AC433C1; Tue, 23 Aug 2022 08:27:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243270; bh=hmBBC3rXmDgnAJTGGbM1FP0s6fS3OG2Gq1iLirJXgSY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZAr98klI0YjJ+k+Cpfv42BtstAe0QPHKUB169wiIdBb5okqTPP7z9AqPhAooFi/FE kIWLsUO0gfYRQL36Va+gplwNmxLL3Hem2XdymTAF+yrcs8Gi6VpSynfsB2f6ycTfQ1 AeE0rOQn1sWvPeWXS8B1jrWlK/eCNPXa3q+uhRnQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sylwester Dziedziuch , Mateusz Palczewski , Konrad Jankowski , Tony Nguyen Subject: [PATCH 5.19 223/365] ice: Fix VF not able to send tagged traffic with no VLAN filters Date: Tue, 23 Aug 2022 10:02:04 +0200 Message-Id: <20220823080127.530680795@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Sylwester Dziedziuch commit 664d4646184ed986f8195df684cc4660563fb02a upstream. 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 Signed-off-by: Mateusz Palczewski Tested-by: Konrad Jankowski Signed-off-by: Tony Nguyen Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 11 +++-- drivers/net/ethernet/intel/ice/ice_virtchnl.c | 57 +++++++++++++++++++++= +---- 2 files changed, 57 insertions(+), 11 deletions(-) --- a/drivers/net/ethernet/intel/ice/ice_vf_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.c @@ -707,13 +707,16 @@ static int ice_cfg_mac_antispoof(struct static int ice_vsi_ena_spoofchk(struct ice_vsi *vsi) { struct ice_vsi_vlan_ops *vlan_ops; - int err; + int err =3D 0; =20 vlan_ops =3D ice_get_compat_vsi_vlan_ops(vsi); =20 - err =3D vlan_ops->ena_tx_filtering(vsi); - if (err) - return err; + /* Allow VF with VLAN 0 only to send all tagged traffic */ + if (vsi->type !=3D ICE_VSI_VF || ice_vsi_has_non_zero_vlans(vsi)) { + err =3D vlan_ops->ena_tx_filtering(vsi); + if (err) + return err; + } =20 return ice_cfg_mac_antispoof(vsi, true); } --- 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(struc =20 /* Enable VLAN filtering on first non-zero VLAN */ if (!vlan_promisc && vid && !ice_is_dvm_ena(&pf->hw)) { + if (vf->spoofchk) { + status =3D vsi->inner_vlan_ops.ena_tx_filtering(vsi); + if (status) { + v_ret =3D 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 =3D 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(struc } =20 /* 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); + } =20 if (vlan_promisc) ice_vf_dis_vlan_promisc(vsi, &vlan); @@ -2814,6 +2825,13 @@ ice_vc_del_vlans(struct ice_vf *vf, stru =20 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 =3D vsi->outer_vlan_ops.dis_tx_filtering(vsi); + if (err) + return err; + } } =20 vc_vlan =3D &vlan_fltr->inner; @@ -2829,8 +2847,17 @@ ice_vc_del_vlans(struct ice_vf *vf, stru /* 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 =3D vsi->inner_vlan_ops.dis_tx_filtering(vsi); + if (err) + return err; + } + } } } =20 @@ -2907,6 +2934,13 @@ ice_vc_add_vlans(struct ice_vf *vf, stru 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 =3D vsi->outer_vlan_ops.ena_tx_filtering(vsi); + if (err) + return err; + } } =20 vc_vlan =3D &vlan_fltr->inner; @@ -2922,10 +2956,19 @@ ice_vc_add_vlans(struct ice_vf *vf, stru /* 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 =3D ice_vf_ena_vlan_promisc(vsi, &vlan); - if (err) - return err; + if (!ice_is_dvm_ena(&vsi->back->hw)) { + if (vlan_promisc) { + err =3D 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 =3D vsi->inner_vlan_ops.ena_tx_filtering(vsi); + if (err) + return err; + } } } }