Commit b3865596 authored by Jay Vosburgh's avatar Jay Vosburgh Committed by Jeff Garzik

[PATCH] : net/core: move set MAC into separate function

	This moves the SIOCSIFHWADDR code from dev_ifsioc() into a
separate new function, dev_set_mac_address().  This provides a single
entry point for all callers performing MAC address changes.
Signed-off-by: default avatarJay Vosburgh <fubar@us.ibm.com>
Signed-off-by: default avatarJeff Garzik <jgarzik@pobox.com>
parent 88f48c81
...@@ -678,6 +678,8 @@ extern unsigned dev_get_flags(const struct net_device *); ...@@ -678,6 +678,8 @@ extern unsigned dev_get_flags(const struct net_device *);
extern int dev_change_flags(struct net_device *, unsigned); extern int dev_change_flags(struct net_device *, unsigned);
extern int dev_change_name(struct net_device *, char *); extern int dev_change_name(struct net_device *, char *);
extern int dev_set_mtu(struct net_device *, int); extern int dev_set_mtu(struct net_device *, int);
extern int dev_set_mac_address(struct net_device *,
struct sockaddr *);
extern void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev); extern void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev);
extern void dev_init(void); extern void dev_init(void);
......
...@@ -2300,6 +2300,21 @@ int dev_set_mtu(struct net_device *dev, int new_mtu) ...@@ -2300,6 +2300,21 @@ int dev_set_mtu(struct net_device *dev, int new_mtu)
return err; return err;
} }
int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa)
{
int err;
if (!dev->set_mac_address)
return -EOPNOTSUPP;
if (sa->sa_family != dev->type)
return -EINVAL;
if (!netif_device_present(dev))
return -ENODEV;
err = dev->set_mac_address(dev, sa);
if (!err)
notifier_call_chain(&netdev_chain, NETDEV_CHANGEADDR, dev);
return err;
}
/* /*
* Perform the SIOCxIFxxx calls. * Perform the SIOCxIFxxx calls.
...@@ -2346,17 +2361,7 @@ static int dev_ifsioc(struct ifreq *ifr, unsigned int cmd) ...@@ -2346,17 +2361,7 @@ static int dev_ifsioc(struct ifreq *ifr, unsigned int cmd)
return 0; return 0;
case SIOCSIFHWADDR: case SIOCSIFHWADDR:
if (!dev->set_mac_address) return dev_set_mac_address(dev, &ifr->ifr_hwaddr);
return -EOPNOTSUPP;
if (ifr->ifr_hwaddr.sa_family != dev->type)
return -EINVAL;
if (!netif_device_present(dev))
return -ENODEV;
err = dev->set_mac_address(dev, &ifr->ifr_hwaddr);
if (!err)
notifier_call_chain(&netdev_chain,
NETDEV_CHANGEADDR, dev);
return err;
case SIOCSIFHWBROADCAST: case SIOCSIFHWBROADCAST:
if (ifr->ifr_hwaddr.sa_family != dev->type) if (ifr->ifr_hwaddr.sa_family != dev->type)
...@@ -3322,6 +3327,7 @@ EXPORT_SYMBOL(dev_set_allmulti); ...@@ -3322,6 +3327,7 @@ EXPORT_SYMBOL(dev_set_allmulti);
EXPORT_SYMBOL(dev_set_promiscuity); EXPORT_SYMBOL(dev_set_promiscuity);
EXPORT_SYMBOL(dev_change_flags); EXPORT_SYMBOL(dev_change_flags);
EXPORT_SYMBOL(dev_set_mtu); EXPORT_SYMBOL(dev_set_mtu);
EXPORT_SYMBOL(dev_set_mac_address);
EXPORT_SYMBOL(free_netdev); EXPORT_SYMBOL(free_netdev);
EXPORT_SYMBOL(netdev_boot_setup_check); EXPORT_SYMBOL(netdev_boot_setup_check);
EXPORT_SYMBOL(netdev_set_master); EXPORT_SYMBOL(netdev_set_master);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment