sysfs/udev in CT newbie(ish) question

iamGavinJ

New Member
Mar 18, 2023
1
0
1
Los Angeles, CA
Hi,
While I've been fairly entrenched in Linux for a number of years, I haven't ever really had the need to dive deep into sysfs and udev... until now :/

I'm trying to write some udev rules to do some specific things (namely a RUN) with `veth` interfaces however inside a container, I'm seeing a fraction of the available attributes that I see in the PVE host. What I'm specifically looking for is the `ID_NET_DRIVER` attribute which is set on the PVE host pair of the `veth` but missing on the CT side. Alternatively the `DEVTYPE` attribute would be helpful though from looking at the `veth.c` driver, it appears that's never being set anyway.
Bash:
# udevadm info /devices/virtual/net/veth100i0
P: /devices/virtual/net/veth100i0
L: 0
E: DEVPATH=/devices/virtual/net/veth100i0
E: INTERFACE=veth100i0
E: IFINDEX=26
E: SUBSYSTEM=net
E: USEC_INITIALIZED=***REMOVED***
E: ID_NET_DRIVER=veth
E: ID_NET_LINK_FILE=/usr/lib/systemd/network/99-default.link
E: ID_NET_NAME=veth100i0
E: SYSTEMD_ALIAS=/sys/subsystem/net/devices/veth100i0
E: TAGS=:systemd:
E: CURRENT_TAGS=:systemd:

Even if I create a new test pair of `veth`s inside the container, both the primary and peer are missing the `ID_NET_DRIVER` attribute.
Bash:
# ip l add test type veth peer name testpeer
# udevadm info /devices/virtual/net/test
P: /devices/virtual/net/test
M: test
U: net
I: 20
E: DEVPATH=/devices/virtual/net/test
E: SUBSYSTEM=net
E: INTERFACE=test
E: IFINDEX=20

This is a problem for me, because while i *could* parse the interface names for the `veth` prefix, this naming convention is not mandatory, so I could potentially miss some interfaces when enumerating.

I'm wondering firstly where the discrepancy is rooted:
  • Is it because unprivileged containers are not allowed to see the full scope of sysfs, even when devices are created and/or visible in that namespace?
  • Is it something to do with running Arch (amd64) in the container?
And is there any way to get around this?

Kernel == 6.1.15-1-pve #1 SMP PREEMPT_DYNAMIC PVE 6.1.15-1 (2023-03-08T08:53Z) x86_64 GNU/Linux

Many thanks.
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!