Commit 5cd5724b authored by Daniel Borkmann's avatar Daniel Borkmann Committed by Sasha Levin

ipv6: addrconf: add missing validate_link_af handler

[ Upstream commit 11b1f828 ]

We still need a validate_link_af() handler with an appropriate nla policy,
similarly as we have in IPv4 case, otherwise size validations are not being
done properly in that case.

Fixes: f53adae4 ("net: ipv6: add tokenized interface identifier support")
Fixes: bc91b0f0 ("ipv6: addrconf: implement address generation modes")
Cc: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarJiri Pirko <jiri@resnulli.us>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sasha.levin@oracle.com>
parent a7dc52c7
...@@ -4536,6 +4536,22 @@ static int inet6_set_iftoken(struct inet6_dev *idev, struct in6_addr *token) ...@@ -4536,6 +4536,22 @@ static int inet6_set_iftoken(struct inet6_dev *idev, struct in6_addr *token)
return 0; return 0;
} }
static const struct nla_policy inet6_af_policy[IFLA_INET6_MAX + 1] = {
[IFLA_INET6_ADDR_GEN_MODE] = { .type = NLA_U8 },
[IFLA_INET6_TOKEN] = { .len = sizeof(struct in6_addr) },
};
static int inet6_validate_link_af(const struct net_device *dev,
const struct nlattr *nla)
{
struct nlattr *tb[IFLA_INET6_MAX + 1];
if (dev && !__in6_dev_get(dev))
return -EAFNOSUPPORT;
return nla_parse_nested(tb, IFLA_INET6_MAX, nla, inet6_af_policy);
}
static int inet6_set_link_af(struct net_device *dev, const struct nlattr *nla) static int inet6_set_link_af(struct net_device *dev, const struct nlattr *nla)
{ {
int err = -EINVAL; int err = -EINVAL;
...@@ -5351,6 +5367,7 @@ static struct rtnl_af_ops inet6_ops = { ...@@ -5351,6 +5367,7 @@ static struct rtnl_af_ops inet6_ops = {
.family = AF_INET6, .family = AF_INET6,
.fill_link_af = inet6_fill_link_af, .fill_link_af = inet6_fill_link_af,
.get_link_af_size = inet6_get_link_af_size, .get_link_af_size = inet6_get_link_af_size,
.validate_link_af = inet6_validate_link_af,
.set_link_af = inet6_set_link_af, .set_link_af = inet6_set_link_af,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment