core: Add ioctls to control device unicast hw addresses
Subsystems (2)
RFC PATCH 1/1 core: Add ioctls to control device unicast hw addresses
There is currently a way to manage the multicast HW address list through SIOCADDMULTI/SIOCDELMULTI, but there is no way to consistently manage the unicast list. Some drivers provide FDB based interface, but that depends on driver configuration in almost every case.
This patch provides 2 new ioctls that allow on to add/delete unicast HW address on a device.
--- include/uapi/linux/sockios.h | 4 ++++ net/core/dev_ioctl.c | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 0 deletions(-)
include/uapi/linux/sockios.h +4 -0
@@ -127,6 +127,10 @@/* hardware time stamping: parameters in linux/net_tstamp.h */ #define SIOCSHWTSTAMP 0x89b0 +/* Device address management */ +#define SIOCADDHWADDR 0x89c0/* Unicast address list */ +#define SIOCDELHWADDR 0x8932 +/* Device private ioctl calls */ /*
net/core/dev_ioctl.c +22 -0
@@ -314,6 +314,26 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd) ifr->ifr_newname[IFNAMSIZ -1 ] ='\0' ;return dev_change_name (dev, ifr->ifr_newname); +case SIOCADDHWADDR : +if (!ops->ndo_set_rx_mode || + ifr->ifr_hwaddr.sa_family !=AF_UNSPEC ) +return -EINVAL ; +if (!netif_device_present (dev)) +return -ENODEV ; +if (!is_unicast_ether_addr (addr)) +return -EINVAL ; +return dev_uc_add_excl (dev, ifr->ifr_hwaddr.sa_data); + +case SIOCDELHWADDR : +if (!ops->ndo_set_rx_mode || + ifr->ifr_hwaddr.sa_family !=AF_UNSPEC ) +return -EINVAL ; +if (!netif_device_present (dev)) +return -ENODEV ; +if (!is_unicast_ether_addr (addr)) +return -EINVAL ; +return dev_uc_del (dev, ifr->ifr_hwaddr.sa_data); +case SIOCSHWTSTAMP : err =net_hwtstamp_validate (ifr);if (err)
@@ -532,6 +552,8 @@ int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg)case SIOCBRADDIF :case SIOCBRDELIF :case SIOCSHWTSTAMP : +case SIOCADDHWADDR : +case SIOCDELHWADDR :if (!ns_capable (net->user_ns,CAP_NET_ADMIN ))return -EPERM ;/* fall through */
Signature · 1 line
1.7.7.6
David Miller
maintainerNo new ioctls please, extend the netlink interfaces as necessary instead.
Thanks.
RFC PATCH 1/1 core: Add ioctls to control device unicast hw addresses
Quoted 4 lines · David Miller
No new ioctls please, extend the netlink interfaces as necessary instead.
Thanks.
So, something like below patch (compiled only) would be better in your opinion? The one concern I have is that there is no way to probe for the availabilty of this functionality, since netlink will just ignore unknown types and appear to succeed. With an ioctl it is clear if the support is present.
-- >8 --
[RFC PATCH] rtnetlink: Add support for adding/removing additional hw addresses.
Add an ability to add and remove HW addresses to the device unicast and multicast address lists. Right now, we only have an ioctl() to manage the multicast addresses and there is no way the manage the unicast list.
--- include/uapi/linux/if_link.h | 3 + include/uapi/linux/rtnetlink.h | 1 + net/core/rtnetlink.c | 84 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 87 insertions(+), 1 deletions(-)
include/uapi/linux/if_link.h +3 -0
@@ -143,6 +143,9 @@ enum {IFLA_NUM_TX_QUEUES ,IFLA_NUM_RX_QUEUES ,IFLA_CARRIER , +IFLA_HW_ADDR_ADD , +IFLA_HW_ADDR_DEL , +IFLA_HW_ADDR_LIST , __IFLA_MAX };
include/uapi/linux/rtnetlink.h +1 -0
@@ -631,6 +631,7 @@ struct tcamsg {/* New extended info filters for IFLA_EXT_MASK */ #define RTEXT_FILTER_VF (1 << 0)#define RTEXT_FILTER_BRVLAN (1 << 1) +#define RTEXT_FILTER_MACLIST (1 << 2)/* End of information exported to user level */
net/core/rtnetlink.c +83 -1
120 lines not on this page · raw message
Signature · 1 line
1.7.7.6
David Miller
maintainerFrom: Vlad Yasevich <[email protected]>
Date: Tue, 26 Feb 2013 14:44:22 -0500
Quoted 14 lines
Quoted 4 lines · David Miller
No new ioctls please, extend the netlink interfaces as necessary instead.
Thanks.
So, something like below patch (compiled only) would be better in your opinion? The one concern I have is that there is no way to probe for the availabilty of this functionality, since netlink will just ignore unknown types and appear to succeed. With an ioctl it is clear if the support is present.
-- >8 --
Quoted 8 lines
[RFC PATCH] rtnetlink: Add support for adding/removing additional hw addresses.
Add an ability to add and remove HW addresses to the device unicast and multicast address lists. Right now, we only have an
ioctl()to manage the multicast addresses and there is no way the manage the unicast list.Signed-off-by Vlad Yasevich <[email protected]>
This is a step in the right direction, and you're right that there is a difficulty in detecting whether support exists or not.
I am so surprised that we've have ->set_rx_mode() support for multiple unicast MAC addresses in so many drivers all this time, yet no way outside of FDB to make use of it at all.
Anyways, as per the feature detection issue, we could create a new RTM_* operation that returns a u32 feature flag mask. It's just one idea.
Quoted 24 lines · David Miller
From: Vlad Yasevich <[email protected]>
Date: Tue, 26 Feb 2013 14:44:22 -0500Quoted 21 lines
Quoted 4 lines · David Miller
No new ioctls please, extend the netlink interfaces as necessary instead.
Thanks.
So, something like below patch (compiled only) would be better in your opinion? The one concern I have is that there is no way to probe for the availabilty of this functionality, since netlink will just ignore unknown types and appear to succeed. With an ioctl it is clear if the support is present.
-- >8 --
[RFC PATCH] rtnetlink: Add support for adding/removing additional hw addresses.
Add an ability to add and remove HW addresses to the device unicast and multicast address lists. Right now, we only have an
ioctl()to manage the multicast addresses and there is no way the manage the unicast list.
Quoted 8 lines
Quoted 1 line
Signed-off-by Vlad Yasevich <[email protected]>This is a step in the right direction, and you're right that there is a difficulty in detecting whether support exists or not.
I am so surprised that we've have ->set_rx_mode() support for multiple unicast MAC addresses in so many drivers all this time, yet no way outside of FDB to make use of it at all.
And even that is not always available. In most drivers it requires
module parameters or other explicit configuration steps. Meanwhile set_rx_mode() doesn't seem to depend on any of those and just does the right thing.
For what I was trying to do ioctl() was a really easy way out for both kernel and user space implementation, so I gave is shot.
-vlad
Quoted 5 lines
Anyways, as per the feature detection issue, we could create a new RTM_* operation that returns a u32 feature flag mask. It's just one idea.
David Miller
maintainerFrom: Vlad Yasevich <[email protected]>
Date: Tue, 26 Feb 2013 15:24:33 -0500
Quoted 2 lines
For what I was trying to do
ioctl()was a really easy way out for both kernel and user space implementation, so I gave is shot.
Look at it this way, you were going to have to add these config values to the rtnetlink LINK dumps anyways. :-)
[...]
Quoted 24 lines
Quoted 10 lines
Quoted 10 lines
[RFC PATCH] rtnetlink: Add support for adding/removing additional hw addresses.
Add an ability to add and remove HW addresses to the device unicast and multicast address lists. Right now, we only have an
ioctl()to manage the multicast addresses and there is no way the manage the unicast list.Quoted 8 lines
Quoted 1 line
Signed-off-by Vlad Yasevich <[email protected]>This is a step in the right direction, and you're right that there is a difficulty in detecting whether support exists or not.
I am so surprised that we've have ->set_rx_mode() support for multiple unicast MAC addresses in so many drivers all this time, yet no way outside of FDB to make use of it at all.
And even that is not always available. In most drivers it requires module parameters or other explicit configuration steps. Meanwhile
set_rx_mode()doesn't seem to depend on any of those and just does the right thing.
Quoted 5 lines
For what I was trying to do
ioctl()was a really easy way out for both kernel and user space implementation, so I gave is shot.-vlad
Don't we already support this with
int (*ndo_fdb_add)(struct ndmsg *ndm,
struct nlattr *tb[], struct net_device *dev, const unsigned char *addr, u16 flags);
int (*ndo_fdb_del)(struct ndmsg *ndm,
struct nlattr *tb[], struct net_device *dev, const unsigned char *addr);
int (*ndo_fdb_dump)(struct sk_buff *skb,
structnetlink_callback *cb,
struct net_device *dev, int idx);
David Miller
maintainerFrom: John Fastabend <[email protected]>
Date: Tue, 26 Feb 2013 13:58:39 -0800
Quoted 26 lines
[...]
Quoted 24 lines
Quoted 10 lines
Quoted 10 lines
[RFC PATCH] rtnetlink: Add support for adding/removing additional hw addresses.
Add an ability to add and remove HW addresses to the device unicast and multicast address lists. Right now, we only have an
ioctl()to manage the multicast addresses and there is no way the manage the unicast list.Quoted 8 lines
Quoted 1 line
Signed-off-by Vlad Yasevich <[email protected]>This is a step in the right direction, and you're right that there is a difficulty in detecting whether support exists or not.
I am so surprised that we've have ->set_rx_mode() support for multiple unicast MAC addresses in so many drivers all this time, yet no way outside of FDB to make use of it at all.
And even that is not always available. In most drivers it requires module parameters or other explicit configuration steps. Meanwhile
set_rx_mode()doesn't seem to depend on any of those and just does the right thing.
Quoted 7 lines
Quoted 5 lines
For what I was trying to do
ioctl()was a really easy way out for both kernel and user space implementation, so I gave is shot.-vlad
Don't we already support this with
The whole point is that these multiple-unicast-address configuration facilities are inaccessible without FDB, and there is no reason whatsoever for that.
Quoted 32 lines · David Miller
From: John Fastabend <[email protected]>
Date: Tue, 26 Feb 2013 13:58:39 -0800Quoted 29 lines
[...]
Quoted 27 lines
Quoted 10 lines
Quoted 10 lines
[RFC PATCH] rtnetlink: Add support for adding/removing additional hw addresses.
Add an ability to add and remove HW addresses to the device unicast and multicast address lists. Right now, we only have an
ioctl()to manage the multicast addresses and there is no way the manage the unicast list.Quoted 8 lines
Quoted 1 line
Signed-off-by Vlad Yasevich <[email protected]>This is a step in the right direction, and you're right that there is a difficulty in detecting whether support exists or not.
I am so surprised that we've have ->set_rx_mode() support for multiple unicast MAC addresses in so many drivers all this time, yet no way outside of FDB to make use of it at all.
And even that is not always available. In most drivers it requires module parameters or other explicit configuration steps. Meanwhile
set_rx_mode()doesn't seem to depend on any of those and just does the right thing.For what I was trying to do
ioctl()was a really easy way out for both kernel and user space implementation, so I gave is shot.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
-vlad
Don't we already support this with
The whole point is that these multiple-unicast-address configuration facilities are inaccessible without FDB, and there is no reason whatsoever for that.
Yes I see now sorry I was behind the thread.
We could just use the fdb hooks and add a dflt routine to handle the case where the netdev doesn't provide a specific ndo_op for us. This boils down to calling set_rx_mode anyways through this call chain,
ndo_fdb_add
dev_uc_add_excl __dev_set_rx_mode ndo_set_rx_mode
As long as folks don't think this is too much of an abuse of the fdb hooks. Here's an example I only compile tested this so take it as an example only. It probably needs some cleanups and the dump routine needs some thought not sure you want to dump all MACs always.
[RFC PATCH] net: fdb: generic set support for drivers without ndo_op
If the driver does not support the ndo_op use the generic handler for it. This should work in the majority of cases. Eventually the fdb_dflt_add call gets translated into a __dev_set_rx_mode() call which should handle hardware support for filtering via the IFF_UNICAST_FLT flag.
Namely IFF_UNICAST_FLT indicates if the hardware can do unicast address filtering. If no support is available the device is put into promisc mode.
It looks like we likely also need IFF_MULTICAST_FLT and also tighten up how drivers handle multicast filters. But thats another patch.
--- net/core/rtnetlink.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 74 insertions(+), 6 deletions(-)
net/core/rtnetlink.c +74 -6
@@ -2049,6 +2049,37 @@ errout:rtnl_set_sk_err (net,RTNLGRP_NEIGH , err); } +/** +* ndo_dflt_fdb_add - default netdevice operation to add an FDB entry +*/ +static int ndo_dflt_fdb_add (struct ndmsg *ndm, +struct nlattr *tb[], +struct net_device *dev, +const unsigned char *addr, +u16 flags) +{ +int err = -EINVAL ; + +/* If aging addresses are supported device will need to +* implement its own handler for this. +*/ +if (ndm->ndm_state && !(ndm->ndm_state &NUD_PERMANENT )) { +pr_info ("%s: FDB only supports static addresses\n" , dev->name); +return err; + } + +if (is_unicast_ether_addr (addr) ||is_link_local_ether_addr (addr)) + err =dev_uc_add_excl (dev, addr); +else if (is_multicast_ether_addr (addr)) + err =dev_mc_add_excl (dev, addr); + +/* Only return duplicate errors if NLM_F_EXCL is set */ +if (err == -EEXIST && !(flags &NLM_F_EXCL )) + err =0 ; + +return err; +} +static int rtnl_fdb_add (struct sk_buff *skb,struct nlmsghdr *nlh,void *arg) {struct net *net =sock_net (skb->sk);
@@ -2101,10 +2132,14 @@ static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) }/* Embedded bridge, macvlan, and any other device support */ -if ((ndm->ndm_flags &NTF_SELF ) && dev->netdev_ops->ndo_fdb_add) { - err = dev->netdev_ops->ndo_fdb_add (ndm, tb, - dev, addr, - nlh->nlmsg_flags); +if ((ndm->ndm_flags &NTF_SELF )) { +if (dev->netdev_ops->ndo_fdb_add) + err = dev->netdev_ops->ndo_fdb_add (ndm, tb, + dev, addr, + nlh->nlmsg_flags); +else + err =ndo_dflt_fdb_add (ndm, tb, dev, addr, + nlh->nlmsg_flags);if (!err) {rtnl_fdb_notify (dev, addr,RTM_NEWNEIGH );
@@ -2115,6 +2150,34 @@ out:return err; } +/** +* ndo_dflt_fdb_del - default netdevice operation to delete an FDB entry +*/ +static int ndo_dflt_fdb_del (struct ndmsg *ndm, +struct nlattr *tb[], +struct net_device *dev, +const unsigned char *addr) +{ +int err = -EOPNOTSUPP ; + +/* If aging addresses are supported device will need to +* implement its own handler for this. +*/ +if (ndm->ndm_state &NUD_PERMANENT ) { +pr_info ("%s: FDB only supports static addresses\n" , dev->name); +return -EINVAL ; + } + +if (is_unicast_ether_addr (addr)) + err =dev_uc_del (dev, addr); +else if (is_multicast_ether_addr (addr)) + err =dev_mc_del (dev, addr); +else + err = -EINVAL ; + +return err; +} +static int rtnl_fdb_del (struct sk_buff *skb,struct nlmsghdr *nlh,void *arg) {struct net *net =sock_net (skb->sk);
@@ -2172,8 +2235,11 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) }/* Embedded bridge, macvlan, and any other device support */ -if ((ndm->ndm_flags &NTF_SELF ) && dev->netdev_ops->ndo_fdb_del) { - err = dev->netdev_ops->ndo_fdb_del (ndm, tb, dev, addr); +if (ndm->ndm_flags &NTF_SELF ) { +if (dev->netdev_ops->ndo_fdb_del) + err = dev->netdev_ops->ndo_fdb_del (ndm, tb, dev, addr); +else + err =ndo_dflt_fdb_del (ndm, tb, dev, addr);if (!err) {rtnl_fdb_notify (dev, addr,RTM_DELNEIGH );
@@ -2258,6 +2324,8 @@ static int rtnl_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb)if (dev->netdev_ops->ndo_fdb_dump) idx = dev->netdev_ops->ndo_fdb_dump (skb, cb, dev, idx); +else +ndo_dflt_fdb_dump (skb, cb, dev, idx); }rcu_read_unlock ();
Quoted 53 lines · John Fastabend
Quoted 32 lines · David Miller
From: John Fastabend <[email protected]>
Date: Tue, 26 Feb 2013 13:58:39 -0800Quoted 29 lines
[...]
Quoted 27 lines
Quoted 10 lines
Quoted 10 lines
[RFC PATCH] rtnetlink: Add support for adding/removing additional hw addresses.
Add an ability to add and remove HW addresses to the device unicast and multicast address lists. Right now, we only have an
ioctl()to manage the multicast addresses and there is no way the manage the unicast list.Quoted 8 lines
Quoted 1 line
Signed-off-by Vlad Yasevich <[email protected]>This is a step in the right direction, and you're right that there is a difficulty in detecting whether support exists or not.
I am so surprised that we've have ->set_rx_mode() support for multiple unicast MAC addresses in so many drivers all this time, yet no way outside of FDB to make use of it at all.
And even that is not always available. In most drivers it requires module parameters or other explicit configuration steps. Meanwhile
set_rx_mode()doesn't seem to depend on any of those and just does the right thing.For what I was trying to do
ioctl()was a really easy way out for both kernel and user space implementation, so I gave is shot.Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
-vlad
Don't we already support this with
The whole point is that these multiple-unicast-address configuration facilities are inaccessible without FDB, and there is no reason whatsoever for that.
Yes I see now sorry I was behind the thread.
We could just use the fdb hooks and add a dflt routine to handle the case where the netdev doesn't provide a specific
ndo_opfor us. This boils down to callingset_rx_modeanyways through this call chain,ndo_fdb_add dev_uc_add_excl __dev_set_rx_mode ndo_set_rx_mode
Quoted 4 lines
As long as folks don't think this is too much of an abuse of the fdb hooks. Here's an example I only compile tested this so take it as an example only. It probably needs some cleanups and the dump routine needs some thought not sure you want to dump all MACs always.
I thought about doing, but this becomes broken on the drivers that support ndo_fdb_* functions. Those drivers mainly require additional configuration that is not necessary for dev_uc_add_excl() to work.
For example, ixgbe and melanox requires VF to be on, qlogic needs a module parameter, macvlan has to be in passthrough. However, ndo_set_rx_mode() in most cases doesn't care about those settings and just works.
So fdb will not always work even if the driver has proper support for IFF_UNICAST_FLT.
-vlad
Quoted 143 lines
[RFC PATCH] net: fdb: generic set support for drivers without
ndo_opIf the driver does not support the
ndo_opuse the generic handler for it. This should work in the majority of cases. Eventually thefdb_dflt_addcall gets translated into a__dev_set_rx_mode()call which should handle hardware support for filtering via theIFF_UNICAST_FLTflag.Namely
IFF_UNICAST_FLTindicates if the hardware can do unicast address filtering. If no support is available the device is put into promisc mode.It looks like we likely also need
IFF_MULTICAST_FLTand also tighten up how drivers handle multicast filters. But thats another patch.Signed-off-by John Fastabend <[email protected]>--- net/core/rtnetlink.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 74 insertions(+), 6 deletions(-)net/core/rtnetlink.c +74
-6@@ -2049,6 +2049,37 @@ errout:rtnl_set_sk_err (net,RTNLGRP_NEIGH , err); } +/** +* ndo_dflt_fdb_add - default netdevice operation to add an FDB entry +*/ +static int ndo_dflt_fdb_add (struct ndmsg *ndm, +struct nlattr *tb[], +struct net_device *dev, +const unsigned char *addr, +u16 flags) +{ +int err = -EINVAL ; + +/* If aging addresses are supported device will need to +* implement its own handler for this. +*/ +if (ndm->ndm_state && !(ndm->ndm_state &NUD_PERMANENT )) { +pr_info ("%s: FDB only supports static addresses\n" , dev->name); +return err; + } + +if (is_unicast_ether_addr (addr) ||is_link_local_ether_addr (addr)) + err =dev_uc_add_excl (dev, addr); +else if (is_multicast_ether_addr (addr)) + err =dev_mc_add_excl (dev, addr); + +/* Only return duplicate errors if NLM_F_EXCL is set */ +if (err == -EEXIST && !(flags &NLM_F_EXCL )) + err =0 ; + +return err; +} +static int rtnl_fdb_add (struct sk_buff *skb,struct nlmsghdr *nlh,void *arg) {struct net *net =sock_net (skb->sk);@@ -2101,10 +2132,14 @@ static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) }/* Embedded bridge, macvlan, and any other device support */ -if ((ndm->ndm_flags &NTF_SELF ) && dev->netdev_ops->ndo_fdb_add) { - err = dev->netdev_ops->ndo_fdb_add (ndm, tb, - dev, addr, - nlh->nlmsg_flags); +if ((ndm->ndm_flags &NTF_SELF )) { +if (dev->netdev_ops->ndo_fdb_add) + err = dev->netdev_ops->ndo_fdb_add (ndm, tb, + dev, addr, + nlh->nlmsg_flags); +else + err =ndo_dflt_fdb_add (ndm, tb, dev, addr, + nlh->nlmsg_flags);if (!err) {rtnl_fdb_notify (dev, addr,RTM_NEWNEIGH );@@ -2115,6 +2150,34 @@ out:return err; } +/** +* ndo_dflt_fdb_del - default netdevice operation to delete an FDB entry +*/ +static int ndo_dflt_fdb_del (struct ndmsg *ndm, +struct nlattr *tb[], +struct net_device *dev, +const unsigned char *addr) +{ +int err = -EOPNOTSUPP ; + +/* If aging addresses are supported device will need to +* implement its own handler for this. +*/ +if (ndm->ndm_state &NUD_PERMANENT ) { +pr_info ("%s: FDB only supports static addresses\n" , dev->name); +return -EINVAL ; + } + +if (is_unicast_ether_addr (addr)) + err =dev_uc_del (dev, addr); +else if (is_multicast_ether_addr (addr)) + err =dev_mc_del (dev, addr); +else + err = -EINVAL ; + +return err; +} +static int rtnl_fdb_del (struct sk_buff *skb,struct nlmsghdr *nlh,void *arg) {struct net *net =sock_net (skb->sk);@@ -2172,8 +2235,11 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) }/* Embedded bridge, macvlan, and any other device support */ -if ((ndm->ndm_flags &NTF_SELF ) && dev->netdev_ops->ndo_fdb_del) { - err = dev->netdev_ops->ndo_fdb_del (ndm, tb, dev, addr); +if (ndm->ndm_flags &NTF_SELF ) { +if (dev->netdev_ops->ndo_fdb_del) + err = dev->netdev_ops->ndo_fdb_del (ndm, tb, dev, addr); +else + err =ndo_dflt_fdb_del (ndm, tb, dev, addr);if (!err) {rtnl_fdb_notify (dev, addr,RTM_DELNEIGH );@@ -2258,6 +2324,8 @@ static int rtnl_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb)if (dev->netdev_ops->ndo_fdb_dump) idx = dev->netdev_ops->ndo_fdb_dump (skb, cb, dev, idx); +else +ndo_dflt_fdb_dump (skb, cb, dev, idx); }rcu_read_unlock ();
Quoted 60 lines · Vlad Yasevich
Quoted 54 lines · John Fastabend
Quoted 33 lines · David Miller
From: John Fastabend <[email protected]>
Date: Tue, 26 Feb 2013 13:58:39 -0800Quoted 30 lines
[...]
Quoted 28 lines
Quoted 12 lines
Quoted 11 lines
[RFC PATCH] rtnetlink: Add support for adding/removing additional hw addresses.
Add an ability to add and remove HW addresses to the device unicast and multicast address lists. Right now, we only have an
ioctl()to manage the multicast addresses and there is no way the manage the unicast list.Signed-off-by Vlad Yasevich <[email protected]>Quoted 7 lines
This is a step in the right direction, and you're right that there is a difficulty in detecting whether support exists or not.
I am so surprised that we've have ->set_rx_mode() support for multiple
unicast MAC addresses in so many drivers all this time, yet no way outside of FDB to make use of it at all.And even that is not always available. In most drivers it requires module parameters or other explicit configuration steps. Meanwhile
set_rx_mode()doesn't seem to depend on any of those and just does the right thing.For what I was trying to do
ioctl()was a really easy way out for both kernel and user space implementation, so I gave is shot.Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
-vlad
Don't we already support this with
The whole point is that these multiple-unicast-address configuration facilities are inaccessible without FDB, and there is no reason whatsoever for that.
Yes I see now sorry I was behind the thread.
We could just use the fdb hooks and add a dflt routine to handle the case where the netdev doesn't provide a specific
ndo_opfor us. This boils down to callingset_rx_modeanyways through this call chain,ndo_fdb_add dev_uc_add_excl __dev_set_rx_mode ndo_set_rx_modeQuoted 4 lines
As long as folks don't think this is too much of an abuse of the fdb hooks. Here's an example I only compile tested this so take it as an example only. It probably needs some cleanups and the dump routine needs some thought not sure you want to dump all MACs always.
Quoted 9 lines
I thought about doing, but this becomes broken on the drivers that support ndo_fdb_* functions. Those drivers mainly require additional configuration that is not necessary for
dev_uc_add_excl()to work.For example, ixgbe and melanox requires VF to be on, qlogic needs a module parameter, macvlan has to be in passthrough. However,
ndo_set_rx_mode()in most cases doesn't care about those settings and just works.
The ixgbe piece could just use the dflt routines I put below. The SR-IOV check is only there because when I wrote that I didn't consider adding additional addresses without VFs. This was a poor example.
The mlx4 card is checking if the device is a slave or master before adding/removing addresses. My guess is this is the same type of check as ixgbe and would work just fine without it.
I'm not sure macvlan supports unicast hw addresses either way but there is no reason we couldn't. The idea was we would come back and write it later. Like many things I haven't got to it yet.
Calling set_rx_mode() on qlcnic doesn't look to help you at all either it appears to ignore the uc_list either way.
is that all the callers? looks like it.
Quoted 3 lines
So fdb will not always work even if the driver has proper support for
IFF_UNICAST_FLT.
The fdb could work if we fix the drivers it seems to me most the cases where it wouldn't work are just lack of foresight or the code isn't there yet. I think it might be valuable to have a single API for both use cases.
.John
Quoted 2 lines
-vlad
Quoted 83 lines · John Fastabend
Quoted 64 lines · Vlad Yasevich
Quoted 58 lines · John Fastabend
Quoted 37 lines · David Miller
From: John Fastabend <[email protected]>
Date: Tue, 26 Feb 2013 13:58:39 -0800Quoted 34 lines
[...]
Quoted 32 lines
Quoted 13 lines
Quoted 6 lines
[RFC PATCH] rtnetlink: Add support for adding/removing additional hw
addresses.Quoted 6 lines
Add an ability to add and remove HW addresses to the device unicast and multicast address lists. Right now, we only have an
ioctl()to manage the multicast addresses and there is no way the manage the unicast list.Signed-off-by Vlad Yasevich <[email protected]>Quoted 8 lines
This is a step in the right direction, and you're right that there is
a difficulty in detecting whether support exists or not.I am so surprised that we've have ->set_rx_mode() support for multiple
unicast MAC addresses in so many drivers all this time, yet no way outside of FDB to make use of it at all.And even that is not always available. In most drivers it requires module parameters or other explicit configuration steps. Meanwhile
set_rx_mode()doesn't seem to depend on any of those and just does the
right thing.For what I was trying to do
ioctl()was a really easy way out for both
kernel and user space implementation, so I gave is shot.Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
-vlad
Don't we already support this with
The whole point is that these multiple-unicast-address configuration facilities are inaccessible without FDB, and there is no reason whatsoever for that.
Yes I see now sorry I was behind the thread.
We could just use the fdb hooks and add a dflt routine to handle the case where the netdev doesn't provide a specific
ndo_opfor us. This boils down to callingset_rx_modeanyways through this call chain,ndo_fdb_add dev_uc_add_excl __dev_set_rx_mode ndo_set_rx_modeQuoted 4 lines
As long as folks don't think this is too much of an abuse of the fdb hooks. Here's an example I only compile tested this so take it as an example only. It probably needs some cleanups and the dump routine needs some thought not sure you want to dump all MACs always.
Quoted 9 lines
I thought about doing, but this becomes broken on the drivers that support ndo_fdb_* functions. Those drivers mainly require additional configuration that is not necessary for
dev_uc_add_excl()to work.For example, ixgbe and melanox requires VF to be on, qlogic needs a module parameter, macvlan has to be in passthrough. However,
ndo_set_rx_mode()in most cases doesn't care about those settings and just works.The ixgbe piece could just use the dflt routines I put below. The SR-IOV check is only there because when I wrote that I didn't consider adding additional addresses without VFs. This was a poor example.
The mlx4 card is checking if the device is a slave or master before adding/removing addresses. My guess is this is the same type of check as ixgbe and would work just fine without it.
Quoted 6 lines
I'm not sure macvlan supports unicast hw addresses either way but there is no reason we couldn't. The idea was we would come back and write it later. Like many things I haven't got to it yet.
Calling
set_rx_mode()on qlcnic doesn't look to help you at all either it appears to ignore theuc_listeither way.
Even though we use module parameter for fdb but it would be good it have set_rx_mode().
We don't ignore uc_list but it never called set_rx_mode() when I use dev_uc_add_excl when added support and thought that's how it might designed.
-Jiten
Quoted 21 lines
is that all the callers? looks like it.
Quoted 3 lines
So fdb will not always work even if the driver has proper support for
IFF_UNICAST_FLT.The fdb could work if we fix the drivers it seems to me most the cases where it wouldn't work are just lack of foresight or the code isn't there yet. I think it might be valuable to have a single API for both use cases.
.John
Quoted 2 lines
-vlad
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 94 lines · Jitendra Kalsaria
Quoted 83 lines · John Fastabend
Quoted 64 lines · Vlad Yasevich
Quoted 58 lines · John Fastabend
Quoted 37 lines · David Miller
From: John Fastabend <[email protected]>
Date: Tue, 26 Feb 2013 13:58:39 -0800Quoted 34 lines
[...]
Quoted 32 lines
Quoted 13 lines
Quoted 6 lines
[RFC PATCH] rtnetlink: Add support for adding/removing additional hw
addresses.Quoted 6 lines
Add an ability to add and remove HW addresses to the device unicast and multicast address lists. Right now, we only have an
ioctl()to manage the multicast addresses and there is no way the manage the unicast list.Signed-off-by Vlad Yasevich <[email protected]>Quoted 8 lines
This is a step in the right direction, and you're right that there is
a difficulty in detecting whether support exists or not.I am so surprised that we've have ->set_rx_mode() support for multiple
unicast MAC addresses in so many drivers all this time, yet no way outside of FDB to make use of it at all.And even that is not always available. In most drivers it requires module parameters or other explicit configuration steps. Meanwhile
set_rx_mode()doesn't seem to depend on any of those and just does the
right thing.For what I was trying to do
ioctl()was a really easy way out for both
kernel and user space implementation, so I gave is shot.Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
-vlad
Don't we already support this with
The whole point is that these multiple-unicast-address configuration facilities are inaccessible without FDB, and there is no reason whatsoever for that.
Yes I see now sorry I was behind the thread.
We could just use the fdb hooks and add a dflt routine to handle the case where the netdev doesn't provide a specific
ndo_opfor us. This boils down to callingset_rx_modeanyways through this call chain,ndo_fdb_add dev_uc_add_excl __dev_set_rx_mode ndo_set_rx_modeQuoted 4 lines
As long as folks don't think this is too much of an abuse of the fdb hooks. Here's an example I only compile tested this so take it as an example only. It probably needs some cleanups and the dump routine needs some thought not sure you want to dump all MACs always.
Quoted 9 lines
I thought about doing, but this becomes broken on the drivers that support ndo_fdb_* functions. Those drivers mainly require additional configuration that is not necessary for
dev_uc_add_excl()to work.For example, ixgbe and melanox requires VF to be on, qlogic needs a module parameter, macvlan has to be in passthrough. However,
ndo_set_rx_mode()in most cases doesn't care about those settings and just works.The ixgbe piece could just use the dflt routines I put below. The SR-IOV check is only there because when I wrote that I didn't consider adding additional addresses without VFs. This was a poor example.
The mlx4 card is checking if the device is a slave or master before adding/removing addresses. My guess is this is the same type of check as ixgbe and would work just fine without it.
Quoted 6 lines
I'm not sure macvlan supports unicast hw addresses either way but there is no reason we couldn't. The idea was we would come back and write it later. Like many things I haven't got to it yet.
Calling
set_rx_mode()on qlcnic doesn't look to help you at all either it appears to ignore theuc_listeither way.
Quoted 8 lines
Even though we use module parameter for fdb but it would be good it have
set_rx_mode().
We don't ignoreuc_listbut it never calledset_rx_mode()when I usedev_uc_add_exclwhen added support and thought that's how it might designed.-Jiten
Quoted 1 line
Hopefully not too off topic but you probably should use dev_uc_add_excl in fdb_add and then fix your set_rx_mode() handler to configure the uc_list correctly. Not sure what happens today when a unicast addr is added to the list for example with macvlan looks like a bug to me.
.John
Signature · 1 line
John Fastabend Intel Corporation
Quoted 91 lines · Jitendra Kalsaria
Quoted 87 lines · John Fastabend
Quoted 64 lines · Vlad Yasevich
Quoted 58 lines · John Fastabend
Quoted 37 lines · David Miller
From: John Fastabend <[email protected]>
Date: Tue, 26 Feb 2013 13:58:39 -0800Quoted 34 lines
[...]
Quoted 32 lines
Quoted 13 lines
Quoted 6 lines
[RFC PATCH] rtnetlink: Add support for adding/removing additional hw
addresses.Quoted 6 lines
Add an ability to add and remove HW addresses to the device unicast and multicast address lists. Right now, we only have an
ioctl()to manage the multicast addresses and there is no way the manage the unicast list.Signed-off-by Vlad Yasevich <[email protected]>Quoted 8 lines
This is a step in the right direction, and you're right that there is
a difficulty in detecting whether support exists or not.I am so surprised that we've have ->set_rx_mode() support for multiple
unicast MAC addresses in so many drivers all this time, yet no way outside of FDB to make use of it at all.And even that is not always available. In most drivers it requires module parameters or other explicit configuration steps. Meanwhile
set_rx_mode()doesn't seem to depend on any of those and just does the
right thing.For what I was trying to do
ioctl()was a really easy way out for both
kernel and user space implementation, so I gave is shot.Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
-vlad
Don't we already support this with
The whole point is that these multiple-unicast-address configuration facilities are inaccessible without FDB, and there is no reason whatsoever for that.
Yes I see now sorry I was behind the thread.
We could just use the fdb hooks and add a dflt routine to handle the case where the netdev doesn't provide a specific
ndo_opfor us. This boils down to callingset_rx_modeanyways through this call chain,ndo_fdb_add dev_uc_add_excl __dev_set_rx_mode ndo_set_rx_modeQuoted 4 lines
As long as folks don't think this is too much of an abuse of the fdb hooks. Here's an example I only compile tested this so take it as an example only. It probably needs some cleanups and the dump routine needs some thought not sure you want to dump all MACs always.
Quoted 9 lines
I thought about doing, but this becomes broken on the drivers that support ndo_fdb_* functions. Those drivers mainly require additional configuration that is not necessary for
dev_uc_add_excl()to work.For example, ixgbe and melanox requires VF to be on, qlogic needs a module parameter, macvlan has to be in passthrough. However,
ndo_set_rx_mode()in most cases doesn't care about those settings and just works.The ixgbe piece could just use the dflt routines I put below. The SR-IOV check is only there because when I wrote that I didn't consider adding additional addresses without VFs. This was a poor example.
The mlx4 card is checking if the device is a slave or master before adding/removing addresses. My guess is this is the same type of check as ixgbe and would work just fine without it.
I'm not sure macvlan supports unicast hw addresses either way but there is no reason we couldn't. The idea was we would come back and write it later. Like many things I haven't got to it yet.
Quoted 8 lines
Quoted 2 lines
Calling
set_rx_mode()on qlcnic doesn't look to help you at all either it appears to ignore theuc_listeither way.Even though we use module parameter for fdb but it would be good it have
set_rx_mode().
We don't ignoreuc_listbut it never calledset_rx_mode()when I usedev_uc_add_exclwhen added support and thought that's how it might designed.
I doesn't look like you ever call dev_uc_add_excl(). Also, since the driver doesn't set IFF_UNICAST_FLT, anyone who does call that (macvlan for instance) will end up turning promisc on.
-vlad
Quoted 25 lines
-Jiten
Quoted 21 lines
is that all the callers? looks like it.
Quoted 3 lines
So fdb will not always work even if the driver has proper support for
IFF_UNICAST_FLT.The fdb could work if we fix the drivers it seems to me most the cases where it wouldn't work are just lack of foresight or the code isn't there yet. I think it might be valuable to have a single API for both use cases.
.John
Quoted 2 lines
-vlad
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html