๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #18442

Re: [PATCH net-next 3/4] eth: mpnic: sync unicast and multicast address lists

#18442
From: "Daniel Zahka"
Date: Wed, 18 Nov 2026 10:21
121 lines
15637 bytes
On Wed Nov 18, 2026 at 4:12 AM EST, netdev-bot+sashiko wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue(s) to consider.
>
> Critical: 0 ยท High: 0 ยท Medium: 1 ยท Low: 0
>
> If you believe none of the issues are legitimate, please reply to each
> issue of Medium severity or higher and explain why the AI is wrong.
> If any of them are legitimate and you plan to respin, please let patchwork
> know by including "pw-bot: cr" as a separate line at the end of your reply
> (one such reply per series is enough).
>
> - [Medium] The unicast and multicast lists are synced in the wrong order
>   in __mpnic_set_rx_mode()โ€ฆ
>
> --
>
> eth: mpnic: sync unicast and multicast address lists
>
> This commit adds the secondary unicast and multicast addresses to the
> MACDA TCAM and advertises IFF_UNICAST_FLT. When either list outgrows the
> table, the driver falls back to promiscuous or all-multicast mode. A
> per-slot users count is kept so the same address can sit in both dev->uc
> and dev->mc.
>
>> diff --git a/drivers/net/ethernet/meta/mpnic/mpnic_netdev.c b/drivers/net/ethernet/meta/mpnic/mpnic_netdev.c
>> index 43547a7d6e5c7..c01e276c4a74d 100644
>> --- a/drivers/net/ethernet/meta/mpnic/mpnic_netdev.c
>> +++ b/drivers/net/ethernet/meta/mpnic/mpnic_netdev.c
>
> [ ... ]
>
>> @@ -35,7 +53,14 @@ static void __mpnic_set_rx_mode(struct mpnic_dev *mpd,
>>  		mac_addr->state = MPNIC_TCAM_S_ADD;
>>  	}
>>  
>> -	if (!netdev_hw_addr_list_empty(mc))
>> +	err = __hw_addr_sync_dev(uc, netdev, mpnic_addr_sync,
>> +				 mpnic_addr_unsync);
>> +	if (err == -ENOSPC)
>> +		uc_promisc = true;
>> +
>> +	err = __hw_addr_sync_dev(mc, netdev, mpnic_addr_sync,
>> +				 mpnic_addr_unsync);
>> +	if (err == -ENOSPC)
>>  		mc_promisc = true;
>
> [Severity: Medium]
> Can the device get stuck in unicast promiscuous mode here, even though a
> TCAM slot is free?
>
> The uc and mc lists share the same MACDA slots (between
> MPNIC_TCAM_MACDA_BROADCAST_IDX and MPNIC_TCAM_MACDA_HOST_ADDR_IDX). The
> whole uc pass, both its flush and its add phase, runs before the mc pass
> flushes stale multicast entries.
>
> Consider this sequence:
>
> 1. The table is full of multicast entries and a secondary unicast
>    address U is added. mpnic_macda_sync() returns -ENOSPC, U stays at
>    sync_cnt == 0, and mpnic_promisc_sync() enables unicast promisc.
>
> 2. A multicast address M is then removed. The core runs
>    netif_rx_mode_run()->mpnic_set_rx_mode()->__mpnic_set_rx_mode().
>
> 3. The uc pass retries U. M's slot is still MPNIC_TCAM_S_VALID, so
>    mpnic_macda_free() rejects it, mpnic_macda_sync() returns -ENOSPC
>    again, and uc_promisc is set.
>
> 4. The mc flush runs only after that. It calls mpnic_macda_unsync() on M:
>
> 	if (!--mac_addr->users)
> 		mac_addr->state = MPNIC_TCAM_S_DELETE;
>
>    mpnic_write_macda() then frees the slot.
>
> The reverse case works. A unicast removal can make room for a pending
> multicast address, because the uc flush runs before the mc add.
>
> Would it make sense to flush stale entries from both lists before either
> add phase runs?
>

I see this more as a low severity issue, because having the device be in
promiscuous mode when a slot is free is not incorrect, just not optimal.

If anything I would probably just rerun __hw_addr_sync_dev() on the uc
list again after the mc one, if the first call returned -ENOSPC. I
didn't think that was really worth it when this same comment came up in
local review though.

