route(8): -n means numeric for default too

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

route(8): -n means numeric for default too

Denis Fondras
When using "route -n", also print numeric value for default route.

Before :

[denis@jig-ai] route -n show -inet6
Routing tables

Internet6:
Destination                        Gateway                        Flags   Refs      Use   Mtu  Prio Iface
default                            2a00:6060:1::1                 UGS        2     1549     -     8 em0  
::/96                              ::1                            UGRS       0        0 32768     8 lo0  
::1                                ::1                            UHhl      10       20 32768     1 lo0  

After :

[denis@jig-ai] route -n show -inet6
Routing tables

Internet6:
Destination                        Gateway                        Flags   Refs      Use   Mtu  Prio Iface
::/0                               2a00:6060:1::1                 UGS        2     1549     -     8 em0  
::/96                              ::1                            UGRS       0        0 32768     8 lo0  
::1                                ::1                            UHhl      10       20 32768     1 lo0  


Index: show.c
===================================================================
RCS file: /cvs/src/sbin/route/show.c,v
retrieving revision 1.114
diff -u -p -r1.114 show.c
--- show.c 31 Aug 2018 15:18:02 -0000 1.114
+++ show.c 11 May 2019 16:56:38 -0000
@@ -539,7 +539,7 @@ netname4(in_addr_t in, struct sockaddr_i
  cp = hp->h_name;
  }
  if (in == INADDR_ANY && mask == INADDR_ANY)
- cp = "default";
+ cp = nflag ? "0.0.0.0/0" : "default";
  mbits = mask ? 33 - ffs(mask) : 0;
  in = ntohl(in);
  if (cp)
@@ -636,7 +636,7 @@ netname6(struct sockaddr_in6 *sa6, struc
  masklen = 128;
 
  if (masklen == 0 && IN6_IS_ADDR_UNSPECIFIED(&sin6.sin6_addr))
- return ("default");
+ return (nflag ? "::/0" : "default");
 
  if (illegal)
  warnx("illegal prefixlen");

Reply | Threaded
Open this post in threaded view
|

Re: route(8): -n means numeric for default too

Alexander Bluhm
On Sat, May 11, 2019 at 07:03:34PM +0200, Denis Fondras wrote:
> When using "route -n", also print numeric value for default route.

I use -n to avoid DNS lookups.  "default" does not do that.

So I do not see the benefit of this change.  It has been that way
for ever without harm.  New behavior would be different.  It breaks
peoples expectations and possibly some scripts.

What is wrong with "default"?  Why is "0.0.0.0/0" and "::/0" better?

bluhm

Reply | Threaded
Open this post in threaded view
|

Re: route(8): -n means numeric for default too

Denis Fondras
On Sat, May 11, 2019 at 01:15:16PM -0400, Alexander Bluhm wrote:
> What is wrong with "default"?  Why is "0.0.0.0/0" and "::/0" better?
>

Nothing wrong per-se. I was comparing the output of "bgpctl sh fib" and "route
show" when I noticed this.