mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 10:04:04 +02:00
Merge branch 'netconsole-populate-dynamic-entry-even-if-netpoll-fails'
Breno Leitao says: ==================== netconsole: Populate dynamic entry even if netpoll fails The current implementation of netconsole removes the entry and fails entirely if netpoll fails to initialize. This approach is suboptimal, as it prevents reconfiguration or re-enabling of the target through configfs. While this issue might seem minor if it were rare, it actually occurs frequently when the network module is configured as a loadable module. In such cases, the network is unavailable when netconsole initializes, causing netpoll to fail. This failure forces users to reconfigure the target from scratch, discarding any settings provided via the command line. The proposed change would keep the target available in configfs, albeit in a disabled state. This modification allows users to adjust settings or simply re-enable the target once the network module has loaded, providing a more flexible and user-friendly solution. v2: https://lore.kernel.org/20240819103616.2260006-1-leitao@debian.org v1: https://lore.kernel.org/20240809161935.3129104-1-leitao@debian.org ==================== Link: https://patch.msgid.link/20240822111051.179850-1-leitao@debian.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
9f08ae4ffa
|
|
@ -1258,11 +1258,18 @@ static struct netconsole_target *alloc_param_target(char *target_config,
|
|||
goto fail;
|
||||
|
||||
err = netpoll_setup(&nt->np);
|
||||
if (err)
|
||||
goto fail;
|
||||
|
||||
if (err) {
|
||||
pr_err("Not enabling netconsole for %s%d. Netpoll setup failed\n",
|
||||
NETCONSOLE_PARAM_TARGET_PREFIX, cmdline_count);
|
||||
if (!IS_ENABLED(CONFIG_NETCONSOLE_DYNAMIC))
|
||||
/* only fail if dynamic reconfiguration is set,
|
||||
* otherwise, keep the target in the list, but disabled.
|
||||
*/
|
||||
goto fail;
|
||||
} else {
|
||||
nt->enabled = true;
|
||||
}
|
||||
populate_configfs_item(nt, cmdline_count);
|
||||
nt->enabled = true;
|
||||
|
||||
return nt;
|
||||
|
||||
|
|
|
|||
|
|
@ -624,12 +624,9 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev)
|
|||
const struct net_device_ops *ops;
|
||||
int err;
|
||||
|
||||
np->dev = ndev;
|
||||
strscpy(np->dev_name, ndev->name, IFNAMSIZ);
|
||||
|
||||
if (ndev->priv_flags & IFF_DISABLE_NETPOLL) {
|
||||
np_err(np, "%s doesn't support polling, aborting\n",
|
||||
np->dev_name);
|
||||
ndev->name);
|
||||
err = -ENOTSUPP;
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -647,7 +644,7 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev)
|
|||
|
||||
refcount_set(&npinfo->refcnt, 1);
|
||||
|
||||
ops = np->dev->netdev_ops;
|
||||
ops = ndev->netdev_ops;
|
||||
if (ops->ndo_netpoll_setup) {
|
||||
err = ops->ndo_netpoll_setup(ndev, npinfo);
|
||||
if (err)
|
||||
|
|
@ -658,6 +655,8 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev)
|
|||
refcount_inc(&npinfo->refcnt);
|
||||
}
|
||||
|
||||
np->dev = ndev;
|
||||
strscpy(np->dev_name, ndev->name, IFNAMSIZ);
|
||||
npinfo->netpoll = np;
|
||||
|
||||
/* last thing to do is link it to the net device structure */
|
||||
|
|
@ -675,6 +674,7 @@ EXPORT_SYMBOL_GPL(__netpoll_setup);
|
|||
int netpoll_setup(struct netpoll *np)
|
||||
{
|
||||
struct net_device *ndev = NULL;
|
||||
bool ip_overwritten = false;
|
||||
struct in_device *in_dev;
|
||||
int err;
|
||||
|
||||
|
|
@ -739,6 +739,7 @@ int netpoll_setup(struct netpoll *np)
|
|||
}
|
||||
|
||||
np->local_ip.ip = ifa->ifa_local;
|
||||
ip_overwritten = true;
|
||||
np_info(np, "local IP %pI4\n", &np->local_ip.ip);
|
||||
} else {
|
||||
#if IS_ENABLED(CONFIG_IPV6)
|
||||
|
|
@ -755,6 +756,7 @@ int netpoll_setup(struct netpoll *np)
|
|||
!!(ipv6_addr_type(&np->remote_ip.in6) & IPV6_ADDR_LINKLOCAL))
|
||||
continue;
|
||||
np->local_ip.in6 = ifp->addr;
|
||||
ip_overwritten = true;
|
||||
err = 0;
|
||||
break;
|
||||
}
|
||||
|
|
@ -785,6 +787,9 @@ int netpoll_setup(struct netpoll *np)
|
|||
return 0;
|
||||
|
||||
put:
|
||||
DEBUG_NET_WARN_ON_ONCE(np->dev);
|
||||
if (ip_overwritten)
|
||||
memset(&np->local_ip, 0, sizeof(np->local_ip));
|
||||
netdev_put(ndev, &np->dev_tracker);
|
||||
unlock:
|
||||
rtnl_unlock();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user