From 6b3336ab425cc346b48a9d6772631b60b9a9563c Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 3 Mar 2025 08:38:28 +0800 Subject: [PATCH] Fallback to get NIC driver by /sys/class/net/NIC/device/driver/module Resolves: https://issues.redhat.com/browse/RHEL-67131 Conflict: Upstream uses a different path dracut/99kdumpbase/module-setup.sh. Upstream Status: git@github.com:rhkdump/kdump-utils.git commit 821a5e648dcb72d89065078e0cadb58a5313b183 Author: Coiby Xu Date: Thu Nov 28 18:07:49 2024 +0800 Fallback to get NIC driver by /sys/class/net/NIC/device/driver/module Resolves: https://issues.redhat.com/browse/RHEL-67131 Some drivers like dwmac_tegra may report its name incorrectly. So fallback to /sys/class/net/NIC/device/driver/modul to address these cases. Note this method only for physical NICs i.e it doesn't work for virtual NICs like bonding NIC. Suggested-by: Michal Schmidt Signed-off-by: Coiby Xu Signed-off-by: Coiby Xu --- dracut-module-setup.sh | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 8b67c86..59b38af 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -380,7 +380,27 @@ EOF } _get_nic_driver() { - ethtool -i "$1" | sed -n -E "s/driver: (.*)/\1/p" + local _driver + + _driver=$(ethtool -i "$1" | sed -n -E "s/driver: (.*)/\1/p") + + if [[ $_driver == "802.1Q VLAN Support" ]]; then + # ethtool somehow doesn't return the driver name for a VLAN NIC + _driver=8021q + fi + + if ! modinfo "$_driver" &> /dev/null; then + # Fallback to get NIC driver by /sys/class/net/NIC/device/driver/module + # as some drivers like dwmac_tegra may report its name incorrectly. + # Note this method only for physical NICs i.e it doesn't work for + # virtual NICs like bonding NIC + _driver=$(basename "$(readlink -f /sys/class/net/"$1"/device/driver/module)") + if ! modinfo "$_driver" &> /dev/null; then + derror "Failed to find the driver for $1 ($_driver doesnt exist)" + fi + fi + + echo -n "$_driver" } _get_hpyerv_physical_driver() { @@ -412,10 +432,7 @@ kdump_install_nic_driver() { exit 1 fi - if [[ $_driver == "802.1Q VLAN Support" ]]; then - # ethtool somehow doesn't return the driver name for a VLAN NIC - _driver=8021q - elif [[ $_driver == "team" ]]; then + if [[ $_driver == "team" ]]; then # install the team mode drivers like team_mode_roundrobin.ko as well _driver='=drivers/net/team' elif [[ $_driver == "hv_netvsc" ]]; then