diff mbox series

[ethtool] ioctl: less confusing error message for master-slave parameter

Message ID 87e48543d091a6851ba1bd62c6fb79cf11a478de.1613952250.git.mkubecek@suse.cz (mailing list archive)
State Accepted, archived
Delegated to: Michal Kubecek
Headers show
Series [ethtool] ioctl: less confusing error message for master-slave parameter | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Michal Kubecek Feb. 22, 2021, 12:05 a.m. UTC
The fallback code issues a reasonable error message when a subcommand
implemented only via netlink would end up being processed by ioctl code,
e.g. because a new ethtool runs on an older kernel without netlink support.
But when a netlink only parameter is passed to subcommand which is
recognized by ioctl code in general, it is handled as an unknown one.

At the the moment, there is only one such parameter: master-slave for
'-s' subcommand. As it is not handled by the generic command line parser,
address this with a quick fix and leave updating the generic parser for
later.

Reported-by: Bruce LIU <ccieliu@gmail.com>
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
 ethtool.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/ethtool.c b/ethtool.c
index fb90e9e456b9..15e9d34831b3 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -72,6 +72,16 @@  static void exit_bad_args(void)
 	exit(1);
 }
 
+static void exit_nlonly_param(const char *name) __attribute__((noreturn));
+
+static void exit_nlonly_param(const char *name)
+{
+	fprintf(stderr,
+		"ethtool: parameter '%s' can be used only with netlink\n",
+		name);
+	exit(1);
+}
+
 typedef enum {
 	CMDL_NONE,
 	CMDL_BOOL,
@@ -3066,6 +3076,8 @@  static int do_sset(struct cmd_context *ctx)
 					ARRAY_SIZE(cmdline_msglvl));
 				break;
 			}
+		} else if (!strcmp(argp[i], "master-slave")) {
+			exit_nlonly_param(argp[i]);
 		} else {
 			exit_bad_args();
 		}