macvlan: add NETIF_F_NETNS_LOCAL flag
Subsystems (2)
PATCH 1/1 macvlan: add NETIF_F_NETNS_LOCAL flag
From: Cong Wang <[email protected]>
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.
---
drivers/net/macvlan.c +2 -2
@@ -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; }
Quoted 7 lines · Cong Wang
From: Cong Wang <[email protected]>
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
Quoted 12 lines · Hannes Frederic Sowa
Quoted 7 lines · Cong Wang
From: Cong Wang <[email protected]>
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.
Quoted 11 lines · Cong Wang
Quoted 9 lines · Hannes Frederic Sowa
Quoted 7 lines · Cong Wang
From: Cong Wang <[email protected]>
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.
Quoted 7 lines
Quoted 3 lines
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.
Quoted 3 lines
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
Quoted 7 lines · Cong Wang
From: Cong Wang <[email protected]>
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 !
Quoted 5 lines · Hannes Frederic Sowa
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.
Quoted 10 lines · Eric Dumazet
Quoted 5 lines · Hannes Frederic Sowa
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.
Quoted 1 line · Cong Wang
Exactly broken by design.
Design of what ? Do you have a pointer to a document about this 'design' ?
Quoted 2 lines
IFA_LINKis an ifindex, ifindex is per-netns. macvlan should not useIFA_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 <[email protected]> and Cong Wang <[email protected]> different persons ?
Quoted 8 lines · Eric Dumazet
Quoted 1 line · Cong Wang
Exactly broken by design.
Design of what ? Do you have a pointer to a document about this 'design' ?
Quoted 1 line
Quoted 8 lines
Quoted 1 line
IFA_LINKis an ifindex, ifindex is per-netns. macvlan should not useIFA_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 :
net/core/rtnetlink.c +1 -0
@@ -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)) ||
Quoted 9 lines · Eric Dumazet
Simple patch would be :
net/core/rtnetlink.c +0
-0
net/core/rtnetlink.c static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, · line 969
Quoted 7 lines
net/core/rtnetlink.c +1
-0@@ -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.
Quoted 9 lines · Eric Dumazet
Quoted 5 lines · Hannes Frederic Sowa
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.
Quoted 21 lines · Eric Dumazet
Quoted 9 lines · Eric Dumazet
Simple patch would be :
net/core/rtnetlink.c +0
-0net/core/rtnetlink.c static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, · line 969
Quoted 7 lines
net/core/rtnetlink.c +1
-0@@ -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.
Quoted 1 line
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?