cloud-init
cloud-init copied to clipboard
Presence of mac802154_hwsim WPAN network interfaces causes network setup to fail
Bug report
The presence of a simulated WPAN network interface created using mac802154_hwsim causes an exception:
2023-07-17 09:57:00,094 - util.py[WARNING]: failed stage init-local
failed run of stage init-local
------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/cloudinit/cmd/main.py", line 767, in status_wrapper
ret = functor(name, args)
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/cloudinit/cmd/main.py", line 433, in main_init
init.apply_network_config(bring_up=bring_up_interfaces)
File "/usr/lib/python3/dist-packages/cloudinit/stages.py", line 887, in apply_network_config
netcfg, src = self._find_networking_config()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/cloudinit/stages.py", line 828, in _find_networking_config
if self.datasource and hasattr(self.datasource, "network_config"):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceConfigDrive.py", line 176, in network_config
self._network_config = openstack.convert_net_json(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/cloudinit/sources/helpers/openstack.py", line 717, in convert_net_json
known_macs = net.get_interfaces_by_mac()
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/cloudinit/net/__init__.py", line 926, in get_interfaces_by_mac
return get_interfaces_by_mac_on_linux(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/cloudinit/net/__init__.py", line 1004, in get_interfaces_by_mac_on_linux
for name, mac, driver, _devid in get_interfaces(
^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/cloudinit/net/__init__.py", line 1120, in get_interfaces
ret.append((name, mac, driver, device_devid(name)))
^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/cloudinit/net/__init__.py", line 367, in device_devid
dev_id = read_sys_net_safe(devname, "device/device")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/cloudinit/net/__init__.py", line 107, in read_sys_net_safe
return read_sys_net(
^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/cloudinit/net/__init__.py", line 76, in read_sys_net
contents = util.load_file(dev_path)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/cloudinit/util.py", line 1531, in load_file
with open(fname, "rb") as ifh:
^^^^^^^^^^^^^^^^^
IsADirectoryError: [Errno 21] Is a directory: '/sys/class/net/wpan1/device/device'
/sys/class/net/wpan1/device
is a symlink to the directory /sys/devices/platform/mac802154_hwsim/ieee802154/phy1
, and /sys/class/net/wpan1/device/device
is a symlink to the directory /sys/devices/platform/mac802154_hwsim
.
Perhaps read_sys_net()
can handle EISDIR?
Steps to reproduce the problem
- Set up a WPAN network interface using mac802154_hwsim
- Run cloud-init in such a way that it needs to configure networking
Environment details
- Cloud-init version: 22.4.2
- Operating System Distribution: Debian
- Cloud provider, platform or installer type: OpenStack
cloud-init logs
Thanks for the bug @ajdlinux can you please attach the output of the following to this bug as I don't have access to this hardware and would like to see how sysfs represents the device files.
#!/bin/bash
ls -l /sys/class/net/wpan1/device/
ls -l /sys/devices/platform/mac802154_hwsim/ieee802154/phy1/
ls -l /sys/class/net/wpan1/device/device/
[ -f /sys/class/net/wpan1/device/device/device ] && cat /sys/class/net/wpan1/device/device/device
I agree this is a bug in how cloud-init handles those nested device links. I just don't have a full enough picture to understand how we should fix this without additional logs related to the /sys/class/net files representing this device and configuration.
Output is as follows:
total 0
lrwxrwxrwx 1 root root 0 Jul 19 13:40 device -> ../../../mac802154_hwsim
-r--r--r-- 1 root root 65536 Jul 19 13:40 index
-r--r--r-- 1 root root 65536 Jul 19 13:40 name
drwxr-xr-x 3 root root 0 Jul 19 13:40 net
drwxr-xr-x 2 root root 0 Jul 19 13:40 power
lrwxrwxrwx 1 root root 0 Jul 19 13:40 subsystem -> ../../../../../class/ieee802154
-rw-r--r-- 1 root root 65536 Jul 19 13:40 uevent
total 0
lrwxrwxrwx 1 root root 0 Jul 19 13:40 device -> ../../../mac802154_hwsim
-r--r--r-- 1 root root 65536 Jul 19 13:40 index
-r--r--r-- 1 root root 65536 Jul 19 13:40 name
drwxr-xr-x 3 root root 0 Jul 19 13:40 net
drwxr-xr-x 2 root root 0 Jul 19 13:40 power
lrwxrwxrwx 1 root root 0 Jul 19 13:40 subsystem -> ../../../../../class/ieee802154
-rw-r--r-- 1 root root 65536 Jul 19 13:40 uevent
total 0
lrwxrwxrwx 1 root root 0 Jul 19 13:40 driver -> ../../../bus/platform/drivers/mac802154_hwsim
-rw-r--r-- 1 root root 65536 Jul 19 13:41 driver_override
drwxr-xr-x 4 root root 0 Jul 19 13:40 ieee802154
-r--r--r-- 1 root root 65536 Jul 19 13:41 modalias
drwxr-xr-x 2 root root 0 Jul 19 13:41 power
lrwxrwxrwx 1 root root 0 Jul 19 13:40 subsystem -> ../../../bus/platform
-rw-r--r-- 1 root root 65536 Jul 19 13:40 uevent