Re: [net-next PATCH v0 2/5] net: addr_list: add exclusive dev_uc_add

11 views
Skip to first unread message

Roopa Prabhu

unread,
Mar 25, 2012, 9:07:45 AM3/25/12
to John Fastabend, j...@mojatatu.com, shemm...@vyatta.com, bhutc...@solarflare.com, da...@davemloft.net, jeffrey....@intel.com, net...@vger.kernel.org, m...@redhat.com, chr...@redhat.com, gregory...@intel.com, k...@vger.kernel.org, s...@us.ibm.com, che...@imsco-us.com


On 3/18/12 11:51 PM, "John Fastabend" <john.r.f...@intel.com> wrote:

> This adds a dev_uc_add_excl() call similar to the original
> dev_uc_add() except it sets the global bit. With this
> change the reference count will not be bumped and -EEXIST
> will be returned if a duplicate address exists.
>
> This is useful for drivers that support SR-IOV and want
> to manage the unicast lists.
>
> Signed-off-by: John Fastabend <john.r.f...@intel.com>
> ---
>
> include/linux/netdevice.h | 1 +
> net/core/dev_addr_lists.c | 19 +++++++++++++++++++
> 2 files changed, 20 insertions(+), 0 deletions(-)
>
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 4208901..5e43cec 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -2571,6 +2571,7 @@ extern int dev_addr_init(struct net_device *dev);
>
> /* Functions used for unicast addresses handling */
> extern int dev_uc_add(struct net_device *dev, unsigned char *addr);
> +extern int dev_uc_add_excl(struct net_device *dev, unsigned char *addr);
> extern int dev_uc_del(struct net_device *dev, unsigned char *addr);
> extern int dev_uc_sync(struct net_device *to, struct net_device *from);
> extern void dev_uc_unsync(struct net_device *to, struct net_device *from);
> diff --git a/net/core/dev_addr_lists.c b/net/core/dev_addr_lists.c
> index 29c07fe..c7d27ad 100644
> --- a/net/core/dev_addr_lists.c
> +++ b/net/core/dev_addr_lists.c
> @@ -377,6 +377,25 @@ EXPORT_SYMBOL(dev_addr_del_multiple);
> */
>
> /**
> + * dev_uc_add_excl - Add a global secondary unicast address
> + * @dev: device
> + * @addr: address to add
> + */
> +int dev_uc_add_excl(struct net_device *dev, unsigned char *addr)
> +{
> + int err;
> +
> + netif_addr_lock_bh(dev);
> + err = __hw_addr_add_ex(&dev->uc, addr, dev->addr_len,
> + NETDEV_HW_ADDR_T_UNICAST, true);
> + if (!err)
> + __dev_set_rx_mode(dev);
> + netif_addr_unlock_bh(dev);
> + return err;
> +}
> +EXPORT_SYMBOL(dev_uc_add_excl);
> +
> +/**

ACK.
We will need a similar function for multicast as well ?. Macvlan could use
it.

Thanks,
Roopa

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

Reply all
Reply to author
Forward
0 new messages