Commit e9b86c7e authored by geb's avatar geb

Use udevadm info $dev to discover nic name for MAC spoofing notification failures (refs: #17784)

Delegate the discover of interface names to udev, instead of relying
on reading and parsing /sys and lspci ourself, to make the discover
more resilient to missing files, bus agnostic (allowing to discover
non PCI devices like USB ones), and explicit (using udev's own hwdb).
parent 1df2cbd2
......@@ -43,9 +43,9 @@ get_module_used_by_nic() {
get_name_of_nic() {
vendor=$(sed 's/^0x\(.*\)$/\1/' "/sys/class/net/${1}/device/vendor")
device=$(sed 's/^0x\(.*\)$/\1/' "/sys/class/net/${1}/device/device")
lspci -nn | sed -n "s/^\S\+\s\+[^:]\+:\s\+\(.*\)\s\+\[$vendor:$device\].*$/\1/p"
vendor=$(udevadm info -x --query=property /sys/class/net/${1} | sed -n "s/ID_VENDOR_FROM_DATABASE='\(.*\)'/\\1/p")
device=$(udevadm info -x --query=property /sys/class/net/${1} | sed -n "s/ID_MODEL_FROM_DATABASE='\(.*\)'/\\1/p")
echo "$vendor $device"
# Auxillary function for mod_rev_dep(). It recurses over the graph of
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment