Subject: Re: [net-next PATCH v1 2/7] net: addr_list: add exclusive dev_uc_add and dev_mc_add

From: John Fastabend <[email-masked]>
Date: Wed, 11 Apr 2012 07:46:07 -0700

On 4/10/2012 8:33 PM, Ben Hutchings wrote:
> On Mon, 2012-04-09 at 15:00 -0700, John Fastabend wrote:
>> This adds a dev_uc_add_excl() and dev_mc_add_excl() calls
>> similar to the original dev_{uc|mc}_add() except it sets
>> the global bit and returns -EEXIST for duplicat entires.
>>
>> This is useful for drivers that support SR-IOV, macvlan
>> devices and any other devices that need to manage the
>> unicast and multicast lists.
> [...]
>> +/**
>> + *	dev_mc_add_excl - Add a global secondary multicast address
>> + *	@dev: device
>> + *	@addr: address to add
>> + */
>> +int dev_mc_add_excl(struct net_device *dev, unsigned char *addr)
>> +{
>> +	struct netdev_hw_addr *ha;
>> +	int err;
>> +
>> +	netif_addr_lock_bh(dev);
>> +	list_for_each_entry(ha, &dev->mc.list, list) {
>> +		if (!memcmp(ha->addr, addr, dev->addr_len) &&
>> +		    ha->type == NETDEV_HW_ADDR_T_UNICAST) {
>> +			err = -EEXIST;
>> +			goto out;
>> +		}
>> +	}
>> +	err = __hw_addr_create_ex(&dev->mc, addr, dev->addr_len,
>> +				  NETDEV_HW_ADDR_T_UNICAST, true);
> [...]
> 
> The address types are wrong.  But do we even need this function yet?
> 
> Ben.
> 

macvlan wants to manage multicast addresses as well. Good catch thanks.

.John