Skip to content

Commit

Permalink
Fallback to get NIC driver by /sys/class/net/NIC/device/driver/module
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
coiby committed Dec 17, 2024
1 parent 8a92f45 commit 82f229b
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions dracut/99kdumpbase/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,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() {
Expand Down Expand Up @@ -395,10 +415,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
Expand Down

0 comments on commit 82f229b

Please sign in to comment.