Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1575360pxb; Thu, 28 Oct 2021 06:20:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUkt/ai6CBb+4art1LVTgodC9aOYFgxEYpAf1ufVwMauXzMqBuwIr93hqWX3LroWrAJNLV X-Received: by 2002:a05:6402:2155:: with SMTP id bq21mr6013192edb.181.1635427223209; Thu, 28 Oct 2021 06:20:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635427223; cv=none; d=google.com; s=arc-20160816; b=DngE+2DwuQMw6PTg7G5YCNtDp4BqbYRYRAydXcva9n3G6Fy/GmW/ZCL9XjRdN3lro6 RAkMZW0xhRrvyMjR0Hkj+O16dPuQiK+vBUf4eG1b5Rsr0lSgOv+IX3KtVvElKqGd7o7x Q0m0WE8nDfnzg2D/elVOKoRmzXEceS/6l/w9rIS9DqxFz/Z6Io6qACEoAES5UVl424hW cucVbldWRgbSf9Hx0NCHeUyQJbT35TZrvfxefS9C3OOFAv+ZLR9kjfK22IA4ued2CBy+ /Z1EkfuWc+FvmFfGJcoxz1ZgA5xz4YkLpqUYdXUnGB59mAx3IF4tEPcZrUEWI/sIqtCF /KJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=63xsOrefK8IpWCuKzERNw+CRB2T7SLnoFp/degpMT/s=; b=G88eRIvanlXRtBEJlnaNYTpXR1meHfpK1vbFGD+NX1UvuvYA2/cwXM8j5WWCUh+H2G gt5IAWA5NE/oEt0gocAsopKzx51PboRYbjbVkQ+otPnDz3Fb5hmVflGKFEb7d2ybChP9 FdpOXGq3dx0elCIo0YD2m+q7+NsL1ywn+5MGqb8F7sS6ncfCRb2yn2XFW5lUOq3dJX1M wJDcpbEHg+sv5LnBIX1wmvMsB30hgxCYceLGU3BBYD1TPAYylP5uS5hLXrcighoMZuGi rIrDyD7OPvSL9gxjCT7yL9Ued0mj2jM1XcIIPGQrTQ/jQgHOVHjb+yUtZi+IWX/PGixM JqtQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sa4si2975046ejc.498.2021.10.28.06.19.58; Thu, 28 Oct 2021 06:20:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230240AbhJ1NUg (ORCPT + 99 others); Thu, 28 Oct 2021 09:20:36 -0400 Received: from relay12.mail.gandi.net ([217.70.178.232]:53431 "EHLO relay12.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229641AbhJ1NUf (ORCPT ); Thu, 28 Oct 2021 09:20:35 -0400 Received: (Authenticated sender: maxime.chevallier@bootlin.com) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 37921200021; Thu, 28 Oct 2021 13:18:05 +0000 (UTC) From: Maxime Chevallier To: davem@davemloft.net, Russell King , Hideaki YOSHIFUJI , David Ahern , Jakub Kicinski , Antoine Tenart Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com Subject: [PATCH net-next v2] net: ipconfig: Release the rtnl_lock while waiting for carrier Date: Thu, 28 Oct 2021 15:18:04 +0200 Message-Id: <20211028131804.413243-1-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While waiting for a carrier to come on one of the netdevices, some devices will require to take the rtnl lock at some point to fully initialize all parts of the link. That's the case for SFP, where the rtnl is taken when a module gets detected. This prevents mounting an NFS rootfs over an SFP link. This means that while ipconfig waits for carriers to be detected, no SFP modules can be detected in the meantime, it's only detected after ipconfig times out. This commit releases the rtnl_lock while waiting for the carrier to come up, and re-takes it to check the for the init device and carrier status. Signed-off-by: Maxime Chevallier --- v2: - Following Antoine's review, release the lock earlier and only explicitely protect the for_each_netdev loop - Rebased and targeted the patch towards net-next - Dropped the Fixes tag net/ipv4/ipconfig.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index 816d8aad5a68..9d41d5d5cd1e 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -262,6 +262,11 @@ static int __init ic_open_devs(void) dev->name, able, d->xid); } } + /* Devices with a complex topology like SFP ethernet interfaces needs + * the rtnl_lock at init. The carrier wait-loop must therefore run + * without holding it. + */ + rtnl_unlock(); /* no point in waiting if we could not bring up at least one device */ if (!ic_first_dev) @@ -274,9 +279,13 @@ static int __init ic_open_devs(void) msecs_to_jiffies(carrier_timeout * 1000))) { int wait, elapsed; + rtnl_lock(); for_each_netdev(&init_net, dev) - if (ic_is_init_dev(dev) && netif_carrier_ok(dev)) + if (ic_is_init_dev(dev) && netif_carrier_ok(dev)) { + rtnl_unlock(); goto have_carrier; + } + rtnl_unlock(); msleep(1); @@ -289,7 +298,6 @@ static int __init ic_open_devs(void) next_msg = jiffies + msecs_to_jiffies(20000); } have_carrier: - rtnl_unlock(); *last = NULL; -- 2.25.4