mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-04 13:21:45 +00:00
rtnetlink: provide permanent hardware address in RTM_NEWLINK
Permanent hardware address of a network device was traditionally provided via ethtool ioctl interface but as Jiri Pirko pointed out in a review of ethtool netlink interface, rtnetlink is much more suitable for it so let's add it to the RTM_NEWLINK message. Add IFLA_PERM_ADDRESS attribute to RTM_NEWLINK messages unless the permanent address is all zeros (i.e. device driver did not fill it). As permanent address is not modifiable, reject userspace requests containing IFLA_PERM_ADDRESS attribute. Note: we already provide permanent hardware address for bond slaves; unfortunately we cannot drop that attribute for backward compatibility reasons. v5 -> v6: only add the attribute if permanent address is not zero Signed-off-by: Michal Kubecek <mkubecek@suse.cz> Acked-by: Jiri Pirko <jiri@mellanox.com> Acked-by: Stephen Hemminger <stephen@networkplumber.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
545a682299
commit
f74877a545
2 changed files with 6 additions and 0 deletions
|
@ -169,6 +169,7 @@ enum {
|
||||||
IFLA_MAX_MTU,
|
IFLA_MAX_MTU,
|
||||||
IFLA_PROP_LIST,
|
IFLA_PROP_LIST,
|
||||||
IFLA_ALT_IFNAME, /* Alternative ifname */
|
IFLA_ALT_IFNAME, /* Alternative ifname */
|
||||||
|
IFLA_PERM_ADDRESS,
|
||||||
__IFLA_MAX
|
__IFLA_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1041,6 +1041,7 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev,
|
||||||
+ nla_total_size(4) /* IFLA_MIN_MTU */
|
+ nla_total_size(4) /* IFLA_MIN_MTU */
|
||||||
+ nla_total_size(4) /* IFLA_MAX_MTU */
|
+ nla_total_size(4) /* IFLA_MAX_MTU */
|
||||||
+ rtnl_prop_list_size(dev)
|
+ rtnl_prop_list_size(dev)
|
||||||
|
+ nla_total_size(MAX_ADDR_LEN) /* IFLA_PERM_ADDRESS */
|
||||||
+ 0;
|
+ 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1757,6 +1758,9 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb,
|
||||||
nla_put_s32(skb, IFLA_NEW_IFINDEX, new_ifindex) < 0)
|
nla_put_s32(skb, IFLA_NEW_IFINDEX, new_ifindex) < 0)
|
||||||
goto nla_put_failure;
|
goto nla_put_failure;
|
||||||
|
|
||||||
|
if (memchr_inv(dev->perm_addr, '\0', dev->addr_len) &&
|
||||||
|
nla_put(skb, IFLA_PERM_ADDRESS, dev->addr_len, dev->perm_addr))
|
||||||
|
goto nla_put_failure;
|
||||||
|
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
if (rtnl_fill_link_af(skb, dev, ext_filter_mask))
|
if (rtnl_fill_link_af(skb, dev, ext_filter_mask))
|
||||||
|
@ -1822,6 +1826,7 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = {
|
||||||
[IFLA_PROP_LIST] = { .type = NLA_NESTED },
|
[IFLA_PROP_LIST] = { .type = NLA_NESTED },
|
||||||
[IFLA_ALT_IFNAME] = { .type = NLA_STRING,
|
[IFLA_ALT_IFNAME] = { .type = NLA_STRING,
|
||||||
.len = ALTIFNAMSIZ - 1 },
|
.len = ALTIFNAMSIZ - 1 },
|
||||||
|
[IFLA_PERM_ADDRESS] = { .type = NLA_REJECT },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = {
|
static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue