From: Ben Hutchings <bhutchings@solarflare.com>
To: Or Gerlitz <or.gerlitz@gmail.com>,
Bill Fink <billfink@mindspring.com>, <netdev@vger.kernel.org>
Subject: [PATCH ethtool] ethtool: Accept long feature names reported by -k option as input to -K option
Date: Wed, 8 Jan 2014 21:52:11 +0000 [thread overview]
Message-ID: <1389217931.1644.44.camel@bwh-desktop.uk.level5networks.com> (raw)
Before the generic features API was introduced, the ethtool -K option
took short names for various features, e.g. 'gso' but the -k option
reported their state using longer names,
e.g. 'generic-segmentation-offload'.
All newer features have a single kernel-provided name so input
and output are consistent. But the old features still aren't, and
although their short names are documented it's not good to have
these exceptions.
Change the argument parsing code for -K so that the long names
reported by -k are also accepted.
Reported-by: Or Gerlitz <or.gerlitz@gmail.com>
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
This turned out to be pretty easy to do as the argument processing is
all table-driven already. I'll push this if it works for you.
Ben.
ethtool.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/ethtool.c b/ethtool.c
index b06dfa3..4226d2e 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -2053,25 +2053,31 @@ 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");
return 1;
}
- for (i = 0; i < ARRAY_SIZE(off_flag_def); i++)
+ 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[2 * i]);
+ flag_to_cmdline_info(off_flag_def[i].long_name,
+ off_flag_def[i].value,
+ &off_flags_wanted, &off_flags_mask,
+ &cmdline_features[2 * i] + 1);
+ }
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[2 * ARRAY_SIZE(off_flag_def) + i]);
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) {
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
next reply other threads:[~2014-01-08 21:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-08 21:52 Ben Hutchings [this message]
2014-01-08 22:00 ` [PATCH ethtool] ethtool: Accept long feature names reported by -k option as input to -K option Allan, Bruce W
2014-01-09 21:11 ` Ben Hutchings
2014-01-09 21:11 ` Ben Hutchings
2014-01-27 1:33 ` Ben Hutchings
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1389217931.1644.44.camel@bwh-desktop.uk.level5networks.com \
--to=bhutchings@solarflare.com \
--cc=billfink@mindspring.com \
--cc=netdev@vger.kernel.org \
--cc=or.gerlitz@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox