1 // SPDX-License-Identifier: GPL-2.0
3 * NETLINK Netlink attributes
9 #include <linux/export.h>
10 #include <linux/kernel.h>
11 #include <linux/errno.h>
12 #include <linux/jiffies.h>
13 #include <linux/skbuff.h>
14 #include <linux/string.h>
15 #include <linux/types.h>
16 #include <net/netlink.h>
18 /* For these data types, attribute length should be exactly the given
19 * size. However, to maintain compatibility with broken commands, if the
20 * attribute length does not match the expected size a warning is emitted
21 * to the user that the command is sending invalid data and needs to be fixed.
23 static const u8 nla_attr_len[NLA_TYPE_MAX+1] = {
24 [NLA_U8] = sizeof(u8),
25 [NLA_U16] = sizeof(u16),
26 [NLA_U32] = sizeof(u32),
27 [NLA_U64] = sizeof(u64),
28 [NLA_S8] = sizeof(s8),
29 [NLA_S16] = sizeof(s16),
30 [NLA_S32] = sizeof(s32),
31 [NLA_S64] = sizeof(s64),
34 static const u8 nla_attr_minlen[NLA_TYPE_MAX+1] = {
35 [NLA_U8] = sizeof(u8),
36 [NLA_U16] = sizeof(u16),
37 [NLA_U32] = sizeof(u32),
38 [NLA_U64] = sizeof(u64),
39 [NLA_MSECS] = sizeof(u64),
40 [NLA_NESTED] = NLA_HDRLEN,
41 [NLA_S8] = sizeof(s8),
42 [NLA_S16] = sizeof(s16),
43 [NLA_S32] = sizeof(s32),
44 [NLA_S64] = sizeof(s64),
48 * Nested policies might refer back to the original
49 * policy in some cases, and userspace could try to
50 * abuse that and recurse by nesting in the right
51 * ways. Limit recursion to avoid this problem.
53 #define MAX_POLICY_RECURSION_DEPTH 10
55 static int __nla_validate_parse(const struct nlattr *head, int len, int maxtype,
56 const struct nla_policy *policy,
57 unsigned int validate,
58 struct netlink_ext_ack *extack,
59 struct nlattr **tb, unsigned int depth);
61 static int validate_nla_bitfield32(const struct nlattr *nla,
62 const u32 valid_flags_mask)
64 const struct nla_bitfield32 *bf = nla_data(nla);
66 if (!valid_flags_mask)
69 /*disallow invalid bit selector */
70 if (bf->selector & ~valid_flags_mask)
73 /*disallow invalid bit values */
74 if (bf->value & ~valid_flags_mask)
77 /*disallow valid bit values that are not selected*/
78 if (bf->value & ~bf->selector)
84 static int nla_validate_array(const struct nlattr *head, int len, int maxtype,
85 const struct nla_policy *policy,
86 struct netlink_ext_ack *extack,
87 unsigned int validate, unsigned int depth)
89 const struct nlattr *entry;
92 nla_for_each_attr(entry, head, len, rem) {
95 if (nla_len(entry) == 0)
98 if (nla_len(entry) < NLA_HDRLEN) {
99 NL_SET_ERR_MSG_ATTR(extack, entry,
100 "Array element too short");
104 ret = __nla_validate_parse(nla_data(entry), nla_len(entry),
105 maxtype, policy, validate, extack,
114 void nla_get_range_unsigned(const struct nla_policy *pt,
115 struct netlink_range_validation *range)
117 WARN_ON_ONCE(pt->validation_type != NLA_VALIDATE_RANGE_PTR &&
118 (pt->min < 0 || pt->max < 0));
127 range->max = U16_MAX;
130 range->max = U32_MAX;
134 range->max = U64_MAX;
141 switch (pt->validation_type) {
142 case NLA_VALIDATE_RANGE:
143 range->min = pt->min;
144 range->max = pt->max;
146 case NLA_VALIDATE_RANGE_PTR:
149 case NLA_VALIDATE_MIN:
150 range->min = pt->min;
152 case NLA_VALIDATE_MAX:
153 range->max = pt->max;
160 static int nla_validate_int_range_unsigned(const struct nla_policy *pt,
161 const struct nlattr *nla,
162 struct netlink_ext_ack *extack)
164 struct netlink_range_validation range;
169 value = nla_get_u8(nla);
172 value = nla_get_u16(nla);
175 value = nla_get_u32(nla);
179 value = nla_get_u64(nla);
185 nla_get_range_unsigned(pt, &range);
187 if (value < range.min || value > range.max) {
188 NL_SET_ERR_MSG_ATTR(extack, nla,
189 "integer out of range");
196 void nla_get_range_signed(const struct nla_policy *pt,
197 struct netlink_range_validation_signed *range)
205 range->min = S16_MIN;
206 range->max = S16_MAX;
209 range->min = S32_MIN;
210 range->max = S32_MAX;
213 range->min = S64_MIN;
214 range->max = S64_MAX;
221 switch (pt->validation_type) {
222 case NLA_VALIDATE_RANGE:
223 range->min = pt->min;
224 range->max = pt->max;
226 case NLA_VALIDATE_RANGE_PTR:
227 *range = *pt->range_signed;
229 case NLA_VALIDATE_MIN:
230 range->min = pt->min;
232 case NLA_VALIDATE_MAX:
233 range->max = pt->max;
240 static int nla_validate_int_range_signed(const struct nla_policy *pt,
241 const struct nlattr *nla,
242 struct netlink_ext_ack *extack)
244 struct netlink_range_validation_signed range;
249 value = nla_get_s8(nla);
252 value = nla_get_s16(nla);
255 value = nla_get_s32(nla);
258 value = nla_get_s64(nla);
264 nla_get_range_signed(pt, &range);
266 if (value < range.min || value > range.max) {
267 NL_SET_ERR_MSG_ATTR(extack, nla,
268 "integer out of range");
275 static int nla_validate_int_range(const struct nla_policy *pt,
276 const struct nlattr *nla,
277 struct netlink_ext_ack *extack)
285 return nla_validate_int_range_unsigned(pt, nla, extack);
290 return nla_validate_int_range_signed(pt, nla, extack);
297 static int validate_nla(const struct nlattr *nla, int maxtype,
298 const struct nla_policy *policy, unsigned int validate,
299 struct netlink_ext_ack *extack, unsigned int depth)
301 u16 strict_start_type = policy[0].strict_start_type;
302 const struct nla_policy *pt;
303 int minlen = 0, attrlen = nla_len(nla), type = nla_type(nla);
306 if (strict_start_type && type >= strict_start_type)
307 validate |= NL_VALIDATE_STRICT;
309 if (type <= 0 || type > maxtype)
314 BUG_ON(pt->type > NLA_TYPE_MAX);
316 if ((nla_attr_len[pt->type] && attrlen != nla_attr_len[pt->type]) ||
317 (pt->type == NLA_EXACT_LEN &&
318 pt->validation_type == NLA_VALIDATE_WARN_TOO_LONG &&
319 attrlen != pt->len)) {
320 pr_warn_ratelimited("netlink: '%s': attribute type %d has an invalid length.\n",
321 current->comm, type);
322 if (validate & NL_VALIDATE_STRICT_ATTRS) {
323 NL_SET_ERR_MSG_ATTR(extack, nla,
324 "invalid attribute length");
329 if (validate & NL_VALIDATE_NESTED) {
330 if ((pt->type == NLA_NESTED || pt->type == NLA_NESTED_ARRAY) &&
331 !(nla->nla_type & NLA_F_NESTED)) {
332 NL_SET_ERR_MSG_ATTR(extack, nla,
333 "NLA_F_NESTED is missing");
336 if (pt->type != NLA_NESTED && pt->type != NLA_NESTED_ARRAY &&
337 pt->type != NLA_UNSPEC && (nla->nla_type & NLA_F_NESTED)) {
338 NL_SET_ERR_MSG_ATTR(extack, nla,
339 "NLA_F_NESTED not expected");
346 if (extack && pt->reject_message) {
347 NL_SET_BAD_ATTR(extack, nla);
348 extack->_msg = pt->reject_message;
360 if (attrlen != sizeof(struct nla_bitfield32))
363 err = validate_nla_bitfield32(nla, pt->bitfield32_valid);
370 minlen = min_t(int, attrlen, pt->len + 1);
374 if (!minlen || memchr(nla_data(nla), '\0', minlen) == NULL) {
385 char *buf = nla_data(nla);
387 if (buf[attrlen - 1] == '\0')
390 if (attrlen > pt->len)
396 if (pt->len && attrlen > pt->len)
401 /* a nested attributes is allowed to be empty; if its not,
402 * it must have a size of at least NLA_HDRLEN.
406 if (attrlen < NLA_HDRLEN)
408 if (pt->nested_policy) {
409 err = __nla_validate_parse(nla_data(nla), nla_len(nla),
410 pt->len, pt->nested_policy,
411 validate, extack, NULL,
415 * return directly to preserve the inner
416 * error message/attribute pointer
422 case NLA_NESTED_ARRAY:
423 /* a nested array attribute is allowed to be empty; if its not,
424 * it must have a size of at least NLA_HDRLEN.
428 if (attrlen < NLA_HDRLEN)
430 if (pt->nested_policy) {
433 err = nla_validate_array(nla_data(nla), nla_len(nla),
434 pt->len, pt->nested_policy,
435 extack, validate, depth);
438 * return directly to preserve the inner
439 * error message/attribute pointer
447 if (validate & NL_VALIDATE_UNSPEC) {
448 NL_SET_ERR_MSG_ATTR(extack, nla,
449 "Unsupported attribute");
454 if (attrlen < pt->len)
459 if (pt->validation_type != NLA_VALIDATE_WARN_TOO_LONG) {
460 if (attrlen != pt->len)
469 minlen = nla_attr_minlen[pt->type];
471 if (attrlen < minlen)
475 /* further validation */
476 switch (pt->validation_type) {
477 case NLA_VALIDATE_NONE:
480 case NLA_VALIDATE_RANGE_PTR:
481 case NLA_VALIDATE_RANGE:
482 case NLA_VALIDATE_MIN:
483 case NLA_VALIDATE_MAX:
484 err = nla_validate_int_range(pt, nla, extack);
488 case NLA_VALIDATE_FUNCTION:
490 err = pt->validate(nla, extack);
499 NL_SET_ERR_MSG_ATTR(extack, nla, "Attribute failed policy validation");
503 static int __nla_validate_parse(const struct nlattr *head, int len, int maxtype,
504 const struct nla_policy *policy,
505 unsigned int validate,
506 struct netlink_ext_ack *extack,
507 struct nlattr **tb, unsigned int depth)
509 const struct nlattr *nla;
512 if (depth >= MAX_POLICY_RECURSION_DEPTH) {
513 NL_SET_ERR_MSG(extack,
514 "allowed policy recursion depth exceeded");
519 memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1));
521 nla_for_each_attr(nla, head, len, rem) {
522 u16 type = nla_type(nla);
524 if (type == 0 || type > maxtype) {
525 if (validate & NL_VALIDATE_MAXTYPE) {
526 NL_SET_ERR_MSG_ATTR(extack, nla,
527 "Unknown attribute type");
533 int err = validate_nla(nla, maxtype, policy,
534 validate, extack, depth);
541 tb[type] = (struct nlattr *)nla;
544 if (unlikely(rem > 0)) {
545 pr_warn_ratelimited("netlink: %d bytes leftover after parsing attributes in process `%s'.\n",
547 NL_SET_ERR_MSG(extack, "bytes leftover after parsing attributes");
548 if (validate & NL_VALIDATE_TRAILING)
556 * __nla_validate - Validate a stream of attributes
557 * @head: head of attribute stream
558 * @len: length of attribute stream
559 * @maxtype: maximum attribute type to be expected
560 * @policy: validation policy
561 * @validate: validation strictness
562 * @extack: extended ACK report struct
564 * Validates all attributes in the specified attribute stream against the
565 * specified policy. Validation depends on the validate flags passed, see
566 * &enum netlink_validation for more details on that.
567 * See documenation of struct nla_policy for more details.
569 * Returns 0 on success or a negative error code.
571 int __nla_validate(const struct nlattr *head, int len, int maxtype,
572 const struct nla_policy *policy, unsigned int validate,
573 struct netlink_ext_ack *extack)
575 return __nla_validate_parse(head, len, maxtype, policy, validate,
578 EXPORT_SYMBOL(__nla_validate);
581 * nla_policy_len - Determin the max. length of a policy
582 * @policy: policy to use
583 * @n: number of policies
585 * Determines the max. length of the policy. It is currently used
586 * to allocated Netlink buffers roughly the size of the actual
589 * Returns 0 on success or a negative error code.
592 nla_policy_len(const struct nla_policy *p, int n)
596 for (i = 0; i < n; i++, p++) {
598 len += nla_total_size(p->len);
599 else if (nla_attr_len[p->type])
600 len += nla_total_size(nla_attr_len[p->type]);
601 else if (nla_attr_minlen[p->type])
602 len += nla_total_size(nla_attr_minlen[p->type]);
607 EXPORT_SYMBOL(nla_policy_len);
610 * __nla_parse - Parse a stream of attributes into a tb buffer
611 * @tb: destination array with maxtype+1 elements
612 * @maxtype: maximum attribute type to be expected
613 * @head: head of attribute stream
614 * @len: length of attribute stream
615 * @policy: validation policy
616 * @validate: validation strictness
617 * @extack: extended ACK pointer
619 * Parses a stream of attributes and stores a pointer to each attribute in
620 * the tb array accessible via the attribute type.
621 * Validation is controlled by the @validate parameter.
623 * Returns 0 on success or a negative error code.
625 int __nla_parse(struct nlattr **tb, int maxtype,
626 const struct nlattr *head, int len,
627 const struct nla_policy *policy, unsigned int validate,
628 struct netlink_ext_ack *extack)
630 return __nla_validate_parse(head, len, maxtype, policy, validate,
633 EXPORT_SYMBOL(__nla_parse);
636 * nla_find - Find a specific attribute in a stream of attributes
637 * @head: head of attribute stream
638 * @len: length of attribute stream
639 * @attrtype: type of attribute to look for
641 * Returns the first attribute in the stream matching the specified type.
643 struct nlattr *nla_find(const struct nlattr *head, int len, int attrtype)
645 const struct nlattr *nla;
648 nla_for_each_attr(nla, head, len, rem)
649 if (nla_type(nla) == attrtype)
650 return (struct nlattr *)nla;
654 EXPORT_SYMBOL(nla_find);
657 * nla_strlcpy - Copy string attribute payload into a sized buffer
658 * @dst: where to copy the string to
659 * @nla: attribute to copy the string from
660 * @dstsize: size of destination buffer
662 * Copies at most dstsize - 1 bytes into the destination buffer.
663 * The result is always a valid NUL-terminated string. Unlike
664 * strlcpy the destination buffer is always padded out.
666 * Returns the length of the source buffer.
668 size_t nla_strlcpy(char *dst, const struct nlattr *nla, size_t dstsize)
670 size_t srclen = nla_len(nla);
671 char *src = nla_data(nla);
673 if (srclen > 0 && src[srclen - 1] == '\0')
677 size_t len = (srclen >= dstsize) ? dstsize - 1 : srclen;
679 memset(dst, 0, dstsize);
680 memcpy(dst, src, len);
685 EXPORT_SYMBOL(nla_strlcpy);
688 * nla_strdup - Copy string attribute payload into a newly allocated buffer
689 * @nla: attribute to copy the string from
690 * @flags: the type of memory to allocate (see kmalloc).
692 * Returns a pointer to the allocated buffer or NULL on error.
694 char *nla_strdup(const struct nlattr *nla, gfp_t flags)
696 size_t srclen = nla_len(nla);
697 char *src = nla_data(nla), *dst;
699 if (srclen > 0 && src[srclen - 1] == '\0')
702 dst = kmalloc(srclen + 1, flags);
704 memcpy(dst, src, srclen);
709 EXPORT_SYMBOL(nla_strdup);
712 * nla_memcpy - Copy a netlink attribute into another memory area
713 * @dest: where to copy to memcpy
714 * @src: netlink attribute to copy from
715 * @count: size of the destination area
717 * Note: The number of bytes copied is limited by the length of
718 * attribute's payload. memcpy
720 * Returns the number of bytes copied.
722 int nla_memcpy(void *dest, const struct nlattr *src, int count)
724 int minlen = min_t(int, count, nla_len(src));
726 memcpy(dest, nla_data(src), minlen);
728 memset(dest + minlen, 0, count - minlen);
732 EXPORT_SYMBOL(nla_memcpy);
735 * nla_memcmp - Compare an attribute with sized memory area
736 * @nla: netlink attribute
738 * @size: size of memory area
740 int nla_memcmp(const struct nlattr *nla, const void *data,
743 int d = nla_len(nla) - size;
746 d = memcmp(nla_data(nla), data, size);
750 EXPORT_SYMBOL(nla_memcmp);
753 * nla_strcmp - Compare a string attribute against a string
754 * @nla: netlink string attribute
755 * @str: another string
757 int nla_strcmp(const struct nlattr *nla, const char *str)
759 int len = strlen(str);
760 char *buf = nla_data(nla);
761 int attrlen = nla_len(nla);
764 if (attrlen > 0 && buf[attrlen - 1] == '\0')
769 d = memcmp(nla_data(nla), str, len);
773 EXPORT_SYMBOL(nla_strcmp);
777 * __nla_reserve - reserve room for attribute on the skb
778 * @skb: socket buffer to reserve room on
779 * @attrtype: attribute type
780 * @attrlen: length of attribute payload
782 * Adds a netlink attribute header to a socket buffer and reserves
783 * room for the payload but does not copy it.
785 * The caller is responsible to ensure that the skb provides enough
786 * tailroom for the attribute header and payload.
788 struct nlattr *__nla_reserve(struct sk_buff *skb, int attrtype, int attrlen)
792 nla = skb_put(skb, nla_total_size(attrlen));
793 nla->nla_type = attrtype;
794 nla->nla_len = nla_attr_size(attrlen);
796 memset((unsigned char *) nla + nla->nla_len, 0, nla_padlen(attrlen));
800 EXPORT_SYMBOL(__nla_reserve);
803 * __nla_reserve_64bit - reserve room for attribute on the skb and align it
804 * @skb: socket buffer to reserve room on
805 * @attrtype: attribute type
806 * @attrlen: length of attribute payload
807 * @padattr: attribute type for the padding
809 * Adds a netlink attribute header to a socket buffer and reserves
810 * room for the payload but does not copy it. It also ensure that this
811 * attribute will have a 64-bit aligned nla_data() area.
813 * The caller is responsible to ensure that the skb provides enough
814 * tailroom for the attribute header and payload.
816 struct nlattr *__nla_reserve_64bit(struct sk_buff *skb, int attrtype,
817 int attrlen, int padattr)
819 if (nla_need_padding_for_64bit(skb))
820 nla_align_64bit(skb, padattr);
822 return __nla_reserve(skb, attrtype, attrlen);
824 EXPORT_SYMBOL(__nla_reserve_64bit);
827 * __nla_reserve_nohdr - reserve room for attribute without header
828 * @skb: socket buffer to reserve room on
829 * @attrlen: length of attribute payload
831 * Reserves room for attribute payload without a header.
833 * The caller is responsible to ensure that the skb provides enough
834 * tailroom for the payload.
836 void *__nla_reserve_nohdr(struct sk_buff *skb, int attrlen)
838 return skb_put_zero(skb, NLA_ALIGN(attrlen));
840 EXPORT_SYMBOL(__nla_reserve_nohdr);
843 * nla_reserve - reserve room for attribute on the skb
844 * @skb: socket buffer to reserve room on
845 * @attrtype: attribute type
846 * @attrlen: length of attribute payload
848 * Adds a netlink attribute header to a socket buffer and reserves
849 * room for the payload but does not copy it.
851 * Returns NULL if the tailroom of the skb is insufficient to store
852 * the attribute header and payload.
854 struct nlattr *nla_reserve(struct sk_buff *skb, int attrtype, int attrlen)
856 if (unlikely(skb_tailroom(skb) < nla_total_size(attrlen)))
859 return __nla_reserve(skb, attrtype, attrlen);
861 EXPORT_SYMBOL(nla_reserve);
864 * nla_reserve_64bit - reserve room for attribute on the skb and align it
865 * @skb: socket buffer to reserve room on
866 * @attrtype: attribute type
867 * @attrlen: length of attribute payload
868 * @padattr: attribute type for the padding
870 * Adds a netlink attribute header to a socket buffer and reserves
871 * room for the payload but does not copy it. It also ensure that this
872 * attribute will have a 64-bit aligned nla_data() area.
874 * Returns NULL if the tailroom of the skb is insufficient to store
875 * the attribute header and payload.
877 struct nlattr *nla_reserve_64bit(struct sk_buff *skb, int attrtype, int attrlen,
882 if (nla_need_padding_for_64bit(skb))
883 len = nla_total_size_64bit(attrlen);
885 len = nla_total_size(attrlen);
886 if (unlikely(skb_tailroom(skb) < len))
889 return __nla_reserve_64bit(skb, attrtype, attrlen, padattr);
891 EXPORT_SYMBOL(nla_reserve_64bit);
894 * nla_reserve_nohdr - reserve room for attribute without header
895 * @skb: socket buffer to reserve room on
896 * @attrlen: length of attribute payload
898 * Reserves room for attribute payload without a header.
900 * Returns NULL if the tailroom of the skb is insufficient to store
901 * the attribute payload.
903 void *nla_reserve_nohdr(struct sk_buff *skb, int attrlen)
905 if (unlikely(skb_tailroom(skb) < NLA_ALIGN(attrlen)))
908 return __nla_reserve_nohdr(skb, attrlen);
910 EXPORT_SYMBOL(nla_reserve_nohdr);
913 * __nla_put - Add a netlink attribute to a socket buffer
914 * @skb: socket buffer to add attribute to
915 * @attrtype: attribute type
916 * @attrlen: length of attribute payload
917 * @data: head of attribute payload
919 * The caller is responsible to ensure that the skb provides enough
920 * tailroom for the attribute header and payload.
922 void __nla_put(struct sk_buff *skb, int attrtype, int attrlen,
927 nla = __nla_reserve(skb, attrtype, attrlen);
928 memcpy(nla_data(nla), data, attrlen);
930 EXPORT_SYMBOL(__nla_put);
933 * __nla_put_64bit - Add a netlink attribute to a socket buffer and align it
934 * @skb: socket buffer to add attribute to
935 * @attrtype: attribute type
936 * @attrlen: length of attribute payload
937 * @data: head of attribute payload
938 * @padattr: attribute type for the padding
940 * The caller is responsible to ensure that the skb provides enough
941 * tailroom for the attribute header and payload.
943 void __nla_put_64bit(struct sk_buff *skb, int attrtype, int attrlen,
944 const void *data, int padattr)
948 nla = __nla_reserve_64bit(skb, attrtype, attrlen, padattr);
949 memcpy(nla_data(nla), data, attrlen);
951 EXPORT_SYMBOL(__nla_put_64bit);
954 * __nla_put_nohdr - Add a netlink attribute without header
955 * @skb: socket buffer to add attribute to
956 * @attrlen: length of attribute payload
957 * @data: head of attribute payload
959 * The caller is responsible to ensure that the skb provides enough
960 * tailroom for the attribute payload.
962 void __nla_put_nohdr(struct sk_buff *skb, int attrlen, const void *data)
966 start = __nla_reserve_nohdr(skb, attrlen);
967 memcpy(start, data, attrlen);
969 EXPORT_SYMBOL(__nla_put_nohdr);
972 * nla_put - Add a netlink attribute to a socket buffer
973 * @skb: socket buffer to add attribute to
974 * @attrtype: attribute type
975 * @attrlen: length of attribute payload
976 * @data: head of attribute payload
978 * Returns -EMSGSIZE if the tailroom of the skb is insufficient to store
979 * the attribute header and payload.
981 int nla_put(struct sk_buff *skb, int attrtype, int attrlen, const void *data)
983 if (unlikely(skb_tailroom(skb) < nla_total_size(attrlen)))
986 __nla_put(skb, attrtype, attrlen, data);
989 EXPORT_SYMBOL(nla_put);
992 * nla_put_64bit - Add a netlink attribute to a socket buffer and align it
993 * @skb: socket buffer to add attribute to
994 * @attrtype: attribute type
995 * @attrlen: length of attribute payload
996 * @data: head of attribute payload
997 * @padattr: attribute type for the padding
999 * Returns -EMSGSIZE if the tailroom of the skb is insufficient to store
1000 * the attribute header and payload.
1002 int nla_put_64bit(struct sk_buff *skb, int attrtype, int attrlen,
1003 const void *data, int padattr)
1007 if (nla_need_padding_for_64bit(skb))
1008 len = nla_total_size_64bit(attrlen);
1010 len = nla_total_size(attrlen);
1011 if (unlikely(skb_tailroom(skb) < len))
1014 __nla_put_64bit(skb, attrtype, attrlen, data, padattr);
1017 EXPORT_SYMBOL(nla_put_64bit);
1020 * nla_put_nohdr - Add a netlink attribute without header
1021 * @skb: socket buffer to add attribute to
1022 * @attrlen: length of attribute payload
1023 * @data: head of attribute payload
1025 * Returns -EMSGSIZE if the tailroom of the skb is insufficient to store
1026 * the attribute payload.
1028 int nla_put_nohdr(struct sk_buff *skb, int attrlen, const void *data)
1030 if (unlikely(skb_tailroom(skb) < NLA_ALIGN(attrlen)))
1033 __nla_put_nohdr(skb, attrlen, data);
1036 EXPORT_SYMBOL(nla_put_nohdr);
1039 * nla_append - Add a netlink attribute without header or padding
1040 * @skb: socket buffer to add attribute to
1041 * @attrlen: length of attribute payload
1042 * @data: head of attribute payload
1044 * Returns -EMSGSIZE if the tailroom of the skb is insufficient to store
1045 * the attribute payload.
1047 int nla_append(struct sk_buff *skb, int attrlen, const void *data)
1049 if (unlikely(skb_tailroom(skb) < NLA_ALIGN(attrlen)))
1052 skb_put_data(skb, data, attrlen);
1055 EXPORT_SYMBOL(nla_append);