All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch net] macvlan: add NETIF_F_NETNS_LOCAL flag
@ 2014-02-11  1:36 Cong Wang
  2014-02-11  1:45 ` Hannes Frederic Sowa
  2014-02-11  4:14 ` Eric Dumazet
  0 siblings, 2 replies; 12+ messages in thread
From: Cong Wang @ 2014-02-11  1:36 UTC (permalink / raw)
  To: netdev; +Cc: Patrick McHardy, David S. Miller, Cong Wang, Cong Wang

From: Cong Wang <cwang@twopensource.com>

BZ: https://bugzilla.kernel.org/show_bug.cgi?id=66691

There is no point to allow moving a macvlan device to
another namespace while the lower device is still in
this namespace. tunnels already set this flag.

Cc: Patrick McHardy <kaber@trash.net>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Cong Wang <cwang@twopensource.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>

---
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 8433de4..9bc3b13 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -539,7 +539,7 @@ static int macvlan_init(struct net_device *dev)
 	dev->state		= (dev->state & ~MACVLAN_STATE_MASK) |
 				  (lowerdev->state & MACVLAN_STATE_MASK);
 	dev->features 		= lowerdev->features & MACVLAN_FEATURES;
-	dev->features		|= NETIF_F_LLTX;
+	dev->features		|= NETIF_F_LLTX | NETIF_F_NETNS_LOCAL;
 	dev->gso_max_size	= lowerdev->gso_max_size;
 	dev->iflink		= lowerdev->ifindex;
 	dev->hard_header_len	= lowerdev->hard_header_len;
@@ -699,7 +699,7 @@ static netdev_features_t macvlan_fix_features(struct net_device *dev,
 	features = netdev_increment_features(vlan->lowerdev->features,
 					     features,
 					     mask);
-	features |= NETIF_F_LLTX;
+	features |= NETIF_F_LLTX | NETIF_F_NETNS_LOCAL;
 
 	return features;
 }

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

* Re: [Patch net] macvlan: add NETIF_F_NETNS_LOCAL flag
  2014-02-11  1:36 [Patch net] macvlan: add NETIF_F_NETNS_LOCAL flag Cong Wang
@ 2014-02-11  1:45 ` Hannes Frederic Sowa
  2014-02-11  2:25   ` Cong Wang
  2014-02-11  4:14 ` Eric Dumazet
  1 sibling, 1 reply; 12+ messages in thread
From: Hannes Frederic Sowa @ 2014-02-11  1:45 UTC (permalink / raw)
  To: Cong Wang; +Cc: netdev, Patrick McHardy, David S. Miller, Cong Wang

On Mon, Feb 10, 2014 at 05:36:33PM -0800, Cong Wang wrote:
> From: Cong Wang <cwang@twopensource.com>
> 
> BZ: https://bugzilla.kernel.org/show_bug.cgi?id=66691
> 
> There is no point to allow moving a macvlan device to
> another namespace while the lower device is still in
> this namespace. tunnels already set this flag.

Can't we solve this somehow differently, like not showing anything at all
etc.? I guess this is a feature some people use and haven't noticed yet.

Greetings,

  Hannes

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

* Re: [Patch net] macvlan: add NETIF_F_NETNS_LOCAL flag
  2014-02-11  1:45 ` Hannes Frederic Sowa
@ 2014-02-11  2:25   ` Cong Wang
  2014-02-11  2:40     ` Hannes Frederic Sowa
  0 siblings, 1 reply; 12+ messages in thread
From: Cong Wang @ 2014-02-11  2:25 UTC (permalink / raw)
  To: Cong Wang, netdev, Patrick McHardy, David S. Miller, Cong Wang

On Mon, Feb 10, 2014 at 5:45 PM, Hannes Frederic Sowa
<hannes@stressinduktion.org> wrote:
> On Mon, Feb 10, 2014 at 05:36:33PM -0800, Cong Wang wrote:
>> From: Cong Wang <cwang@twopensource.com>
>>
>> BZ: https://bugzilla.kernel.org/show_bug.cgi?id=66691
>>
>> There is no point to allow moving a macvlan device to
>> another namespace while the lower device is still in
>> this namespace. tunnels already set this flag.
>
> Can't we solve this somehow differently, like not showing anything at all
> etc.? I guess this is a feature some people use and haven't noticed yet.
>

I don't understand what you mean by "not showing anything at all".
I assume you mean mac1@xxx, not matter whether we show xxx
here, mac1 relies on xxx to function.

Please give a real use case rather than just guessing, I don't think
there is any valid case until we support moving multiple devices into
a netns atomically.

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

