diff mbox series

[iproute2] ip: drop 2-char command assumption

Message ID 20210418034958.505267-1-Tony.Ambardar@gmail.com (mailing list archive)
State Superseded
Delegated to: David Ahern
Headers show
Series [iproute2] ip: drop 2-char command assumption | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Tony Ambardar April 18, 2021, 3:49 a.m. UTC
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(-)

Comments

David Ahern April 18, 2021, 5:18 p.m. UTC | #1
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.
diff mbox series

Patch

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);