diff options
author | Andrei Vagin <avagin@gmail.com> | 2021-04-07 08:40:03 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2021-04-07 23:42:12 +0200 |
commit | 7e4a51319d3a71ac8002c96f817bcbeb36789b07 (patch) | |
tree | b0d76fad49603063e1cb6f1d0002ce9b78a7e1ea /net/core | |
parent | Merge tag 'mlx5-updates-2021-04-06' of git://git.kernel.org/pub/scm/linux/ker... (diff) | |
download | linux-7e4a51319d3a71ac8002c96f817bcbeb36789b07.tar.xz linux-7e4a51319d3a71ac8002c96f817bcbeb36789b07.zip |
net: introduce nla_policy for IFLA_NEW_IFINDEX
In this case, we don't need to check that new_ifindex is positive in
validate_linkmsg.
Fixes: eeb85a14ee34 ("net: Allow to specify ifindex when device is moved to another namespace")
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
Acked-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/rtnetlink.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index d51252afde0a..9108a7e6c0c0 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -1877,6 +1877,7 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = { .len = ALTIFNAMSIZ - 1 }, [IFLA_PERM_ADDRESS] = { .type = NLA_REJECT }, [IFLA_PROTO_DOWN_REASON] = { .type = NLA_NESTED }, + [IFLA_NEW_IFINDEX] = NLA_POLICY_MIN(NLA_S32, 1), }; static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = { @@ -2266,9 +2267,6 @@ static int validate_linkmsg(struct net_device *dev, struct nlattr *tb[]) return -EINVAL; } - if (tb[IFLA_NEW_IFINDEX] && nla_get_s32(tb[IFLA_NEW_IFINDEX]) <= 0) - return -EINVAL; - if (tb[IFLA_AF_SPEC]) { struct nlattr *af; int rem, err; |