> [ ... ]
>
>> @@ -53,7 +78,7 @@ static int mpnic_set_rx_mode(struct net_device *netdev,
>>  	struct mpnic_net *mpn = netdev_priv(netdev);
>>  
>>  	if (netif_running(netdev))
>> -		__mpnic_set_rx_mode(mpn->mpd, mc);
>> +		__mpnic_set_rx_mode(mpn->mpd, uc, mc);
>>  
>>  	return 0;
>>  }
>
> Because mpnic_set_rx_mode() always returns 0, netif_rx_mode_run() never
> calls netif_rx_mode_schedule_retry() for the case above.
>
> mpnic_service_task() doesn't re-run the rx mode sync either. So U stays
> unsynced and the promisc entry (zero mask) stays installed until some
> unrelated rx-mode event happens. The commit message says:
>
>   Advertise IFF_UNICAST_FLT so we don't need to use promiscuous mode to
>   handle extra unicast addresses.
>
> The later patch in the series, "eth: mpnic: support changing the MAC
> address", keeps the same uc-then-mc ordering.
Technical Details
Message-ID: <DMY9FTQ22U8T.JKYB4HL8J8PH@gmail.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366033-linux-kernel-netdev=dewy.ru
References: <20261116-mpnic-l2-oot-v1-3-8dc6eb3582b0@gmail.com> <179499313262.3136.12811016164943625265@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-366033-linux-kernel-netdev=dewy.ru
From: daniel.zahka@gmail.com ("Daniel Zahka")
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next 3/4] eth: mpnic: sync unicast and multicast
 address lists
Date: Wed, 18 Nov 2026 05:21:44 -0500
Organization: Usenet Network
Message-ID: <DMY9FTQ22U8T.JKYB4HL8J8PH@gmail.com>
References: <20261116-mpnic-l2-oot-v1-3-8dc6eb3582b0@gmail.com>
 <179499313262.3136.12811016164943625265@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
	logging-data="2567128"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:J+PcvQkIeVd8tySAj9P03s0pGtE= sha256:jhb9cGIcV18N8OwvG4pCdMBzb2EdPpqTb6l11TQaFxI=
	sha1:J9bxbHstBsFm0sRWAN3delLrCSA= sha256:IAoafLtBHtNHR9WBiEZj9tewf9HgwALY6LFKaiW8QEw=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 5F0D211521C; Wed, 18 Nov 2026 13:22:02 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id w3Mddtp1kRKm;
	Wed, 18 Nov 2026 13:21:58 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-366033-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 28D7F115235; Wed, 18 Nov 2026 13:21:50 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id B58E1363CF; Wed, 18 Nov 2026 10:21:48 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794997308;
	b=SDeTK/OKuBZ37+LVLROU1HxZgvQbgJcH0EsNYPSgyZaIYticSYL2ZDf3ovYmesEVAyfF
	 fBUme0iwlYBKhA4kibRbnXuB6cY7p9+Bo+V6lTJR48rCkOvjc3khpwQfdlotdht1UNcNb
	 Djxl6nxPou1D/qBuofqOXsh6iPrYiuKoMoBbcoSP1zfRbm9GF2NcYFdlSGAVK/50Bu1JR
	 W6R7LAfyDBo9CCvZNbu9UHPJNM1Hqyr0/hGU76gQORoor6mc8fxVLH0GxXuQhjbrx8ZsS
	 Qz5cJ2QBI+6K/WQZt3JAJrqh0APVLxRLE6EkkjzJmrbu+PPD94SSXHKj6jsBrrMzFsQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794997308;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
	 X-Gm-Gg:X-Received:Received:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 Mime-Version:Content-Transfer-Encoding:Content-Type:Date:Message-Id:
	 Cc:Subject:From:To:X-Mailer:References:In-Reply-To;
	bh=s3IJ5oLj14lpgQEhMKNadywDImk2GjSKGL/HdUAQRNM=;
	b=E7ZghTSD5AgN1i/BPWHQ/QgOC89FvVHmmWoQu1a/ksqrGGCVCmhMsPvj+F7ypV8Ejkvp
	 hYtW9B/2mXuE3aefiJ7ucDzBhsQwr/OYliz2H+NZqbcuzAQ6ipkL/70+y1ERtJm52LMXi
	 b5YgU8itXnEa0wUK0+ziigXKXMGC3MgkQ4Flu6TfFer4NzwUT4YwSVApgR7xVpSWY+PIt
	 VIO9tb/DHCbLuqkQoANeWiM2Etdgg4orLMiz4JglaTBaOFhcoYtafMDYrXAtTQlr62w2o
	 jg1vlaKdUJ+CIeb5MZp1YpOXqFl2h4SMI9hOi0lwiiRY6eW8ZDn0WHZuv7jz8GJKrjQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=BU4bYpyz;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 8569F606A333;
	Wed, 18 Nov 2026 10:21:48 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=BU4bYpyz
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.219.53
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794997307;
	b=fcszzHexM9qQSaGxUfLtp6YoNYg83X5Fx3lIjWiI5pk3LTP0+o1jMRViML8s9c/yMSIT
	 WvzSYPPF56HDtpJuOJDYNLw9IsB4Tff8M5RSrwblf2CWTETYHlUXuZF/tR1DVgr2o3rcY
	 5IiorE5LS1TJae+65PFTtH+t19gJn/YQ9cm+rgqUEIEsXtYd6SWZMvxYrZPj1NY5tcIpd
	 3GBvZQZF0YKVdTLB5mdHcAjL9WuGJm4RqAz2eaNSmWLv4kjafbC5VqMUlMMrCPVZQJaFd
	 Dsx1+b3vnlaoxXuZNgTWd1MiAupu6Vrn5bXRzYWGpw5Pj07tPhhWq390F3EQQmL8qLg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794997307;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
	 Mime-Version:Content-Transfer-Encoding:Content-Type:Date:Message-Id:
	 Cc:Subject:From:To:X-Mailer:References:In-Reply-To;
	bh=s3IJ5oLj14lpgQEhMKNadywDImk2GjSKGL/HdUAQRNM=;
	b=xCK3WzkCY5Tpv/rD1lymTyeiM/292bY3WLPcCbFqGNwsLmS9QDp1NmS71zk2QU4bjLlN
	 qDAFjAZZ4nYcC26y93Lh86SFM8JXuguoDGvx3PI9UhPS9QSjM69Cu//Hkn7iGhDgiQetp
	 4F1MT7YeqFNP6pylZmE5tp3Hmek1WxIAZpqDd2XmE9tv68+VlW8lSNjLtuS3R7rS8W/zb
	 /wK6njAZVlSWL8HsBluxFikYpYBnxjOL4N4kK5o31gQ8jXua79KCzXoZJACzOW6q5aScz
	 rR8lxTHQQS+EVN5HTOSq46Iwrvdx/lSe+MZ0PZEZ9U3oGfo7VuZ0zHUr/N9bK8+yvYA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=BU4bYpyz;
	arc=none smtp.remote-ip=209.85.219.53
