mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
net: move altnames together with the netdevice
commit8e15aee621upstream. 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: <BROADCAST,NOARP> 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: <BROADCAST,NOARP> 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:36fbf1e52b("net: rtnetlink: add linkprop commands to add and delete alternative ifnames") Reviewed-by: Jiri Pirko <jiri@nvidia.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
c1d531aa09
commit
46de539282
@@ -381,6 +381,7 @@ static void netdev_name_node_alt_flush(struct net_device *dev)
|
|||||||
/* Device list insertion */
|
/* Device list insertion */
|
||||||
static void list_netdevice(struct net_device *dev)
|
static void list_netdevice(struct net_device *dev)
|
||||||
{
|
{
|
||||||
|
struct netdev_name_node *name_node;
|
||||||
struct net *net = dev_net(dev);
|
struct net *net = dev_net(dev);
|
||||||
|
|
||||||
ASSERT_RTNL();
|
ASSERT_RTNL();
|
||||||
@@ -392,6 +393,9 @@ static void list_netdevice(struct net_device *dev)
|
|||||||
dev_index_hash(net, dev->ifindex));
|
dev_index_hash(net, dev->ifindex));
|
||||||
write_unlock(&dev_base_lock);
|
write_unlock(&dev_base_lock);
|
||||||
|
|
||||||
|
netdev_for_each_altname(dev, name_node)
|
||||||
|
netdev_name_node_add(net, name_node);
|
||||||
|
|
||||||
dev_base_seq_inc(net);
|
dev_base_seq_inc(net);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -400,8 +404,13 @@ static void list_netdevice(struct net_device *dev)
|
|||||||
*/
|
*/
|
||||||
static void unlist_netdevice(struct net_device *dev, bool lock)
|
static void unlist_netdevice(struct net_device *dev, bool lock)
|
||||||
{
|
{
|
||||||
|
struct netdev_name_node *name_node;
|
||||||
|
|
||||||
ASSERT_RTNL();
|
ASSERT_RTNL();
|
||||||
|
|
||||||
|
netdev_for_each_altname(dev, name_node)
|
||||||
|
netdev_name_node_del(name_node);
|
||||||
|
|
||||||
/* Unlink dev from the device chain */
|
/* Unlink dev from the device chain */
|
||||||
if (lock)
|
if (lock)
|
||||||
write_lock(&dev_base_lock);
|
write_lock(&dev_base_lock);
|
||||||
@@ -10851,7 +10860,6 @@ void unregister_netdevice_many(struct list_head *head)
|
|||||||
synchronize_net();
|
synchronize_net();
|
||||||
|
|
||||||
list_for_each_entry(dev, head, unreg_list) {
|
list_for_each_entry(dev, head, unreg_list) {
|
||||||
struct netdev_name_node *name_node;
|
|
||||||
struct sk_buff *skb = NULL;
|
struct sk_buff *skb = NULL;
|
||||||
|
|
||||||
/* Shutdown queueing discipline. */
|
/* Shutdown queueing discipline. */
|
||||||
@@ -10877,9 +10885,6 @@ void unregister_netdevice_many(struct list_head *head)
|
|||||||
dev_uc_flush(dev);
|
dev_uc_flush(dev);
|
||||||
dev_mc_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_alt_flush(dev);
|
||||||
netdev_name_node_free(dev->name_node);
|
netdev_name_node_free(dev->name_node);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user