Skip to contentSkip to conversation

Add runtime support for disabling netlink

PATCH Applied Krzysztof Olędzki 2 participants 2 messages Sep 12, 2024 – Sep 16, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Add runtime support for disabling netlink

Provide --disable-netlink option for disabling netlink during runtime, without the need to recompile the binary.

---
 ethtool.8.in      | 6 ++++++
 ethtool.c         | 6 ++++++
 internal.h        | 1 +
 netlink/netlink.c | 5 +++++
 4 files changed, 18 insertions(+)
ethtool.8.in +6 -0
index 11bb0f9..0b54983 100644
@@ -137,6 +137,9 @@ ethtool \- query or control network driver and hardware settings
 .BN --debug
 .I args
 .HP
+.B ethtool [--disable-netlink]
+.I args
+.HP
 .B ethtool [--json]
 .I args
 .HP
@@ -579,6 +582,9 @@ lB	l.
 0x10  Structure of netlink messages
 .TE
 .TP
+.BI \-\-disable-netlink
+Do not use netlink and fall back to the ioctl interface if possible.
+.TP
 .BI \-\-json
 Output results in JavaScript Object Notation (JSON). Only a subset of
 options support this. Those which do not will continue to output
ethtool.c +6 -0
index 7f47407..dc28069 100644
@@ -6537,6 +6537,12 @@ int main(int argc, char **argp)
 			argc -= 2;
 			continue;
 		}
+		if (*argp && !strcmp(*argp, "--disable-netlink")) {
+			ctx.nl_disable = true;
+			argp += 1;
+			argc -= 1;
+			continue;
+		}
 		if (*argp && !strcmp(*argp, "--json")) {
 			ctx.json = true;
 			argp += 1;
internal.h +1 -0
index 4b994f5..84c64be 100644
@@ -221,6 +221,7 @@ struct cmd_context {
 	char **argp;		/* arguments to the sub-command */
 	unsigned long debug;	/* debugging mask */
 	bool json;		/* Output JSON, if supported */
+	bool nl_disable;	/* Disable netlink even if available */
 	bool show_stats;	/* include command-specific stats */
 #ifdef ETHTOOL_ENABLE_NETLINK
 	struct nl_context *nlctx;	/* netlink context (opaque) */
netlink/netlink.c +5 -0
index ef0d825..3cf1710 100644
@@ -470,6 +470,11 @@ void netlink_run_handler(struct cmd_context *ctx, nl_chk_t nlchk,
 	const char *reason;
 	int ret;
 
+	if (ctx->nl_disable) {
+		reason = "netlink disabled";
+		goto no_support;
+	}
+
 	if (nlchk && !nlchk(ctx)) {
 		reason = "ioctl-only request";
 		goto no_support;
Signature · 1 line
2.46.0
#1 lore raw
This series was applied to ethtool/ethtool.git (master) by Michal Kubecek <[email protected]>:

Hello:

This series was applied to ethtool/ethtool.git (master) by Michal Kubecek <[email protected]>:

Quoted 10 lines · On Wed, 11 Sep 2024 23:56:45 -0700 you wrote:

Provide --disable-netlink option for disabling netlink during runtime, without the need to recompile the binary.

---
 ethtool.8.in      | 6 ++++++
 ethtool.c         | 6 ++++++
 internal.h        | 1 +
 netlink/netlink.c | 5 +++++
 4 files changed, 18 insertions(+)

Here is the summary with links:
- [ethtool,1/2] Add runtime support for disabling netlink

    https://git.kernel.org/pub/scm/network/ethtool/ethtool.git/commit/?id=6e3ac505bcc7
  - [ethtool,2/2] qsf: Better handling of Page A2h netlink read failure
    https://git.kernel.org/pub/scm/network/ethtool/ethtool.git/commit/?id=814980faaef1

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html