[Bug 271895] route(8) shows Invalid argument on an i386 jail when setting the default route

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 07 Jun 2023 21:49:03 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=271895

            Bug ID: 271895
           Summary: route(8) shows Invalid argument on an i386 jail when
                    setting the default route
           Product: Base System
           Version: 13.2-RELEASE
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: DtxdF@disroot.org

Description:

When setting the default route on an i386 jail `route(8)` displays the error
`Invalid argument` on an amd64 host. `route(8)` on an amd64 jail will work as
expected.

Steps to reproduce this issue:

```
# pwd
/var/jail/jtest
# wget -O components/i386-13.2-RELEASE-base.txz
https://download.freebsd.org/releases/i386/13.2-RELEASE/base.txz
--2023-06-07 17:32:22-- 
https://download.freebsd.org/releases/i386/13.2-RELEASE/base.txz
Resolving download.freebsd.org (download.freebsd.org)... 96.47.72.116,
2610:1c1:1:606c::15:0
Connecting to download.freebsd.org (download.freebsd.org)|96.47.72.116|:443...
connected.
HTTP request sent, awaiting response... 200 OK
Length: 187400420 (179M) [application/octet-stream]
Saving to: ‘components/i386-13.2-RELEASE-base.txz’

components/i386-13.2-RELEASE-base.txz    
100%[====================================================================================>]
178.72M   512KB/s    in 4m 55s

2023-06-07 17:37:17 (621 KB/s) - ‘components/i386-13.2-RELEASE-base.txz’ saved
[187400420/187400420]

# tar -C root -xpf components/i386-13.2-RELEASE-base.txz
# jail -cf jail.conf
jtest: created
ELF ldconfig path: /lib /usr/lib /usr/lib/compat
/etc/rc: WARNING: $hostname is not set -- see rc.conf(5).
Starting Network: lo0 em0.
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
        inet 127.0.0.1 netmask 0xff000000
        groups: lo
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
em0: flags=8862<BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
       
options=481249b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,LRO,WOL_MAGIC,VLAN_HWFILTER,NOMAP>
        ether xx:xx:xx:xx:xx:xx
        media: Ethernet autoselect (100baseTX <full-duplex>)
        status: active
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
route: writing to routing socket: Invalid argument
add host 127.0.0.1: gateway lo0 fib 0: Invalid argument
route: writing to routing socket: Invalid argument
add host ::1: gateway lo0 fib 0: Invalid argument
add net fe80::: gateway ::1 fib 0: route already in table
add net ff02::: gateway ::1 fib 0: route already in table
add net ::ffff:0.0.0.0: gateway ::1 fib 0: route already in table
add net ::0.0.0.0: gateway ::1 fib 0: route already in table
Clearing /tmp (X related).
Creating and/or trimming log files.
Updating motd:.
Updating /var/run/os-release done.
Starting syslogd.
Starting sendmail_submit.
Starting sendmail_msp_queue.
Starting cron.

Wed Jun  7 21:38:46 UTC 2023
# jexec -l jtest ifconfig em0 inet 192.168.1.146/24
root@dtxdf-test:/var/jail/jtest # jexec -l jtest ifconfig em0
em0: flags=8863<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
       
options=481249b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,LRO,WOL_MAGIC,VLAN_HWFILTER,NOMAP>
        ether xx:xx:xx:xx:xx:xx
        inet 192.168.1.146 netmask 0xffffff00 broadcast 192.168.1.255
        media: Ethernet autoselect (100baseTX <full-duplex>)
        status: active
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
root@dtxdf-test:/var/jail/jtest # jexec -l jtest ping -c4 192.168.1.1
PING 192.168.1.1 (192.168.1.1): 56 data bytes
64 bytes from 192.168.1.1: icmp_seq=0 ttl=64 time=0.756 ms
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.348 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.404 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.435 ms

--- 192.168.1.1 ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.348/0.486/0.756/0.159 ms
# jexec -l jtest netstat -4rn
Routing tables
(0) (0) UH  6968
(0) (0) U
(0) (0) UHS  6968
# jexec -l jtest route add default 192.168.1.1
route: writing to routing socket: Invalid argument
add net default: gateway 192.168.1.1 fib 0: Invalid argument
```

Jail configuration:

```
# cat /var/jail/jtest/jail.conf
jtest {
        path = "/var/jail/${name}/root";
        exec.start = "/bin/sh /etc/rc";
        exec.stop = "/bin/sh /etc/rc.shutdown jail";
        vnet;
        vnet.interface = em0;
        mount.devfs;
}
# jls -sj jtest
devfs_ruleset=0 enforce_statfs=2 host=new ip4=inherit ip6=inherit jid=12
name=jtest osreldate=1302001 osrelease=13.2-RELEASE path=/var/jail/jtest/root
nopersist securelevel=-1 sysvmsg=disable sysvsem=disable sysvshm=disable
vnet=new zfs=new allow.nochflags allow.nomlock allow.nomount
allow.mount.nodevfs allow.mount.nofdescfs allow.mount.nonullfs
allow.mount.noprocfs allow.mount.notmpfs allow.mount.nozfs allow.noquotas
allow.noraw_sockets allow.noread_msgbuf allow.reserved_ports allow.set_hostname
allow.nosocket_af allow.suser allow.nosysvipc allow.unprivileged_proc_debug
children.max=0 host.domainname="" host.hostid=0 host.hostname=""
host.hostuuid=00000000-0000-0000-0000-000000000000 zfs.mount_snapshot=0
```

Host information:

```
# uname -a
FreeBSD dtxdf-test 13.2-RELEASE FreeBSD 13.2-RELEASE
releng/13.2-n254617-525ecfdad597 GENERIC amd64
```

-- 
You are receiving this mail because:
You are the assignee for the bug.