Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp676245img; Thu, 21 Mar 2019 06:46:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqxFHXSlfw4tbooY5Zod7drawXO2icy6mKNMHOs3rTpnSAWKLD/x75E0G+LBK4j5maPc3js3 X-Received: by 2002:a17:902:b698:: with SMTP id c24mr3551613pls.221.1553175962932; Thu, 21 Mar 2019 06:46:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553175962; cv=none; d=google.com; s=arc-20160816; b=EvpvGKxRxVPPtuV3UwEbXyRUPQg2K97ZmxZTvYWXwJOSIYlTZnznTB1S4rJzR3yubo R0a0L37oQRABWcXD6Ob+naj3VyYThL7Zgiqv2C2BMlFjbAhOdfenwG2rv8mze9BzcLy7 U+qIesDveqjUMjJbsR1F6M/UuSrtF9SJLLxSYkXOtoceoZEU80ErA3y2LDZ2pp0Fsrk4 FrFeEIW2Yz7EMnJcPVPCRpWvt7RYoCtuvO91akamR+hRyzN594Lz4lnRCo3R3mLC4lqT zQIOvVKaEcIb4V442BnZOIVGBOqbOZQ5n0xbhrk9r0ahpfrESwOW+yHquNPu70YNVhyi bjbg== 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=qw+jnJIzPzsrMwam+XWSzotitMcf+fr8fFgdQ5gwVfwK9ryJViYvYRiM2kehyALV42 nRVSKYG1CbFo4ebZZiGjKT+KtjaVBICoqeIT1AYPg9RsnLsaQuLCLNohN82HBXm7+L8f Ht6xM969ynUy+v55loVvuzUeyiNcYQM8PihA6oYI704kzKgXzoonyqvJhtZova+75Z75 0yppblJXLDOVpb1fDh/5Z5kE9lqU1nFwNHoOYtRlRNnjhNpwcYDJrJtiGWwaH56bTjBt ThC43ipplsyHUJPY2G4ezR7ziLPff+MCKE6U6AuF94SQc8lM/+TWfIxL8//soFFgBBHW 7mLA== 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 m10si4486800pls.65.2019.03.21.06.45.45; Thu, 21 Mar 2019 06:46:02 -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 S1728332AbfCUNk1 (ORCPT + 99 others); Thu, 21 Mar 2019 09:40:27 -0400 Received: from mx2.suse.de ([195.135.220.15]:36134 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728299AbfCUNkZ (ORCPT ); Thu, 21 Mar 2019 09:40:25 -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 63186AF67; Thu, 21 Mar 2019 13:40:24 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id 14E0DE00BF; Thu, 21 Mar 2019 14:40:24 +0100 (CET) Message-Id: <2f5584ba0a74bb84e96a3ae1cc3a92ee7a6f79c1.1553170807.git.mkubecek@suse.cz> In-Reply-To: References: From: Michal Kubecek Subject: [PATCH net-next v4 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 , linux-kernel@vger.kernel.org Date: Thu, 21 Mar 2019 14:40:24 +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