public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [net-next PATCH] macvlan: resolve ENOENT errors on creation
@ 2013-10-21 21:28 John Fastabend
  2013-10-21 21:34 ` Veaceslav Falico
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: John Fastabend @ 2013-10-21 21:28 UTC (permalink / raw)
  To: vfalico, nhorman; +Cc: netdev

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 <vfalico@redhat.com>
Date:   Wed Sep 25 09:20:32 2013 +0200

    net: create sysfs symlinks for neighbour devices

CC: Veaceslav Falico <vfalico@redhat.com>
CC: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
 drivers/net/macvlan.c |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 9bf46bd..cc9845e 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -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)

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [net-next PATCH] macvlan: resolve ENOENT errors on creation
  2013-10-21 21:28 [net-next PATCH] macvlan: resolve ENOENT errors on creation John Fastabend
@ 2013-10-21 21:34 ` Veaceslav Falico
  2013-10-21 21:48   ` John Fastabend
  2013-10-21 21:54 ` Neil Horman
  2013-10-22 23:23 ` David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Veaceslav Falico @ 2013-10-21 21:34 UTC (permalink / raw)
  To: John Fastabend; +Cc: nhorman, netdev

On Mon, Oct 21, 2013 at 02:28:02PM -0700, John Fastabend wrote:
>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.

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.

Acked-by: Veaceslav Falico <vfalico@redhat.com>

>
>Regression introduced here,
>
>commit 5831d66e8097aedfa3bc35941cf265ada2352317
>Author: Veaceslav Falico <vfalico@redhat.com>
>Date:   Wed Sep 25 09:20:32 2013 +0200
>
>    net: create sysfs symlinks for neighbour devices
>
>CC: Veaceslav Falico <vfalico@redhat.com>
>CC: Neil Horman <nhorman@tuxdriver.com>
>Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
>---
> drivers/net/macvlan.c |   11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
>diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
>index 9bf46bd..cc9845e 100644
>--- a/drivers/net/macvlan.c
>+++ b/drivers/net/macvlan.c
>@@ -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)
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [net-next PATCH] macvlan: resolve ENOENT errors on creation
  2013-10-21 21:34 ` Veaceslav Falico
@ 2013-10-21 21:48   ` John Fastabend
  2013-10-21 22:05     ` Veaceslav Falico
  0 siblings, 1 reply; 6+ messages in thread
From: John Fastabend @ 2013-10-21 21:48 UTC (permalink / raw)
  To: Veaceslav Falico; +Cc: nhorman, netdev

On 10/21/2013 02:34 PM, Veaceslav Falico wrote:
> On Mon, Oct 21, 2013 at 02:28:02PM -0700, John Fastabend wrote:
>> 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.
>
> 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

-- 
John Fastabend         Intel Corporation

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [net-next PATCH] macvlan: resolve ENOENT errors on creation
  2013-10-21 21:28 [net-next PATCH] macvlan: resolve ENOENT errors on creation John Fastabend
  2013-10-21 21:34 ` Veaceslav Falico
@ 2013-10-21 21:54 ` Neil Horman
  2013-10-22 23:23 ` David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: Neil Horman @ 2013-10-21 21:54 UTC (permalink / raw)
  To: John Fastabend; +Cc: vfalico, netdev

On Mon, Oct 21, 2013 at 02:28:02PM -0700, John Fastabend wrote:
> 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 <vfalico@redhat.com>
> Date:   Wed Sep 25 09:20:32 2013 +0200
> 
>     net: create sysfs symlinks for neighbour devices
> 
> CC: Veaceslav Falico <vfalico@redhat.com>
> CC: Neil Horman <nhorman@tuxdriver.com>
> Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [net-next PATCH] macvlan: resolve ENOENT errors on creation
  2013-10-21 21:48   ` John Fastabend
@ 2013-10-21 22:05     ` Veaceslav Falico
  0 siblings, 0 replies; 6+ messages in thread
From: Veaceslav Falico @ 2013-10-21 22:05 UTC (permalink / raw)
  To: John Fastabend; +Cc: nhorman, netdev

On Mon, Oct 21, 2013 at 02:48:55PM -0700, John Fastabend wrote:
>On 10/21/2013 02:34 PM, Veaceslav Falico wrote:
>>On Mon, Oct 21, 2013 at 02:28:02PM -0700, John Fastabend wrote:
>>>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.
>>
>>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.

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.

>
>.John
>
>-- 
>John Fastabend         Intel Corporation

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [net-next PATCH] macvlan: resolve ENOENT errors on creation
  2013-10-21 21:28 [net-next PATCH] macvlan: resolve ENOENT errors on creation John Fastabend
  2013-10-21 21:34 ` Veaceslav Falico
  2013-10-21 21:54 ` Neil Horman
@ 2013-10-22 23:23 ` David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2013-10-22 23:23 UTC (permalink / raw)
  To: john.fastabend; +Cc: vfalico, nhorman, netdev

From: John Fastabend <john.fastabend@gmail.com>
Date: Mon, 21 Oct 2013 14:28:02 -0700

> 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 <vfalico@redhat.com>
> Date:   Wed Sep 25 09:20:32 2013 +0200
> 
>     net: create sysfs symlinks for neighbour devices
> 
> CC: Veaceslav Falico <vfalico@redhat.com>
> CC: Neil Horman <nhorman@tuxdriver.com>
> Signed-off-by: John Fastabend <john.r.fastabend@intel.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-10-22 23:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-21 21:28 [net-next PATCH] macvlan: resolve ENOENT errors on creation John Fastabend
2013-10-21 21:34 ` Veaceslav Falico
2013-10-21 21:48   ` John Fastabend
2013-10-21 22:05     ` Veaceslav Falico
2013-10-21 21:54 ` Neil Horman
2013-10-22 23:23 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox