main/postmarketos-mkinitfs: unudhcpd can be started with (unnamed net_device)
Describe your issue
What's the expected behaviour?
unudhcpd doesn't start if there is no usb network iface
What's the current behaviour?
unudhcpd get's started with (unnamed net_device)
How to reproduce your issue?
- Make sure your device doesn't have USB Device Controller (/sys/class/udc/ is empty)
- Boot.
- Observe initramfs log spamming unudhcpd restarts:
Setup usb network
/sys/class/android_usb does not exist, skipping android_usb
Setting up an USB gadget through configfs
No USB Device Controller available
Starting unudhcpd with server ip 172.16.42.1, client ip: 172.16.42.2
ifconfig: SIOCSIFADDR: No such device
Using interface (unnamed net_device)
Starting the DHCP daemon
Trying to start server with parameters: Server IP addr: 172.16.42.1:67, client IP addr: 172.16.42.2, interface: (unnamed net_device)
Unable to bind to interface: No such device
(...)
Trying to bind to interface: (unnamed net_device)
Server quit, retrying in 1 second...
Trying to start server with parameters: Server IP addr: 172.16.42.1:67, client IP addr: 172.16.42.2, interface: (unnamed net_device)
Trying to bind to interface: (unnamed net_device)
Server quit, retrying in 1 second...
(loops forever spamming tty1)
What device are you using?
acer-aspire1
On what postmarketOS version did you encounter the issue?
-
edge ( master
branch) -
v23.12
-
v23.06
(supported until 2024-01-18) -
I confirm that the issue still is present after running sudo apk upgrade -a
Additional info
We get to this because setup_usb_network_configfs()
first creates the gadget but assigns it
a usb controller at the very last step, so if there is no UDC, the gadget is left half-done.
Then start_unudhcpd()
checks ifname
prop of the gadget but doesn't check if it's garbage
as it assumes that only empty string is "no interface".
One could fix this on a per-device basis by disabling dhcpd but I think it's nicer to fix the detection for all devices.