Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3919778imm; Mon, 30 Jul 2018 05:54:36 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfdujgCnQUDoUlbUVLaVkAY2s/uETEQhzzp9qcQct0zsY8Zmgl1Gup2Y7UfuDm+yR98Kbeb X-Received: by 2002:a62:9c17:: with SMTP id f23-v6mr17870911pfe.209.1532955276578; Mon, 30 Jul 2018 05:54:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532955276; cv=none; d=google.com; s=arc-20160816; b=eJHzB6lBvsNvCcpkvo9PJI/bPJyzhhP007JTo0KVEg2f2OPqZji4Z8brOWvB3SEfIG LqkaGWYJMn8EURhlEt1U+eJ6SMNNNMEt00G7Wc2PYcb+FdiPkcWrQJ3nPGDLK8OYGm4g UWtv0pGgjNHXw56intPt4GaYJMlf1ci8NWWbMsnpktrM0AiKox+GmNqYWTJEXuoppNkN B/N0A+310xKKy2M88F/+SZCSrhz7rxiyBpOAjbpay0FIrjAcY/k+dpg3EXijwZVAX2r4 WjYMB7OJ9LEltKu5y4jlWuW1HtzOMdmce3F5oeyNE2YZBqeuYGE7rQZ3/PGRq2Z+sTNT DjKA== 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:arc-authentication-results; bh=gxFgQzxEJmk9aF5VxAdoeewQKsO6/Wyz8B58bB8f+AQ=; b=mY+nyuT8V07jgAFD0wxUgerAJVVMqxjaraVIon1BK9DSkDiZwKPdW3vv5EPASXq+ED fpMuch+k7DZDnBRgwzCncb9gKURjmbSlFD3Bll+46kJQQQ0zCT/o4HxCXJffLhHXs241 1jHZ1xqCKGkl2RMrPFJzq0IjS9GpIYIWdVY3GQlI6d7/itGl0IAINMEG/qw1YLea7DUG 5g/jWg9apnOw6ZIFai5sGViUDk9tIqwqx9UDSm+pFXt38IX/rxlIWshCnYa5FBIgw4h3 80laXzKGWIGcQx9293aidY3g4p53e85S8KiHRvPIqHWNGEWyGBnPBGx3wk9wy9J3fbO/ 1UdQ== 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 t16-v6si10387019pga.442.2018.07.30.05.54.21; Mon, 30 Jul 2018 05:54:36 -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 S1731679AbeG3O1l (ORCPT + 99 others); Mon, 30 Jul 2018 10:27:41 -0400 Received: from mx2.suse.de ([195.135.220.15]:48926 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729460AbeG3O1j (ORCPT ); Mon, 30 Jul 2018 10:27:39 -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 B07F8AF42; Mon, 30 Jul 2018 12:52:47 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id 5FB3BA0BE8; Mon, 30 Jul 2018 14:52:47 +0200 (CEST) Message-Id: <1b860198a5b775d24bb4eba2c917d2c87120ac9e.1532953989.git.mkubecek@suse.cz> In-Reply-To: References: From: Michal Kubecek Subject: [RFC PATCH net-next v2 01/17] netlink: introduce nla_put_bitfield32() To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jiri Pirko , David Miller , Florian Fainelli , Roopa Prabhu , Jakub Kicinski , "John W. Linville" Date: Mon, 30 Jul 2018 14:52:47 +0200 (CEST) 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 you already have struct nla_bitfield32, you 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 0c154f98e987..6d4eb6bd9235 100644 --- a/include/net/netlink.h +++ b/include/net/netlink.h @@ -1064,6 +1064,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.18.0