]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: netconsole: Populate dynamic entry even if netpoll fails
authorBreno Leitao <leitao@debian.org>
Thu, 22 Aug 2024 11:10:48 +0000 (04:10 -0700)
committerJakub Kicinski <kuba@kernel.org>
Mon, 26 Aug 2024 16:25:44 +0000 (09:25 -0700)
Currently, netconsole discards targets that fail during initialization,
causing two issues:

1) Inconsistency between target list and configfs entries
  * user pass cmdline0, cmdline1. If cmdline0 fails, then cmdline1
    becomes cmdline0 in configfs.

2) Inability to manage failed targets from userspace
  * If user pass a target that fails with netpoll (interface not loaded at
    netcons initialization time, such as interface is a module), then
    the target will not exist in the configfs, so, user cannot re-enable
    or modify it from userspace.

Failed targets are now added to the target list and configfs, but
remain disabled until manually enabled or reconfigured. This change does
not change the behaviour if CONFIG_NETCONSOLE_DYNAMIC is not set.

CC: Aijay Adams <aijay@meta.com>
Signed-off-by: Breno Leitao <leitao@debian.org>
Link: https://patch.msgid.link/20240822111051.179850-3-leitao@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/netconsole.c

index 72384c1ecc5cebd9d5ff017d4a63aa27b64f639e..01cf33fa75036c641f416fcd4ebf735aaf465b75 100644 (file)
@@ -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;