From 8953b0770ff4e3038a6d4df3cc021f9bfb47548a Mon Sep 17 00:00:00 2001 From: Jiri Pirko Date: Sat, 28 Mar 2020 16:37:42 +0100 Subject: net: introduce nla_put_bitfield32() helper and use it Introduce a helper to pass value and selector to. The helper packs them into struct and puts them into netlink message. Signed-off-by: Jiri Pirko Signed-off-by: David S. Miller --- include/net/netlink.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include/net/netlink.h') diff --git a/include/net/netlink.h b/include/net/netlink.h index 56c365dc6dc7..67c57d6942e3 100644 --- a/include/net/netlink.h +++ b/include/net/netlink.h @@ -1465,6 +1465,21 @@ static inline int nla_put_in6_addr(struct sk_buff *skb, int attrtype, return nla_put(skb, attrtype, sizeof(*addr), addr); } +/** + * nla_put_bitfield32 - Add a bitfield32 netlink attribute to a socket buffer + * @skb: socket buffer to add attribute to + * @attrtype: attribute type + * @value: value carrying bits + * @selector: selector of valid bits + */ +static inline int nla_put_bitfield32(struct sk_buff *skb, int attrtype, + __u32 value, __u32 selector) +{ + struct nla_bitfield32 tmp = { value, selector, }; + + return nla_put(skb, attrtype, sizeof(tmp), &tmp); +} + /** * nla_get_u32 - return payload of u32 attribute * @nla: u32 netlink attribute -- cgit v1.2.3