Bug 274426 - route get command returns a zero even no route is found
Summary: route get command returns a zero even no route is found
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 14.0-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-net (Nobody)
URL:
Keywords: ipv6, needs-qa
Depends on:
Blocks:
 
Reported: 2023-10-12 09:56 UTC by Dmitry Afanasiev
Modified: 2023-12-28 09:23 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Afanasiev 2023-10-12 09:56:28 UTC
I'm using FreeBSD 14.0 commit id 657aec455f7cd960c8fa79a089f88f450c568d2d

On 14.0 I got a new problem which route command - this command now returns 0 as return code even no route is found:
# route -6 get ::
route: route has not been found: No error: 0
# echo $?
0

On 13.2 route get works properly:
# route -6 get ::
route: route has not been found
# echo $?
255

This looks like very old bug bin/112303
Comment 1 Mark Johnston freebsd_committer freebsd_triage 2023-10-12 23:40:22 UTC
Seems to work correctly on main:

markj@nuc> route -6 get ::
route: route has not been found
markj@nuc> echo $?
255

Presumably the difference here is that route(8) is using netlink by default.
Comment 2 Dmitry Afanasiev 2023-12-28 07:59:22 UTC
(In reply to Mark Johnston from comment #1)
What freebsd version are you using?

I'm updated to 14.0-STABLE to commit e373880312fb8ea09c501975e1fd23234a0df1e3 and still have this problem:
$ uname -a
FreeBSD cat 14.0-STABLE FreeBSD 14.0-STABLE #9 e37388031: Wed Dec 27 11:50:11 MSK 2023     root@cat:/usr/obj/usr/src/amd64.amd64/sys/desktop amd64
$ route -6 get ::                                                              
route: route has not been found: No error: 0
$ echo $?                                                                      
0
$ route -6 get 2000::                                                          
route: route has not been found: No error: 0
$ echo $?                                                                      
0
Comment 3 Dmitry Afanasiev 2023-12-28 08:28:12 UTC
Also I tried to download official VM image from https://download.freebsd.org/releases/VM-IMAGES/14.0-RELEASE/amd64/Latest/FreeBSD-14.0-RELEASE-amd64.raw.xz

I got same behavior:
root@freebsd:~ # uname -a
FreeBSD freebsd 14.0-RELEASE FreeBSD 14.0-RELEASE #0 releng/14.0-n265380-f9716eee8ab4: Fri Nov 10 05:57:23 UTC 2023     root@releng1.nyi.freebsd.org:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64
root@freebsd:~ # route -6 delete default
delete net default
root@freebsd:~ # route -6 get ::
route: route has not been found: No error: 0
root@freebsd:~ # echo $?
0
Comment 4 Sergey Zhmylove 2023-12-28 09:17:54 UTC
Hey everyone,

Checked on 14.0-RELEASE #0 releng/14.0-n265380-f9716eee8ab4 and it looks like RELEASE is affected :(

Even if I specify non-zero prefix:

root@freebsd:~ # route -6 get ::/11
route: route has not been found: No error: 0
root@freebsd:~ # echo $?
0

Moreover deleting existing route leads to the same issue:

root@freebsd:~ # route -6 get 2000::1
   route to: 2000::1
destination: default
       mask: default
    gateway: fe80::5054:ff:feb5:5748%vtnet0
        fib: 0
  interface: vtnet0
      flags: <UP,GATEWAY,DONE>
recvpipe  sendpipe  ssthresh  rtt,msec    mtu        weight    expire
       0         0         0         0      1500         1         0 
root@freebsd:~ # route -6 delete default
delete net default
root@freebsd:~ # route -6 get 2000::1
route: route has not been found: No error: 0
root@freebsd:~ # echo $?
0