]> git.hungrycats.org Git - linux/commitdiff
[NET]: Fix up RTM_SETLINK handling.
authorRoland Dreier <roland@topspin.com>
Wed, 15 Jan 2003 15:47:42 +0000 (07:47 -0800)
committerLinus Torvalds <torvalds@penguin.transmeta.com>
Wed, 15 Jan 2003 15:47:42 +0000 (07:47 -0800)
include/linux/netdevice.h
net/core/dev.c
net/core/rtnetlink.c
net/netsyms.c

index 2a6e10e6e5981d8d48d7306f2830088c50560d11..20d73363c07970d7c93d0dc4c32b949359b100d7 100644 (file)
@@ -480,6 +480,7 @@ extern int          register_netdevice(struct net_device *dev);
 extern int             unregister_netdevice(struct net_device *dev);
 extern int             register_netdevice_notifier(struct notifier_block *nb);
 extern int             unregister_netdevice_notifier(struct notifier_block *nb);
+extern int             call_netdevice_notifiers(unsigned long val, void *v);
 extern int             dev_new_index(void);
 extern struct net_device       *dev_get_by_index(int ifindex);
 extern struct net_device       *__dev_get_by_index(int ifindex);
index 573121fd49c03484035c17f07fb3d2dc4fa6abc4..c70d31cea4869783ec87ddca01429a6d3dd8b26f 100644 (file)
@@ -877,6 +877,18 @@ int unregister_netdevice_notifier(struct notifier_block *nb)
        return notifier_chain_unregister(&netdev_chain, nb);
 }
 
+/**
+ *     call_netdevice_notifiers - call all network notifier blocks
+ *
+ *     Call all network notifier blocks.  Parameters and return value
+ *     are as for notifier_call_chain().
+ */
+
+int call_netdevice_notifiers(unsigned long val, void *v)
+{
+       return notifier_call_chain(&netdev_chain, val, v);
+}
+
 /*
  *     Support routine. Sends outgoing frames to any network
  *     taps currently in use.
index e324ae6f75f33e3ceafa3de2387a6b19e4fe597e..eac888a5e82e04977002a498ce6ebca5952d314f 100644 (file)
@@ -234,10 +234,20 @@ static int do_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
        err = -EINVAL;
 
        if (ida[IFLA_ADDRESS - 1]) {
+               if (!dev->set_mac_address) {
+                       err = -EOPNOTSUPP;
+                       goto out;
+               }
+               if (!netif_device_present(dev)) {
+                       err = -ENODEV;
+                       goto out;
+               }
                if (ida[IFLA_ADDRESS - 1]->rta_len != RTA_LENGTH(dev->addr_len))
                        goto out;
-               memcpy(dev->dev_addr, RTA_DATA(ida[IFLA_ADDRESS - 1]),
-                      dev->addr_len);
+
+               err = dev->set_mac_address(dev, RTA_DATA(ida[IFLA_ADDRESS - 1]));
+               if (err)
+                       goto out;
        }
 
        if (ida[IFLA_BROADCAST - 1]) {
@@ -250,6 +260,9 @@ static int do_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
        err = 0;
 
 out:
+       if (!err)
+               call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
+
        dev_put(dev);
        return err;
 }
index d689ed8f7ea7c528f310b9e9520593f8be3b2f79..dadfc1e8932a4a462f112c40bb9df121166f4724 100644 (file)
@@ -508,6 +508,7 @@ EXPORT_SYMBOL(tr_type_trans);
 /* Device callback registration */
 EXPORT_SYMBOL(register_netdevice_notifier);
 EXPORT_SYMBOL(unregister_netdevice_notifier);
+EXPORT_SYMBOL(call_netdevice_notifiers);
 
 /* support for loadable net drivers */
 #ifdef CONFIG_NET