diff options
author | Parav Pandit <parav@nvidia.com> | 2020-09-21 19:41:29 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-09-22 17:38:42 -0700 |
commit | ba356c90985defec30c8680077bf571a50a4004b (patch) | |
tree | 385db55b763ff0c6cb38d98941e4dca0f2a21f2f /net/core | |
parent | 3ab0a7a0c349a1d7beb2bb371a62669d1528269d (diff) | |
download | linux-ba356c90985defec30c8680077bf571a50a4004b.tar.bz2 |
devlink: Enhance policy to validate eswitch mode value
Use range checking facility of nla_policy to validate eswitch mode input
attribute value is valid or not.
Signed-off-by: Parav Pandit <parav@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/devlink.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/net/core/devlink.c b/net/core/devlink.c index 045468390480..b0b3af3ef355 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -7064,7 +7064,8 @@ static const struct nla_policy devlink_nl_policy[DEVLINK_ATTR_MAX + 1] = { [DEVLINK_ATTR_SB_POOL_THRESHOLD_TYPE] = { .type = NLA_U8 }, [DEVLINK_ATTR_SB_THRESHOLD] = { .type = NLA_U32 }, [DEVLINK_ATTR_SB_TC_INDEX] = { .type = NLA_U16 }, - [DEVLINK_ATTR_ESWITCH_MODE] = { .type = NLA_U16 }, + [DEVLINK_ATTR_ESWITCH_MODE] = NLA_POLICY_RANGE(NLA_U16, DEVLINK_ESWITCH_MODE_LEGACY, + DEVLINK_ESWITCH_MODE_SWITCHDEV), [DEVLINK_ATTR_ESWITCH_INLINE_MODE] = { .type = NLA_U8 }, [DEVLINK_ATTR_ESWITCH_ENCAP_MODE] = { .type = NLA_U8 }, [DEVLINK_ATTR_DPIPE_TABLE_NAME] = { .type = NLA_NUL_STRING }, |