diff mbox series

[RFC,iproute2] ip route: get: allow zero-length subnet mask

Message ID 20190213200954.32271-1-bluca@debian.org
State Superseded
Delegated to: stephen hemminger
Headers show
Series [RFC,iproute2] ip route: get: allow zero-length subnet mask | expand

Commit Message

Luca Boccassi Feb. 13, 2019, 8:09 p.m. UTC
A /0 subnet mask is theoretically valid, but ip route get doesn't allow
it:

$ ip route get 1.0.0.0/0
need at least a destination address

Remove the check so that it can go through:

$ ip/ip route get 1.0.0.0/0
1.0.0.0 via 192.168.1.1 dev eth0 src 192.168.1.91 uid 1000
    cache

Reported-by: Clément Hertling <wxcafe@wxcafe.net>
Signed-off-by: Luca Boccassi <bluca@debian.org>
---
Stephen et al, this was reported by a Debian user:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=921737

It makes sense to me at a cursory glance, but sending as RFC as I'm
not 100% familiar with the route get function.

 ip/iproute.c | 5 -----
 1 file changed, 5 deletions(-)

Comments

Stephen Hemminger Feb. 13, 2019, 8:37 p.m. UTC | #1
On Wed, 13 Feb 2019 20:09:53 +0000
Luca Boccassi <bluca@debian.org> wrote:

> A /0 subnet mask is theoretically valid, but ip route get doesn't allow
> it:
> 
> $ ip route get 1.0.0.0/0
> need at least a destination address
> 
> Remove the check so that it can go through:
> 
> $ ip/ip route get 1.0.0.0/0
> 1.0.0.0 via 192.168.1.1 dev eth0 src 192.168.1.91 uid 1000
>     cache
> 
> Reported-by: Clément Hertling <wxcafe@wxcafe.net>
> Signed-off-by: Luca Boccassi <bluca@debian.org>
> ---
> Stephen et al, this was reported by a Debian user:
> 
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=921737
> 
> It makes sense to me at a cursory glance, but sending as RFC as I'm
> not 100% familiar with the route get function.
> 
>  ip/iproute.c | 5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/ip/iproute.c b/ip/iproute.c
> index 5f58a3b3..d78f43d8 100644
> --- a/ip/iproute.c
> +++ b/ip/iproute.c
> @@ -2041,11 +2041,6 @@ static int iproute_get(int argc, char **argv)
>  		argc--; argv++;
>  	}
>  
> -	if (req.r.rtm_dst_len == 0) {
> -		fprintf(stderr, "need at least a destination address\n");
> -		return -1;
> -	}
> -
>  	if (idev || odev)  {
>  		int idx;
>  

You still need a way to report error for:
	ip route get
(i.e when no address is present)
diff mbox series

Patch

diff --git a/ip/iproute.c b/ip/iproute.c
index 5f58a3b3..d78f43d8 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -2041,11 +2041,6 @@  static int iproute_get(int argc, char **argv)
 		argc--; argv++;
 	}
 
-	if (req.r.rtm_dst_len == 0) {
-		fprintf(stderr, "need at least a destination address\n");
-		return -1;
-	}
-
 	if (idev || odev)  {
 		int idx;