Article View: linux.kernel.netdev
Article #14870Re: [PATCH net] ipvlan: update port flags only after ipvlan_set_port_mode() succeeds
From: Wenbo Sun
Date: Thu, 12 Nov 2026 03:51
Date: Thu, 12 Nov 2026 03:51
44 lines
10851 bytes
10851 bytes
Hi Hangbin,
On Wed, Nov 11, 2026 at 09:02:17PM +0800, Hangbin Liu wrote:
> If ipvlan_set_port_mode() failed, the unregister_netdevice(dev) will be
> called. Does port->flags still need to restore?
Thank you very much for taking the time to review this patch and for
pointing out the question about the commit description.
You are completely right that when creating the first ipvlan device on a
lower device, unregister_netdevice(dev) drops the last reference to the
port in ipvlan_uninit() -> ipvlan_port_put(), destroying the port so no
flag restoration is needed.
The issue happens when one or more ipvlan interfaces already exist on the
same lower device:
1. Because struct ipvl_port is shared across all ipvlan interfaces on a
lower device, ipvlan_init() takes an additional reference via
refcount_inc(&port->count) when creating a new ipvlan interface.
2. If ipvlan_link_new() writes port->flags before calling
ipvlan_set_port_mode(), and ipvlan_set_port_mode() fails (for
instance, requesting L3S mode when CONFIG_IPVLAN_L3S is disabled),
unregister_netdevice(dev) only decrements port->count back down to at
least 1. Since ipvlan_port_destroy() is not called, the shared port
remains active for the existing ipvlan interfaces while still carrying
the newly written port->flags.
Rather than saving and restoring port->flags on the error path, moving
the port->flags assignment after ipvlan_set_port_mode() succeeds avoids
modifying it on failure altogether, as there are no remaining failure
paths afterward in ipvlan_link_new() (matching ipvlan_nl_changelink()).
I see that the v1 commit message phrased this awkwardly ("never restored")
and did not clearly distinguish the shared-port case with existing
interfaces. If you agree with this explanation and approach, I will be
happy to send a v2 with a clearer and more precise commit message once the
24-hour resend window passes.
Thanks again for the review!
Best regards,
Wenbo
Technical Details
Message-ID:
<20261112035152.43363-1-sunwenbo@cmss.chinamobile.com>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361485-linux-kernel-netdev=dewy.ruReferences:
<20261111064655.233265-1-sunwenbo@cmss.chinamobile.com> <avRnWUbGFbdfirZB@fedora>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361485-linux-kernel-netdev=dewy.ru From: sunwenbo@cmss.chinamobile.com (Wenbo Sun) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] ipvlan: update port flags only after ipvlan_set_port_mode() succeeds Date: Thu, 12 Nov 2026 11:51:52 +0800 Organization: Usenet Network Message-ID: <20261112035152.43363-1-sunwenbo@cmss.chinamobile.com> References: <20261111064655.233265-1-sunwenbo@cmss.chinamobile.com> <avRnWUbGFbdfirZB@fedora> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1003050"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:ewSfXFDYfwXDcx7GymuS2+9klLA= sha256:IbcLl/RmwWyoEFtdmBsJaIZNbnXM1pn5Pwxp01aTSaI= sha1:Ml0ip1wlqVxfLL3XPHIKn706MTE= sha256:lbKi1mgvg2QwTNibB2BejBLpNuNvlCG4wvXV/W0IeLE= 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 4769B1140EB; Thu, 12 Nov 2026 06:52:52 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.851 X-Spam-Status: No, score=-2.851 tagged_above=-9999 required=6.31 tests=[DKIM_INVALID=0.1, DKIM_SIGNED=0.1, 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=fail (1024-bit key) reason="fail (body has been altered)" header.d=cmss.chinamobile.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 zRdEqYdL6byx; Thu, 12 Nov 2026 06:52:48 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-361485-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=cmss.chinamobile.com X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 628EF1140CB; Thu, 12 Nov 2026 06:52:40 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id EE559621830; Thu, 12 Nov 2026 03:52:25 +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=1794455540; b=4aTfPxyRcbw+RnbFG0Rhzop9VHsO9GTX62AZHRaWyKMSAZ6W4TE3RbjjAnUSGb6dNfM4 5UDeQlsW+Ncc6SInz3JrS2VGHsR6Br/vnDqr/pBmoDwnOoVIOJoIc51xA3G3QFbItA4Ph xdg2AoBuebDdp7wumTA4qn/sT7H4s19pRf5pWRorjlpR46waEPFtIHCXE4QLXmQIVtzUX ZFQhcH8C3tH1o5VsS7jcTr8L5cXjgmQdRh8UhUmi8fMNEV24cv3kpNENgrVVtF1opxkD7 +WEM9QU9wwZ9RNn51lLd9B6mG8ZoW0VAKMimP56BkZJ9RUsizHUP3Canjn65ycNFGjA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794455540; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:X-RM-TagInfo: X-RM-SPAM-FLAG:Received:X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG: Received:X-RM-TRANSID:From:To:Cc:Subject:Date:Message-Id:X-Mailer: In-Reply-To:References:X-Mailing-List:List-Id:List-Post:List-Help: List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Type:Content-Transfer-Encoding; bh=oJjEKVEAKHGwMXnMBrqjNVfsEmgIQU1/u5wEHFXaSQI=; b=JK2TZdHoTmRhh9fNH2wxRGHO+ogxPXcfNSFXFUD17Q0N73YNm943+VoOur1Y2zQmQb7t mNrvfNZotbD3f9nH+Pb8quEONE//PTqBw2dfoqwY0xncJw5rPRV2ZmxwUNGnp5Ym2zIi8 p4yP9QS23OHNUKeJbugkrIkDhSZiXwg2a1nPq/FfgJ6LRHc51iLckZEH+9Ir13lzytG8Q VgtiLPwkJKfQpqMElvVt+zlX+q8P14/ZdW/ApzC3ntqiAHmNPzC9AcKRzjhhvfJrQLNu5 dA1vRDLQpztEp0n38dMMlyNhZ5sD+Qj99n6vybNJlpb4v/xuE9N2vfpW5opVno0v60A== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b="bQLh/WyJ"; dmarc=pass header.from=cmss.chinamobile.com; spf=pass smtp.mailfrom=cmss.chinamobile.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 AE316606A32A; Thu, 12 Nov 2026 03:52:20 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=bQLh/WyJ X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=111.22.67.151 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794455534; b=5WQAuAUVN43+KK8TjwdDhydqWAAt9RnZBaUXSdSI+eR5Ffo75oTOlGEaqOBdKmjpygu0 qtlTk0kX/+wofyeY/+/gOME47HHymjuXhdLYfmJ0j411O6tTpztz7fqqWNcWwxihKUBhD z9V1SVjKQEJpFuEifQ+K91eD0paEw6J/JdkdRcr05H2PkSFA5XI0Lt4WYaWMvcR+b1UAe siUQ0m82DwjufJtUzEkop+J/F1PcmEaGrnwzvW0zR1FNOLG9YmTynHWzc/8zFCvYg7s+e SL4WGelZtcycQH3HweeqlAzCL25uP+5/CNK36q8y1EJuc9Q0Negl7Gh+MytIr9BajRQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794455534; h=DMARC-Filter:DKIM-Signature:X-RM-TagInfo:X-RM-SPAM-FLAG:Received: X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG:Received:X-RM-TRANSID:From: To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=oJjEKVEAKHGwMXnMBrqjNVfsEmgIQU1/u5wEHFXaSQI=; b=gtQxA4LLbBQXJXOJEeJF/ah5I7UiGUBCF7d/Zwj5nb2/pt62o0Q24kmE2iiVlQpinofQ MSOIpxInrIhkcv2wdcjQrdVcNt1D4BRSawArcqHyEtb3UghoSJtG6j+lAKjsZUhpsiKA+ EuEPNbB/J2c+7m8SroSwJ+foLD22WrkWD+FjEn1elhDRToOu84+hvAmVoJbneJD/ga6V/ JfKXKa/l4/7gC77/ps5xxRLmyvlEJJvar1HL9NNKKyZO1hLBfeAp8B+NIHAEjyUPgqQFO x6v68R8AGbaszg+nY2VLx+I2Ol8KVZ+IQgkAxJroixtWwbcSwiL6sYkTJUvP+8Pfd3Q== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=cmss.chinamobile.com; spf=pass smtp.mailfrom=cmss.chinamobile.com; dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b="bQLh/WyJ"; arc=none smtp.remote-ip=111.22.67.151 X-Received: from cmccmta8.chinamobile.com (cmccmta8.chinamobile.com [111.22.67.151]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BDA7C606A321; Thu, 12 Nov 2026 03:52:13 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BDA7C606A321 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmss.chinamobile.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmss.chinamobile.com X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmss.chinamobile.com; s=default; l=0; h=from:subject:message-id:to:cc:mime-version; bh=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=; b=bQLh/WyJjXEzqZ1pf3Ouk4IxgieDVprTMltgLLD+ANL7q/yUSPnDYjxiOXeqslwae6/DKW3+HvWc2 bekKDE6qPC3ufHNHJ5WlqCOsWSE/86Qb1fgdMHcfInBUc4qp0VY0/nelUOHaw5cXFDZbDHpnJXN0Fb nR5Rs7kBgHOGsmtU= X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 X-Received: from spf.mail.chinamobile.com (unknown[10.188.0.87]) by rmmx-syy-dmz-app06-12006 (RichMail) with SMTP id 2ee66af537eb6b7-aa3f9; Thu, 12 Nov 2026 11:52:12 +0800 (CST) X-RM-TRANSID: 2ee66af537eb6b7-aa3f9 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 X-Received: from localhost.net (unknown[223.64.115.200]) by rmsmtp-syy-appsvr01-12001 (RichMail) with SMTP id 2ee16af537ea705-f1ab7; Thu, 12 Nov 2026 11:52:12 +0800 (CST) X-RM-TRANSID: 2ee16af537ea705-f1ab7 X-Cc: Andrew Lunn <andrew+netdev@lunn.ch>, "David S . Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Kuniyuki Iwashima <kuniyu@google.com>, Mahesh Bandewar <maheshb@google.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, sunwenbo@cmss.chinamobile.com, 1342116488@qq.com X-Mailer: git-send-email 2.33.0 X-In-Reply-To: <avRnWUbGFbdfirZB@fedora> 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