diff mbox series

[net-next,v5,03/22] netlink: add strict version of nla_parse_nested()

Message ID 3a0ca34890256f86a4ca0c4f4582a0cff5af95ad.1553532199.git.mkubecek@suse.cz
State Changes Requested
Delegated to: David Miller
Headers show
Series ethtool netlink interface, part 1 | expand

Commit Message

Michal Kubecek March 25, 2019, 5:08 p.m. UTC
Similar to nla_parse_strict() and nlmsg_parse_strict(), add also
nla_parse_nested_strict() as a version of nla_parse_nested() with strict
policy checking.

Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
 include/net/netlink.h | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Jiri Pirko March 26, 2019, 10:11 a.m. UTC | #1
Mon, Mar 25, 2019 at 06:08:03PM CET, mkubecek@suse.cz wrote:
>Similar to nla_parse_strict() and nlmsg_parse_strict(), add also
>nla_parse_nested_strict() as a version of nla_parse_nested() with strict
>policy checking.
>
>Signed-off-by: Michal Kubecek <mkubecek@suse.cz>

Acked-by: Jiri Pirko <jiri@mellanox.com>
Florian Fainelli March 28, 2019, 1:57 a.m. UTC | #2
On 3/25/2019 10:08 AM, Michal Kubecek wrote:
> Similar to nla_parse_strict() and nlmsg_parse_strict(), add also
> nla_parse_nested_strict() as a version of nla_parse_nested() with strict
> policy checking.
> 
> Signed-off-by: Michal Kubecek <mkubecek@suse.cz>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
diff mbox series

Patch

diff --git a/include/net/netlink.h b/include/net/netlink.h
index bc0497076bec..723139637ba4 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -913,6 +913,15 @@  static inline int nla_parse_nested(struct nlattr *tb[], int maxtype,
 			 extack);
 }
 
+static inline int nla_parse_nested_strict(struct nlattr *tb[], int maxtype,
+					  const struct nlattr *nla,
+					  const struct nla_policy *policy,
+					  struct netlink_ext_ack *extack)
+{
+	return nla_parse_strict(tb, maxtype, nla_data(nla), nla_len(nla),
+				policy, extack);
+}
+
 /**
  * nla_put_u8 - Add a u8 netlink attribute to a socket buffer
  * @skb: socket buffer to add attribute to