Message ID | 7c28b1aa87436515de39e04206db36f6f374dc2f.1575982069.git.mkubecek@suse.cz |
---|---|
State | Superseded |
Delegated to: | David Miller |
Headers | show |
Series | ethtool netlink interface, preliminary part | expand |
On Tue, 10 Dec 2019 14:07:53 +0100 (CET), Michal Kubecek wrote: > @@ -1822,6 +1826,7 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = { > [IFLA_PROP_LIST] = { .type = NLA_NESTED }, > [IFLA_ALT_IFNAME] = { .type = NLA_STRING, > .len = ALTIFNAMSIZ - 1 }, > + [IFLA_PERM_ADDRESS] = { .type = NLA_REJECT }, > }; > > static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = { Jiri, I just noticed ifla_policy didn't get strict_start_type set when ALT_IFNAME was added, should we add it in net? 🤔
Tue, Dec 10, 2019 at 06:51:05PM CET, jakub.kicinski@netronome.com wrote: >On Tue, 10 Dec 2019 14:07:53 +0100 (CET), Michal Kubecek wrote: >> @@ -1822,6 +1826,7 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = { >> [IFLA_PROP_LIST] = { .type = NLA_NESTED }, >> [IFLA_ALT_IFNAME] = { .type = NLA_STRING, >> .len = ALTIFNAMSIZ - 1 }, >> + [IFLA_PERM_ADDRESS] = { .type = NLA_REJECT }, >> }; >> >> static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = { > >Jiri, I just noticed ifla_policy didn't get strict_start_type set when >ALT_IFNAME was added, should we add it in net? 🤔 Hmm, I guess that is a good idea.
On Tue, 2019-12-10 at 09:51 -0800, Jakub Kicinski wrote: > On Tue, 10 Dec 2019 14:07:53 +0100 (CET), Michal Kubecek wrote: > > @@ -1822,6 +1826,7 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = { > > [IFLA_PROP_LIST] = { .type = NLA_NESTED }, > > [IFLA_ALT_IFNAME] = { .type = NLA_STRING, > > .len = ALTIFNAMSIZ - 1 }, > > + [IFLA_PERM_ADDRESS] = { .type = NLA_REJECT }, > > }; > > > > static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = { > > Jiri, I just noticed ifla_policy didn't get strict_start_type set when > ALT_IFNAME was added, should we add it in net? 🤔 Does it need one? It shouldn't be used with nla_parse_nested_deprecated(), and if it's used with nla_parse_nested() then it doesn't matter? johannes
On Tue, 2019-12-10 at 21:22 +0100, Johannes Berg wrote: > On Tue, 2019-12-10 at 09:51 -0800, Jakub Kicinski wrote: > > On Tue, 10 Dec 2019 14:07:53 +0100 (CET), Michal Kubecek wrote: > > > @@ -1822,6 +1826,7 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = { > > > [IFLA_PROP_LIST] = { .type = NLA_NESTED }, > > > [IFLA_ALT_IFNAME] = { .type = NLA_STRING, > > > .len = ALTIFNAMSIZ - 1 }, > > > + [IFLA_PERM_ADDRESS] = { .type = NLA_REJECT }, > > > }; > > > > > > static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = { > > > > Jiri, I just noticed ifla_policy didn't get strict_start_type set when > > ALT_IFNAME was added, should we add it in net? 🤔 > > Does it need one? It shouldn't be used with > nla_parse_nested_deprecated(), and if it's used with nla_parse_nested() > then it doesn't matter? No, wait. I misread, you said "when ALT_IFNAME was added" but somehow I managed to read "when it was added"... So yeah, it should have one. Dunno about net, your call. I'd probably not bother for an NLA_REJECT attribute, there's little use including it anyway. johannes
On 12/10/19 1:23 PM, Johannes Berg wrote: > On Tue, 2019-12-10 at 21:22 +0100, Johannes Berg wrote: >> On Tue, 2019-12-10 at 09:51 -0800, Jakub Kicinski wrote: >>> On Tue, 10 Dec 2019 14:07:53 +0100 (CET), Michal Kubecek wrote: >>>> @@ -1822,6 +1826,7 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = { >>>> [IFLA_PROP_LIST] = { .type = NLA_NESTED }, >>>> [IFLA_ALT_IFNAME] = { .type = NLA_STRING, >>>> .len = ALTIFNAMSIZ - 1 }, >>>> + [IFLA_PERM_ADDRESS] = { .type = NLA_REJECT }, >>>> }; >>>> >>>> static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = { >>> >>> Jiri, I just noticed ifla_policy didn't get strict_start_type set when >>> ALT_IFNAME was added, should we add it in net? 🤔 >> >> Does it need one? It shouldn't be used with >> nla_parse_nested_deprecated(), and if it's used with nla_parse_nested() >> then it doesn't matter? > > No, wait. I misread, you said "when ALT_IFNAME was added" but somehow I > managed to read "when it was added"... > > So yeah, it should have one. Dunno about net, your call. I'd probably > not bother for an NLA_REJECT attribute, there's little use including it > anyway. > It's new in net, so it has to be there not net-next.
On Tue, 2019-12-10 at 13:27 -0700, David Ahern wrote: > On 12/10/19 1:23 PM, Johannes Berg wrote: > > On Tue, 2019-12-10 at 21:22 +0100, Johannes Berg wrote: > > > On Tue, 2019-12-10 at 09:51 -0800, Jakub Kicinski wrote: > > > > On Tue, 10 Dec 2019 14:07:53 +0100 (CET), Michal Kubecek wrote: > > > > > @@ -1822,6 +1826,7 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = { > > > > > [IFLA_PROP_LIST] = { .type = NLA_NESTED }, > > > > > [IFLA_ALT_IFNAME] = { .type = NLA_STRING, > > > > > .len = ALTIFNAMSIZ - 1 }, > > > > > + [IFLA_PERM_ADDRESS] = { .type = NLA_REJECT }, > > > > > }; > > > > > > > > > > static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = { > > > > > > > > Jiri, I just noticed ifla_policy didn't get strict_start_type set when > > > > ALT_IFNAME was added, should we add it in net? 🤔 > > > > > > Does it need one? It shouldn't be used with > > > nla_parse_nested_deprecated(), and if it's used with nla_parse_nested() > > > then it doesn't matter? > > > > No, wait. I misread, you said "when ALT_IFNAME was added" but somehow I > > managed to read "when it was added"... > > > > So yeah, it should have one. Dunno about net, your call. I'd probably > > not bother for an NLA_REJECT attribute, there's little use including it > > anyway. > > > > It's new in net, so it has to be there not net-next. Oh, ok. Well, I was actually thinking to just add it on the next attribute or so, but I guess now that we're discussing it there's a higher chance of it actually happening :) johannes
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index 8aec8769d944..1d69f637c5d6 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h @@ -169,6 +169,7 @@ enum { IFLA_MAX_MTU, IFLA_PROP_LIST, IFLA_ALT_IFNAME, /* Alternative ifname */ + IFLA_PERM_ADDRESS, __IFLA_MAX }; diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 02916f43bf63..20bc406f3871 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -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_MAX_MTU */ + rtnl_prop_list_size(dev) + + nla_total_size(MAX_ADDR_LEN) /* IFLA_PERM_ADDRESS */ + 0; } @@ -1757,6 +1758,9 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, nla_put_s32(skb, IFLA_NEW_IFINDEX, new_ifindex) < 0) 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(); 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_ALT_IFNAME] = { .type = NLA_STRING, .len = ALTIFNAMSIZ - 1 }, + [IFLA_PERM_ADDRESS] = { .type = NLA_REJECT }, }; static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = {