udev rules to apply ethtool settings

In order to apply specific ethtool settings to all interfaces matching a specific regular expression, run:

1
2
3
cat <<'EOF'> /etc/udev/rules.d/99-ethtool.rules
ACTION=="add", SUBSYSTEM=="net", NAME=="eno12409v[0-4]", RUN+="/sbin/ethtool -K $name generic-receive-offload off"
EOF

Note: See https://man7.org/linux/man-pages/man7/udev.7.html for available variable names.

Note: Naming the file correctly is important, as order of operations is critical.

The easiest way to play around with such udev rules is adding virtual interfaces or SR-IOV Virtual Functions:

  • Run udevadm control --log-priority=debug to enable debugging.
  • Change udev rules in file.
  • Run /sbin/udevadm control --reload-rules.
  • Manually create / destroy Virtual Functions: echo 0 > /sys/devices/pci.../.../.../sriov_numvfs; echo 8 > /sys/devices/pci.../.../.../sriov_numvfs.
  • Scan the journal for matching log messages: journalctl -f | grep "ethtool".