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 <coxu@redhat.com>
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 <mschmidt@redhat.com>
    Signed-off-by: Coiby Xu <coxu@redhat.com>

Signed-off-by: Coiby Xu <coxu@redhat.com>
This commit is contained in:
Coiby Xu 2025-03-03 08:38:28 +08:00
parent 1b91a29a7c
commit 6b3336ab42

View File

@ -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