diff mbox series

[ethtool,1/2] Add runtime support for disabling netlink

Message ID 810dd96b-aff6-403a-88e5-3608ef248b90@ans.pl (mailing list archive)
State Accepted
Commit 6e3ac505bcc778b04d43dd1858af8287e8a08ef7
Delegated to: Michal Kubecek
Headers show
Series [ethtool,1/2] Add runtime support for disabling netlink | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Krzysztof Olędzki Sept. 12, 2024, 6:56 a.m. UTC
Provide --disable-netlink option for disabling netlink during runtime,
without the need to recompile the binary.

Signed-off-by: Krzysztof Piotr Oledzki <ole@ans.pl>
---
 ethtool.8.in      | 6 ++++++
 ethtool.c         | 6 ++++++
 internal.h        | 1 +
 netlink/netlink.c | 5 +++++
 4 files changed, 18 insertions(+)

Comments

patchwork-bot+netdevbpf@kernel.org Sept. 16, 2024, 8:10 p.m. UTC | #1
Hello:

This series was applied to ethtool/ethtool.git (master)
by Michal Kubecek <mkubecek@suse.cz>:

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.
> 
> Signed-off-by: Krzysztof Piotr Oledzki <ole@ans.pl>
> ---
>  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!
diff mbox series

Patch

diff --git a/ethtool.8.in b/ethtool.8.in
index 11bb0f9..0b54983 100644
--- a/ethtool.8.in
+++ b/ethtool.8.in
@@ -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
diff --git a/ethtool.c b/ethtool.c
index 7f47407..dc28069 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -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;
diff --git a/internal.h b/internal.h
index 4b994f5..84c64be 100644
--- a/internal.h
+++ b/internal.h
@@ -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) */
diff --git a/netlink/netlink.c b/netlink/netlink.c
index ef0d825..3cf1710 100644
--- a/netlink/netlink.c
+++ b/netlink/netlink.c
@@ -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;