[Devel,RH7] ms/net: allow macvlans to move to net namespace

Submitted by Pavel Tikhomirov on Oct. 31, 2016, 9:37 a.m.

Details

Message ID 1477906628-8979-1-git-send-email-ptikhomirov@virtuozzo.com
State New
Series "ms/net: allow macvlans to move to net namespace"
Headers show

Commit Message

Pavel Tikhomirov Oct. 31, 2016, 9:37 a.m.
From: Francesco Ruggeri <fruggeri@arista.com>

We have a problem in macvlan criu test on VZ7:

https://ci.openvz.org/job/CRIU/job/CRIU-virtuozzo/branch/criu-dev/837/consoleFull

Patch hide | download patch | download mbox

======================== Run zdtm/static/macvlan in ns =========================
Start test
Test is SUID
./macvlan --pidfile=macvlan.pid --outfile=macvlan.out
RTNETLINK answers: Invalid argument
Running zdtm/static/macvlan.hook(--post-start)

because macvlan_fix_features called from register_netdevice
updates features from lowerdev and not dropping NETIF_F_NETNS_LOCAL.

And thus moving zdtmmvlan0 to other ns fails, so changing it to
be mainstream like. (That do not changes behaviour in CT as macvlan
is still forbidden there.)

  net: allow macvlans to move to net namespace

  I cannot move a macvlan interface created on top of a bonding interface
  to a different namespace:

  % ip netns add dummy0
  % ip link add link bond0 mac0 type macvlan
  % ip link set mac0 netns dummy0
  RTNETLINK answers: Invalid argument
  %

  The problem seems to be that commit f9399814927a ("bonding: Don't allow
  bond devices to change network namespaces.") sets NETIF_F_NETNS_LOCAL
  on bonding interfaces, and commit 797f87f83b60 ("macvlan: fix netdev
  feature propagation from lower device") causes macvlan interfaces
  to inherit its features from the lower device.

  NETIF_F_NETNS_LOCAL should not be inherited from the lower device
  by a macvlan.
  Patch tested on 3.16.

  Signed-off-by: Francesco Ruggeri <fruggeri@arista.com>
  Acked-by: Cong Wang <cwang@twopensource.com>
  Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
---
 drivers/net/macvlan.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 108ceb8..cb3d4de 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -734,6 +734,7 @@  static netdev_features_t macvlan_fix_features(struct net_device *dev,
 					     features,
 					     mask);
 	features |= ALWAYS_ON_FEATURES;
+	features &= ~NETIF_F_NETNS_LOCAL;
 
 	return features;
 }

Comments

Andrey Vagin Nov. 8, 2016, 10:23 p.m.
Acked-by: Andrew Vagin <avagin@virtuozzo.com>

On Mon, Oct 31, 2016 at 12:37:08PM +0300, Pavel Tikhomirov wrote:
> From: Francesco Ruggeri <fruggeri@arista.com>
> 
> We have a problem in macvlan criu test on VZ7:
> 
> https://ci.openvz.org/job/CRIU/job/CRIU-virtuozzo/branch/criu-dev/837/consoleFull
> ======================== Run zdtm/static/macvlan in ns =========================
> Start test
> Test is SUID
> ./macvlan --pidfile=macvlan.pid --outfile=macvlan.out
> RTNETLINK answers: Invalid argument
> Running zdtm/static/macvlan.hook(--post-start)
> 
> because macvlan_fix_features called from register_netdevice
> updates features from lowerdev and not dropping NETIF_F_NETNS_LOCAL.
> 
> And thus moving zdtmmvlan0 to other ns fails, so changing it to
> be mainstream like. (That do not changes behaviour in CT as macvlan
> is still forbidden there.)
> 
>   net: allow macvlans to move to net namespace
> 
>   I cannot move a macvlan interface created on top of a bonding interface
>   to a different namespace:
> 
>   % ip netns add dummy0
>   % ip link add link bond0 mac0 type macvlan
>   % ip link set mac0 netns dummy0
>   RTNETLINK answers: Invalid argument
>   %
> 
>   The problem seems to be that commit f9399814927a ("bonding: Don't allow
>   bond devices to change network namespaces.") sets NETIF_F_NETNS_LOCAL
>   on bonding interfaces, and commit 797f87f83b60 ("macvlan: fix netdev
>   feature propagation from lower device") causes macvlan interfaces
>   to inherit its features from the lower device.
> 
>   NETIF_F_NETNS_LOCAL should not be inherited from the lower device
>   by a macvlan.
>   Patch tested on 3.16.
> 
>   Signed-off-by: Francesco Ruggeri <fruggeri@arista.com>
>   Acked-by: Cong Wang <cwang@twopensource.com>
>   Signed-off-by: David S. Miller <davem@davemloft.net>
> 
> Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
> ---
>  drivers/net/macvlan.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
> index 108ceb8..cb3d4de 100644
> --- a/drivers/net/macvlan.c
> +++ b/drivers/net/macvlan.c
> @@ -734,6 +734,7 @@ static netdev_features_t macvlan_fix_features(struct net_device *dev,
>  					     features,
>  					     mask);
>  	features |= ALWAYS_ON_FEATURES;
> +	features &= ~NETIF_F_NETNS_LOCAL;
>  
>  	return features;
>  }
> -- 
> 2.7.4
>