Lines Matching +full:attribute +full:- +full:set
1 /* SPDX-License-Identifier: GPL-2.0 */
12 * ------------------------------------------------------------------------
14 * ------------------------------------------------------------------------
17 * <--- nlmsg_total_size(payload) --->
18 * <-- nlmsg_msg_size(payload) ->
19 * +----------+- - -+-------------+- - -+-------- - -
21 * +----------+- - -+-------------+- - -+-------- - -
22 * nlmsg_data(nlh)---^ ^
23 * nlmsg_next(nlh)-----------------------+
26 * <---------------------- nlmsg_len(nlh) --------------------->
27 * <------ hdrlen ------> <- nlmsg_attrlen(nlh, hdrlen) ->
28 * +----------------------+- - -+--------------------------------+
30 * +----------------------+- - -+--------------------------------+
31 * nlmsg_attrdata(nlh, hdrlen)---^
67 * nlmsg_find_attr() find an attribute in a message
75 * ------------------------------------------------------------------------
77 * ------------------------------------------------------------------------
79 * Attribute Format:
80 * <------- nla_total_size(payload) ------->
81 * <---- nla_attr_size(payload) ----->
82 * +----------+- - -+- - - - - - - - - +- - -+-------- - -
84 * +----------+- - -+- - - - - - - - - +- - -+-------- - -
85 * <- nla_len(nla) -> ^
86 * nla_data(nla)----^ |
87 * nla_next(nla)-----------------------------'
90 * struct nlattr netlink attribute header
92 * Attribute Construction:
93 * nla_reserve(skb, type, len) reserve room for an attribute
94 * nla_reserve_nohdr(skb, len) reserve room for an attribute w/o hdr
95 * nla_put(skb, type, len, data) add attribute to skb
96 * nla_put_nohdr(skb, len, data) add attribute w/o hdr
99 * Attribute Construction for Basic Types:
100 * nla_put_u8(skb, type, value) add u8 attribute to skb
101 * nla_put_u16(skb, type, value) add u16 attribute to skb
102 * nla_put_u32(skb, type, value) add u32 attribute to skb
104 * value, padattr) add u64 attribute to skb
105 * nla_put_s8(skb, type, value) add s8 attribute to skb
106 * nla_put_s16(skb, type, value) add s16 attribute to skb
107 * nla_put_s32(skb, type, value) add s32 attribute to skb
109 * padattr) add s64 attribute to skb
110 * nla_put_string(skb, type, str) add string attribute to skb
111 * nla_put_flag(skb, type) add flag attribute to skb
113 * padattr) add msecs attribute to skb
114 * nla_put_in_addr(skb, type, addr) add IPv4 address attribute to skb
115 * nla_put_in6_addr(skb, type, addr) add IPv6 address attribute to skb
118 * nla_nest_start(skb, type) start a nested attribute
119 * nla_nest_end(skb, nla) finalize a nested attribute
120 * nla_nest_cancel(skb, nla) cancel nested attribute construction
122 * Attribute Length Calculations:
123 * nla_attr_size(payload) length of attribute w/o padding
124 * nla_total_size(payload) length of attribute w/ padding
127 * Attribute Payload Access:
128 * nla_data(nla) head of attribute payload
129 * nla_len(nla) length of attribute payload
131 * Attribute Payload Access for Basic Types:
132 * nla_get_uint(nla) get payload for a uint attribute
133 * nla_get_sint(nla) get payload for a sint attribute
134 * nla_get_u8(nla) get payload for a u8 attribute
135 * nla_get_u16(nla) get payload for a u16 attribute
136 * nla_get_u32(nla) get payload for a u32 attribute
137 * nla_get_u64(nla) get payload for a u64 attribute
138 * nla_get_s8(nla) get payload for a s8 attribute
139 * nla_get_s16(nla) get payload for a s16 attribute
140 * nla_get_s32(nla) get payload for a s32 attribute
141 * nla_get_s64(nla) get payload for a s64 attribute
143 * nla_get_msecs(nla) get payload for a msecs attribute
145 * Attribute Misc:
146 * nla_memcpy(dest, nla, count) copy attribute into memory
147 * nla_memcmp(nla, data, size) compare attribute with memory area
148 * nla_strscpy(dst, nla, size) copy attribute to a sized string
149 * nla_strcmp(nla, str) compare attribute with string
151 * Attribute Parsing:
153 * nla_next(nla, remaining) get next netlink attribute
156 * nla_find() find attribute in stream of attributes
157 * nla_find_nested() find attribute in nested attributes
170 * Standard attribute types to specify validation policy
198 #define NLA_TYPE_MAX (__NLA_TYPE_MAX - 1)
220 * struct nla_policy - attribute validation policy
221 * @type: Type of attribute or NLA_UNSPEC
222 * @validation_type: type of attribute validation done in addition to
223 * type-specific validation (e.g. range, function call), see
228 * accessible by attribute type up to the highest identifier to be expected.
234 * NLA_BINARY Maximum length of attribute payload
252 * All other Minimum length of attribute payload
255 * NLA_BITFIELD32 This is a 32-bit bitmap/bitselector attribute and
257 * NLA_REJECT This attribute is always rejected and `reject_message'
261 * also set `len' to the max attribute number. Use the
264 * parse, the nested sub-policies.
266 * must also set `len' to the max attribute number. Use
271 * level down and the attribute types directly in the
287 * the value of the integer attribute.
291 * of s16 - do that using the NLA_POLICY_FULL_RANGE()
299 * NLA_U64 If the validation_type field instead is set to
308 * NLA_S64 If the validation_type field instead is set to
316 * integers) of the attribute is enforced.
318 * All other Unused - but note that it's a union
321 * NLA_BINARY Validation function called for the attribute.
322 * All other Unused - but note that it's a union
341 * @strict_start_type: first attribute to validate strictly
343 * This entry is special, and used for the attribute at index 0
346 * starts for any attribute types >= this value, also, strict
355 * For completely new families it should be set to 1 so that the
357 * it should be set at least when new attributes are added to
358 * the enum used by the policy, and be set to the new value that
363 /* private: use NLA_POLICY_*() to set */
386 _NLA_POLICY_NESTED(ARRAY_SIZE(policy) - 1, policy)
388 _NLA_POLICY_NESTED_ARRAY(ARRAY_SIZE(policy) - 1, policy)
474 * struct nl_info - netlink source information
479 * @skip_notify_kernel: Skip selected in-kernel notifications
490 * enum netlink_validation - netlink message/attribute validation levels
491 * @NL_VALIDATE_LIBERAL: Old-style "be liberal" validation, not caring about
494 * @NL_VALIDATE_TRAILING: Reject junk data encountered after attribute parsing.
498 * This can safely be set by the kernel when the given policy has no
501 * @NL_VALIDATE_STRICT_ATTRS: strict attribute policy parsing (e.g.
503 * @NL_VALIDATE_NESTED: Check that NLA_F_NESTED is set for NLA_NESTED(_ARRAY)
566 * nlmsg_msg_size - length of netlink message not including padding
575 * nlmsg_total_size - length of netlink message including padding
584 * nlmsg_padlen - length of padding at the message's tail
589 return nlmsg_total_size(payload) - nlmsg_msg_size(payload); in nlmsg_padlen()
593 * nlmsg_data - head of message payload
602 * nlmsg_len - length of message payload
607 return nlh->nlmsg_len - NLMSG_HDRLEN; in nlmsg_len()
611 * nlmsg_attrdata - head of attributes data
623 * nlmsg_attrlen - length of attributes data
629 return nlmsg_len(nlh) - NLMSG_ALIGN(hdrlen); in nlmsg_attrlen()
633 * nlmsg_ok - check if the netlink message fits into the remaining bytes
640 nlh->nlmsg_len >= sizeof(struct nlmsghdr) && in nlmsg_ok()
641 nlh->nlmsg_len <= remaining); in nlmsg_ok()
645 * nlmsg_next - next netlink message in message stream
655 int totlen = NLMSG_ALIGN(nlh->nlmsg_len); in nlmsg_next()
657 *remaining -= totlen; in nlmsg_next()
663 * nla_parse - Parse a stream of attributes into a tb buffer
665 * @maxtype: maximum attribute type to be expected
666 * @head: head of attribute stream
667 * @len: length of attribute stream
671 * Parses a stream of attributes and stores a pointer to each attribute in
672 * the tb array accessible via the attribute type. Attributes with a type
688 * nla_parse_deprecated - Parse a stream of attributes into a tb buffer
690 * @maxtype: maximum attribute type to be expected
691 * @head: head of attribute stream
692 * @len: length of attribute stream
696 * Parses a stream of attributes and stores a pointer to each attribute in
697 * the tb array accessible via the attribute type. Attributes with a type
713 * nla_parse_deprecated_strict - Parse a stream of attributes into a tb buffer
715 * @maxtype: maximum attribute type to be expected
716 * @head: head of attribute stream
717 * @len: length of attribute stream
721 * Parses a stream of attributes and stores a pointer to each attribute in
722 * the tb array accessible via the attribute type. Attributes with a type
739 * __nlmsg_parse - parse attributes of a netlink message
743 * @maxtype: maximum attribute type to be expected
756 if (nlh->nlmsg_len < nlmsg_msg_size(hdrlen)) { in __nlmsg_parse()
758 return -EINVAL; in __nlmsg_parse()
767 * nlmsg_parse - parse attributes of a netlink message
771 * @maxtype: maximum attribute type to be expected
787 * nlmsg_parse_deprecated - parse attributes of a netlink message
791 * @maxtype: maximum attribute type to be expected
807 * nlmsg_parse_deprecated_strict - parse attributes of a netlink message
811 * @maxtype: maximum attribute type to be expected
828 * nlmsg_find_attr - find a specific attribute in a netlink message
831 * @attrtype: type of attribute to look for
833 * Returns the first attribute which matches the specified type.
843 * nla_validate_deprecated - Validate a stream of attributes
844 * @head: head of attribute stream
845 * @len: length of attribute stream
846 * @maxtype: maximum attribute type to be expected
850 * Validates all attributes in the specified attribute stream against the
866 * nla_validate - Validate a stream of attributes
867 * @head: head of attribute stream
868 * @len: length of attribute stream
869 * @maxtype: maximum attribute type to be expected
873 * Validates all attributes in the specified attribute stream against the
888 * nlmsg_validate_deprecated - validate a netlink message including attributes
891 * @maxtype: maximum attribute type to be expected
900 if (nlh->nlmsg_len < nlmsg_msg_size(hdrlen)) in nlmsg_validate_deprecated()
901 return -EINVAL; in nlmsg_validate_deprecated()
911 * nlmsg_report - need to report back to application?
918 return nlh ? !!(nlh->nlmsg_flags & NLM_F_ECHO) : 0; in nlmsg_report()
922 * nlmsg_seq - return the seq number of netlink message
929 return nlh ? nlh->nlmsg_seq : 0; in nlmsg_seq()
933 * nlmsg_for_each_attr - iterate over a stream of attributes
934 * @pos: loop counter, set to current attribute
944 * nlmsg_put - Add a new netlink message to an skb
965 * nlmsg_append - Add more data to a nlmsg in a skb
970 * with multiple fixed-format headers (which is rare).
979 if (NLMSG_ALIGN(size) - size) in nlmsg_append()
981 NLMSG_ALIGN(size) - size); in nlmsg_append()
986 * nlmsg_put_answer - Add a new callback based netlink message to an skb
1001 return nlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, in nlmsg_put_answer()
1006 * nlmsg_new - Allocate a new netlink message
1019 * nlmsg_new_large - Allocate a new netlink message with non-contiguous
1023 * The allocated skb is unable to have frag page for shinfo->frags*,
1024 * as the NULL setting for skb->head in netlink_skb_destructor() will
1033 * nlmsg_end - Finalize a netlink message
1043 nlh->nlmsg_len = skb_tail_pointer(skb) - (unsigned char *)nlh; in nlmsg_end()
1047 * nlmsg_get_pos - return current position in netlink message
1058 * nlmsg_trim - Trim message to a mark
1067 WARN_ON((unsigned char *) mark < skb->data); in nlmsg_trim()
1068 skb_trim(skb, (unsigned char *) mark - skb->data); in nlmsg_trim()
1073 * nlmsg_cancel - Cancel construction of a netlink message
1086 * nlmsg_free - drop a netlink message
1095 * nlmsg_consume - free a netlink message
1104 * nlmsg_multicast_filtered - multicast a netlink message with filter function
1134 * nlmsg_multicast - multicast a netlink message
1149 * nlmsg_unicast - unicast a netlink message
1166 * nlmsg_for_each_msg - iterate over a stream of messages
1167 * @pos: loop counter, set to current message
1178 * nl_dump_check_consistent - check if sequence is consistent and advertise if not
1185 * The correct way to use it is to set cb->seq to the generation counter when
1196 if (cb->prev_seq && cb->seq != cb->prev_seq) in nl_dump_check_consistent()
1197 nlh->nlmsg_flags |= NLM_F_DUMP_INTR; in nl_dump_check_consistent()
1198 cb->prev_seq = cb->seq; in nl_dump_check_consistent()
1206 * nla_attr_size - length of attribute not including padding
1215 * nla_total_size - total length of attribute including padding
1224 * nla_padlen - length of padding at the tail of attribute
1229 return nla_total_size(payload) - nla_attr_size(payload); in nla_padlen()
1233 * nla_type - attribute type
1234 * @nla: netlink attribute
1238 return nla->nla_type & NLA_TYPE_MASK; in nla_type()
1242 * nla_data - head of payload
1243 * @nla: netlink attribute
1251 * nla_len - length of payload
1252 * @nla: netlink attribute
1256 return nla->nla_len - NLA_HDRLEN; in nla_len()
1260 * nla_ok - check if the netlink attribute fits into the remaining bytes
1261 * @nla: netlink attribute
1262 * @remaining: number of bytes remaining in attribute stream
1267 nla->nla_len >= sizeof(*nla) && in nla_ok()
1268 nla->nla_len <= remaining; in nla_ok()
1272 * nla_next - next netlink attribute in attribute stream
1273 * @nla: netlink attribute
1274 * @remaining: number of bytes remaining in attribute stream
1276 * Returns the next netlink attribute in the attribute stream and
1277 * decrements remaining by the size of the current attribute.
1281 unsigned int totlen = NLA_ALIGN(nla->nla_len); in nla_next()
1283 *remaining -= totlen; in nla_next()
1288 * nla_find_nested - find attribute in a set of nested attributes
1289 * @nla: attribute containing the nested attributes
1290 * @attrtype: type of attribute to look for
1292 * Returns the first attribute which matches the specified type.
1301 * nla_parse_nested - parse nested attributes
1303 * @maxtype: maximum attribute type to be expected
1304 * @nla: attribute containing the nested attributes
1315 if (!(nla->nla_type & NLA_F_NESTED)) { in nla_parse_nested()
1317 return -EINVAL; in nla_parse_nested()
1325 * nla_parse_nested_deprecated - parse nested attributes
1327 * @maxtype: maximum attribute type to be expected
1328 * @nla: attribute containing the nested attributes
1344 * nla_put_u8 - Add a u8 netlink attribute to a socket buffer
1345 * @skb: socket buffer to add attribute to
1346 * @attrtype: attribute type
1351 /* temporary variables to work around GCC PR81715 with asan-stack=1 */ in nla_put_u8()
1358 * nla_put_u16 - Add a u16 netlink attribute to a socket buffer
1359 * @skb: socket buffer to add attribute to
1360 * @attrtype: attribute type
1371 * nla_put_be16 - Add a __be16 netlink attribute to a socket buffer
1372 * @skb: socket buffer to add attribute to
1373 * @attrtype: attribute type
1384 * nla_put_net16 - Add 16-bit network byte order netlink attribute to a socket buffer
1385 * @skb: socket buffer to add attribute to
1386 * @attrtype: attribute type
1397 * nla_put_le16 - Add a __le16 netlink attribute to a socket buffer
1398 * @skb: socket buffer to add attribute to
1399 * @attrtype: attribute type
1410 * nla_put_u32 - Add a u32 netlink attribute to a socket buffer
1411 * @skb: socket buffer to add attribute to
1412 * @attrtype: attribute type
1423 * nla_put_uint - Add a variable-size unsigned int to a socket buffer
1424 * @skb: socket buffer to add attribute to
1425 * @attrtype: attribute type
1439 * nla_put_be32 - Add a __be32 netlink attribute to a socket buffer
1440 * @skb: socket buffer to add attribute to
1441 * @attrtype: attribute type
1452 * nla_put_net32 - Add 32-bit network byte order netlink attribute to a socket buffer
1453 * @skb: socket buffer to add attribute to
1454 * @attrtype: attribute type
1465 * nla_put_le32 - Add a __le32 netlink attribute to a socket buffer
1466 * @skb: socket buffer to add attribute to
1467 * @attrtype: attribute type
1478 * nla_put_u64_64bit - Add a u64 netlink attribute to a skb and align it
1479 * @skb: socket buffer to add attribute to
1480 * @attrtype: attribute type
1482 * @padattr: attribute type for the padding
1493 * nla_put_be64 - Add a __be64 netlink attribute to a socket buffer and align it
1494 * @skb: socket buffer to add attribute to
1495 * @attrtype: attribute type
1497 * @padattr: attribute type for the padding
1508 * nla_put_net64 - Add 64-bit network byte order nlattr to a skb and align it
1509 * @skb: socket buffer to add attribute to
1510 * @attrtype: attribute type
1512 * @padattr: attribute type for the padding
1524 * nla_put_le64 - Add a __le64 netlink attribute to a socket buffer and align it
1525 * @skb: socket buffer to add attribute to
1526 * @attrtype: attribute type
1528 * @padattr: attribute type for the padding
1539 * nla_put_s8 - Add a s8 netlink attribute to a socket buffer
1540 * @skb: socket buffer to add attribute to
1541 * @attrtype: attribute type
1552 * nla_put_s16 - Add a s16 netlink attribute to a socket buffer
1553 * @skb: socket buffer to add attribute to
1554 * @attrtype: attribute type
1565 * nla_put_s32 - Add a s32 netlink attribute to a socket buffer
1566 * @skb: socket buffer to add attribute to
1567 * @attrtype: attribute type
1578 * nla_put_s64 - Add a s64 netlink attribute to a socket buffer and align it
1579 * @skb: socket buffer to add attribute to
1580 * @attrtype: attribute type
1582 * @padattr: attribute type for the padding
1593 * nla_put_sint - Add a variable-size signed int to a socket buffer
1594 * @skb: socket buffer to add attribute to
1595 * @attrtype: attribute type
1609 * nla_put_string - Add a string netlink attribute to a socket buffer
1610 * @skb: socket buffer to add attribute to
1611 * @attrtype: attribute type
1621 * nla_put_flag - Add a flag netlink attribute to a socket buffer
1622 * @skb: socket buffer to add attribute to
1623 * @attrtype: attribute type
1631 * nla_put_msecs - Add a msecs netlink attribute to a skb and align it
1632 * @skb: socket buffer to add attribute to
1633 * @attrtype: attribute type
1635 * @padattr: attribute type for the padding
1646 * nla_put_in_addr - Add an IPv4 address netlink attribute to a socket
1648 * @skb: socket buffer to add attribute to
1649 * @attrtype: attribute type
1661 * nla_put_in6_addr - Add an IPv6 address netlink attribute to a socket
1663 * @skb: socket buffer to add attribute to
1664 * @attrtype: attribute type
1674 * nla_put_bitfield32 - Add a bitfield32 netlink attribute to a socket buffer
1675 * @skb: socket buffer to add attribute to
1676 * @attrtype: attribute type
1689 * nla_get_u32 - return payload of u32 attribute
1690 * @nla: u32 netlink attribute
1698 * nla_get_be32 - return payload of __be32 attribute
1699 * @nla: __be32 netlink attribute
1707 * nla_get_le32 - return payload of __le32 attribute
1708 * @nla: __le32 netlink attribute
1716 * nla_get_u16 - return payload of u16 attribute
1717 * @nla: u16 netlink attribute
1725 * nla_get_be16 - return payload of __be16 attribute
1726 * @nla: __be16 netlink attribute
1734 * nla_get_le16 - return payload of __le16 attribute
1735 * @nla: __le16 netlink attribute
1743 * nla_get_u8 - return payload of u8 attribute
1744 * @nla: u8 netlink attribute
1752 * nla_get_u64 - return payload of u64 attribute
1753 * @nla: u64 netlink attribute
1765 * nla_get_uint - return payload of uint attribute
1766 * @nla: uint netlink attribute
1776 * nla_get_be64 - return payload of __be64 attribute
1777 * @nla: __be64 netlink attribute
1789 * nla_get_le64 - return payload of __le64 attribute
1790 * @nla: __le64 netlink attribute
1798 * nla_get_s32 - return payload of s32 attribute
1799 * @nla: s32 netlink attribute
1807 * nla_get_s16 - return payload of s16 attribute
1808 * @nla: s16 netlink attribute
1816 * nla_get_s8 - return payload of s8 attribute
1817 * @nla: s8 netlink attribute
1825 * nla_get_s64 - return payload of s64 attribute
1826 * @nla: s64 netlink attribute
1838 * nla_get_sint - return payload of uint attribute
1839 * @nla: uint netlink attribute
1849 * nla_get_flag - return payload of flag attribute
1850 * @nla: flag netlink attribute
1858 * nla_get_msecs - return payload of msecs attribute
1859 * @nla: msecs netlink attribute
1871 * nla_get_in_addr - return payload of IPv4 address attribute
1872 * @nla: IPv4 address netlink attribute
1880 * nla_get_in6_addr - return payload of IPv6 address attribute
1881 * @nla: IPv6 address netlink attribute
1892 * nla_get_bitfield32 - return payload of 32 bitfield attribute
1893 * @nla: nla_bitfield32 attribute
1904 * nla_memdup - duplicate attribute memory (kmemdup)
1905 * @src: netlink attribute to duplicate from
1915 * nla_nest_start_noflag - Start a new level of nested attributes
1917 * @attrtype: attribute type of container
1923 * Returns the container attribute or NULL on error
1937 * nla_nest_start - Start a new level of nested attributes, with NLA_F_NESTED
1939 * @attrtype: attribute type of container
1941 * Unlike nla_nest_start_noflag(), mark the nest attribute with NLA_F_NESTED
1944 * Returns the container attribute or NULL on error
1952 * nla_nest_end - Finalize nesting of attributes
1954 * @start: container attribute
1956 * Corrects the container attribute header to include the all
1963 start->nla_len = skb_tail_pointer(skb) - (unsigned char *)start; in nla_nest_end()
1964 return skb->len; in nla_nest_end()
1968 * nla_nest_cancel - Cancel nesting of attributes
1970 * @start: container attribute
1972 * Removes the container attribute and including all nested
1973 * attributes. Returns -EMSGSIZE
1981 * __nla_validate_nested - Validate a stream of nested attributes
1982 * @start: container attribute
1983 * @maxtype: maximum attribute type to be expected
1988 * Validates all attributes in the nested attribute stream against the
2022 * nla_need_padding_for_64bit - test 64-bit alignment of the next attribute
2025 * Return true if padding is needed to align the next attribute (nla_data()) to
2026 * a 64-bit aligned area.
2032 * if the skb->data _is_ aligned. A NOP attribute, plus in nla_need_padding_for_64bit()
2033 * nlattr header for next attribute, will make nla_data() in nla_need_padding_for_64bit()
2034 * 8-byte aligned. in nla_need_padding_for_64bit()
2043 * nla_align_64bit - 64-bit align the nla_data() of next attribute
2045 * @padattr: attribute type for the padding
2047 * Conditionally emit a padding netlink attribute in order to make
2048 * the next attribute we emit have a 64-bit aligned nla_data() area.
2058 return -EMSGSIZE; in nla_align_64bit()
2064 * nla_total_size_64bit - total length of attribute including padding
2077 * nla_for_each_attr - iterate over a stream of attributes
2078 * @pos: loop counter, set to current attribute
2079 * @head: head of attribute stream
2080 * @len: length of attribute stream
2089 * nla_for_each_attr_type - iterate over a stream of attributes
2090 * @pos: loop counter, set to current attribute
2091 * @type: required attribute type for @pos
2092 * @head: head of attribute stream
2093 * @len: length of attribute stream
2101 * nla_for_each_nested - iterate over nested attributes
2102 * @pos: loop counter, set to current attribute
2103 * @nla: attribute containing the nested attributes
2110 * nla_for_each_nested_type - iterate over nested attributes
2111 * @pos: loop counter, set to current attribute
2112 * @type: required attribute type for @pos
2113 * @nla: attribute containing the nested attributes
2121 * nla_is_last - Test if attribute is last in stream
2122 * @nla: attribute to test
2127 return nla->nla_len == rem; in nla_is_last()