All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH ethtool] ioctl: less confusing error message for master-slave parameter
@ 2021-02-22  0:05 Michal Kubecek
  0 siblings, 0 replies; only message in thread
From: Michal Kubecek @ 2021-02-22  0:05 UTC (permalink / raw)
  To: netdev; +Cc: Bruce LIU

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 --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();
 		}
-- 
2.30.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-02-22  0:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-22  0:05 [PATCH ethtool] ioctl: less confusing error message for master-slave parameter Michal Kubecek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.