{"id":2224527,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2224527/?format=json","web_url":"http://patchwork.ozlabs.org/project/intel-wired-lan/patch/dc7fb6f6bc737049a9ab8c42bd2f4b34b477907a.1776426683.git.poros@redhat.com/","project":{"id":46,"url":"http://patchwork.ozlabs.org/api/1.2/projects/46/?format=json","name":"Intel Wired Ethernet development","link_name":"intel-wired-lan","list_id":"intel-wired-lan.osuosl.org","list_email":"intel-wired-lan@osuosl.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<dc7fb6f6bc737049a9ab8c42bd2f4b34b477907a.1776426683.git.poros@redhat.com>","list_archive_url":null,"date":"2026-04-17T14:29:44","name":"[iwl-net,v2,3/4] iavf: wait for PF confirmation before removing VLAN filters","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"bcb497c7928deeba032a958c98c3825711466ab6","submitter":{"id":74657,"url":"http://patchwork.ozlabs.org/api/1.2/people/74657/?format=json","name":"Petr Oros","email":"poros@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/intel-wired-lan/patch/dc7fb6f6bc737049a9ab8c42bd2f4b34b477907a.1776426683.git.poros@redhat.com/mbox/","series":[{"id":500351,"url":"http://patchwork.ozlabs.org/api/1.2/series/500351/?format=json","web_url":"http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=500351","date":"2026-04-17T14:29:41","name":"iavf: fix VLAN filter state machine races","version":2,"mbox":"http://patchwork.ozlabs.org/series/500351/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2224527/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2224527/checks/","tags":{},"related":[],"headers":{"Return-Path":"<intel-wired-lan-bounces@osuosl.org>","X-Original-To":["incoming@patchwork.ozlabs.org","intel-wired-lan@lists.osuosl.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","intel-wired-lan@lists.osuosl.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256\n header.s=default header.b=Ytvr/f0h;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org\n (client-ip=140.211.166.138; helo=smtp1.osuosl.org;\n envelope-from=intel-wired-lan-bounces@osuosl.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fxy340H7bz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 18 Apr 2026 00:30:24 +1000 (AEST)","from localhost (localhost [127.0.0.1])\n\tby smtp1.osuosl.org (Postfix) with ESMTP id 0E03580A46;\n\tFri, 17 Apr 2026 14:30:20 +0000 (UTC)","from smtp1.osuosl.org ([127.0.0.1])\n by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP\n id GxNuEuYv_vd3; Fri, 17 Apr 2026 14:30:19 +0000 (UTC)","from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142])\n\tby smtp1.osuosl.org (Postfix) with ESMTP id 492EF813B6;\n\tFri, 17 Apr 2026 14:30:19 +0000 (UTC)","from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138])\n by lists1.osuosl.org (Postfix) with ESMTP id 47DF8270\n for <intel-wired-lan@lists.osuosl.org>; Fri, 17 Apr 2026 14:30:18 +0000 (UTC)","from localhost (localhost [127.0.0.1])\n by smtp1.osuosl.org (Postfix) with ESMTP id 3A05480C47\n for <intel-wired-lan@lists.osuosl.org>; Fri, 17 Apr 2026 14:30:18 +0000 (UTC)","from smtp1.osuosl.org ([127.0.0.1])\n by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP\n id ZADmTKWbGW7I for <intel-wired-lan@lists.osuosl.org>;\n Fri, 17 Apr 2026 14:30:17 +0000 (UTC)","from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.129.124])\n by smtp1.osuosl.org (Postfix) with ESMTPS id 1D75F80A85\n for <intel-wired-lan@lists.osuosl.org>; Fri, 17 Apr 2026 14:30:16 +0000 (UTC)","from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-609-qN3pg3HzOBS6RW1OI8S-DA-1; Fri,\n 17 Apr 2026 10:30:12 -0400","from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id 1ADA1195609D; Fri, 17 Apr 2026 14:30:07 +0000 (UTC)","from ShadowPeak.redhat.com (unknown [10.44.32.76])\n by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id 73678180047F; Fri, 17 Apr 2026 14:30:02 +0000 (UTC)"],"X-Virus-Scanned":["amavis at osuosl.org","amavis at osuosl.org"],"X-Comment":"SPF check N/A for local connections - client-ip=140.211.166.142;\n helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org;\n receiver=<UNKNOWN> ","DKIM-Filter":["OpenDKIM Filter v2.11.0 smtp1.osuosl.org 492EF813B6","OpenDKIM Filter v2.11.0 smtp1.osuosl.org 1D75F80A85"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org;\n\ts=default; t=1776436219;\n\tbh=So3UL4GLmFGEb2cMh3LixTfYDLK8oXuy3PKPaHp8JM4=;\n\th=From:To:Date:In-Reply-To:References:Subject:List-Id:\n\t List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe:\n\t Cc:From;\n\tb=Ytvr/f0hwWqsZoyxzia7CyIndULkeSjdhlTsRhrIwU6VIwjAWblIBt8JxL2q1CmXi\n\t mcydokB41qfba3BanhnqaOhpeHAAbQO809kgcwliERInaBZoyskv2nszjyw0z796A4\n\t N12IaaIein+fsop7cQps9Sv4+NGAm7Mgpc8ETQcASB0FOrxildopEX2oHMfg7S6Zsk\n\t ZrY0bnnj0NlWbbFAGvGA1NSuYXNa8gQN2vDMnctm4iugrm6DzlLevfLpyHSs7AJ+4d\n\t skDiLNJPgu32g40HvqU/7lwWv4Ny3UyHwrX7Q0SP+IYqPBUllTVqaKPnlgf0XEwLld\n\t RWFYLn+J5oIoA==","Received-SPF":"Pass (mailfrom) identity=mailfrom; client-ip=170.10.129.124;\n helo=us-smtp-delivery-124.mimecast.com; envelope-from=poros@redhat.com;\n receiver=<UNKNOWN>","DMARC-Filter":"OpenDMARC Filter v1.4.2 smtp1.osuosl.org 1D75F80A85","X-MC-Unique":"qN3pg3HzOBS6RW1OI8S-DA-1","X-Mimecast-MFC-AGG-ID":"qN3pg3HzOBS6RW1OI8S-DA_1776436207","From":"Petr Oros <poros@redhat.com>","To":"netdev@vger.kernel.org","Date":"Fri, 17 Apr 2026 16:29:44 +0200","Message-ID":"\n <dc7fb6f6bc737049a9ab8c42bd2f4b34b477907a.1776426683.git.poros@redhat.com>","In-Reply-To":"<cover.1776426683.git.poros@redhat.com>","References":"<cover.1776426683.git.poros@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.4.1 on 10.30.177.93","X-Mimecast-MFC-PROC-ID":"3KRT8FsTIiGIDr6mUpcYJEYH8u9w9U3VeDIcy1iMxek_1776436207","X-Mimecast-Originator":"redhat.com","Content-Transfer-Encoding":"8bit","content-type":"text/plain; charset=\"US-ASCII\"; x-default=true","X-Mailman-Original-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com;\n s=mimecast20190719; t=1776436215;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=So3UL4GLmFGEb2cMh3LixTfYDLK8oXuy3PKPaHp8JM4=;\n b=NSnnsffYFG+qI1rEd6gm3AJjbYt0MPYFw7XY5iQOGzTV2rSKkf2/I/8eTWarx3yvxrvUVz\n he45X2pnWmywpBvBLdAf97u9Go6jJ9w28DL6X6nkdSQj/v6JSWqU8e89EKjo5/UVeWfIMU\n JS9v4NbDjuiEU3l8faIGjrR4gFzJIZ4=","X-Mailman-Original-Authentication-Results":["smtp1.osuosl.org;\n dmarc=pass (p=quarantine dis=none)\n header.from=redhat.com","smtp1.osuosl.org;\n dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com\n header.a=rsa-sha256 header.s=mimecast20190719 header.b=NSnnsffY"],"Subject":"[Intel-wired-lan] [PATCH iwl-net v2 3/4] iavf: wait for PF\n confirmation before removing VLAN filters","X-BeenThere":"intel-wired-lan@osuosl.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Intel Wired Ethernet Linux Kernel Driver Development\n <intel-wired-lan.osuosl.org>","List-Unsubscribe":"<https://lists.osuosl.org/mailman/options/intel-wired-lan>,\n <mailto:intel-wired-lan-request@osuosl.org?subject=unsubscribe>","List-Archive":"<http://lists.osuosl.org/pipermail/intel-wired-lan/>","List-Post":"<mailto:intel-wired-lan@osuosl.org>","List-Help":"<mailto:intel-wired-lan-request@osuosl.org?subject=help>","List-Subscribe":"<https://lists.osuosl.org/mailman/listinfo/intel-wired-lan>,\n <mailto:intel-wired-lan-request@osuosl.org?subject=subscribe>","Cc":"Przemyslaw Patynowski <przemyslawx.patynowski@intel.com>,\n Aaron Brown <aaron.f.brown@intel.com>,\n Przemek Kitszel <przemyslaw.kitszel@intel.com>,\n Mitch Williams <mitch.a.williams@intel.com>,\n Eric Dumazet <edumazet@google.com>, \"David S. Miller\" <davem@davemloft.net>,\n Aleksandr Loktionov <aleksandr.loktionov@intel.com>,\n Andrew Lunn <andrew+netdev@lunn.ch>,\n Tony Nguyen <anthony.l.nguyen@intel.com>,\n Jesse Brandeburg <jesse.brandeburg@intel.com>, jacob.e.keller@intel.com,\n Jakub Kicinski <kuba@kernel.org>,\n Jedrzej Jagielski <jedrzej.jagielski@intel.com>,\n Paolo Abeni <pabeni@redhat.com>,\n Rafal Romanowski <rafal.romanowski@intel.com>,\n linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org","Errors-To":"intel-wired-lan-bounces@osuosl.org","Sender":"\"Intel-wired-lan\" <intel-wired-lan-bounces@osuosl.org>"},"content":"The VLAN filter DELETE path was asymmetric with the ADD path: ADD\nwaits for PF confirmation (ADD -> ADDING -> ACTIVE), but DELETE\nimmediately frees the filter struct after sending the DEL message\nwithout waiting for the PF response.\n\nThis is problematic because:\n - If the PF rejects the DEL, the filter remains in HW but the driver\n   has already freed the tracking structure, losing sync.\n - Race conditions between DEL pending and other operations\n   (add, reset) cannot be properly resolved if the filter struct\n   is already gone.\n\nAdd IAVF_VLAN_REMOVING state to make the DELETE path symmetric:\n\n  REMOVE -> REMOVING (send DEL) -> PF confirms -> kfree\n                                -> PF rejects  -> ACTIVE\n\nIn iavf_del_vlans(), transition filters from REMOVE to REMOVING\ninstead of immediately freeing them. The new DEL completion handler\nin iavf_virtchnl_completion() frees filters on success or reverts\nthem to ACTIVE on error.\n\nUpdate iavf_add_vlan() to handle the REMOVING state: if a DEL is\npending and the user re-adds the same VLAN, queue it for ADD so\nit gets re-programmed after the PF processes the DEL.\n\nThe !VLAN_FILTERING_ALLOWED early-exit path still frees filters\ndirectly since no PF message is sent in that case.\n\nAlso update iavf_del_vlan() to skip filters already in REMOVING\nstate: DEL has been sent to PF and the completion handler will\nfree the filter when PF confirms. Without this guard, the sequence\nDEL(pending) -> user-del -> second DEL could cause the PF to return\nan error for the second DEL (filter already gone), causing the\ncompletion handler to incorrectly revert a deleted filter back to\nACTIVE.\n\nFixes: 968996c070ef (\"iavf: Fix VLAN_V2 addition/rejection\")\nSigned-off-by: Petr Oros <poros@redhat.com>\nReviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>\nTested-by: Rafal Romanowski <rafal.romanowski@intel.com>\n---\n drivers/net/ethernet/intel/iavf/iavf.h        |  1 +\n drivers/net/ethernet/intel/iavf/iavf_main.c   | 13 ++++---\n .../net/ethernet/intel/iavf/iavf_virtchnl.c   | 37 +++++++++++++------\n 3 files changed, 34 insertions(+), 17 deletions(-)","diff":"diff --git a/drivers/net/ethernet/intel/iavf/iavf.h b/drivers/net/ethernet/intel/iavf/iavf.h\nindex 5765715914d6b2..050f8241ef5e6b 100644\n--- a/drivers/net/ethernet/intel/iavf/iavf.h\n+++ b/drivers/net/ethernet/intel/iavf/iavf.h\n@@ -161,6 +161,7 @@ enum iavf_vlan_state_t {\n \tIAVF_VLAN_ADDING,\t/* ADD sent to PF, waiting for response */\n \tIAVF_VLAN_ACTIVE,\t/* PF confirmed, filter is in HW */\n \tIAVF_VLAN_REMOVE,\t/* filter queued for DEL from PF */\n+\tIAVF_VLAN_REMOVING,\t/* DEL sent to PF, waiting for response */\n };\n \n struct iavf_vlan_filter {\ndiff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c\nindex 12e102506011a6..d373feee4c7e9c 100644\n--- a/drivers/net/ethernet/intel/iavf/iavf_main.c\n+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c\n@@ -757,10 +757,10 @@ iavf_vlan_filter *iavf_add_vlan(struct iavf_adapter *adapter,\n \t\tadapter->num_vlan_filters++;\n \t\tiavf_schedule_aq_request(adapter, IAVF_FLAG_AQ_ADD_VLAN_FILTER);\n \t} else if (f->state == IAVF_VLAN_REMOVE) {\n-\t\t/* Re-add the filter since we cannot tell whether the\n-\t\t * pending delete has already been processed by the PF.\n-\t\t * A duplicate add is harmless.\n-\t\t */\n+\t\t/* DEL not yet sent to PF, cancel it */\n+\t\tf->state = IAVF_VLAN_ACTIVE;\n+\t} else if (f->state == IAVF_VLAN_REMOVING) {\n+\t\t/* DEL already sent to PF, re-add after completion */\n \t\tf->state = IAVF_VLAN_ADD;\n \t\tiavf_schedule_aq_request(adapter,\n \t\t\t\t\t IAVF_FLAG_AQ_ADD_VLAN_FILTER);\n@@ -791,11 +791,14 @@ static void iavf_del_vlan(struct iavf_adapter *adapter, struct iavf_vlan vlan)\n \t\t\tlist_del(&f->list);\n \t\t\tkfree(f);\n \t\t\tadapter->num_vlan_filters--;\n-\t\t} else {\n+\t\t} else if (f->state != IAVF_VLAN_REMOVING) {\n \t\t\tf->state = IAVF_VLAN_REMOVE;\n \t\t\tiavf_schedule_aq_request(adapter,\n \t\t\t\t\t\t IAVF_FLAG_AQ_DEL_VLAN_FILTER);\n \t\t}\n+\t\t/* If REMOVING, DEL is already sent to PF; completion\n+\t\t * handler will free the filter when PF confirms.\n+\t\t */\n \t}\n \n \tspin_unlock_bh(&adapter->mac_vlan_list_lock);\ndiff --git a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c\nindex 4f197d908124e6..93ca79c3e3b535 100644\n--- a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c\n+++ b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c\n@@ -948,12 +948,10 @@ void iavf_del_vlans(struct iavf_adapter *adapter)\n \n \t\tvvfl->vsi_id = adapter->vsi_res->vsi_id;\n \t\tvvfl->num_elements = count;\n-\t\tlist_for_each_entry_safe(f, ftmp, &adapter->vlan_filter_list, list) {\n+\t\tlist_for_each_entry(f, &adapter->vlan_filter_list, list) {\n \t\t\tif (f->state == IAVF_VLAN_REMOVE) {\n \t\t\t\tvvfl->vlan_id[i] = f->vlan.vid;\n-\t\t\t\tlist_del(&f->list);\n-\t\t\t\tkfree(f);\n-\t\t\t\tadapter->num_vlan_filters--;\n+\t\t\t\tf->state = IAVF_VLAN_REMOVING;\n \t\t\t\ti++;\n \t\t\t\tif (i == count)\n \t\t\t\t\tbreak;\n@@ -990,7 +988,7 @@ void iavf_del_vlans(struct iavf_adapter *adapter)\n \n \t\tvvfl_v2->vport_id = adapter->vsi_res->vsi_id;\n \t\tvvfl_v2->num_elements = count;\n-\t\tlist_for_each_entry_safe(f, ftmp, &adapter->vlan_filter_list, list) {\n+\t\tlist_for_each_entry(f, &adapter->vlan_filter_list, list) {\n \t\t\tif (f->state == IAVF_VLAN_REMOVE) {\n \t\t\t\tstruct virtchnl_vlan_supported_caps *filtering_support =\n \t\t\t\t\t&adapter->vlan_v2_caps.filtering.filtering_support;\n@@ -1005,9 +1003,7 @@ void iavf_del_vlans(struct iavf_adapter *adapter)\n \t\t\t\tvlan->tci = f->vlan.vid;\n \t\t\t\tvlan->tpid = f->vlan.tpid;\n \n-\t\t\t\tlist_del(&f->list);\n-\t\t\t\tkfree(f);\n-\t\t\t\tadapter->num_vlan_filters--;\n+\t\t\t\tf->state = IAVF_VLAN_REMOVING;\n \t\t\t\ti++;\n \t\t\t\tif (i == count)\n \t\t\t\t\tbreak;\n@@ -2370,10 +2366,6 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,\n \t\t\tether_addr_copy(adapter->hw.mac.addr, netdev->dev_addr);\n \t\t\twake_up(&adapter->vc_waitqueue);\n \t\t\tbreak;\n-\t\tcase VIRTCHNL_OP_DEL_VLAN:\n-\t\t\tdev_err(&adapter->pdev->dev, \"Failed to delete VLAN filter, error %s\\n\",\n-\t\t\t\tiavf_stat_str(&adapter->hw, v_retval));\n-\t\t\tbreak;\n \t\tcase VIRTCHNL_OP_DEL_ETH_ADDR:\n \t\t\tdev_err(&adapter->pdev->dev, \"Failed to delete MAC filter, error %s\\n\",\n \t\t\t\tiavf_stat_str(&adapter->hw, v_retval));\n@@ -2895,6 +2887,27 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,\n \t\tspin_unlock_bh(&adapter->mac_vlan_list_lock);\n \t\t}\n \t\tbreak;\n+\tcase VIRTCHNL_OP_DEL_VLAN:\n+\tcase VIRTCHNL_OP_DEL_VLAN_V2: {\n+\t\tstruct iavf_vlan_filter *f, *ftmp;\n+\n+\t\tspin_lock_bh(&adapter->mac_vlan_list_lock);\n+\t\tlist_for_each_entry_safe(f, ftmp, &adapter->vlan_filter_list,\n+\t\t\t\t\t list) {\n+\t\t\tif (f->state == IAVF_VLAN_REMOVING) {\n+\t\t\t\tif (v_retval) {\n+\t\t\t\t\t/* PF rejected DEL, keep filter */\n+\t\t\t\t\tf->state = IAVF_VLAN_ACTIVE;\n+\t\t\t\t} else {\n+\t\t\t\t\tlist_del(&f->list);\n+\t\t\t\t\tkfree(f);\n+\t\t\t\t\tadapter->num_vlan_filters--;\n+\t\t\t\t}\n+\t\t\t}\n+\t\t}\n+\t\tspin_unlock_bh(&adapter->mac_vlan_list_lock);\n+\t\t}\n+\t\tbreak;\n \tcase VIRTCHNL_OP_ENABLE_VLAN_STRIPPING:\n \t\t/* PF enabled vlan strip on this VF.\n \t\t * Update netdev->features if needed to be in sync with ethtool.\n","prefixes":["iwl-net","v2","3/4"]}