OpenWRT software appliance on OpenIndiana#

I got myself a ThinkPad T470 and unfortunately the WiFi chip is not supported by illumos. Since my kernel driver porting skills are not so good ;) I decided to do a different thing.

I'm going to run a bhyve VM, pass through the WiFi card to it, and run OpenWRT inside the VM.

Download OpenWRT#

Go to https://downloads.openwrt.org/releases/ pick a version and download the openwrt*x86-64-generic-ext4-combined-efi.img image, I used https://downloads.openwrt.org/releases/22.03.3/targets/x86/64/openwrt-22.03.3-x86-64-generic-ext4-combined-efi.img.gz.

Setup the bhyve zone#

# zonecfg -z router
create -b
set zonepath=/export/zones/router
set brand=bhyve
set autoboot=true
set ip-type=exclusive
add net
set physical="routerint0"
end
add device
set match="/dev/zvol/rdsk/rpool/export/bhyve/routerd0"
end
add device
set match="/dev/ppt0"
end
add attr
set name="bootrom"
set type="string"
set value="BHYVE_RELEASE"
end
add attr
set name="bootdisk"
set type="string"
set value="rpool/export/bhyve/routerd0"
end
add attr
set name="vcpus"
set type="string"
set value="1"
end
add attr
set name="ram"
set type="string"
set value="1G"
end
add attr
set name="vnc"
set type="string"
set value="on"
end
add attr
set name="extra"
set type="string"
set value="-S -s 8:0,passthru,/dev/ppt0"
end

Now we need to create the VNIC, the disk and the passthru device.

The Disk ist easy:

# zfs create -V 1G -o compression=lz4 rpool/export/bhyve/routerd0
# dd if=openwrt-22.03.3-x86-64-generic-ext4-combined-efi.img of=/dev/zvol/rdsk/rpool/export/bhyve/routerd0 bs=1024k

Now, let's set up the networking. We are going to create an Etherstub with two interfaces, one for the laptops global zone and one for the router vm.

First ensure that nwam (NetWork AutoMagic) is turned off:

# svcadm enable svc:/network/physical:default
# svcadm disable svc:/network/physical:nwam

Now we will create the Etherstub (SDN switch) and the virtual NICs:

# dladm create-etherstub dmz0
# dladm create-vnic -l dmz0 routerint0
# dladm create-vnic -l dmz0 dmzint0

We need to create an IP interface, configure a static IP on that interface and set the new default route persistent ("route -p") to the later configured OpenWRT:

# ipadm create-if dmzint0
# ipadm create-addr -T static -a local=172.24.0.1/24 dmzint0/v4
# route -p add default 172.24.0.250

Boot OpenWRT the first time#

Open two different xterms. In the first we install the zone and then open the zones console:
# zoneadm -z router install
# zlogin -C router

In the other xterm we boot up the zone:

# zoneadm -z router boot

After ca. 60 seconds or even less, OpenWRT should be booted completely and if you hit "return" in the zones console, you should get the OpenWRT root shell:

root@OpenWrt:~# 

At this prompt, we need to configure the Ethernet first. VNICs on illumos have a MTU of 9000 by default, so we should configure the same MTU for the eth0 in the OpenWRT config also. At the same time we change the LAN IP to the one we chose before. For that we open with vi the /etc/config/network file on the OpenWRT and change the relevant parts:

config device                         
        option name 'br-lan'          
        option type 'bridge'          
        list ports 'eth0'             
        option mtu '9000'             
        option mtu6 '9000'  

config interface 'lan'                         
        option device 'br-lan'                 
        option proto 'static'                  
        option netmask '255.255.255.0'         
        option ip6assign '60'         
        option ipaddr '172.24.0.250'  
                                      
config device                         
        option name 'eth0'            
        option mtu '9000'             
        option mtu6 '9000'            

after that reboot the OpenWRT instance:

root@OpenWrt:~# reboot

After that step, you need to configure the wifi card correctly, for that you need to install the correct packages to OpenWRT with okpg, please consult the OpenWRT documentation.

After setting up this stuff, I realised that DrScream also already did something very similar here: https://www.cyber-tec.org/2019/05/29/using-bhyve-pci-passthrough-on-omnios/