diff mbox series

[net-next] netconsole: Do not shutdown dynamic configuration if cmdline is invalid

Message ID 20240510103005.3001545-1-leitao@debian.org (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net-next] netconsole: Do not shutdown dynamic configuration if cmdline is invalid | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 925 this patch: 925
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/build_clang success Errors and warnings before: 936 this patch: 936
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 936 this patch: 936
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 19 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline fail Was 0 now: 1
netdev/contest success net-next-2024-05-13--18-00 (tests: 1019)

Commit Message

Breno Leitao May 10, 2024, 10:30 a.m. UTC
If a user provides an invalid netconsole configuration during boot time
(e.g., specifying an invalid ethX interface), netconsole will be
entirely disabled. Consequently, the user won't be able to create new
entries in /sys/kernel/config/netconsole/ as that directory does not
exist.

Apart from misconfiguration, another issue arises when ethX is loaded as
a module and the netconsole= line in the command line points to ethX,
resulting in an obvious failure. This renders netconsole unusable, as
/sys/kernel/config/netconsole/ will never appear. This is more annoying
since users reconfigure (or just toggle) the configuratin later (see
commit 5fbd6cdbe304b ("netconsole: Attach cmdline target to dynamic
target"))

Create /sys/kernel/config/netconsole/ even if the command line arguments
are invalid, so, users can create dynamic entries in netconsole.

Reported-by: Aijay Adams <aijay@meta.com>
Signed-off-by: Breno Leitao <leitao@debian.org>
---
 drivers/net/netconsole.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Jakub Kicinski May 13, 2024, 9:51 p.m. UTC | #1
On Fri, 10 May 2024 03:30:05 -0700 Breno Leitao wrote:
> +static inline bool dynamic_netconsole_enabled(void)
> +{
> +	return IS_ENABLED(CONFIG_NETCONSOLE_DYNAMIC);
> +}

Why the separate static inline?
We can put IS_ENABLED.. directly in the if condition.
Breno Leitao May 14, 2024, 12:06 p.m. UTC | #2
On Mon, May 13, 2024 at 02:51:29PM -0700, Jakub Kicinski wrote:
> On Fri, 10 May 2024 03:30:05 -0700 Breno Leitao wrote:
> > +static inline bool dynamic_netconsole_enabled(void)
> > +{
> > +	return IS_ENABLED(CONFIG_NETCONSOLE_DYNAMIC);
> > +}
> 
> Why the separate static inline?

I thought it would make the code easier to read.

> We can put IS_ENABLED.. directly in the if condition.

Sure. I will send a v2 with the IS_ENABLED() inside the if condition.

Thanks for the review.
diff mbox series

Patch

diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index d7070dd4fe73..e69bc88c22a0 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -122,6 +122,11 @@  struct netconsole_target {
 	struct netpoll		np;
 };
 
+static inline bool dynamic_netconsole_enabled(void)
+{
+	return IS_ENABLED(CONFIG_NETCONSOLE_DYNAMIC);
+}
+
 #ifdef	CONFIG_NETCONSOLE_DYNAMIC
 
 static struct configfs_subsystem netconsole_subsys;
@@ -1262,6 +1267,8 @@  static int __init init_netconsole(void)
 		while ((target_config = strsep(&input, ";"))) {
 			nt = alloc_param_target(target_config, count);
 			if (IS_ERR(nt)) {
+				if (dynamic_netconsole_enabled())
+					continue;
 				err = PTR_ERR(nt);
 				goto fail;
 			}