From: Vlad Yasevich <vyasevic@redhat.com>
To: netdev@vger.kernel.org
Subject: [RFC PATCH] core: Add ioctls to control device unicast hw addresses
Date: Tue, 26 Feb 2013 11:59:30 -0500 [thread overview]
Message-ID: <1361897970-1728-1-git-send-email-vyasevic@redhat.com> (raw)
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.
Signed-off-by: Vlad Yasevich <vyasevic@redhat.com>
---
include/uapi/linux/sockios.h | 4 ++++
net/core/dev_ioctl.c | 22 ++++++++++++++++++++++
2 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/include/uapi/linux/sockios.h b/include/uapi/linux/sockios.h
index 7997a50..442360e 100644
--- a/include/uapi/linux/sockios.h
+++ b/include/uapi/linux/sockios.h
@@ -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 */
/*
diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
index 6cc0481..d84f6f9 100644
--- a/net/core/dev_ioctl.c
+++ b/net/core/dev_ioctl.c
@@ -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 */
--
1.7.7.6
next reply other threads:[~2013-02-26 16:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-26 16:59 Vlad Yasevich [this message]
2013-02-26 17:43 ` [RFC PATCH] core: Add ioctls to control device unicast hw addresses David Miller
2013-02-26 19:44 ` Vlad Yasevich
2013-02-26 20:03 ` David Miller
2013-02-26 20:24 ` Vlad Yasevich
2013-02-26 20:48 ` David Miller
2013-02-26 21:58 ` John Fastabend
2013-02-26 22:15 ` David Miller
2013-02-27 2:07 ` John Fastabend
2013-02-27 2:27 ` Vlad Yasevich
2013-02-27 5:01 ` John Fastabend
2013-02-27 5:42 ` Jitendra Kalsaria
2013-02-27 7:34 ` John Fastabend
2013-02-27 15:27 ` Vlad Yasevich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1361897970-1728-1-git-send-email-vyasevic@redhat.com \
--to=vyasevic@redhat.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).