From patchwork Thu Feb 20 07:07:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 1241267 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=idosch.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=PuxHCl40; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 48NQfp5WPBz9sRN for ; Thu, 20 Feb 2020 18:08:34 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726871AbgBTHId (ORCPT ); Thu, 20 Feb 2020 02:08:33 -0500 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:52375 "EHLO out2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726813AbgBTHIb (ORCPT ); Thu, 20 Feb 2020 02:08:31 -0500 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id D863D21E6A; Thu, 20 Feb 2020 02:08:30 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 20 Feb 2020 02:08:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=qQKcQhuKEmGEKzCdkOO2/hCttwTnv8VIy5dyBGSVZiE=; b=PuxHCl40 jm4OsmL4m/7fTn3EUZCPVqXx51mS666kjZ28ddzKP7USsvo4R8tSRZOG9aiQxkvr lTLLh10maX2hetIONlQTMDiDNbRw1yaYfb8NIEEUn37InItZFz83MklMJ8If+Cmy AdmrQIAlo3nl/Ce+mfompe/jxorhTsPvcpkOprfEw83uq8/JeRGOvBv0DC0kivYf KqPbrNOHAvKAsz3KB2eUO8iQw1y3AAftV9aeUPSTcWeQOCnavLg75lbu1xkAoqVH kyTYZ2cPCUHwS+OPYA8/DhfXOUCBfv9YyPxLgNPBExIgJqShcif2zx0/y/uh7OGa t3Fqpt74GkxKcA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrkedugddutdegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepkfguohcuufgthhhimhhmvghluceoihguohhstghhsehiugho shgthhdrohhrgheqnecukfhppeduleefrdegjedrudeihedrvdehudenucevlhhushhtvg hrufhiiigvpeegnecurfgrrhgrmhepmhgrihhlfhhrohhmpehiughoshgthhesihguohhs tghhrdhorhhg X-ME-Proxy: Received: from splinter.mtl.com (unknown [193.47.165.251]) by mail.messagingengine.com (Postfix) with ESMTPA id B9FFB3060D1A; Thu, 20 Feb 2020 02:08:29 -0500 (EST) From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, jiri@mellanox.com, mlxsw@mellanox.com, Ido Schimmel Subject: [PATCH net-next 09/15] mlxsw: spectrum_router: Do not assume RTNL is taken during RIF teardown Date: Thu, 20 Feb 2020 09:07:54 +0200 Message-Id: <20200220070800.364235-10-idosch@idosch.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200220070800.364235-1-idosch@idosch.org> References: <20200220070800.364235-1-idosch@idosch.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ido Schimmel IPv6 addresses are deleted in an atomic context, so the driver defers the potential teardown of the associated router interface (RIF) to a work item that takes RTNL. The RIF is only destroyed if the associated netdev does not have any IP addresses (both IPv4 and IPv6). The IPv4 device ('struct in_device') is currently fetched via __in_dev_get_rtnl() which assumes RTNL is taken. Since RTNL is going to be removed, convert it to use __in_dev_get_rcu() from an RCU read-side critical section. Note that the IPv6 device ('struct inet6_dev') is fetched via __in6_dev_get(), which does not require RTNL. Signed-off-by: Ido Schimmel Acked-by: Jiri Pirko --- drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 28dca7aa4ce0..21e8539727be 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -6285,7 +6285,8 @@ mlxsw_sp_rif_should_config(struct mlxsw_sp_rif *rif, struct net_device *dev, case NETDEV_UP: return rif == NULL; case NETDEV_DOWN: - idev = __in_dev_get_rtnl(dev); + rcu_read_lock(); + idev = __in_dev_get_rcu(dev); if (idev && idev->ifa_list) addr_list_empty = false; @@ -6293,6 +6294,7 @@ mlxsw_sp_rif_should_config(struct mlxsw_sp_rif *rif, struct net_device *dev, if (addr_list_empty && inet6_dev && !list_empty(&inet6_dev->addr_list)) addr_list_empty = false; + rcu_read_unlock(); /* macvlans do not have a RIF, but rather piggy back on the * RIF of their lower device.