Subject: Re: [PATCH net-next-2.6] bonding: allow arp_ip_targets to be on a separate vlan from bond device

From: Eric Dumazet <[email-masked]>
Date: Wed, 02 Dec 2009 06:13:15 +0100

Andy Gospodarek a écrit :
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 5d131c2..eeee269 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -2439,8 +2439,8 @@ int netif_receive_skb(struct sk_buff *skb)
>  		skb->skb_iif = skb->dev->ifindex;
>  
>  	null_or_orig = NULL;
> -	orig_dev = skb->dev;
> -	if (orig_dev->master) {
> +	orig_dev = __dev_get_by_index(dev_net(skb->dev),skb->skb_iif);
> +	if (orig_dev->master && !(skb->dev->priv_flags & IFF_802_1Q_VLAN)) {
>  		if (skb_bond_should_drop(skb))
>  			null_or_orig = orig_dev; /* deliver only exact match */
>  		else

Please dont add a __dev_get_by_index() call in netif_receive_skb()

First, this is not safe against writers.

Second its very expensive on some setups.

Eventually, you could do something like :

Change prototypes of netif_receive_skb() to include the orig_dev in arguments.
Change vlan code to call __netif_receive_skb(skb, orig_dev)
instead of netif_received_skb(skb)

int __netif_receive_skb(struct sk_buff *skb, struct net_device *orig_dev)
{
...
	if (!skb->skb_iif) {
		skb->skb_iif = orig_dev->ifindex;
	} else {
		if (orig_dev->master &&  ...) 
	}

}

int netif_receive_skb(struct sk_buff *skb)
{
	return __netif_receive_skb(skb, skb->dev);
}