diff options
author | Patrick McHardy <kaber@trash.net> | 2007-07-11 22:42:31 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-07-11 22:45:36 -0400 |
commit | 0e06877c6fdbc67b1132be895f995acd1ff30135 (patch) | |
tree | ddaba8cddc8a95d23ee18f812c6aba67dd9b1c6f /net/8021q | |
parent | 2d85cba2b272a5201a60966a65a4f8c0bcc0bb71 (diff) |
[RTNETLINK]: rtnl_link: allow specifying initial device address
Drivers need to validate the initial addresses in their netlink attribute
validation function or manually reject them if they can't support this.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/8021q')
-rw-r--r-- | net/8021q/vlan.c | 8 | ||||
-rw-r--r-- | net/8021q/vlan_netlink.c | 7 |
2 files changed, 13 insertions, 2 deletions
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index 34c1d0b241ca..abb9900edb3f 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c | |||
@@ -324,8 +324,10 @@ static int vlan_dev_init(struct net_device *dev) | |||
324 | (1<<__LINK_STATE_DORMANT))) | | 324 | (1<<__LINK_STATE_DORMANT))) | |
325 | (1<<__LINK_STATE_PRESENT); | 325 | (1<<__LINK_STATE_PRESENT); |
326 | 326 | ||
327 | memcpy(dev->broadcast, real_dev->broadcast, real_dev->addr_len); | 327 | if (is_zero_ether_addr(dev->dev_addr)) |
328 | memcpy(dev->dev_addr, real_dev->dev_addr, real_dev->addr_len); | 328 | memcpy(dev->dev_addr, real_dev->dev_addr, dev->addr_len); |
329 | if (is_zero_ether_addr(dev->broadcast)) | ||
330 | memcpy(dev->broadcast, real_dev->broadcast, dev->addr_len); | ||
329 | 331 | ||
330 | if (real_dev->features & NETIF_F_HW_VLAN_TX) { | 332 | if (real_dev->features & NETIF_F_HW_VLAN_TX) { |
331 | dev->hard_header = real_dev->hard_header; | 333 | dev->hard_header = real_dev->hard_header; |
@@ -373,6 +375,8 @@ void vlan_setup(struct net_device *new_dev) | |||
373 | new_dev->set_multicast_list = vlan_dev_set_multicast_list; | 375 | new_dev->set_multicast_list = vlan_dev_set_multicast_list; |
374 | new_dev->destructor = free_netdev; | 376 | new_dev->destructor = free_netdev; |
375 | new_dev->do_ioctl = vlan_dev_ioctl; | 377 | new_dev->do_ioctl = vlan_dev_ioctl; |
378 | |||
379 | memset(new_dev->broadcast, 0, sizeof(ETH_ALEN)); | ||
376 | } | 380 | } |
377 | 381 | ||
378 | static void vlan_transfer_operstate(const struct net_device *dev, struct net_device *vlandev) | 382 | static void vlan_transfer_operstate(const struct net_device *dev, struct net_device *vlandev) |
diff --git a/net/8021q/vlan_netlink.c b/net/8021q/vlan_netlink.c index 844c7e43d0fa..6cdd1e015e2d 100644 --- a/net/8021q/vlan_netlink.c +++ b/net/8021q/vlan_netlink.c | |||
@@ -41,6 +41,13 @@ static int vlan_validate(struct nlattr *tb[], struct nlattr *data[]) | |||
41 | u16 id; | 41 | u16 id; |
42 | int err; | 42 | int err; |
43 | 43 | ||
44 | if (tb[IFLA_ADDRESS]) { | ||
45 | if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN) | ||
46 | return -EINVAL; | ||
47 | if (!is_valid_ether_addr(nla_data(tb[IFLA_ADDRESS]))) | ||
48 | return -EADDRNOTAVAIL; | ||
49 | } | ||
50 | |||
44 | if (!data) | 51 | if (!data) |
45 | return -EINVAL; | 52 | return -EINVAL; |
46 | 53 | ||