X-Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57C83606A320
	for <netdev@vger.kernel.org>; Wed, 18 Nov 2026 10:21:47 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 57C83606A320
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-920fed989b2so6410186d6.2
        for <netdev@vger.kernel.org>; Wed, 18 Nov 2026 02:21:47 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1794997306; x=1795602106; darn=vger.kernel.org;
        h=in-reply-to:references:to:from:subject:cc:message-id:date
         :content-type:content-transfer-encoding:mime-version:from:to:cc
         :subject:date:message-id:reply-to:content-type;
        bh=s3IJ5oLj14lpgQEhMKNadywDImk2GjSKGL/HdUAQRNM=;
        b=BU4bYpyzpln6vZPMuIQM2DiZhzvlWv3UrOF8HiTMlCx9epoczmdAlqona7iT71/xPK
         xQZcHXmpkmOGqbS+IqrsIi4I/vCGTDwE0ogByZ1KhpwjzRyOSxcTbzBa7WpJzxFiS1Zd
         Il/HokkCS/e1n6/KvDdLx+eUywc8IYUJT/iKUz3QRnQVbBnlAGC76FdapV+y4hAFp/8T
         eELeXTSkXEO+Tx/nBx+i3Zxul1hACemoZj94gmtP2cItO4JSwtx7iDyzOZ8wdYwiG1CT
         t2aOGZ6hRwvNzznHQKCQBZsQYFh2d5I2WmSu/yHKMC1vSut5dj3bAkKFWBc2FKvh9icf
         E80Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1794997306; x=1795602106;
        h=in-reply-to:references:to:from:subject:cc:message-id:date
         :content-type:content-transfer-encoding:mime-version:x-gm-gg
         :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
         :content-type;
        bh=s3IJ5oLj14lpgQEhMKNadywDImk2GjSKGL/HdUAQRNM=;
        b=ptblOPcabBf1cCCcEzmC/CNWYYOzFE5Si8neQ2EfxMbqRm+QeesyyGPZbxK1U4312K
         CX2KOYlaNz1GxZ1soXnftKx6dfxCM1iXfAcjy5rTOMBuH5GtxfzOQqeXkO/US6f5lkE2
         1JG3KpisTgwtKOn+NeAKO403uarxxh/6zKocLcQ0BYd4WXlbTiOByZfoNPs7605QK5Jj
         /uARTN1dSIG5OoAM7jIudjZQ9tQD0MtoogmNGu4Q3dMyahmrkhoEBCYPg3dMkfHuze0u
         piNV9yUpczrZQyh6x6E4z8rm+niY2vknZ5JtEeHJo8/U3ivg04E1uDB7fHspLLPIeAqy
         B3uw==
