netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH ethtool] features: accept long legacy flag names when setting features
@ 2020-04-13 21:21 Michal Kubecek
  2020-05-13 19:57 ` John W. Linville
  0 siblings, 1 reply; 2+ messages in thread
From: Michal Kubecek @ 2020-04-13 21:21 UTC (permalink / raw)
  To: John Linville; +Cc: netdev, Konstantin Kharlamov

The legacy feature flags have long names (e.g. "generic-receive-offload")
and short names (e.g. "gro"). While "ethtool -k" shows only long names,
"ethtool -K" accepts only short names. This is a bit confusing as users
have to resort to documentation to see what flag name to use; in
particular, if a legacy flag corresponds to only one actual kernel feature,
"ethtool -k" shows the output in the same form as if long flag name were
a kernel feature name but this name cannot be used to set the flag/feature.

Accept both short and long legacy flag names in "ethool -K".

Reported-by: Konstantin Kharlamov <hi-angel@yandex.ru>
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
 ethtool.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/ethtool.c b/ethtool.c
index 1b4e08b6e60f..73f15b3912c1 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -2297,26 +2297,33 @@ static int do_sfeatures(struct cmd_context *ctx)
 	/* Generate cmdline_info for legacy flags and kernel-named
 	 * features, and parse our arguments.
 	 */
-	cmdline_features = calloc(ARRAY_SIZE(off_flag_def) + defs->n_features,
+	cmdline_features = calloc(2 * ARRAY_SIZE(off_flag_def) +
+				  defs->n_features,
 				  sizeof(cmdline_features[0]));
 	if (!cmdline_features) {
 		perror("Cannot parse arguments");
 		rc = 1;
 		goto err;
 	}
-	for (i = 0; i < ARRAY_SIZE(off_flag_def); i++)
+	j = 0;
+	for (i = 0; i < ARRAY_SIZE(off_flag_def); i++) {
 		flag_to_cmdline_info(off_flag_def[i].short_name,
 				     off_flag_def[i].value,
 				     &off_flags_wanted, &off_flags_mask,
-				     &cmdline_features[i]);
+				     &cmdline_features[j++]);
+		flag_to_cmdline_info(off_flag_def[i].long_name,
+				     off_flag_def[i].value,
+				     &off_flags_wanted, &off_flags_mask,
+				     &cmdline_features[j++]);
+	}
 	for (i = 0; i < defs->n_features; i++)
 		flag_to_cmdline_info(
 			defs->def[i].name, FEATURE_FIELD_FLAG(i),
 			&FEATURE_WORD(efeatures->features, i, requested),
 			&FEATURE_WORD(efeatures->features, i, valid),
-			&cmdline_features[ARRAY_SIZE(off_flag_def) + i]);
+			&cmdline_features[j++]);
 	parse_generic_cmdline(ctx, &any_changed, cmdline_features,
-			      ARRAY_SIZE(off_flag_def) + defs->n_features);
+			      2 * ARRAY_SIZE(off_flag_def) + defs->n_features);
 	free(cmdline_features);
 
 	if (!any_changed) {
-- 
2.26.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH ethtool] features: accept long legacy flag names when setting features
  2020-04-13 21:21 [PATCH ethtool] features: accept long legacy flag names when setting features Michal Kubecek
@ 2020-05-13 19:57 ` John W. Linville
  0 siblings, 0 replies; 2+ messages in thread
From: John W. Linville @ 2020-05-13 19:57 UTC (permalink / raw)
  To: Michal Kubecek; +Cc: netdev, Konstantin Kharlamov

On Mon, Apr 13, 2020 at 11:21:20PM +0200, Michal Kubecek wrote:
> The legacy feature flags have long names (e.g. "generic-receive-offload")
> and short names (e.g. "gro"). While "ethtool -k" shows only long names,
> "ethtool -K" accepts only short names. This is a bit confusing as users
> have to resort to documentation to see what flag name to use; in
> particular, if a legacy flag corresponds to only one actual kernel feature,
> "ethtool -k" shows the output in the same form as if long flag name were
> a kernel feature name but this name cannot be used to set the flag/feature.
> 
> Accept both short and long legacy flag names in "ethool -K".
> 
> Reported-by: Konstantin Kharlamov <hi-angel@yandex.ru>
> Signed-off-by: Michal Kubecek <mkubecek@suse.cz>

Thanks (belatedly) -- queued for next release!

John
-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-13 20:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-13 21:21 [PATCH ethtool] features: accept long legacy flag names when setting features Michal Kubecek
2020-05-13 19:57 ` John W. Linville

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).