* Re: [Patch net] macvlan: add NETIF_F_NETNS_LOCAL flag
  2014-02-11  2:25   ` Cong Wang
@ 2014-02-11  2:40     ` Hannes Frederic Sowa
  2014-02-11  4:15       ` Eric Dumazet
  0 siblings, 1 reply; 12+ messages in thread
From: Hannes Frederic Sowa @ 2014-02-11  2:40 UTC (permalink / raw)
  To: Cong Wang; +Cc: Cong Wang, netdev, Patrick McHardy, David S. Miller

On Mon, Feb 10, 2014 at 06:25:51PM -0800, Cong Wang wrote:
> On Mon, Feb 10, 2014 at 5:45 PM, Hannes Frederic Sowa
> <hannes@stressinduktion.org> wrote:
> > On Mon, Feb 10, 2014 at 05:36:33PM -0800, Cong Wang wrote:
> >> From: Cong Wang <cwang@twopensource.com>
> >>
> >> BZ: https://bugzilla.kernel.org/show_bug.cgi?id=66691
> >>
> >> There is no point to allow moving a macvlan device to
> >> another namespace while the lower device is still in
> >> this namespace. tunnels already set this flag.
> >
> > Can't we solve this somehow differently, like not showing anything at all
> > etc.? I guess this is a feature some people use and haven't noticed yet.
> >
> 
> I don't understand what you mean by "not showing anything at all".
> I assume you mean mac1@xxx, not matter whether we show xxx
> here, mac1 relies on xxx to function.

Sorry, I have no idea how to resolve this easily, maybe set the ifindex to
something generic. I'll try to think about it.

Maybe revserve an id and install a generic name for it, so old software
doesn't get confused.

> Please give a real use case rather than just guessing, I don't think
> there is any valid case until we support moving multiple devices into
> a netns atomically.

Setting up a macvlan and moving it into another namespace without moving
the parent device is a nice feature. I am not an administrator, so I don't
use that stuff often, but given you can easily spawn namespaces and put
applications into them, one of the easiest things to connect those to
local network without routing over veth and such is the macvlan interface.

Greetings,

  Hannes

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

* Re: [Patch net] macvlan: add NETIF_F_NETNS_LOCAL flag
  2014-02-11  1:36 [Patch net] macvlan: add NETIF_F_NETNS_LOCAL flag Cong Wang
  2014-02-11  1:45 ` Hannes Frederic Sowa
@ 2014-02-11  4:14 ` Eric Dumazet
  1 sibling, 0 replies; 12+ messages in thread
From: Eric Dumazet @ 2014-02-11  4:14 UTC (permalink / raw)
  To: Cong Wang; +Cc: netdev, Patrick McHardy, David S. Miller, Cong Wang

On Mon, 2014-02-10 at 17:36 -0800, Cong Wang wrote:
> From: Cong Wang <cwang@twopensource.com>
> 
> BZ: https://bugzilla.kernel.org/show_bug.cgi?id=66691
> 
> There is no point to allow moving a macvlan device to
> another namespace while the lower device is still in
> this namespace. tunnels already set this flag.

What do you mean ?

This is probably one of the needed/useful feature of macvlan !

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

* Re: [Patch net] macvlan: add NETIF_F_NETNS_LOCAL flag
  2014-02-11  2:40     ` Hannes Frederic Sowa
@ 2014-02-11  4:15       ` Eric Dumazet
  2014-02-11  4:41         ` Cong Wang
  2014-02-12  9:47         ` Nicolas Dichtel
  0 siblings, 2 replies; 12+ messages in thread
From: Eric Dumazet @ 2014-02-11  4:15 UTC (permalink / raw)
  To: Hannes Frederic Sowa
  Cc: Cong Wang, Cong Wang, netdev, Patrick McHardy, David S. Miller

On Tue, 2014-02-11 at 03:40 +0100, Hannes Frederic Sowa wrote:

> Setting up a macvlan and moving it into another namespace without moving
> the parent device is a nice feature. I am not an administrator, so I don't
> use that stuff often, but given you can easily spawn namespaces and put
> applications into them, one of the easiest things to connect those to
> local network without routing over veth and such is the macvlan interface.

Exactly.

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

* Re: [Patch net] macvlan: add NETIF_F_NETNS_LOCAL flag
  2014-02-11  4:15       ` Eric Dumazet
