mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 19:56:18 +00:00
[NET]: Validate device addr prior to interface-up
Signed-off-by: Jeff Garzik <jgarzik@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
c9927c2bf4
commit
bada339ba2
3 changed files with 20 additions and 5 deletions
|
@ -669,6 +669,8 @@ struct net_device
|
||||||
#define HAVE_SET_MAC_ADDR
|
#define HAVE_SET_MAC_ADDR
|
||||||
int (*set_mac_address)(struct net_device *dev,
|
int (*set_mac_address)(struct net_device *dev,
|
||||||
void *addr);
|
void *addr);
|
||||||
|
#define HAVE_VALIDATE_ADDR
|
||||||
|
int (*validate_addr)(struct net_device *dev);
|
||||||
#define HAVE_PRIVATE_IOCTL
|
#define HAVE_PRIVATE_IOCTL
|
||||||
int (*do_ioctl)(struct net_device *dev,
|
int (*do_ioctl)(struct net_device *dev,
|
||||||
struct ifreq *ifr, int cmd);
|
struct ifreq *ifr, int cmd);
|
||||||
|
|
|
@ -1007,17 +1007,20 @@ int dev_open(struct net_device *dev)
|
||||||
* Call device private open method
|
* Call device private open method
|
||||||
*/
|
*/
|
||||||
set_bit(__LINK_STATE_START, &dev->state);
|
set_bit(__LINK_STATE_START, &dev->state);
|
||||||
if (dev->open) {
|
|
||||||
|
if (dev->validate_addr)
|
||||||
|
ret = dev->validate_addr(dev);
|
||||||
|
|
||||||
|
if (!ret && dev->open)
|
||||||
ret = dev->open(dev);
|
ret = dev->open(dev);
|
||||||
if (ret)
|
|
||||||
clear_bit(__LINK_STATE_START, &dev->state);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If it went open OK then:
|
* If it went open OK then:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!ret) {
|
if (ret)
|
||||||
|
clear_bit(__LINK_STATE_START, &dev->state);
|
||||||
|
else {
|
||||||
/*
|
/*
|
||||||
* Set the flags.
|
* Set the flags.
|
||||||
*/
|
*/
|
||||||
|
@ -1038,6 +1041,7 @@ int dev_open(struct net_device *dev)
|
||||||
*/
|
*/
|
||||||
call_netdevice_notifiers(NETDEV_UP, dev);
|
call_netdevice_notifiers(NETDEV_UP, dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -298,6 +298,14 @@ static int eth_change_mtu(struct net_device *dev, int new_mtu)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int eth_validate_addr(struct net_device *dev)
|
||||||
|
{
|
||||||
|
if (!is_valid_ether_addr(dev->dev_addr))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
const struct header_ops eth_header_ops ____cacheline_aligned = {
|
const struct header_ops eth_header_ops ____cacheline_aligned = {
|
||||||
.create = eth_header,
|
.create = eth_header,
|
||||||
.parse = eth_header_parse,
|
.parse = eth_header_parse,
|
||||||
|
@ -317,6 +325,7 @@ void ether_setup(struct net_device *dev)
|
||||||
|
|
||||||
dev->change_mtu = eth_change_mtu;
|
dev->change_mtu = eth_change_mtu;
|
||||||
dev->set_mac_address = eth_mac_addr;
|
dev->set_mac_address = eth_mac_addr;
|
||||||
|
dev->validate_addr = eth_validate_addr;
|
||||||
|
|
||||||
dev->type = ARPHRD_ETHER;
|
dev->type = ARPHRD_ETHER;
|
||||||
dev->hard_header_len = ETH_HLEN;
|
dev->hard_header_len = ETH_HLEN;
|
||||||
|
|
Loading…
Reference in a new issue