Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2739889imj; Mon, 18 Feb 2019 11:15:57 -0800 (PST) X-Google-Smtp-Source: AHgI3IbrOU6+/40ApgSTJomssdbkIrK/HrkMHmP4SyPN+iQaQ+54BxvRiHDCqzgVxiSWOw407ETd X-Received: by 2002:a62:3990:: with SMTP id u16mr25662358pfj.80.1550517357274; Mon, 18 Feb 2019 11:15:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550517357; cv=none; d=google.com; s=arc-20160816; b=oBWSCYb06z0xF6OSAv9cL+S1F57pk86fy7WoD1ApQDw9srB7dJPUt87nqpU4OgTv0g 9SUzhmPJxCf/1Ied3Aed7LPj3uZfNJCi86yk0pqayuDuLYxPKtv8bRb+VXkE1AG5iJ1Y y/wwf43+B6IwmMaeaOEdxt2i5nsOsrr611ibOBdypaN0mMZNo4cWS88aQRvC05Cy5MtC FrACm2ICSHVKiOQCWqG8EeBsnpn9D3Qrey05Vhpbrsq2bsBtgTCKaYzu3oXIhShDv11K TlGINJGNPeZfyFeGPQyYRctokIxMVxWo/XYJjswuF9WpRGWpodksSW6zbyOADZs4jPDJ 3asA== 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=Hc2dJI1oPwJbn8QOmoqs+KrbZW18c7j2Z3ong4mrQRg=; b=OOEce3U2O1zGW5qCca0752V+jg6Rgj4JAkljbOmuxVP1CVA62xiVKrE46/+x1xW6Hx jrXAXvv8ba2zN9ut73h6fymMYiixccB90bBps7g7qzmcRA4WQyoHD4s9zvp09dOdbaUJ Y2iRxjMbNui7kNl5LOHgFK1SypAtGGZnx0YxtUEgC26imyW5b/5oMe1pOLUn6SxoYW2B mTLukA2UKOT2NCdEJLOGFmxpke7CWj1vznSj0WI3f32t/lgHsuxKAzbVr7yRRCh47Ck8 SflZD5ro7oxgmk97WCmZrWf3O/JBnmpsb6DHa7ND4scuKV6JqeqVPUS/T9A6U9i7fMNM vR2Q== 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 v6si473649pgr.191.2019.02.18.11.15.41; Mon, 18 Feb 2019 11:15:57 -0800 (PST) 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 S2392099AbfBRSVc (ORCPT + 99 others); Mon, 18 Feb 2019 13:21:32 -0500 Received: from mx2.suse.de ([195.135.220.15]:45954 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389263AbfBRSVb (ORCPT ); Mon, 18 Feb 2019 13:21:31 -0500 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 D5AF5AEB8; Mon, 18 Feb 2019 18:21:29 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id 88748E0122; Mon, 18 Feb 2019 19:21:29 +0100 (CET) Message-Id: In-Reply-To: References: From: Michal Kubecek Subject: [RFC PATCH net-next v3 01/21] netlink: introduce nla_put_bitfield32() To: netdev@vger.kernel.org Cc: David Miller , Andrew Lunn , Jakub Kicinski , Jiri Pirko , linux-kernel@vger.kernel.org Date: Mon, 18 Feb 2019 19:21:29 +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.20.1