@ 2014-02-11  4:41         ` Cong Wang
  2014-02-11  5:21           ` Eric Dumazet
  2014-02-12  9:47         ` Nicolas Dichtel
  1 sibling, 1 reply; 12+ messages in thread
From: Cong Wang @ 2014-02-11  4:41 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Hannes Frederic Sowa, Cong Wang, netdev, Patrick McHardy,
	David S. Miller

On Mon, Feb 10, 2014 at 8:15 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> On Tue, 2014-02-11 at 03:40 +0100, Hannes Frederic Sowa wrote:
>
>> Setting up a macvlan and moving it into another namespace without moving
>> the parent device is a nice feature. I am not an administrator, so I don't
>> use that stuff often, but given you can easily spawn namespaces and put
>> applications into them, one of the easiest things to connect those to
>> local network without routing over veth and such is the macvlan interface.
>
> Exactly.
>

Exactly broken by design.

IFA_LINK is an ifindex, ifindex is per-netns. macvlan should not use IFA_LINK.

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

* Re: [Patch net] macvlan: add NETIF_F_NETNS_LOCAL flag
  2014-02-11  4:41         ` Cong Wang
@ 2014-02-11  5:21           ` Eric Dumazet
  2014-02-11  5:37             ` Eric Dumazet
  0 siblings, 1 reply; 12+ messages in thread
From: Eric Dumazet @ 2014-02-11  5:21 UTC (permalink / raw)
  To: Cong Wang
  Cc: Hannes Frederic Sowa, Cong Wang, netdev, Patrick McHardy,
	David S. Miller

On Mon, 2014-02-10 at 20:41 -0800, Cong Wang wrote:

> Exactly broken by design.

Design of what ? Do you have a pointer to a document about this
'design' ?

> 
> IFA_LINK is an ifindex, ifindex is per-netns. macvlan should not use IFA_LINK.

When this was 'designed', ifindex were not per netns.

Apparently nobody spotted this when ifindexes become per netns.

I am sure we can find a solution, keeping this very useful
functionality.

BTW, are Cong Wang <cwang@twopensource.com> and Cong Wang
<xiyou.wangcong@gmail.com> different persons ?

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

* Re: [Patch net] macvlan: add NETIF_F_NETNS_LOCAL flag
  2014-02-11  5:21           ` Eric Dumazet
@ 2014-02-11  5:37             ` Eric Dumazet
  2014-02-11  5:38               ` Eric Dumazet
  0 siblings, 1 reply; 12+ messages in thread
From: Eric Dumazet @ 2014-02-11  5:37 UTC (permalink / raw)
  To: Cong Wang
  Cc: Hannes Frederic Sowa, Cong Wang, netdev, Patrick McHardy,
	David S. Miller

On Mon, 2014-02-10 at 21:21 -0800, Eric Dumazet wrote:
> On Mon, 2014-02-10 at 20:41 -0800, Cong Wang wrote:
> 
> > Exactly broken by design.
> 
> Design of what ? Do you have a pointer to a document about this
> 'design' ?
> 
> > 
> > IFA_LINK is an ifindex, ifindex is per-netns. macvlan should not use IFA_LINK.
> 
> When this was 'designed', ifindex were not per netns.
> 
> Apparently nobody spotted this when ifindexes become per netns.
> 
> I am sure we can find a solution, keeping this very useful
> functionality.

Simple patch would be :

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 048dc8d183aa..31bbba34fd1e 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -963,6 +963,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
 	    nla_put_u32(skb, IFLA_NUM_RX_QUEUES, dev->num_rx_queues) ||
 #endif
 	    (dev->ifindex != dev->iflink &&
+	     __dev_get_by_index(dev_net(dev), dev->iflink) &&
 	     nla_put_u32(skb, IFLA_LINK, dev->iflink)) ||
 	    (upper_dev &&
 	     nla_put_u32(skb, IFLA_MASTER, upper_dev->ifindex)) ||

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

* Re: [Patch net] macvlan: add NETIF_F_NETNS_LOCAL flag
  2014-02-11  5:37             ` Eric Dumazet
@ 2014-02-11  5:38               ` Eric Dumazet
  2014-02-12 10:03                 ` Nicolas Dichtel
  0 siblings, 1 reply; 12+ messages in thread
From: Eric Dumazet @ 2014-02-11  5:38 UTC (permalink / raw)
  To: Cong Wang
  Cc: Hannes Frederic Sowa, Cong Wang, netdev, Patrick McHardy,
	David S. Miller

On Mon, 2014-02-10 at 21:37 -0800, Eric Dumazet wrote:

