@@ -538,6 +538,31 @@ nlmsg_next(const struct nlmsghdr *nlh, int *remaining)
538538 return (struct nlmsghdr * ) ((unsigned char * ) nlh + totlen );
539539}
540540
541+ /**
542+ * nla_parse - Parse a stream of attributes into a tb buffer
543+ * @tb: destination array with maxtype+1 elements
544+ * @maxtype: maximum attribute type to be expected
545+ * @head: head of attribute stream
546+ * @len: length of attribute stream
547+ * @policy: validation policy
548+ * @extack: extended ACK pointer
549+ *
550+ * Parses a stream of attributes and stores a pointer to each attribute in
551+ * the tb array accessible via the attribute type. Attributes with a type
552+ * exceeding maxtype will be rejected, policy must be specified, attributes
553+ * will be validated in the strictest way possible.
554+ *
555+ * Returns 0 on success or a negative error code.
556+ */
557+ static inline int nla_parse (struct nlattr * * tb , int maxtype ,
558+ const struct nlattr * head , int len ,
559+ const struct nla_policy * policy ,
560+ struct netlink_ext_ack * extack )
561+ {
562+ return __nla_parse (tb , maxtype , head , len , policy ,
563+ NL_VALIDATE_STRICT , extack );
564+ }
565+
541566/**
542567 * nla_parse_deprecated - Parse a stream of attributes into a tb buffer
543568 * @tb: destination array with maxtype+1 elements
@@ -617,6 +642,27 @@ static inline int __nlmsg_parse(const struct nlmsghdr *nlh, int hdrlen,
617642 extack );
618643}
619644
645+ /**
646+ * nlmsg_parse - parse attributes of a netlink message
647+ * @nlh: netlink message header
648+ * @hdrlen: length of family specific header
649+ * @tb: destination array with maxtype+1 elements
650+ * @maxtype: maximum attribute type to be expected
651+ * @validate: validation strictness
652+ * @extack: extended ACK report struct
653+ *
654+ * See nla_parse()
655+ */
656+ static inline int nlmsg_parse (const struct nlmsghdr * nlh , int hdrlen ,
657+ struct nlattr * tb [], int maxtype ,
658+ const struct nla_policy * policy ,
659+ struct netlink_ext_ack * extack )
660+ {
661+ return __nla_parse (tb , maxtype , nlmsg_attrdata (nlh , hdrlen ),
662+ nlmsg_attrlen (nlh , hdrlen ), policy ,
663+ NL_VALIDATE_STRICT , extack );
664+ }
665+
620666/**
621667 * nlmsg_parse_deprecated - parse attributes of a netlink message
622668 * @nlh: netlink message header
@@ -695,6 +741,28 @@ static inline int nla_validate_deprecated(const struct nlattr *head, int len,
695741 extack );
696742}
697743
744+ /**
745+ * nla_validate - Validate a stream of attributes
746+ * @head: head of attribute stream
747+ * @len: length of attribute stream
748+ * @maxtype: maximum attribute type to be expected
749+ * @policy: validation policy
750+ * @validate: validation strictness
751+ * @extack: extended ACK report struct
752+ *
753+ * Validates all attributes in the specified attribute stream against the
754+ * specified policy. Validation is done in strict mode.
755+ * See documenation of struct nla_policy for more details.
756+ *
757+ * Returns 0 on success or a negative error code.
758+ */
759+ static inline int nla_validate (const struct nlattr * head , int len , int maxtype ,
760+ const struct nla_policy * policy ,
761+ struct netlink_ext_ack * extack )
762+ {
763+ return __nla_validate (head , len , maxtype , policy , NL_VALIDATE_STRICT ,
764+ extack );
765+ }
698766
699767/**
700768 * nlmsg_validate_deprecated - validate a netlink message including attributes
@@ -1031,6 +1099,25 @@ nla_find_nested(const struct nlattr *nla, int attrtype)
10311099 return nla_find (nla_data (nla ), nla_len (nla ), attrtype );
10321100}
10331101
1102+ /**
1103+ * nla_parse_nested - parse nested attributes
1104+ * @tb: destination array with maxtype+1 elements
1105+ * @maxtype: maximum attribute type to be expected
1106+ * @nla: attribute containing the nested attributes
1107+ * @policy: validation policy
1108+ * @extack: extended ACK report struct
1109+ *
1110+ * See nla_parse()
1111+ */
1112+ static inline int nla_parse_nested (struct nlattr * tb [], int maxtype ,
1113+ const struct nlattr * nla ,
1114+ const struct nla_policy * policy ,
1115+ struct netlink_ext_ack * extack )
1116+ {
1117+ return __nla_parse (tb , maxtype , nla_data (nla ), nla_len (nla ), policy ,
1118+ NL_VALIDATE_STRICT , extack );
1119+ }
1120+
10341121/**
10351122 * nla_parse_nested_deprecated - parse nested attributes
10361123 * @tb: destination array with maxtype+1 elements
0 commit comments