Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1238461pxu; Mon, 23 Nov 2020 15:36:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJypLUaa57qZ1IARljzcukXrWJGCwb3gyYEdCSgFSNpmsWJyC5iOUqbuDdU58w3Atn2g/YM4 X-Received: by 2002:a17:906:7c95:: with SMTP id w21mr1784266ejo.304.1606174614501; Mon, 23 Nov 2020 15:36:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606174614; cv=none; d=google.com; s=arc-20160816; b=RW8nhxSfPBFZZmMJYNIN/2RYXNo3d3/kq5eDnlFe0PFki/+XnpU7mqzoDZOb5W+f9g q+STiFC4BXw56iOJ0D0An367x+fXH22LbRB3mBi2ilIldrCeCMUU5Ruz2fx2afRui0Pi Z3B8NhHOxtO3lvWcFDX5GNrR+J9uEIiwvS2wx2DDP5LhY+ZFiY7o1cVeXivzFFa3rbR6 bK6+DY87KgqpFEb/NPp8IHO31UyGCNBiQz0EFfqeg32oHNAzzVHm+6YnDL1wRTnW8kVE K+yrX2AD4PIHoeUpr1pU9QDSQQlGGZ7UBE34YRaAqVEthjM9RXdb2RixF+Uq/b6XLWKj 8eVA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kOhds4DmTT8BWUm6/kTmTW6AJFbvF1yr9kW7GKWPcHI=; b=woznP47JLdVWABaOQhZhxjcj6rZGpUZK3g+G3IsFtuP+FSUHB2rYbWfoeF7POz+3Mc r2I/x1/q3ai1P4cv07iyKZr/Ccrzub7eRQCqjP2F3OZLeAtKTxJXcHAWVQFp1JMLb7s5 dJVSY2rYXfO8TSg32Zg81wVNEpuxVZLMNhs+8BeJHf9I2sIym2Q0PZbAD+SY87ghluPd s5WiyhuFNim5XJxfW0tnRS2rkgLDVozXShj+D5PWLT/zGW2eaTY/w3gfex7dXLU4/2fR 1vLmVDEgYGnDR6+Emb2jlep77pra+s+SSZPpQokWnruhEDDReoQq0TSUpSFLY+HYEFmv BcnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PcG9wIco; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hq35si6651130ejc.633.2020.11.23.15.36.32; Mon, 23 Nov 2020 15:36:54 -0800 (PST) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PcG9wIco; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731357AbgKWMeY (ORCPT + 99 others); Mon, 23 Nov 2020 07:34:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:45884 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731328AbgKWMeQ (ORCPT ); Mon, 23 Nov 2020 07:34:16 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1142820721; Mon, 23 Nov 2020 12:34:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606134855; bh=ChFTd4UevgyoLFuqHEffVVU0+91cGatDPh6lse5N6c0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PcG9wIco9g24hEQNtUdJpg9XiQaNIRceRrW3SypRmIFYvofXdwH4rwTYngnBekkGi AlEfA7BM8LXdp3zLOA8ntfaylXlYEMKD3rv1YStWQ5hLBYiEjL+RV4gIIjZffSi6+A s+9HHH7cE+Y9bfGpsE5f4RUudWgd1MSmwiN/NUHA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , Florian Fainelli , Jakub Kicinski Subject: [PATCH 5.4 015/158] net: Have netpoll bring-up DSA management interface Date: Mon, 23 Nov 2020 13:20:43 +0100 Message-Id: <20201123121820.672444155@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121819.943135899@linuxfoundation.org> References: <20201123121819.943135899@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Florian Fainelli [ Upstream commit 1532b9778478577152201adbafa7738b1e844868 ] DSA network devices rely on having their DSA management interface up and running otherwise their ndo_open() will return -ENETDOWN. Without doing this it would not be possible to use DSA devices as netconsole when configured on the command line. These devices also do not utilize the upper/lower linking so the check about the netpoll device having upper is not going to be a problem. The solution adopted here is identical to the one done for net/ipv4/ipconfig.c with 728c02089a0e ("net: ipv4: handle DSA enabled master network devices"), with the network namespace scope being restricted to that of the process configuring netpoll. Fixes: 04ff53f96a93 ("net: dsa: Add netconsole support") Tested-by: Vladimir Oltean Signed-off-by: Florian Fainelli Link: https://lore.kernel.org/r/20201117035236.22658-1-f.fainelli@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/core/netpoll.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) --- a/net/core/netpoll.c +++ b/net/core/netpoll.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -637,15 +638,15 @@ EXPORT_SYMBOL_GPL(__netpoll_setup); int netpoll_setup(struct netpoll *np) { - struct net_device *ndev = NULL; + struct net_device *ndev = NULL, *dev = NULL; + struct net *net = current->nsproxy->net_ns; struct in_device *in_dev; int err; rtnl_lock(); - if (np->dev_name[0]) { - struct net *net = current->nsproxy->net_ns; + if (np->dev_name[0]) ndev = __dev_get_by_name(net, np->dev_name); - } + if (!ndev) { np_err(np, "%s doesn't exist, aborting\n", np->dev_name); err = -ENODEV; @@ -653,6 +654,19 @@ int netpoll_setup(struct netpoll *np) } dev_hold(ndev); + /* bring up DSA management network devices up first */ + for_each_netdev(net, dev) { + if (!netdev_uses_dsa(dev)) + continue; + + err = dev_change_flags(dev, dev->flags | IFF_UP, NULL); + if (err < 0) { + np_err(np, "%s failed to open %s\n", + np->dev_name, dev->name); + goto put; + } + } + if (netdev_master_upper_dev_get(ndev)) { np_err(np, "%s is a slave device, aborting\n", np->dev_name); err = -EBUSY;