> 
> Simple patch would be :
> 
> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> index 048dc8d183aa..31bbba34fd1e 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -963,6 +963,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
>  	    nla_put_u32(skb, IFLA_NUM_RX_QUEUES, dev->num_rx_queues) ||
>  #endif
>  	    (dev->ifindex != dev->iflink &&
> +	     __dev_get_by_index(dev_net(dev), dev->iflink) &&
>  	     nla_put_u32(skb, IFLA_LINK, dev->iflink)) ||
>  	    (upper_dev &&
>  	     nla_put_u32(skb, IFLA_MASTER, upper_dev->ifindex)) ||
> 

Hmm, not enough.

We probably need to keep a pointer to iflink net structure.

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

* Re: [Patch net] macvlan: add NETIF_F_NETNS_LOCAL flag
  2014-02-11  4:15       ` Eric Dumazet
  2014-02-11  4:41         ` Cong Wang
@ 2014-02-12  9:47         ` Nicolas Dichtel
  1 sibling, 0 replies; 12+ messages in thread
From: Nicolas Dichtel @ 2014-02-12  9:47 UTC (permalink / raw)
  To: Eric Dumazet, Hannes Frederic Sowa
  Cc: Cong Wang, Cong Wang, netdev, Patrick McHardy, David S. Miller

Le 11/02/2014 05:15, Eric Dumazet a écrit :
> On Tue, 2014-02-11 at 03:40 +0100, Hannes Frederic Sowa wrote:
>
>> Setting up a macvlan and moving it into another namespace without moving
>> the parent device is a nice feature. I am not an administrator, so I don't
>> use that stuff often, but given you can easily spawn namespaces and put
>> applications into them, one of the easiest things to connect those to
>> local network without routing over veth and such is the macvlan interface.
>
> Exactly.

I also agree.

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

* Re: [Patch net] macvlan: add NETIF_F_NETNS_LOCAL flag
  2014-02-11  5:38               ` Eric Dumazet
@ 2014-02-12 10:03                 ` Nicolas Dichtel
  0 siblings, 0 replies; 12+ messages in thread
From: Nicolas Dichtel @ 2014-02-12 10:03 UTC (permalink / raw)
  To: Eric Dumazet, Cong Wang
  Cc: Hannes Frederic Sowa, Cong Wang, netdev, Patrick McHardy,
	David S. Miller

Le 11/02/2014 06:38, Eric Dumazet a écrit :
> On Mon, 2014-02-10 at 21:37 -0800, Eric Dumazet wrote:
>
>>
>> Simple patch would be :
>>
>> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
>> index 048dc8d183aa..31bbba34fd1e 100644
>> --- a/net/core/rtnetlink.c
>> +++ b/net/core/rtnetlink.c
>> @@ -963,6 +963,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
>>   	    nla_put_u32(skb, IFLA_NUM_RX_QUEUES, dev->num_rx_queues) ||
>>   #endif
>>   	    (dev->ifindex != dev->iflink &&
>> +	     __dev_get_by_index(dev_net(dev), dev->iflink) &&
>>   	     nla_put_u32(skb, IFLA_LINK, dev->iflink)) ||
>>   	    (upper_dev &&
>>   	     nla_put_u32(skb, IFLA_MASTER, upper_dev->ifindex)) ||
>>
>
> Hmm, not enough.
>
> We probably need to keep a pointer to iflink net structure.
This is also used in ip tunnels, but when i/o device is not in the same netns
that the tunnel device, the userland can not interpret that IFLA_LINK attribute
(userland don't have necessary information to access another netns, maybe they
will be able to do it in the future ;-)).

The goal of your patch was to avoid filling this attribute when iflink is
into a netns != from dev_net(dev)?

If yes, I agree that we need to keep a pointer to the net structure of iflink.
This information is already available in ip tunnels (struct ip_tunnel->net,
struct ip6_tnl->net) but is not generic. Maybe we can move it to struct
net_device?

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

end of thread, other threads:[~2014-02-12 10:03 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-11  1:36 [Patch net] macvlan: add NETIF_F_NETNS_LOCAL flag Cong Wang
2014-02-11  1:45 ` Hannes Frederic Sowa
2014-02-11  2:25   ` Cong Wang
2014-02-11  2:40     ` Hannes Frederic Sowa
2014-02-11  4:15       ` Eric Dumazet
2014-02-11  4:41         ` Cong Wang
2014-02-11  5:21           ` Eric Dumazet
2014-02-11  5:37             ` Eric Dumazet
2014-02-11  5:38               ` Eric Dumazet
2014-02-12 10:03                 ` Nicolas Dichtel
2014-02-12  9:47         ` Nicolas Dichtel
2014-02-11  4:14 ` Eric Dumazet

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.