macvlan: resolve ENOENT errors on creation
Subsystems (2)
PATCH 1/1 macvlan: resolve ENOENT errors on creation
After the commit below attempting to create macvlan devices was resulting in ENOENT errors,
# ip link add link p3p2 type macvlan RTNETLINK answers: Invalid argument
This happens because netdev_upper_dev_link() is called before register_netdevice() in the macvlan code. Through a call chain this results in a call to __netdev_adjacent_dev_insert() and finally a sysfs_create_link(). This requires the kobject of the macvlan to be registered which is done in register_netdevice(). If there is no kobject which is the case here the ENOENT error is seen on the command line.
To resolve this move the netdev_upper_dev_link() call below the register_netdevice() call. This aligns with vlan driver flow.
Regression introduced here,
commit 5831d66e8097aedfa3bc35941cf265ada2352317
Author: Veaceslav Falico <[email protected]> Date: Wed Sep 25 09:20:32 2013 +0200
net: create sysfs symlinks for neighbour devices
--- drivers/net/macvlan.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/net/macvlan.c +5 -6
@@ -828,22 +828,21 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,eth_hw_addr_inherit (dev, lowerdev); } + port->count +=1 ; + err =register_netdevice (dev); +if (err <0 ) + goto destroy_port; + err =netdev_upper_dev_link (lowerdev, dev);if (err) goto destroy_port; - port->count +=1 ; - err =register_netdevice (dev); -if (err <0 ) - goto upper_dev_unlink;list_add_tail_rcu (&vlan->list, &port->vlans);netif_stacked_transfer_operstate (lowerdev, dev);return 0 ; -upper_dev_unlink: -netdev_upper_dev_unlink (lowerdev, dev); destroy_port: port->count -=1 ;if (!port->count)
Quoted 14 lines · John Fastabend
After the commit below attempting to create macvlan devices was resulting in ENOENT errors,
# ip link add link p3p2 type macvlan RTNETLINK answers: Invalid argumentThis happens because
netdev_upper_dev_link()is called beforeregister_netdevice()in the macvlan code. Through a call chain this results in a call to__netdev_adjacent_dev_insert()and finally asysfs_create_link(). This requires the kobject of the macvlan to be registered which is done inregister_netdevice(). If there is no kobject which is the case here the ENOENT error is seen on the command line.
Quoted 3 lines
To resolve this move the
netdev_upper_dev_link()call below theregister_netdevice()call. This aligns with vlan driver flow.
Yep, changed the vlan code, but didn't see the macvlan. My cscope didn't catch it for some reason :-/.
I've also checked - there are no users except bonding, vlan (both are ok), and macvlan.
Quoted 49 lines
Regression introduced here,
commit
5831d66e8097aedfa3bc35941cf265ada2352317Author: Veaceslav Falico <[email protected]> Date: Wed Sep 25 09:20:32 2013 +0200net: create sysfs symlinks for neighbour devices
CC Veaceslav Falico <[email protected]>CC Neil Horman <[email protected]>Signed-off-by John Fastabend <[email protected]>---
drivers/net/macvlan.c| 11 +++++------1 file changed, 5 insertions(+), 6 deletions(-)drivers/net/macvlan.c +5
-6@@ -828,22 +828,21 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,eth_hw_addr_inherit (dev, lowerdev); } + port->count +=1 ; + err =register_netdevice (dev); +if (err <0 ) + goto destroy_port; + err =netdev_upper_dev_link (lowerdev, dev);if (err) goto destroy_port; - port->count +=1 ; - err =register_netdevice (dev); -if (err <0 ) - goto upper_dev_unlink;list_add_tail_rcu (&vlan->list, &port->vlans);netif_stacked_transfer_operstate (lowerdev, dev);return 0 ; -upper_dev_unlink: -netdev_upper_dev_unlink (lowerdev, dev);
destroy_port:port->count -= 1; if (!port->count)
Quoted 19 lines · Veaceslav Falico
Quoted 14 lines · John Fastabend
After the commit below attempting to create macvlan devices was resulting in ENOENT errors,
# ip link add link p3p2 type macvlan RTNETLINK answers: Invalid argumentThis happens because
netdev_upper_dev_link()is called beforeregister_netdevice()in the macvlan code. Through a call chain this results in a call to__netdev_adjacent_dev_insert()and finally asysfs_create_link(). This requires the kobject of the macvlan to be registered which is done inregister_netdevice(). If there is no kobject which is the case here the ENOENT error is seen on the command line.Quoted 3 lines
To resolve this move the
netdev_upper_dev_link()call below theregister_netdevice()call. This aligns with vlan driver flow.
Quoted 6 lines
Yep, changed the vlan code, but didn't see the macvlan. My cscope didn't catch it for some reason :-/.
I've also checked - there are no users except bonding, vlan (both are ok), and macvlan.
The openvswitch code uses netdev_master_upper_dev_link() which eventually calls __netdev_adjacent_dev_insert() as well. But from a quick code inspection I think it should work. Anyways that is one other user.
.John
Signature · 1 line
John Fastabend Intel Corporation
Quoted 21 lines · John Fastabend
After the commit below attempting to create macvlan devices was resulting in ENOENT errors,
# ip link add link p3p2 type macvlan RTNETLINK answers: Invalid argumentThis happens because
netdev_upper_dev_link()is called beforeregister_netdevice()in the macvlan code. Through a call chain this results in a call to__netdev_adjacent_dev_insert()and finally asysfs_create_link(). This requires the kobject of the macvlan to be registered which is done inregister_netdevice(). If there is no kobject which is the case here the ENOENT error is seen on the command line.To resolve this move the
netdev_upper_dev_link()call below theregister_netdevice()call. This aligns with vlan driver flow.Regression introduced here,
commit
5831d66e8097aedfa3bc35941cf265ada2352317
Quoted 8 lines
Author: Veaceslav Falico <[email protected]> Date: Wed Sep 25 09:20:32 2013 +0200net: create sysfs symlinks for neighbour devices
CC Veaceslav Falico <[email protected]>CC Neil Horman <[email protected]>Signed-off-by John Fastabend <[email protected]>
Quoted 23 lines · John Fastabend
Quoted 22 lines · Veaceslav Falico
Quoted 14 lines · John Fastabend
After the commit below attempting to create macvlan devices was resulting in ENOENT errors,
# ip link add link p3p2 type macvlan RTNETLINK answers: Invalid argumentThis happens because
netdev_upper_dev_link()is called beforeregister_netdevice()in the macvlan code. Through a call chain this results in a call to__netdev_adjacent_dev_insert()and finally asysfs_create_link(). This requires the kobject of the macvlan to be registered which is done inregister_netdevice(). If there is no kobject which is the case here the ENOENT error is seen on the command line.Quoted 3 lines
To resolve this move the
netdev_upper_dev_link()call below theregister_netdevice()call. This aligns with vlan driver flow.Yep, changed the vlan code, but didn't see the macvlan. My cscope didn't catch it for some reason :-/.
Quoted 8 lines
Quoted 3 lines
I've also checked - there are no users except bonding, vlan (both are ok), and macvlan.
The openvswitch code uses
netdev_master_upper_dev_link()which eventually calls__netdev_adjacent_dev_insert()as well. But from a quick code inspection I think it should work. Anyways that is one other user.
Yep, checked them also now:
team - links two already existing devices (team->dev and port_dev) batadv - links existing device to another existing device, or creates of if
the latter doesn't exist (and calls register_netdev on creation)
bridge - links two already existing devices (bridge->dev and dev) openvswitch - links two already existing devices (get_dpdev(vport->dp) and
the device found by dev_get_by_name()).
bonding - uses netdev_master_upper_dev_link_private(), and is also ok.
Hopefully we're safe.
Quoted 5 lines
.John
Signature · 1 line
John Fastabend Intel Corporation
From: John Fastabend <[email protected]>
Date: Mon, 21 Oct 2013 14:28:02 -0700
Quoted 21 lines
After the commit below attempting to create macvlan devices was resulting in ENOENT errors,
# ip link add link p3p2 type macvlan RTNETLINK answers: Invalid argumentThis happens because
netdev_upper_dev_link()is called beforeregister_netdevice()in the macvlan code. Through a call chain this results in a call to__netdev_adjacent_dev_insert()and finally asysfs_create_link(). This requires the kobject of the macvlan to be registered which is done inregister_netdevice(). If there is no kobject which is the case here the ENOENT error is seen on the command line.To resolve this move the
netdev_upper_dev_link()call below theregister_netdevice()call. This aligns with vlan driver flow.Regression introduced here,
commit
5831d66e8097aedfa3bc35941cf265ada2352317
Quoted 8 lines
Author: Veaceslav Falico <[email protected]> Date: Wed Sep 25 09:20:32 2013 +0200net: create sysfs symlinks for neighbour devices
CC Veaceslav Falico <[email protected]>CC Neil Horman <[email protected]>Signed-off-by John Fastabend <[email protected]>
Applied, thanks.