Bug 213354 - route reports incorrect results
Summary: route reports incorrect results
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 10.3-STABLE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-10 09:19 UTC by emz
Modified: 2016-10-10 09:19 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description emz 2016-10-10 09:19:36 UTC
Consider I have the following interface:

# ifconfig gre1
gre1: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> metric 0 mtu 1431
        options=80000<LINKSTATE>
        tunnel inet 172.16.4.28 --> 172.16.4.0
        inet 172.16.0.1 --> 172.16.0.0 netmask 0xffffffff 
        inet6 fe80::21a:64ff:fe21:9489%gre1 prefixlen 64 scopeid 0x15 
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>

I have on-interface route for this interface:

# netstat -rn | grep 172.16.0.0
172.16.0.0         link#21            UH         gre1

/sbin/route reports the result incorrectly:

# route -n get 172.16.0.0         
route: writing to routing socket: No such process
# route -n get 172.16.0.0/32
route: writing to routing socket: No such process
# route -n get -host 172.16.0.0/32
route: writing to routing socket: No such process
# route -n get -net 172.16.0.0/32
route: writing to routing socket: No such process
# route -n get -net 172.16.0.0   
route: writing to routing socket: No such process

And only one method works:

[root@crystal-alpha:/etc]# route -n get -host 172.16.0.0
   route to: 172.16.0.0
destination: 172.16.0.0
        fib: 0
  interface: gre1
      flags: <UP,HOST,DONE,PINNED>
 recvpipe  sendpipe  ssthresh  rtt,msec    mtu        weight    expire
       0         0         0         0      1431         1         0

This behaviour differs significantly from other cases with point-to-point interfaces, with /32 network mask:

# ifconfig gre0
gre0: flags=a051<UP,POINTOPOINT,RUNNING,LINK1,MULTICAST> metric 0 mtu 1431
        options=80000<LINKSTATE>
        tunnel inet 172.16.4.27 --> 172.16.4.30
        inet6 fe80::21a:64ff:fe21:9489%gre0 prefixlen 64 scopeid 0x14 
        inet 172.16.1.81 --> 172.16.1.80 netmask 0xffffffff 
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>

# route -n get 172.16.1.80
   route to: 172.16.1.80
destination: 172.16.1.80
        fib: 0
  interface: gre0
      flags: <UP,HOST,DONE,PINNED>
 recvpipe  sendpipe  ssthresh  rtt,msec    mtu        weight    expire
       0         0         0         0      1431         1         0 

This issue is probably triggered by the zeroes in te two last octets of the IP address. I highly doubt someone still uses -net and -host switches, because the approach "use network part without mask for 'route get'" works like 95% of the time. I can still be wrong, but I really think this utility should be more straightforward, and there should not be any exceptions to a general rule.

Furthermore, the message "route: writing to routing socket: No such process" is kinda "blast from the past", since nobody can recall why is it still here and what process is it talking about. It is cryptic, misleading and weird, I really think it should be changed to something more appropriate. To my knowledge, route is not a process, it's rather an entity in the FIB. Although someone may find the history behind this message intriguing and interesting, I personally think it's some geological artifact that keeps people stubmling on.