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=-7.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,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 00AD2C43381 for ; Wed, 27 Mar 2019 07:44:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BB79420811 for ; Wed, 27 Mar 2019 07:44:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=Mellanox.com header.i=@Mellanox.com header.b="MrYA0/oG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726185AbfC0Hor (ORCPT ); Wed, 27 Mar 2019 03:44:47 -0400 Received: from mail-eopbgr50085.outbound.protection.outlook.com ([40.107.5.85]:59990 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725827AbfC0Hor (ORCPT ); Wed, 27 Mar 2019 03:44:47 -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=JO2zC/BkdZL+DDTVhpROWvTvgqlXHdt+di307grbaNA=; b=MrYA0/oGSlX8OWZcyl82Chbzel81MmK/qDbdqKPBxaU5XGp2HkyoyxT5LBObcDxSFImvTgnqvtOUqRkF1r4Gi8TOozfTdT9jY3R1QsdQYqJCW430Ua1V25/OA9pU3ZP0bGAIznlCXANE3LW5k3gi8sVnjMXBq9lmlU5rT2dwTY4= Received: from AM0PR05MB6100.eurprd05.prod.outlook.com (20.178.119.209) by AM0PR05MB6593.eurprd05.prod.outlook.com (20.178.117.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1750.15; Wed, 27 Mar 2019 07:44:43 +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; Wed, 27 Mar 2019 07:44:43 +0000 From: Ido Schimmel To: David Ahern CC: "davem@davemloft.net" , "netdev@vger.kernel.org" , Jiri Pirko , Saeed Mahameed , David Ahern Subject: Re: [PATCH net-next 02/13] ipv4: Move IN_DEV_IGNORE_ROUTES_WITH_LINKDOWN to helper Thread-Topic: [PATCH net-next 02/13] ipv4: Move IN_DEV_IGNORE_ROUTES_WITH_LINKDOWN to helper Thread-Index: AQHU5E1aNqDVBBA6Dk6awuJDcJP1daYfGUSA Date: Wed, 27 Mar 2019 07:44:43 +0000 Message-ID: <20190327074441.GB12504@splinter> References: <20190327032942.20473-1-dsahern@kernel.org> <20190327032942.20473-3-dsahern@kernel.org> In-Reply-To: <20190327032942.20473-3-dsahern@kernel.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM6P194CA0103.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:8f::44) 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: f036a88c-5f8e-4261-5129-08d6b288136d 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:AM0PR05MB6593; x-ms-traffictypediagnostic: AM0PR05MB6593: x-microsoft-antispam-prvs: x-forefront-prvs: 0989A7979C x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(7916004)(366004)(346002)(376002)(396003)(39860400002)(136003)(199004)(189003)(102836004)(25786009)(186003)(33716001)(305945005)(7736002)(4326008)(76176011)(66066001)(6916009)(9686003)(6512007)(478600001)(486006)(71200400001)(106356001)(105586002)(6506007)(386003)(71190400001)(6246003)(6436002)(97736004)(26005)(6486002)(476003)(229853002)(53936002)(446003)(11346002)(14454004)(5660300002)(14444005)(316002)(99286004)(1076003)(8676002)(81166006)(8936002)(54906003)(81156014)(3846002)(2906002)(6116002)(256004)(33656002)(68736007)(52116002)(86362001);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR05MB6593;H:AM0PR05MB6100.eurprd05.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX: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: 90eFtaAAqiOwjgfeVEFWvrwS4821q/wtDS/JP39W0tQfxJnmhCt2nW2UUeXATHl9ejEPGN1Cmbnz+fbldumdQwFshuPxBqFnFhTAa5nCDtfTqrE7URzDRy/ElRRz7hSOwZn70Ocb0S0TIElkYzEbUnRRM0VbTTBu0rrTKFlQLmIirf/vHZQGwu77bIV2DdtFievkB+b3o7BEZyL5nrM0q8kqOuf4sKACp/WtmtcbuG7XymkwD4k5DB3eOWOnStM74XHx60jRvl9inOC8LlWsVwHwHIUCh2e9wEH8xI7hTQPLsx/BwHOXVn+d23xfVozPp3s5Ga8i1hNjtIDlzsZ1/XK611HMovEihcHiIGuwV/SNTt9Mopmne8izf+/DJGKlH1ByY/nvMPWrmHovuUEtVMfkHTNYMWO8V62Ov1zI+hc= Content-Type: text/plain; charset="us-ascii" Content-ID: <1203B18622DBD7418A03D383CCEC95FC@eurprd05.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: f036a88c-5f8e-4261-5129-08d6b288136d X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Mar 2019 07:44:43.4194 (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: AM0PR05MB6593 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Tue, Mar 26, 2019 at 08:29:31PM -0700, David Ahern wrote: > From: David Ahern >=20 > in_dev lookup followed by IN_DEV_IGNORE_ROUTES_WITH_LINKDOWN check > is called in several places, some with the rcu lock and others with the > rtnl held. >=20 > Move the check to a helper similar to what IPv6 has. Since the helper > can be invoked from either context use rcu_dereference_rtnl to > dereference ip_ptr. >=20 > Signed-off-by: David Ahern Reviewed-by: Ido Schimmel See one nit below. > --- > include/linux/inetdevice.h | 14 ++++++++++++++ > net/ipv4/fib_semantics.c | 31 +++++++------------------------ > net/ipv4/fib_trie.c | 4 +--- > 3 files changed, 22 insertions(+), 27 deletions(-) >=20 > diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h > index a64f21a97369..35e0390fd7b8 100644 > --- a/include/linux/inetdevice.h > +++ b/include/linux/inetdevice.h > @@ -237,6 +237,20 @@ static inline struct in_device *__in_dev_get_rtnl(co= nst struct net_device *dev) > return rtnl_dereference(dev->ip_ptr); > } > =20 > +/* called with rc_read_lock or rtnl held */ s/rc_read_lock/rcu_read_lock/ > +static inline bool ip_ignore_linkdown(const struct net_device *dev) > +{ > + struct in_device *in_dev; > + bool rc =3D false; > + > + in_dev =3D rcu_dereference_rtnl(dev->ip_ptr); > + if (in_dev && > + IN_DEV_IGNORE_ROUTES_WITH_LINKDOWN(in_dev)) > + rc =3D true; > + > + return rc; > +}