aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPetr Machata <petrm@mellanox.com>2018-12-13 06:54:30 -0500
committerDavid S. Miller <davem@davemloft.net>2018-12-13 21:41:38 -0500
commit3a37a9636cf3a1af2621a33f7eef8a2a3da81030 (patch)
tree39d632745b9834d8297856b8900b793ec43c45d7 /net
parent95302c394c3de19bdf24fff5e44a2bf935eadf74 (diff)
net: dev: Add extack argument to dev_set_mac_address()
A follow-up patch will add a notifier type NETDEV_PRE_CHANGEADDR, which allows vetoing of MAC address changes. One prominent path to that notification is through dev_set_mac_address(). Therefore give this function an extack argument, so that it can be packed together with the notification. Thus a textual reason for rejection (or a warning) can be communicated back to the user. Signed-off-by: Petr Machata <petrm@mellanox.com> Acked-by: Jiri Pirko <jiri@mellanox.com> Reviewed-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/core/dev.c4
-rw-r--r--net/core/dev_ioctl.c2
-rw-r--r--net/core/rtnetlink.c2
-rw-r--r--net/ieee802154/nl-phy.c2
4 files changed, 6 insertions, 4 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 754284873355..7250a3a73fa4 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -7759,10 +7759,12 @@ EXPORT_SYMBOL(dev_set_group);
7759 * dev_set_mac_address - Change Media Access Control Address 7759 * dev_set_mac_address - Change Media Access Control Address
7760 * @dev: device 7760 * @dev: device
7761 * @sa: new address 7761 * @sa: new address
7762 * @extack: netlink extended ack
7762 * 7763 *
7763 * Change the hardware (MAC) address of the device 7764 * Change the hardware (MAC) address of the device
7764 */ 7765 */
7765int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa) 7766int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa,
7767 struct netlink_ext_ack *extack)
7766{ 7768{
7767 const struct net_device_ops *ops = dev->netdev_ops; 7769 const struct net_device_ops *ops = dev->netdev_ops;
7768 int err; 7770 int err;
diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
index da273ec3cc57..31380fd5a4e2 100644
--- a/net/core/dev_ioctl.c
+++ b/net/core/dev_ioctl.c
@@ -246,7 +246,7 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd)
246 case SIOCSIFHWADDR: 246 case SIOCSIFHWADDR:
247 if (dev->addr_len > sizeof(struct sockaddr)) 247 if (dev->addr_len > sizeof(struct sockaddr))
248 return -EINVAL; 248 return -EINVAL;
249 return dev_set_mac_address(dev, &ifr->ifr_hwaddr); 249 return dev_set_mac_address(dev, &ifr->ifr_hwaddr, NULL);
250 250
251 case SIOCSIFHWBROADCAST: 251 case SIOCSIFHWBROADCAST:
252 if (ifr->ifr_hwaddr.sa_family != dev->type) 252 if (ifr->ifr_hwaddr.sa_family != dev->type)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 3b6e551f9e69..f8bdb8adab2c 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2444,7 +2444,7 @@ static int do_setlink(const struct sk_buff *skb,
2444 sa->sa_family = dev->type; 2444 sa->sa_family = dev->type;
2445 memcpy(sa->sa_data, nla_data(tb[IFLA_ADDRESS]), 2445 memcpy(sa->sa_data, nla_data(tb[IFLA_ADDRESS]),
2446 dev->addr_len); 2446 dev->addr_len);
2447 err = dev_set_mac_address(dev, sa); 2447 err = dev_set_mac_address(dev, sa, extack);
2448 kfree(sa); 2448 kfree(sa);
2449 if (err) 2449 if (err)
2450 goto errout; 2450 goto errout;
diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c
index b231e40f006a..0c25c0bcc4da 100644
--- a/net/ieee802154/nl-phy.c
+++ b/net/ieee802154/nl-phy.c
@@ -242,7 +242,7 @@ int ieee802154_add_iface(struct sk_buff *skb, struct genl_info *info)
242 * dev_set_mac_address require RTNL_LOCK 242 * dev_set_mac_address require RTNL_LOCK
243 */ 243 */
244 rtnl_lock(); 244 rtnl_lock();
245 rc = dev_set_mac_address(dev, &addr); 245 rc = dev_set_mac_address(dev, &addr, NULL);
246 rtnl_unlock(); 246 rtnl_unlock();
247 if (rc) 247 if (rc)
248 goto dev_unregister; 248 goto dev_unregister;