🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25320

Re: [PATCH net-next v4 5/6] enic: manage V2 VF station and administrative MAC

#25320
From: netdev-bot+sashiko
Date: Tue, 01 Dec 2026 14:04
155 lines
13764 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] This patch changes the address-assignment type that userspace
  sees for a V2 VF with a provisioned (nonzero) MAC, and the commit…
- [Low] Several new on-stack MAC buffers are plain `u8[ETH_ALEN]` arrays
  with no `__aligned(2)`.
- [Low] This patch adds two driver paths that rewrite netdev->dev_addr in
  place on a registered netdev while holding only RTNL.

--

enic: manage V2 VF station and administrative MAC

This patch moves the V2 VF station address onto the mailbox MAC
operation and treats the PF administrative MAC as authoritative. PF
notifications are handled in a delayed worker, and policy is refreshed
with CMD_GET_MAC_ADDR after registration. The station address is
installed on open and removed on ordinary stop, and perm_addr is
initialized from the address chosen at probe.

> diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
> index 9c4b94a949809..a2186f65c74a8 100644
> --- a/drivers/net/ethernet/cisco/enic/enic_main.c
> +++ b/drivers/net/ethernet/cisco/enic/enic_main.c

[ ... ]

> @@ -1064,6 +1067,501 @@ static int enic_set_mac_addr(struct net_device *netdev, char *addr)

[ ... ]

