Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[NETLINK]: Add nla_append()

Used to append data to a message without a header or padding.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Patrick McHardy and committed by
David S. Miller
01480e1c 2eb9d75c

+22
+3
include/net/netlink.h
··· 91 91 * nla_reserve_nohdr(skb, len) reserve room for an attribute w/o hdr 92 92 * nla_put(skb, type, len, data) add attribute to skb 93 93 * nla_put_nohdr(skb, len, data) add attribute w/o hdr 94 + * nla_append(skb, len, data) append data to skb 94 95 * 95 96 * Attribute Construction for Basic Types: 96 97 * nla_put_u8(skb, type, value) add u8 attribute to skb ··· 255 254 int attrlen, const void *data); 256 255 extern int nla_put_nohdr(struct sk_buff *skb, int attrlen, 257 256 const void *data); 257 + extern int nla_append(struct sk_buff *skb, int attrlen, 258 + const void *data); 258 259 259 260 /************************************************************************** 260 261 * Netlink Messages
+19
net/netlink/attr.c
··· 430 430 return 0; 431 431 } 432 432 433 + /** 434 + * nla_append - Add a netlink attribute without header or padding 435 + * @skb: socket buffer to add attribute to 436 + * @attrlen: length of attribute payload 437 + * @data: head of attribute payload 438 + * 439 + * Returns -1 if the tailroom of the skb is insufficient to store 440 + * the attribute payload. 441 + */ 442 + int nla_append(struct sk_buff *skb, int attrlen, const void *data) 443 + { 444 + if (unlikely(skb_tailroom(skb) < NLA_ALIGN(attrlen))) 445 + return -1; 446 + 447 + memcpy(skb_put(skb, attrlen), data, attrlen); 448 + return 0; 449 + } 450 + 433 451 EXPORT_SYMBOL(nla_validate); 434 452 EXPORT_SYMBOL(nla_parse); 435 453 EXPORT_SYMBOL(nla_find); ··· 463 445 EXPORT_SYMBOL(nla_memcpy); 464 446 EXPORT_SYMBOL(nla_memcmp); 465 447 EXPORT_SYMBOL(nla_strcmp); 448 + EXPORT_SYMBOL(nla_append);