diff mbox

[net] macvlan: add NETIF_F_NETNS_LOCAL flag

Message ID 1392097032.6615.73.camel@edumazet-glaptop2.roam.corp.google.com
State RFC, archived
Delegated to: David Miller
Headers show

Commit Message

Eric Dumazet Feb. 11, 2014, 5:37 a.m. UTC
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 :



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Eric Dumazet Feb. 11, 2014, 5:38 a.m. UTC | #1
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.



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Nicolas Dichtel Feb. 12, 2014, 10:03 a.m. UTC | #2
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?
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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)) ||