From patchwork Mon Mar 20 13:25:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shay Agroskin X-Patchwork-Id: 13181241 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 318D2C7618A for ; Mon, 20 Mar 2023 13:26:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230178AbjCTN0f (ORCPT ); Mon, 20 Mar 2023 09:26:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229458AbjCTN0b (ORCPT ); Mon, 20 Mar 2023 09:26:31 -0400 Received: from smtp-fw-9103.amazon.com (smtp-fw-9103.amazon.com [207.171.188.200]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BE861B567 for ; Mon, 20 Mar 2023 06:26:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1679318790; x=1710854790; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eF0lhh/WDguKNw67MW2qwtBQ9s98s9AQJa+a0Zwkvyw=; b=aHPebm1rHhprbAQX9mmAew1aDAgakpmXrphT3rcrmyE8Um2zVIPHbSaR 8Io5h/On+hYn1gEEgO6MvMFsFIAFd5dHgFPdOoDWGBzuelAgyoOy5WDKr il2eP8RFpoNUUG+6QJqHif52Uw5Hh7nmqOarPgr7sKCjTEEYp8aezf7v+ M=; X-IronPort-AV: E=Sophos;i="5.98,274,1673913600"; d="scan'208";a="1114315193" Received: from pdx4-co-svc-p1-lb2-vlan3.amazon.com (HELO email-inbound-relay-iad-1e-m6i4x-0aba4706.us-east-1.amazon.com) ([10.25.36.214]) by smtp-border-fw-9103.sea19.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2023 13:26:16 +0000 Received: from EX19D001EUA004.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-iad-1e-m6i4x-0aba4706.us-east-1.amazon.com (Postfix) with ESMTPS id D18C3A0DBE; Mon, 20 Mar 2023 13:26:12 +0000 (UTC) Received: from EX19D028EUB003.ant.amazon.com (10.252.61.31) by EX19D001EUA004.ant.amazon.com (10.252.50.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.24; Mon, 20 Mar 2023 13:26:11 +0000 Received: from u570694869fb251.ant.amazon.com (10.85.143.172) by EX19D028EUB003.ant.amazon.com (10.252.61.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.24; Mon, 20 Mar 2023 13:26:01 +0000 From: Shay Agroskin To: David Miller , Jakub Kicinski , CC: Shay Agroskin , "Woodhouse, David" , "Machulsky, Zorik" , "Matushevsky, Alexander" , Saeed Bshara , "Wilson, Matt" , "Liguori, Anthony" , "Bshara, Nafea" , "Belgazal, Netanel" , "Saidi, Ali" , "Herrenschmidt, Benjamin" , "Kiyanovski, Arthur" , "Dagan, Noam" , "Arinzon, David" , "Itzko, Shahar" , "Abboud, Osama" , Eric Dumazet , Paolo Abeni , Vladimir Oltean , Andrew Lunn , Guangbin Huang , "Jie Wang" , Johannes Berg , Edward Cree , Florian Westphal Subject: [PATCH v6 net-next 1/7] netlink: Add a macro to set policy message with format string Date: Mon, 20 Mar 2023 15:25:17 +0200 Message-ID: <20230320132523.3203254-2-shayagr@amazon.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20230320132523.3203254-1-shayagr@amazon.com> References: <20230320132523.3203254-1-shayagr@amazon.com> MIME-Version: 1.0 X-Originating-IP: [10.85.143.172] X-ClientProxiedBy: EX19D038UWC003.ant.amazon.com (10.13.139.209) To EX19D028EUB003.ant.amazon.com (10.252.61.31) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Similar to NL_SET_ERR_MSG_FMT, add a macro which sets netlink policy error message with a format string. Signed-off-by: Shay Agroskin --- include/linux/netlink.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/linux/netlink.h b/include/linux/netlink.h index 3e8743252167..2ca76ec1fc33 100644 --- a/include/linux/netlink.h +++ b/include/linux/netlink.h @@ -161,9 +161,22 @@ struct netlink_ext_ack { } \ } while (0) +#define NL_SET_ERR_MSG_ATTR_POL_FMT(extack, attr, pol, fmt, args...) do { \ + struct netlink_ext_ack *__extack = (extack); \ + \ + if (__extack) { \ + NL_SET_ERR_MSG_FMT(extack, fmt, ##args); \ + __extack->bad_attr = (attr); \ + __extack->policy = (pol); \ + } \ +} while (0) + #define NL_SET_ERR_MSG_ATTR(extack, attr, msg) \ NL_SET_ERR_MSG_ATTR_POL(extack, attr, NULL, msg) +#define NL_SET_ERR_MSG_ATTR_FMT(extack, attr, msg, args...) \ + NL_SET_ERR_MSG_ATTR_POL_FMT(extack, attr, NULL, msg, ##args) + #define NL_SET_ERR_ATTR_MISS(extack, nest, type) do { \ struct netlink_ext_ack *__extack = (extack); \ \