Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3434881img; Mon, 25 Mar 2019 10:12:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqwIbO2KrTfUyznMTfQaYxRxFBlfMXB5OlClqzannwcEZqzjssqIJBXffc5dDzIIBroKHlQI X-Received: by 2002:a62:4481:: with SMTP id m1mr25522615pfi.253.1553533948883; Mon, 25 Mar 2019 10:12:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553533948; cv=none; d=google.com; s=arc-20160816; b=HnXCrUvAYeD7WwjLqtC3IaWLSfyeZgIoNHBK5MXutkL6A86E2eyw6HT8geG4fs8eua LzdmpGm6B+HT4SslguQv6coqXskrPq8+N641XfE+SPDKnepTxyzJ8vPi9UtoAW8K0Oxl Q/q07c4rgHZm//MTtAttK7yJBGF99Ou8leXFSzGOEbiaqC0h4b0sPz1+9asD1P/xT6uK 3gE62zOS8T0MkuXoCGnhPoqzwTLc5u8IMW35ErxO6pLE9bOXnf12wAWtjypH0KyD3dQp B2+flhY3bENG3VefVDA0I55XDsWq6QcvN1IOfaI/AiWbJWCuxTDnW4a6knrBEFn2HsHj IPnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id; bh=jg151vpGn40b7Va0s4xQ2RgsaaMoHl23yviEpLdJYkM=; b=NkjFLHBi5xF1ErWyai3IZA0l6YQzZpnaEH5Zv8CBVoQ6MaZhqmZeLMwoBMT8MRmwd5 n2yh/SIgMlNg/1FVUEavCVeF6mqdb8jo8IzQPxCmhrbBN0zK8Ue5oaKRrV4UtijvP0a3 Cvp2tftO4VRFQsBYFxu2eA7MtCy/s+iVxZUCrD8b9yeMZl6wIEcLowbEAQlhDDJTUvD5 vHlVEXD3nr0qpNAoFv+YjLJ/WozyseVS/9VW+RSVXL9GP+mTBGC+5dXWWginC4FonZRi yYW1Q39QngiY32l5WzJDJas1ac53KmaLFpUdMJC0EngvpGtGvbyVln3XJwqBzPERVXrv lcug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h66si14394428pgc.537.2019.03.25.10.12.12; Mon, 25 Mar 2019 10:12:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730157AbfCYRKs (ORCPT + 99 others); Mon, 25 Mar 2019 13:10:48 -0400 Received: from mx2.suse.de ([195.135.220.15]:50848 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729947AbfCYRIC (ORCPT ); Mon, 25 Mar 2019 13:08:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id E4CC2AF7C; Mon, 25 Mar 2019 17:08:00 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id 9347DE1404; Mon, 25 Mar 2019 18:08:00 +0100 (CET) Message-Id: <94ec4068f6767acabf6bd795818f5b7ce2dae00b.1553532199.git.mkubecek@suse.cz> In-Reply-To: References: From: Michal Kubecek Subject: [PATCH net-next v5 02/22] netlink: introduce nla_put_bitfield32() To: David Miller , netdev@vger.kernel.org Cc: Jakub Kicinski , Jiri Pirko , Andrew Lunn , Florian Fainelli , John Linville , Stephen Hemminger , linux-kernel@vger.kernel.org Date: Mon, 25 Mar 2019 18:08:00 +0100 (CET) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Similar to other data types, this helper puts NLA_BITFIELD32 attribute into a netlink message. It takes separate value and selector arguments, if there is a struct nla_bitfield32 already, one can use nla_put(). Signed-off-by: Michal Kubecek --- include/net/netlink.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/net/netlink.h b/include/net/netlink.h index 23f27b0b3cef..bc0497076bec 100644 --- a/include/net/netlink.h +++ b/include/net/netlink.h @@ -1211,6 +1211,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 value/selector attribute to + * a socket buffer + * @skb: socket buffer to add attribute to + * @value: 32-bit value bitmap + * @selector: 32-bit selector bitmap + */ +static inline int nla_put_bitfield32(struct sk_buff *skb, int attrtype, + u32 value, u32 selector) +{ + struct nla_bitfield32 tmp = { .value = value, .selector = selector }; + + return nla_put(skb, attrtype, sizeof(tmp), &tmp); +} + /** * nla_get_u32 - return payload of u32 attribute * @nla: u32 netlink attribute -- 2.21.0