Hello John,
Il giorno mar 27 set 2022 alle ore 19:06 John Kacur <jkacur(a)redhat.com> ha
scritto:
+def get_module(intf):
+ """ return the kernel module for the given network interface
"""
+ if intf == 'lo':
+ return ""
+ myp = f'/sys/class/net/{intf}/device/driver'
+ if os.path.exists(myp):
+ return os.path.basename(os.readlink(myp))
+ if os.path.exists(f'/sys/class/net/{intf}/bridge'):
+ return 'bridge'
+ if os.path.exists(f'/sys/class/net/{intf}'):
+ return 'tun'
+ return ""
The last check for the sole existance of /sys/class/net/{intf} to assign it
as "tun" sounds a bit too broad to me.
Just as an example: that can catch my ppp0 device as "tun".
Could we maybe add something more specific? Ie.
/sys/class/net/{intf}/tun_flags ? (should be there from a long time, 2009
or so)
Otherwise I was also looking at /sys/class/net/{intf}/type which should
contain the type (as per
https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/if_arp....)
but not 100% convinced of that (as it seems pretty consistent and perfectly
fine, but get a silly value in one single case of my various network
interfaces that I have to now understand :-) ).
Cheers,
Federico