> +static void enic_vf_admin_mac_work(struct work_struct *work)
> +{
> +	struct enic *enic = container_of(to_delayed_work(work), struct enic,
> +					 vf_admin_mac_work);
> +	u8 policy[ETH_ALEN];
> +	u8 selected[ETH_ALEN];

[Severity: Low]
Should policy[] and selected[] be marked __aligned(2)?

They are passed to ether_addr_copy(), ether_addr_equal() and
eth_hw_addr_set(). include/linux/etherdevice.h documents
ether_addr_copy() with:

 * Please note: dst & src must both be aligned to u16.

Without CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS, both ether_addr_copy()
and ether_addr_equal() access the address through u16 pointer casts. A
plain u8[ETH_ALEN] stack array is only guaranteed byte alignment. ENIC
depends only on PCI, so it can be built for strict-alignment
architectures, where this can trap or need slow fixups.

The same applies to previous_policy[], random_addr[], selected[] and
policy[] in enic_vf_admin_mac_refresh().

This patch already adds __aligned(2) to requested[] in
enic_vf_station_addr_open() and to enic->vf_station_addr. These other
arrays still lack the annotation at the end of the series.

> +	unsigned long delay = 0;
> +	u32 generation = 0;

[ ... ]

> +	changed = !ether_addr_equal(enic->netdev->dev_addr, selected);
> +	enic_vf_station_sync_reset(enic);
> +	eth_hw_addr_set(enic->netdev, selected);

[Severity: Low]
Can a concurrent reader see a torn MAC address here?

This worker runs asynchronously after ENIC_MBOX_PF_SET_ADMIN_MAC_NOTIF.
It rewrites dev_addr in place on a registered netdev while holding only
RTNL:

enic_mbox_vf_handle_admin_mac()
  enic_vf_admin_mac_notify()
    enic_vf_admin_mac_work()
      eth_hw_addr_set()
        __dev_addr_set()   /* memcpy into dev->dev_addr */

The core readers don't take RTNL. netif_get_mac_address()
(SIOCGIFHWADDR) and address_show() (/sys/class/net/*/address) take only
down_read(&dev_addr_sem) and rcu_read_lock(). The core writers
dev_set_mac_address_user() and do_setlink() take
down_write(&dev_addr_sem) for exactly this reason.

Those two lock sets don't overlap. A reader that runs during a PF-driven
change could therefore return a mix of old and new address bytes.

enic_vf_admin_mac_refresh() does the same thing when called from
__enic_open() and enic_admin_chan_reopen(). dev_addr_sem is declared
only in the private net/core/dev.h, so the driver can't simply take it.

[ ... ]

> +static int enic_vf_admin_mac_refresh(struct enic *enic)
> +{

[ ... ]

> +		changed = !ether_addr_equal(enic->netdev->dev_addr, selected);
> +		eth_hw_addr_set(enic->netdev, selected);
> +		if (!zero_policy || changed)
> +			enic->netdev->addr_assign_type = zero_policy ?
> +				NET_ADDR_RANDOM : NET_ADDR_SET;

[Severity: Low]
Is this change to addr_assign_type intended for a provisioned VF MAC?

enic_probe() now calls enic_vf_admin_mac_refresh() before
register_netdev(). For any nonzero CMD_GET_MAC_ADDR value, this sets
NET_ADDR_SET. Probe then copies dev_addr into perm_addr by hand:

enic_probe() {
    ...
	/* Record the initial address while preserving how it was assigned. */
	ether_addr_copy(netdev->perm_addr, netdev->dev_addr);
    ...
}

Before this patch, enic_get_vnic_config() read the same firmware MAC and
installed it with eth_hw_addr_set(). addr_assign_type stayed at
NET_ADDR_PERM, and register_netdevice() filled perm_addr.

/sys/class/net/<if>/addr_assign_type now changes from 0 to 3 for an
address that nothing set through dev_set_mac_address(). The UAPI
describes NET_ADDR_SET as "address is set using dev_set_mac_address()".

Userspace that trusts only NET_ADDR_PERM addresses behaves differently.
For example, systemd's net_id builtin stops producing ID_NET_NAME_MAC.

With a zero policy, perm_addr is a newly generated random address on
every probe. ETHTOOL_GPERMADDR then reports a different permanent
address each time the driver loads.

The commit message does disclose the random case:

    Initialize perm_addr from the selected probe address while retaining its
    assignment type, including NET_ADDR_RANDOM for a generated address.

It doesn't mention that a provisioned address changes from PERM to SET.
Could the commit message describe that change, or should the
provisioned case keep NET_ADDR_PERM?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130-b4-enic-sriov-v2-vf-receive-control-v4-0-5858d5a9ecb1%40cisco.com
Technical Details
Message-ID: <179613389400.3146.4727108812986852753@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375142-linux-kernel-netdev=dewy.ru
References: <20261130-b4-enic-sriov-v2-vf-receive-control-v4-5-5858d5a9ecb1@cisco.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375142-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v4 5/6] enic: manage V2 VF station and administrative MAC
Date: Tue, 01 Dec 2026 14:04:54 +0000
Organization: Usenet Network
Message-ID: <179613389400.3146.4727108812986852753@kernel.org>
References: <20261130-b4-enic-sriov-v2-vf-receive-control-v4-5-5858d5a9ecb1@cisco.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1729833"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:MMMfoztXl6VpQfgoN3EReOM64kI= sha256:CWVYzFyafBISjcuum+2xl/q3WhVjJam4a2dsHXwLM70=
	sha1:sdi+jlVodotvZwGUTU4mZZqzuTc= sha256:/YvWve10LGb0mkEqxpDqkj6MDBnJrnYQ1v2xOuCrCqw=
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 EC4861173D6; Tue,  1 Dec 2026 17:05:27 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
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 gVpytF_S4i3P;
	Tue,  1 Dec 2026 17:05:24 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-375142-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id ED25C1173D4; Tue,  1 Dec 2026 17:05:10 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id C34FB248CF; Tue,  1 Dec 2026 14:05:04 +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=1796133902;
	b=kC1GFm1BMzWkEMAxA10Q5anIz5xkgsVuKB5OxvVc4IBOHEKWsFFzZwMhH24QSlIrtARH
	 5jaEbUwB64gBnSpJbAfOBmLZhbD4DTm0Dpi0bOYQAQ3nlsFSQjYujGOruvZI51CeNgJPs
	 55Xu5b4p5h5cb/OJP8pJjhnvRkWlvxepvisIk/hsY77lFxck45C2hImVojCdKCm/QdqhR
	 aFrysYEEBd9mIT17GkMp463e7ZCSkVjVJYEPrtN2Zj0CfQo1+zN83AstZZ70j+ynjzWxl
	 My+deXDFqHzGLJ9FlvOSNyBs767jCLDbvahnkwExZKxO5W1EMoQL81K7ZrS4pLUk13w==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796133902;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=VPOw44n8c5RKXLhDY3jjfW0NYv6KrfLOtDPw0pRuT3M=;
	b=Ww/TR3/feUXNjU/B81S3UpRPzejfLauKEK3AwK3UQQSiHf9EomkS2ja1DZXTkt2p850/
	 3z/ID+MJaGTXTEVfcEubHtAZE+18c31h6JBIQt3E+rSJIhEGrdUVdRi5e/5cF3DU3FiVm
	 UkYVOed5k+IVwcN5uIJirDOBkHmZAUZtNx2un/+LW8S62BO/X8NVjKpG1BJe/ZCeCluiM
	 R6I+VJ2m6hhBS/p4NCa1QWhGQtI1W4dtnJmB65Qv2259X1VyFN6JuKrMgnjX3Ch9U0bfd
	 +MBRFVUcZIZdHnDXFy0MTvdO6eYj4RlaPzA21Yq6wewlF7cLXrh8IVrXOS+pHLFkzRQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XW8fHMSN;
	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 53B50606A339;
	Tue,  1 Dec 2026 14:05:02 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XW8fHMSN
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796133896;
	b=AcN6zrK91BKZPY5ljoXOrxtUBX5NyxED0SkribF9XboQOvPetgkQe90KmSrU+zvbKj+z
	 6176Vzu1Oxh2HB550FtiZPInCq61pApVJbJipc5FxxmC0gegkCbBRHmeqLS5vgOePI+DN
	 DmQbxnO2Dbe972gequmj5Nd5+QhP5enMC8SDbbJjIADoYw3NOxFeth0AF+NDH5i+6ow3V
	 5z7N9rSYLwnelW99bm8qILIV9UwvKWEQCJWls4S3bfbFelLsjxJvl7KJUuPLjyLPAs+3z
	 gS2tcC5HKmeNr0LUmXh8V1tGzOPE4CmmQ8Zlk0kTDqTCRQSwOtmaF3wqfhCt7SGN+sw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796133896;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=VPOw44n8c5RKXLhDY3jjfW0NYv6KrfLOtDPw0pRuT3M=;
	b=gU0EXKecRbNdklVDFGnt/3edZYZb/9VqwQlccJ1NuU1K7EAjLBm5PppSTZsX+5aVct9Y
	 rXLyfVn+iH0kdTAID4RqdUt0E1LLIsr1VpJM/Cv2cO3Gv0bovtHK2mx8+8bGgxvPoJdbz
	 20sVD4DV5Jpym2U+IRcgjg6YD6s3U6PJJSyXNxmt5VL58Zds0revn5fnBLXsWo4IaNVS3
	 8Tygi0A1aDGW3xvjWLDhO44Ovhw+XhoAWYvxtzDhANF9sL3PsbsYWdb1p8H8PS7ZARAWp
	 zYkoeyWLlP1Jc9FLYUvhQtJvwme6Gwq//uXlvKq0CFTBfwdcWKjjomdEus+dqYmqf8g==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XW8fHMSN;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03600606A335;
	Tue,  1 Dec 2026 14:04:55 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 727351F000C1;
	Tue,  1 Dec 2026 14:04:54 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796133895;
	bh=VPOw44n8c5RKXLhDY3jjfW0NYv6KrfLOtDPw0pRuT3M=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=XW8fHMSNLIKI4fXjtDFGyuVHwO4WzOgxxImKqaoAZ6GFmQv1DP+ftcDZPpXuRLeVe
	 qPLpxCbv0O7mw7I6mSR0IJwOIUmaPyOclfamuNcIu5jUq6djHvTgORSbyouT3jFn26
	 3lSDyD1g1vvaFSGgic9H4ENZ6Cg5tcFRuqZ7Des2bWFDBMQ+ggE3zaTup0GXYgEF/3
	 a4n8dKpVoZmhib4GkfO5JeJIJYJAqSZp3vK+niWeTb5iYRJxkbmntz+F5dOY1TEW/V
	 GVmqQGsiVI0uLWMmSe24eyF8M1izCNY451iVimw9iGY2Zf1CwdiZ25JBb8gh4azTAT
	 P9mSKydUujk5g==
X-Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
 kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, willemb@google.com,
 netdev@vger.kernel.org, linux-kernel@vger.kernel.org, sebaddel@cisco.com,
 aradhana@cisco.com, rfaucett@cisco.com
X-In-Reply-To: <20261130-b4-enic-sriov-v2-vf-receive-control-v4-5-5858d5a9ecb1@cisco.com>
X-sashiko-severity: Low
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