From patchwork Sun Nov 5 16:46:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Vecera X-Patchwork-Id: 161732 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2215807vqu; Sun, 5 Nov 2023 08:57:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IHY3IqokQ/pizT158XT40UHsLCvcAp1ti+/XGo60ASGnSv6n/UF0V7e10AXCQxu37X/b1jW X-Received: by 2002:a05:6a20:8e24:b0:17f:f8f3:ea51 with SMTP id y36-20020a056a208e2400b0017ff8f3ea51mr20393976pzj.20.1699203438106; Sun, 05 Nov 2023 08:57:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699203438; cv=none; d=google.com; s=arc-20160816; b=gehXWi6POwf1mbZwcF/NH07nqs3MPvD24ciOkKphfT+cViTe+j4x3LBFm1PycjvZ1E z5CA9xaO7DHNm1iET/ce5TLmdbQ3z0Id+8tAJHLJPr0Z3Qb1GLPNPYSgyshUCNStalbY kkyJtCIXwpkzpVrHUcZsf/1Lg1HU7Ouw58nVhUMmHllO8Iiyw7ojb0jI+o471gcAbs2x Xxe/51K27wh4bvmaMpNsu3EWV+fjVbhlnIcMHePw+OG/Ii0rRFph2BPMbs+y1zOaI1b9 yj1yNyzzBtk4rBwSZUq/VyRSc4FrgqQi4mVWDKemkGXIvy1/qM1YjnAaMFzNLRotmZd/ gb+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=eC7KMeIBQqNk/V3RXfwXIU+MwIED52IGZpLe2RUKxaU=; fh=pbpoSe4wfv1D3WUHYIrsYhFIwZB3WVwFw/SIFS7Ade8=; b=DXgeOW9Ni1wg16mCi3AEyhIE1UnzGB84r2r5DXh5vIFsKy1MJ9Id7iyE91tvFqgPUw PeCZd4rrhfUErZH2LbvC4EeqBz7ko3Kwq5NyDMgTFcKYKF0TTyAZM8XRWb97ihx8xwax AO+E7k0Tq//LNR+USPNrZYx/fip2L7FKevWajVo6lHnFEqJ/XP2SRtLzlXFu7CDUKxq9 2F95byehN3SZ6hunNFkQFgncWV/gZcSyuADcYaQ1bB2FXK3U3EE5BExQTg3IdJj8E410 1HyACcx74vnDa7Q/IcIaFJL4oVGiK+sVkgJydnUF+F23dO8LPGFcTvFBDm71VfgaFDDW NmKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="MoO/ESCO"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id x1-20020a17090300c100b001c7342b46e4si5858484plc.23.2023.11.05.08.57.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 08:57:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="MoO/ESCO"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 2AB048075036; Sun, 5 Nov 2023 08:56:15 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229524AbjKEQrA (ORCPT + 34 others); Sun, 5 Nov 2023 11:47:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjKEQq6 (ORCPT ); Sun, 5 Nov 2023 11:46:58 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9E3BDD for ; Sun, 5 Nov 2023 08:46:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699202768; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=eC7KMeIBQqNk/V3RXfwXIU+MwIED52IGZpLe2RUKxaU=; b=MoO/ESCOHj2BR+54ElmXfOWoV/p9pK22M1CKd86wA3q7F82p4rbY4dzsaKx85e7+pv1xI6 AP1htrSnU3LuPGXYQLOcfgsm2OJXj7ZqGMri+qJDJXIBUM30Y9mDoeLlDpeA+1Y0Ftjqfj i6/J0plfpLMXAVvyummLQrtIZuAZHrM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-460-cwp2luAZMS6wp8sRjoORrA-1; Sun, 05 Nov 2023 11:46:07 -0500 X-MC-Unique: cwp2luAZMS6wp8sRjoORrA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8578D185A780; Sun, 5 Nov 2023 16:46:06 +0000 (UTC) Received: from p1.luc.cera.cz (unknown [10.45.224.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C71340C6EB9; Sun, 5 Nov 2023 16:46:03 +0000 (UTC) From: Ivan Vecera To: netdev@vger.kernel.org Cc: Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org, Jacob Keller , Wojciech Drewek , Simon Horman Subject: [PATCH net v2] i40e: Fix adding unsupported cloud filters Date: Sun, 5 Nov 2023 17:46:02 +0100 Message-ID: <20231105164602.1107498-1-ivecera@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Spam-Status: No, score=-1.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sun, 05 Nov 2023 08:56:15 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781743944766279057 X-GMAIL-MSGID: 1781743944766279057 If a VF tries to add unsupported cloud filter through virchnl then i40e_add_del_cloud_filter(_big_buf) returns -ENOTSUPP but this error code is stored in 'ret' instead of 'aq_ret' that is used as error code sent back to VF. In this scenario where one of the mentioned functions fails the value of 'aq_ret' is zero so the VF will incorrectly receive a 'success'. Use 'aq_ret' to store return value and remove 'ret' local variable. Additionally fix the issue when filter allocation fails, in this case no notification is sent back to the VF. Fixes: e284fc280473be ("i40e: Add and delete cloud filter") Reviewed-by: Simon Horman Signed-off-by: Ivan Vecera Tested-by: Rafal Romanowski --- .../net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c index 08d7edccfb8ddb..3f99eb19824527 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c @@ -3844,7 +3844,7 @@ static int i40e_vc_add_cloud_filter(struct i40e_vf *vf, u8 *msg) struct i40e_pf *pf = vf->pf; struct i40e_vsi *vsi = NULL; int aq_ret = 0; - int i, ret; + int i; if (!i40e_sync_vf_state(vf, I40E_VF_STATE_ACTIVE)) { aq_ret = -EINVAL; @@ -3868,8 +3868,10 @@ static int i40e_vc_add_cloud_filter(struct i40e_vf *vf, u8 *msg) } cfilter = kzalloc(sizeof(*cfilter), GFP_KERNEL); - if (!cfilter) - return -ENOMEM; + if (!cfilter) { + aq_ret = -ENOMEM; + goto err_out; + } /* parse destination mac address */ for (i = 0; i < ETH_ALEN; i++) @@ -3917,13 +3919,13 @@ static int i40e_vc_add_cloud_filter(struct i40e_vf *vf, u8 *msg) /* Adding cloud filter programmed as TC filter */ if (tcf.dst_port) - ret = i40e_add_del_cloud_filter_big_buf(vsi, cfilter, true); + aq_ret = i40e_add_del_cloud_filter_big_buf(vsi, cfilter, true); else - ret = i40e_add_del_cloud_filter(vsi, cfilter, true); - if (ret) { + aq_ret = i40e_add_del_cloud_filter(vsi, cfilter, true); + if (aq_ret) { dev_err(&pf->pdev->dev, "VF %d: Failed to add cloud filter, err %pe aq_err %s\n", - vf->vf_id, ERR_PTR(ret), + vf->vf_id, ERR_PTR(aq_ret), i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); goto err_free; }