mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-23 09:19:51 +00:00
net: Have netpoll bring-up DSA management interface
[ Upstream commit1532b97784
] 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 with728c02089a
("net: ipv4: handle DSA enabled master network devices"), with the network namespace scope being restricted to that of the process configuring netpoll. Fixes:04ff53f96a
("net: dsa: Add netconsole support") Tested-by: Vladimir Oltean <olteanv@gmail.com> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Link: https://lore.kernel.org/r/20201117035236.22658-1-f.fainelli@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
838973c052
commit
9625d94d29
1 changed files with 18 additions and 4 deletions
|
@ -28,6 +28,7 @@
|
|||
#include <linux/slab.h>
|
||||
#include <linux/export.h>
|
||||
#include <linux/if_vlan.h>
|
||||
#include <net/dsa.h>
|
||||
#include <net/tcp.h>
|
||||
#include <net/udp.h>
|
||||
#include <net/addrconf.h>
|
||||
|
@ -661,15 +662,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;
|
||||
|
@ -677,6 +678,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);
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue