Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tun to static device list in hardware manager #5547

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions supervisor/hardware/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,33 @@

_LOGGER: logging.Logger = logging.getLogger(__name__)

# Some device nodes get created system on startup by kmod-static-nodes.service,
# which in turn uses /usr/bin/kmod to get a list of static device nodes which
# are provided by kernel modules. These type of devices are not listed by udev
# and hence not listed through pyudev. However, on first access the kernel
# module is loaded automatically.
# Which nodes are exposed by module is system specific, so ideally Supervisor
# should read the output of kmod (e.g. /run/tmpfiles.d/static-nodes.conf). But
# this seems a bit overkill, since we are currently only interested in tun.
_STATIC_NODES: list[Device] = [
Device(
"tun",
Path("/dev/net/tun"),
Path("/sys/devices/virtual/misc/tun"),
"misc",
None,
[],
{
"DEVNAME": "/dev/net/tun",
"DEVPATH": "/devices/virtual/misc/tun",
"MAJOR": "10",
"MINOR": "200",
"SUBSYSTEM": "misc",
},
[],
)
]


class HardwareManager(CoreSysAttributes):
"""Hardware manager for supervisor."""
Expand Down Expand Up @@ -114,6 +141,11 @@ def _import_devices(self) -> None:
continue
self._devices[device.sys_name] = Device.import_udev(device)

# Add static nodes if not found through udev (e.g. module not yet loaded)
for device in _STATIC_NODES:
if device.name not in self._devices:
self._devices[device.name] = device

async def load(self) -> None:
"""Load hardware backend."""
self._import_devices()
Expand Down
Loading