X-Forwarded-Encrypted: i=1; AL+hErHD6UXSaeGf0IrYGDub+SeWGJmi/eTfxBsh5haqB1bW4t3qWCZ6B97mdDQSE9v1H8aI6wyOql0=@vger.kernel.org
X-Gm-Message-State: APuU4Z/ObGHuGubl5bUBUOZVSf7dX08+5yAAtpf4mhPc3K4Yb/97bwCS
	W5uzbJvMHP5UreSt+p+loorLx2DtsKuvu6RPomyP2NLdP0R63eaIy3Vq
X-Gm-Gg: AZFdTZfW/RtpQdSBSPA0yUjF21GDm11e1o3VIyve9SMFn7oPMz5BLTbSygQMRtVJqic
	/cRsOfvy435Wr5uJmkSgVAQir/5b83LytW1+LYaBwN9hlbR9Of7SfJdDPWg/DaG9MJU0usj2Jfy
	ruTFl7O+EeMFI8giSrveDKuaLqQJBQRqYtyAhxjyRv19aioWtpD3ysA2U5gr/fyCR9RaHfP3wPx
	mS5WdoqxZqiGGCUqmCYbfAFCdj0S8U9mOSVWqwA+gldHv/nD5DumosGsaXJJWtRKWnt9jBDSofj
	EjdpFhvy+S842km0YqgVert+WA3QHdJiM+3o8NP8wjPhV16KhO/ol54q5IafrmTyxdn+dW2Xheu
	die5dM5qebwo2Rh8a/l9hXTqOc3CyixQzddQ0jPvGGJnRGR17eEXRZOQIiZXx1LblXjtghv3JEK
	r9L6j69qwRHAoIJXK3ySQK4QJNxTEqUryAR02F6iSns/iqIWhsacYkqeH7g5dCfBrMG9RekzISP
	F7D3hTCyj2q7cDroYsUTCsGNJ84SGX8JMpQVMjKhq2uC2RjBZIm9tBSPYLgonftvzCYjCh1SFaa
	sE3NAS0qrtZG8cEXqoKyf0s9Mn9fAG/+0Q==
X-Received: by 2002:a05:6214:3f88:b0:91e:9811:7a2e with SMTP id 6a1803df08f44-92114f415c1mr27630356d6.13.1794997306087;
        Wed, 18 Nov 2026 02:21:46 -0800 (PST)
X-Received: from localhost ([2600:4040:9399:4000:e553:72e5:7d37:c7ef])
        by smtp.gmail.com with ESMTPSA id 6a1803df08f44-92114d70c5csm17918346d6.31.2026.11.18.02.21.44
        (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
        Wed, 18 Nov 2026 02:21:45 -0800 (PST)
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-Cc: <alexanderduyck@fb.com>, <kuba@kernel.org>, <kernel-team@meta.com>,
 <andrew+netdev@lunn.ch>, <davem@davemloft.net>, <edumazet@kernel.org>,
 <pabeni@redhat.com>, <dimitri.daskalakis1@gmail.com>,
 <mohsin.bashr@gmail.com>, <linux-kernel@vger.kernel.org>,
 <netdev@vger.kernel.org>
X-Mailer: aerc 0.21.0-threadmapfix
X-In-Reply-To: <179499313262.3136.12811016164943625265@kernel.org>