* [PATCH iproute2] ip: drop 2-char command assumption @ 2021-04-18 3:49 Tony Ambardar 2021-04-18 17:18 ` David Ahern 0 siblings, 1 reply; 6+ messages in thread From: Tony Ambardar @ 2021-04-18 3:49 UTC (permalink / raw) To: Stephen Hemminger; +Cc: Tony Ambardar, netdev The 'ip' utility hardcodes the assumption of being a 2-char command, where any follow-on characters are passed as an argument: $ ./ip-full help Object "-full" is unknown, try "ip help". This confusing behaviour isn't seen with 'tc' for example, and was added in a 2005 commit without documentation. It was noticed during testing of 'ip' variants built/packaged with different feature sets (e.g. w/o BPF support). Drop the related code. Fixes: 351efcde4e62 ("Update header files to 2.6.14") Signed-off-by: Tony Ambardar <Tony.Ambardar@gmail.com> --- ip/ip.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/ip/ip.c b/ip/ip.c index 4cf09fc3..631ce903 100644 --- a/ip/ip.c +++ b/ip/ip.c @@ -313,9 +313,6 @@ int main(int argc, char **argv) rtnl_set_strict_dump(&rth); - if (strlen(basename) > 2) - return do_cmd(basename+2, argc, argv); - if (argc > 1) return do_cmd(argv[1], argc-1, argv+1); -- 2.25.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH iproute2] ip: drop 2-char command assumption 2021-04-18 3:49 [PATCH iproute2] ip: drop 2-char command assumption Tony Ambardar @ 2021-04-18 17:18 ` David Ahern 2021-04-20 8:26 ` [PATCH iproute2 v2] " Tony Ambardar 0 siblings, 1 reply; 6+ messages in thread From: David Ahern @ 2021-04-18 17:18 UTC (permalink / raw) To: Tony Ambardar, Stephen Hemminger; +Cc: netdev On 4/17/21 8:49 PM, Tony Ambardar wrote: > The 'ip' utility hardcodes the assumption of being a 2-char command, where > any follow-on characters are passed as an argument: > > $ ./ip-full help > Object "-full" is unknown, try "ip help". > > This confusing behaviour isn't seen with 'tc' for example, and was added in > a 2005 commit without documentation. It was noticed during testing of 'ip' > variants built/packaged with different feature sets (e.g. w/o BPF support). > > Drop the related code. > > Fixes: 351efcde4e62 ("Update header files to 2.6.14") > Signed-off-by: Tony Ambardar <Tony.Ambardar@gmail.com> > --- > ip/ip.c | 3 --- > 1 file changed, 3 deletions(-) > > diff --git a/ip/ip.c b/ip/ip.c > index 4cf09fc3..631ce903 100644 > --- a/ip/ip.c > +++ b/ip/ip.c > @@ -313,9 +313,6 @@ int main(int argc, char **argv) > > rtnl_set_strict_dump(&rth); > > - if (strlen(basename) > 2) > - return do_cmd(basename+2, argc, argv); > - > if (argc > 1) > return do_cmd(argv[1], argc-1, argv+1); > > popular change request lately. As I responded to Matteo in January: This has been around for too long to just remove it. How about adding an option to do_cmd that this appears to be guess based on basename? If the guess is wrong, fallback to the next do_cmd. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH iproute2 v2] ip: drop 2-char command assumption 2021-04-18 17:18 ` David Ahern @ 2021-04-20 8:26 ` Tony Ambardar 2021-04-20 15:16 ` Stephen Hemminger 2021-04-26 2:31 ` David Ahern 0 siblings, 2 replies; 6+ messages in thread From: Tony Ambardar @ 2021-04-20 8:26 UTC (permalink / raw) To: Stephen Hemminger, David Ahern; +Cc: Tony Ambardar, netdev The 'ip' utility hardcodes the assumption of being a 2-char command, where any follow-on characters are passed as an argument: $ ./ip-full help Object "-full" is unknown, try "ip help". This confusing behaviour isn't seen with 'tc' for example, and was added in a 2005 commit without documentation. It was noticed during testing of 'ip' variants built/packaged with different feature sets (e.g. w/o BPF support). Mitigate the problem by redoing the command without the 2-char assumption if the follow-on characters fail to parse as a valid command. Fixes: 351efcde4e62 ("Update header files to 2.6.14") Signed-off-by: Tony Ambardar <Tony.Ambardar@gmail.com> --- v2: (feedback from David Ahern) * work around problem but remain compatible with 2-char assumption --- ip/ip.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ip/ip.c b/ip/ip.c index 4cf09fc3..8e4c6eb5 100644 --- a/ip/ip.c +++ b/ip/ip.c @@ -125,7 +125,7 @@ static const struct cmd { { 0 } }; -static int do_cmd(const char *argv0, int argc, char **argv) +static int do_cmd(const char *argv0, int argc, char **argv, bool final) { const struct cmd *c; @@ -134,7 +134,8 @@ static int do_cmd(const char *argv0, int argc, char **argv) return -(c->func(argc-1, argv+1)); } - fprintf(stderr, "Object \"%s\" is unknown, try \"ip help\".\n", argv0); + if (final) + fprintf(stderr, "Object \"%s\" is unknown, try \"ip help\".\n", argv0); return EXIT_FAILURE; } @@ -143,7 +144,7 @@ static int ip_batch_cmd(int argc, char *argv[], void *data) const int *orig_family = data; preferred_family = *orig_family; - return do_cmd(argv[0], argc, argv); + return do_cmd(argv[0], argc, argv, true); } static int batch(const char *name) @@ -313,11 +314,14 @@ int main(int argc, char **argv) rtnl_set_strict_dump(&rth); - if (strlen(basename) > 2) - return do_cmd(basename+2, argc, argv); + if (strlen(basename) > 2) { + int ret = do_cmd(basename+2, argc, argv, false); + if (ret != EXIT_FAILURE) + return ret; + } if (argc > 1) - return do_cmd(argv[1], argc-1, argv+1); + return do_cmd(argv[1], argc-1, argv+1, true); rtnl_close(&rth); usage(); -- 2.25.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH iproute2 v2] ip: drop 2-char command assumption 2021-04-20 8:26 ` [PATCH iproute2 v2] " Tony Ambardar @ 2021-04-20 15:16 ` Stephen Hemminger 2021-04-21 4:49 ` Tony Ambardar 2021-04-26 2:31 ` David Ahern 1 sibling, 1 reply; 6+ messages in thread From: Stephen Hemminger @ 2021-04-20 15:16 UTC (permalink / raw) To: Tony Ambardar; +Cc: David Ahern, netdev On Tue, 20 Apr 2021 01:26:36 -0700 Tony Ambardar <tony.ambardar@gmail.com> wrote: > The 'ip' utility hardcodes the assumption of being a 2-char command, where > any follow-on characters are passed as an argument: > > $ ./ip-full help > Object "-full" is unknown, try "ip help". > > This confusing behaviour isn't seen with 'tc' for example, and was added in > a 2005 commit without documentation. It was noticed during testing of 'ip' > variants built/packaged with different feature sets (e.g. w/o BPF support). > > Mitigate the problem by redoing the command without the 2-char assumption > if the follow-on characters fail to parse as a valid command. > > Fixes: 351efcde4e62 ("Update header files to 2.6.14") > Signed-off-by: Tony Ambardar <Tony.Ambardar@gmail.com> > --- > v2: (feedback from David Ahern) > * work around problem but remain compatible with 2-char assumption I am ok with this, but if you change the name of command, you can expect some friction (and non support). The original commit was inherited from the original integration of tarball's into BitKeeper. This "feature" was put in by Alexey Kuznetsov back in orignal 2.4 time frame. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH iproute2 v2] ip: drop 2-char command assumption 2021-04-20 15:16 ` Stephen Hemminger @ 2021-04-21 4:49 ` Tony Ambardar 0 siblings, 0 replies; 6+ messages in thread From: Tony Ambardar @ 2021-04-21 4:49 UTC (permalink / raw) To: Stephen Hemminger; +Cc: David Ahern, Networking On Tue, 20 Apr 2021 at 08:16, Stephen Hemminger <stephen@networkplumber.org> wrote: > > On Tue, 20 Apr 2021 01:26:36 -0700 > Tony Ambardar <tony.ambardar@gmail.com> wrote: > > > The 'ip' utility hardcodes the assumption of being a 2-char command, where > > any follow-on characters are passed as an argument: > > > > $ ./ip-full help > > Object "-full" is unknown, try "ip help". > > > > This confusing behaviour isn't seen with 'tc' for example, and was added in > > a 2005 commit without documentation. It was noticed during testing of 'ip' > > variants built/packaged with different feature sets (e.g. w/o BPF support). > > > > Mitigate the problem by redoing the command without the 2-char assumption > > if the follow-on characters fail to parse as a valid command. > > > > Fixes: 351efcde4e62 ("Update header files to 2.6.14") > > Signed-off-by: Tony Ambardar <Tony.Ambardar@gmail.com> > > --- > > v2: (feedback from David Ahern) > > * work around problem but remain compatible with 2-char assumption > > I am ok with this, but if you change the name of command, you can expect some > friction (and non support). > The renamed binaries are normally accessed via an 'ip' symlink managed at package installation, so shouldn't be an issue. I only discovered the problem while running regression tests on the the underlying binaries, and thought to fix things. > The original commit was inherited from the original integration of tarball's > into BitKeeper. This "feature" was put in by Alexey Kuznetsov back in orignal 2.4 > time frame. Thanks for the feedback and additional detail, Tony ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH iproute2 v2] ip: drop 2-char command assumption 2021-04-20 8:26 ` [PATCH iproute2 v2] " Tony Ambardar 2021-04-20 15:16 ` Stephen Hemminger @ 2021-04-26 2:31 ` David Ahern 1 sibling, 0 replies; 6+ messages in thread From: David Ahern @ 2021-04-26 2:31 UTC (permalink / raw) To: Tony Ambardar, Stephen Hemminger, David Ahern; +Cc: netdev On 4/20/21 1:26 AM, Tony Ambardar wrote: > The 'ip' utility hardcodes the assumption of being a 2-char command, where > any follow-on characters are passed as an argument: > > $ ./ip-full help > Object "-full" is unknown, try "ip help". > > This confusing behaviour isn't seen with 'tc' for example, and was added in > a 2005 commit without documentation. It was noticed during testing of 'ip' > variants built/packaged with different feature sets (e.g. w/o BPF support). > > Mitigate the problem by redoing the command without the 2-char assumption > if the follow-on characters fail to parse as a valid command. > > Fixes: 351efcde4e62 ("Update header files to 2.6.14") > Signed-off-by: Tony Ambardar <Tony.Ambardar@gmail.com> > --- > v2: (feedback from David Ahern) > * work around problem but remain compatible with 2-char assumption > > --- > ip/ip.c | 16 ++++++++++------ > 1 file changed, 10 insertions(+), 6 deletions(-) > Applied. Thanks, ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-04-26 2:31 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-04-18 3:49 [PATCH iproute2] ip: drop 2-char command assumption Tony Ambardar 2021-04-18 17:18 ` David Ahern 2021-04-20 8:26 ` [PATCH iproute2 v2] " Tony Ambardar 2021-04-20 15:16 ` Stephen Hemminger 2021-04-21 4:49 ` Tony Ambardar 2021-04-26 2:31 ` David Ahern
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.