From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A60AC001E0 for ; Mon, 23 Oct 2023 11:13:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233644AbjJWLN6 (ORCPT ); Mon, 23 Oct 2023 07:13:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233661AbjJWLNx (ORCPT ); Mon, 23 Oct 2023 07:13:53 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23F8AC2 for ; Mon, 23 Oct 2023 04:13:51 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 65073C433C7; Mon, 23 Oct 2023 11:13:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1698059630; bh=2Oo4pVteAcCf3WO1hnymkT0QJ52sQDUoAcZnPH9iUnM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c34JTCNeUYHIE9fCdc98L+oaC4tXKB216BoB/RLSAzygbxHagujRd5OiUTjHUY0Dz vWnwpiZ6KFry1adv0xrY6FZmRRX1DxlI9p1cVVwyl28r7x6X+dVRVDk21ot3P7sY5U Mekx00J/FFZTEJaXrGqGOmQ6943zaYRkZs0pqUKc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jiri Pirko , Jakub Kicinski , Paolo Abeni Subject: [PATCH 6.5 234/241] net: move altnames together with the netdevice Date: Mon, 23 Oct 2023 12:57:00 +0200 Message-ID: <20231023104839.579691257@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231023104833.832874523@linuxfoundation.org> References: <20231023104833.832874523@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 6.5-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jakub Kicinski commit 8e15aee621618a3ee3abecaf1fd8c1428098b7ef upstream. The altname nodes are currently not moved to the new netns when netdevice itself moves: [ ~]# ip netns add test [ ~]# ip -netns test link add name eth0 type dummy [ ~]# ip -netns test link property add dev eth0 altname some-name [ ~]# ip -netns test link show dev some-name 2: eth0: mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 1e:67:ed:19:3d:24 brd ff:ff:ff:ff:ff:ff altname some-name [ ~]# ip -netns test link set dev eth0 netns 1 [ ~]# ip link ... 3: eth0: mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 02:40:88:62:ec:b8 brd ff:ff:ff:ff:ff:ff altname some-name [ ~]# ip li show dev some-name Device "some-name" does not exist. Remove them from the hash table when device is unlisted and add back when listed again. Fixes: 36fbf1e52bd3 ("net: rtnetlink: add linkprop commands to add and delete alternative ifnames") Reviewed-by: Jiri Pirko Signed-off-by: Jakub Kicinski Signed-off-by: Paolo Abeni Signed-off-by: Greg Kroah-Hartman --- net/core/dev.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) --- a/net/core/dev.c +++ b/net/core/dev.c @@ -379,6 +379,7 @@ static void netdev_name_node_alt_flush(s /* Device list insertion */ static void list_netdevice(struct net_device *dev) { + struct netdev_name_node *name_node; struct net *net = dev_net(dev); ASSERT_RTNL(); @@ -390,6 +391,9 @@ static void list_netdevice(struct net_de dev_index_hash(net, dev->ifindex)); write_unlock(&dev_base_lock); + netdev_for_each_altname(dev, name_node) + netdev_name_node_add(net, name_node); + dev_base_seq_inc(net); } @@ -398,8 +402,13 @@ static void list_netdevice(struct net_de */ static void unlist_netdevice(struct net_device *dev, bool lock) { + struct netdev_name_node *name_node; + ASSERT_RTNL(); + netdev_for_each_altname(dev, name_node) + netdev_name_node_del(name_node); + /* Unlink dev from the device chain */ if (lock) write_lock(&dev_base_lock); @@ -10854,7 +10863,6 @@ void unregister_netdevice_many_notify(st synchronize_net(); list_for_each_entry(dev, head, unreg_list) { - struct netdev_name_node *name_node; struct sk_buff *skb = NULL; /* Shutdown queueing discipline. */ @@ -10882,9 +10890,6 @@ void unregister_netdevice_many_notify(st dev_uc_flush(dev); dev_mc_flush(dev); - netdev_for_each_altname(dev, name_node) - netdev_name_node_del(name_node); - synchronize_rcu(); netdev_name_node_alt_flush(dev); netdev_name_node_free(dev->name_node);