From patchwork Thu Aug 27 06:50:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabian Frederick X-Patchwork-Id: 261862 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CD78C433DF for ; Thu, 27 Aug 2020 06:50:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 028F2207BC for ; Thu, 27 Aug 2020 06:50:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727115AbgH0Guk (ORCPT ); Thu, 27 Aug 2020 02:50:40 -0400 Received: from mailrelay116.isp.belgacom.be ([195.238.20.143]:45576 "EHLO mailrelay116.isp.belgacom.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726123AbgH0Guk (ORCPT ); Thu, 27 Aug 2020 02:50:40 -0400 IronPort-SDR: GRLZ7WcFO6WVt6F6tdr/XT/maDaktNshkCXAQttBEndOQMdR+6zw7vGAjgtLKHV1SLTCfuOVv4 9y/XC+5kbFOdmFIs9Ec2IL0k6F+PmTsWvJ7c6pVeY1Kdvtcp8Wm8mMV8s8tQkRNJa+JHdk2MDl L6AAleUCBlg2mhawADrbcgHCxYJEw+WbIibH2yDq/tSZW8q1tv5xym0Jbjufwlugv2aCHIws20 bOlmG0TsCZ1fCU7NRP5rYqOl51BA2C3/zxES3gNNQCKg+WHiRql3tAKLiHaZL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1jn82h0Udfa+30psTcny4Ge5mI0qBa3r2ntgBCXsKvhY5TOHyjl2NTyJTaGusUKIi/Tw7Fo2mApnZRoy3g7yOwj27HptIaWBCEFyMFm3od4qcUfcWdC2SOtNhkiADVbW5T48h1BeutBL1yrZ+Lerb5DcYtZT929hx/ODTix4y+iJuD8iH0GGCUXt0nmUWSD8yxqx/plZ9ylib26hin/NYDcBT5+9OUgoiO57T1fd1C97pVwLafdeISFCmTcu6AT0rVd0+3YxGX0EoF9y8gxXr0yO0DroRkLKXQpo57uaU3GX7Lu5+xmzA2a1niEMpEeVVMmjzqKd19gHVT6DTnkmUjaehduxI0ifH+k+YznuIsV0eWgMmAvaNZmwWekaD9Yex3UjFVbL7Ubk= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2DgBgD4Vkdf/xCltltfgRCBRYEcglBfjTiSS5ICCwEBAQEBAQEBATQBAgQBAYRMgjslOBMCAwEBAQMCBQEBBgEBAQEBAQUEAYYPRUMBDAGBZiKDRwsBIyOBPxKDJoJYKbMaM4QQgUODRYFCgTgBiCaFGYFBP4RfijQEj26KK5w5gm2DDIRckjYPIaBELZIeoV2Bek0gGIMkUBkNnGhCMDcCBgoBAQMJVwE9AYUginMBAQ X-IPAS-Result: A2DgBgD4Vkdf/xCltltfgRCBRYEcglBfjTiSS5ICCwEBAQEBAQEBATQBAgQBAYRMgjslOBMCAwEBAQMCBQEBBgEBAQEBAQUEAYYPRUMBDAGBZiKDRwsBIyOBPxKDJoJYKbMaM4QQgUODRYFCgTgBiCaFGYFBP4RfijQEj26KK5w5gm2DDIRckjYPIaBELZIeoV2Bek0gGIMkUBkNnGhCMDcCBgoBAQMJVwE9AYUginMBAQ Received: from 16.165-182-91.adsl-dyn.isp.belgacom.be (HELO localhost.localdomain) ([91.182.165.16]) by relay.skynet.be with ESMTP; 27 Aug 2020 08:50:35 +0200 From: Fabian Frederick To: davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Fabian Frederick Subject: [PATCH 5/7 net-next] vxlan: add VXLAN_NL2FLAG macro Date: Thu, 27 Aug 2020 08:50:19 +0200 Message-Id: <20200827065019.5787-1-fabf@skynet.be> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Replace common flag assignment with a macro. This could yet be simplified with changelink/supported but it would remove clarity Signed-off-by: Fabian Frederick --- drivers/net/vxlan.c | 113 +++++--------------------------------------- include/net/vxlan.h | 10 ++++ 2 files changed, 23 insertions(+), 100 deletions(-) diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index 1e9ab1002281c..e9b561b9d23e1 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -4034,14 +4034,7 @@ static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[], if (data[IFLA_VXLAN_TTL]) conf->ttl = nla_get_u8(data[IFLA_VXLAN_TTL]); - if (data[IFLA_VXLAN_TTL_INHERIT]) { - err = vxlan_nl2flag(conf, data, IFLA_VXLAN_TTL_INHERIT, - VXLAN_F_TTL_INHERIT, changelink, false, - extack); - if (err) - return err; - - } + VXLAN_NL2FLAG(IFLA_VXLAN_TTL_INHERIT, VXLAN_F_TTL_INHERIT, changelink, false); if (data[IFLA_VXLAN_LABEL]) conf->label = nla_get_be32(data[IFLA_VXLAN_LABEL]) & @@ -4061,37 +4054,10 @@ static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[], if (data[IFLA_VXLAN_AGEING]) conf->age_interval = nla_get_u32(data[IFLA_VXLAN_AGEING]); - if (data[IFLA_VXLAN_PROXY]) { - err = vxlan_nl2flag(conf, data, IFLA_VXLAN_PROXY, - VXLAN_F_PROXY, changelink, false, - extack); - if (err) - return err; - } - - if (data[IFLA_VXLAN_RSC]) { - err = vxlan_nl2flag(conf, data, IFLA_VXLAN_RSC, - VXLAN_F_RSC, changelink, false, - extack); - if (err) - return err; - } - - if (data[IFLA_VXLAN_L2MISS]) { - err = vxlan_nl2flag(conf, data, IFLA_VXLAN_L2MISS, - VXLAN_F_L2MISS, changelink, false, - extack); - if (err) - return err; - } - - if (data[IFLA_VXLAN_L3MISS]) { - err = vxlan_nl2flag(conf, data, IFLA_VXLAN_L3MISS, - VXLAN_F_L3MISS, changelink, false, - extack); - if (err) - return err; - } + VXLAN_NL2FLAG(IFLA_VXLAN_PROXY, VXLAN_F_PROXY, changelink, false); + VXLAN_NL2FLAG(IFLA_VXLAN_RSC, VXLAN_F_RSC, changelink, false); + VXLAN_NL2FLAG(IFLA_VXLAN_L2MISS, VXLAN_F_L2MISS, changelink, false); + VXLAN_NL2FLAG(IFLA_VXLAN_L3MISS, VXLAN_F_L3MISS, changelink, false); if (data[IFLA_VXLAN_LIMIT]) { if (changelink) { @@ -4102,13 +4068,7 @@ static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[], conf->addrmax = nla_get_u32(data[IFLA_VXLAN_LIMIT]); } - if (data[IFLA_VXLAN_COLLECT_METADATA]) { - err = vxlan_nl2flag(conf, data, IFLA_VXLAN_COLLECT_METADATA, - VXLAN_F_COLLECT_METADATA, changelink, false, - extack); - if (err) - return err; - } + VXLAN_NL2FLAG(IFLA_VXLAN_COLLECT_METADATA, VXLAN_F_COLLECT_METADATA, changelink, false); if (data[IFLA_VXLAN_PORT_RANGE]) { if (!changelink) { @@ -4142,60 +4102,13 @@ static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[], conf->flags |= VXLAN_F_UDP_ZERO_CSUM_TX; } - if (data[IFLA_VXLAN_UDP_ZERO_CSUM6_TX]) { - err = vxlan_nl2flag(conf, data, IFLA_VXLAN_UDP_ZERO_CSUM6_TX, - VXLAN_F_UDP_ZERO_CSUM6_TX, changelink, - false, extack); - if (err) - return err; - } - - if (data[IFLA_VXLAN_UDP_ZERO_CSUM6_RX]) { - err = vxlan_nl2flag(conf, data, IFLA_VXLAN_UDP_ZERO_CSUM6_RX, - VXLAN_F_UDP_ZERO_CSUM6_RX, changelink, - false, extack); - if (err) - return err; - } - - if (data[IFLA_VXLAN_REMCSUM_TX]) { - err = vxlan_nl2flag(conf, data, IFLA_VXLAN_REMCSUM_TX, - VXLAN_F_REMCSUM_TX, changelink, false, - extack); - if (err) - return err; - } - - if (data[IFLA_VXLAN_REMCSUM_RX]) { - err = vxlan_nl2flag(conf, data, IFLA_VXLAN_REMCSUM_RX, - VXLAN_F_REMCSUM_RX, changelink, false, - extack); - if (err) - return err; - } - - if (data[IFLA_VXLAN_GBP]) { - err = vxlan_nl2flag(conf, data, IFLA_VXLAN_GBP, - VXLAN_F_GBP, changelink, false, extack); - if (err) - return err; - } - - if (data[IFLA_VXLAN_GPE]) { - err = vxlan_nl2flag(conf, data, IFLA_VXLAN_GPE, - VXLAN_F_GPE, changelink, false, - extack); - if (err) - return err; - } - - if (data[IFLA_VXLAN_REMCSUM_NOPARTIAL]) { - err = vxlan_nl2flag(conf, data, IFLA_VXLAN_REMCSUM_NOPARTIAL, - VXLAN_F_REMCSUM_NOPARTIAL, changelink, - false, extack); - if (err) - return err; - } + VXLAN_NL2FLAG(IFLA_VXLAN_UDP_ZERO_CSUM6_TX, VXLAN_F_UDP_ZERO_CSUM6_TX, changelink, false); + VXLAN_NL2FLAG(IFLA_VXLAN_UDP_ZERO_CSUM6_RX, VXLAN_F_UDP_ZERO_CSUM6_RX, changelink, false); + VXLAN_NL2FLAG(IFLA_VXLAN_REMCSUM_TX, IFLA_VXLAN_REMCSUM_TX, changelink, false); + VXLAN_NL2FLAG(IFLA_VXLAN_REMCSUM_RX, VXLAN_F_REMCSUM_RX, changelink, false); + VXLAN_NL2FLAG(IFLA_VXLAN_GBP, VXLAN_F_GBP, changelink, false); + VXLAN_NL2FLAG(IFLA_VXLAN_GPE, VXLAN_F_GPE, changelink, false); + VXLAN_NL2FLAG(IFLA_VXLAN_REMCSUM_NOPARTIAL, VXLAN_F_REMCSUM_NOPARTIAL, changelink, false); if (tb[IFLA_MTU]) { if (changelink) { diff --git a/include/net/vxlan.h b/include/net/vxlan.h index 3a41627cbdfe5..8a56b7a0f75f9 100644 --- a/include/net/vxlan.h +++ b/include/net/vxlan.h @@ -290,6 +290,16 @@ struct vxlan_dev { VXLAN_F_UDP_ZERO_CSUM6_RX | \ VXLAN_F_COLLECT_METADATA) + +#define VXLAN_NL2FLAG(iflag, flag, changelink, changelink_supported) { \ + if (data[iflag]) { \ + err = vxlan_nl2flag(conf, data, iflag, flag, changelink, \ + changelink_supported, extack); \ + if (err) \ + return err; \ + } \ +} + struct net_device *vxlan_dev_create(struct net *net, const char *name, u8 name_assign_type, struct vxlan_config *conf);