Skip to content

Commit 1532b97

Browse files
ffainellikuba-moo
authored andcommitted
net: Have netpoll bring-up DSA management interface
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 728c020 ("net: ipv4: handle DSA enabled master network devices"), with the network namespace scope being restricted to that of the process configuring netpoll. Fixes: 04ff53f ("net: dsa: Add netconsole support") Tested-by: Vladimir Oltean <[email protected]> Signed-off-by: Florian Fainelli <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 3a36060 commit 1532b97

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

net/core/netpoll.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <linux/slab.h>
3030
#include <linux/export.h>
3131
#include <linux/if_vlan.h>
32+
#include <net/dsa.h>
3233
#include <net/tcp.h>
3334
#include <net/udp.h>
3435
#include <net/addrconf.h>
@@ -657,22 +658,35 @@ EXPORT_SYMBOL_GPL(__netpoll_setup);
657658

658659
int netpoll_setup(struct netpoll *np)
659660
{
660-
struct net_device *ndev = NULL;
661+
struct net_device *ndev = NULL, *dev = NULL;
662+
struct net *net = current->nsproxy->net_ns;
661663
struct in_device *in_dev;
662664
int err;
663665

664666
rtnl_lock();
665-
if (np->dev_name[0]) {
666-
struct net *net = current->nsproxy->net_ns;
667+
if (np->dev_name[0])
667668
ndev = __dev_get_by_name(net, np->dev_name);
668-
}
669+
669670
if (!ndev) {
670671
np_err(np, "%s doesn't exist, aborting\n", np->dev_name);
671672
err = -ENODEV;
672673
goto unlock;
673674
}
674675
dev_hold(ndev);
675676

677+
/* bring up DSA management network devices up first */
678+
for_each_netdev(net, dev) {
679+
if (!netdev_uses_dsa(dev))
680+
continue;
681+
682+
err = dev_change_flags(dev, dev->flags | IFF_UP, NULL);
683+
if (err < 0) {
684+
np_err(np, "%s failed to open %s\n",
685+
np->dev_name, dev->name);
686+
goto put;
687+
}
688+
}
689+
676690
if (netdev_master_upper_dev_get(ndev)) {
677691
np_err(np, "%s is a slave device, aborting\n", np->dev_name);
678692
err = -EBUSY;

0 commit comments

Comments
 (0)