mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
[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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
parent
2d85cba2b2
commit
0e06877c6f
5 changed files with 44 additions and 4 deletions
|
|
@ -84,9 +84,21 @@ static int dummy_xmit(struct sk_buff *skb, struct net_device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int dummy_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
{
|
||||
if (tb[IFLA_ADDRESS]) {
|
||||
if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN)
|
||||
return -EINVAL;
|
||||
if (!is_valid_ether_addr(nla_data(tb[IFLA_ADDRESS])))
|
||||
return -EADDRNOTAVAIL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct rtnl_link_ops dummy_link_ops __read_mostly = {
|
||||
.kind = "dummy",
|
||||
.setup = dummy_setup,
|
||||
.validate = dummy_validate,
|
||||
};
|
||||
|
||||
/* Number of dummy devices to be set up by this module. */
|
||||
|
|
|
|||
|
|
@ -221,10 +221,22 @@ static int ifb_open(struct net_device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int ifb_validate(struct nlattr *tb[], struct nlattr *data[])
|
||||
{
|
||||
if (tb[IFLA_ADDRESS]) {
|
||||
if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN)
|
||||
return -EINVAL;
|
||||
if (!is_valid_ether_addr(nla_data(tb[IFLA_ADDRESS])))
|
||||
return -EADDRNOTAVAIL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct rtnl_link_ops ifb_link_ops __read_mostly = {
|
||||
.kind = "ifb",
|
||||
.priv_size = sizeof(struct ifb_private),
|
||||
.setup = ifb_setup,
|
||||
.validate = ifb_validate,
|
||||
};
|
||||
|
||||
/* Number of ifb devices to be set up by this module. */
|
||||
|
|
|
|||
Loading…
Reference in a new issue