From mboxrd@z Thu Jan 1 00:00:00 1970 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=-4.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED autolearn=ham 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 11101C43381 for ; Thu, 28 Mar 2019 08:34:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D196F2173C for ; Thu, 28 Mar 2019 08:34:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=Mellanox.com header.i=@Mellanox.com header.b="Cto3q3zU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726131AbfC1IeV (ORCPT ); Thu, 28 Mar 2019 04:34:21 -0400 Received: from mail-eopbgr30068.outbound.protection.outlook.com ([40.107.3.68]:9059 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725779AbfC1IeU (ORCPT ); Thu, 28 Mar 2019 04:34:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W3a7yUfNH55jnFFPoYLPxVcYFpog02zdRUpqiEEeY+s=; b=Cto3q3zUMSlvUO0lEdrb8WZPSkqwh+E+jxktg8+ALnDAp6ZEb0dxlX6MT02Do4mj7JUlOzNDdXfQ/U84yJKiA0ZuNu/qiWxs8nYA/QMyLGZelhsi3Hq5REO3URt6td8zGEwQ2eBY7Aoq9Ct24Kw34xCVzcHzX7sCH/r7BAIxd8Q= Received: from AM0PR05MB6100.eurprd05.prod.outlook.com (20.178.119.209) by AM0PR05MB4609.eurprd05.prod.outlook.com (52.133.57.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1730.18; Thu, 28 Mar 2019 08:34:16 +0000 Received: from AM0PR05MB6100.eurprd05.prod.outlook.com ([fe80::85ee:723:721e:51f9]) by AM0PR05MB6100.eurprd05.prod.outlook.com ([fe80::85ee:723:721e:51f9%4]) with mapi id 15.20.1730.019; Thu, 28 Mar 2019 08:34:16 +0000 From: Ido Schimmel To: David Ahern CC: "davem@davemloft.net" , "netdev@vger.kernel.org" , Jiri Pirko , Saeed Mahameed , David Ahern Subject: Re: [PATCH v3 net-next 03/13] ipv4: Create init helper for fib_nh Thread-Topic: [PATCH v3 net-next 03/13] ipv4: Create init helper for fib_nh Thread-Index: AQHU5RpDtbEJn+46DEqTAUfD1jBhOaYgt9aA Date: Thu, 28 Mar 2019 08:34:16 +0000 Message-ID: <20190328083413.GA13114@splinter> References: <20190328035358.4929-1-dsahern@kernel.org> <20190328035358.4929-4-dsahern@kernel.org> In-Reply-To: <20190328035358.4929-4-dsahern@kernel.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: LO2P123CA0008.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:a6::20) To AM0PR05MB6100.eurprd05.prod.outlook.com (2603:10a6:208:12e::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=idosch@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: d1c98cf1-b119-4dcd-19c7-08d6b35829fd x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600127)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:AM0PR05MB4609; x-ms-traffictypediagnostic: AM0PR05MB4609: x-microsoft-antispam-prvs: x-forefront-prvs: 0990C54589 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(7916004)(39860400002)(396003)(136003)(346002)(376002)(366004)(189003)(199004)(6512007)(86362001)(54906003)(52116002)(97736004)(316002)(6486002)(71190400001)(81156014)(14454004)(99286004)(81166006)(478600001)(25786009)(2906002)(8676002)(68736007)(3846002)(33656002)(9686003)(105586002)(33716001)(106356001)(6116002)(8936002)(14444005)(6506007)(71200400001)(256004)(446003)(476003)(66066001)(5660300002)(486006)(26005)(186003)(7736002)(386003)(4326008)(11346002)(53936002)(6916009)(6246003)(229853002)(76176011)(102836004)(6436002)(305945005)(1076003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR05MB4609;H:AM0PR05MB6100.eurprd05.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: YtN8igJoTre7ygtsvRW1eW5ivesIlBDgBtdh3qIeFL2aMAlmPlYQ/KqJNC/d1sXYDW58+uMnyXVoKtNXQQRzGGvJsi/hgZVnkySsp8tLiAjZrG/OAxJSIosEaiMKLi8nYPYS3WEAw0NvBiJOBo0dOu6PX/KDGy2Q06QY1YEf8iCSCtTPa9l2Y86h7I9dx5tczqIds0ILteD+Sst5BabyGkPGY9Nny1uhnfi/iinxoaCX7ahdjfactikN+V8yFCw8E1u404ZkDbBhp3S/uuRWfpCQC2BltlPLtF6RScj1/syMymvSlxPalabN3PqHSR47rbaYMdaurQo8uFZSaZFvPrqRAjTyJJ3m9mNOmFTwauxiP/0/IRmWm5KPID6/V9geL5iCPip8Lsidg3hN4mm9/j9Xo4DbdsHS+qCTTJi7cFw= Content-Type: text/plain; charset="us-ascii" Content-ID: <7157C5455A4CDF4B89BD5C6B45ED9F67@eurprd05.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: d1c98cf1-b119-4dcd-19c7-08d6b35829fd X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Mar 2019 08:34:16.4822 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB4609 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Wed, Mar 27, 2019 at 08:53:48PM -0700, David Ahern wrote: > From: David Ahern >=20 > Consolidate the fib_nh initialization which is duplicated between > fib_create_info for single path and fib_get_nhs for multipath. > Export the helper to allow for use with nexthop objects in the > future. >=20 > Signed-off-by: David Ahern Reviewed-by: Ido Schimmel One comment below. > +int fib_nh_init(struct net *net, struct fib_nh *nh, > + struct fib_config *cfg, int nh_weight, > + struct netlink_ext_ack *extack) > +{ > + int err =3D -ENOMEM; > + > + nh->nh_pcpu_rth_output =3D alloc_percpu(struct rtable __rcu *); > + if (!nh->nh_pcpu_rth_output) > + goto err_out; > + > + if (cfg->fc_encap) { > + struct lwtunnel_state *lwtstate; > + > + err =3D -EINVAL; > + if (cfg->fc_encap_type =3D=3D LWTUNNEL_ENCAP_NONE) { > + NL_SET_ERR_MSG(extack, "LWT encap type not specified"); > + goto lwt_failure; > + } > + err =3D lwtunnel_build_state(cfg->fc_encap_type, > + cfg->fc_encap, AF_INET, cfg, > + &lwtstate, extack); > + if (err) > + goto lwt_failure; > + > + nh->nh_lwtstate =3D lwtstate_get(lwtstate); > + } > + > + nh->nh_oif =3D cfg->fc_oif; > + nh->nh_gw =3D cfg->fc_gw; > + nh->nh_flags =3D cfg->fc_flags; > + > +#ifdef CONFIG_IP_ROUTE_CLASSID > + nh->nh_tclassid =3D cfg->fc_flow; > + if (nh->nh_tclassid) > + net->ipv4.fib_num_tclassid_users++; > +#endif > +#ifdef CONFIG_IP_ROUTE_MULTIPATH > + nh->nh_weight =3D nh_weight; After this series 'nhc_weight' is always defined in the nexthop struct because it is shared with IPv6 which does not have a corresponding Kconfig. This ifdef can be removed from here and probably from a few other places as well. > +#endif > + return 0; > + > +lwt_failure: > + rt_fibinfo_free_cpus(nh->nh_pcpu_rth_output); > + nh->nh_pcpu_rth_output =3D NULL; > +err_out: > + return err; > +}