Use the correct regex to match eth.*

Upstream: RHEL-only
Resolves: https://issues.redhat.com/browse/RHEL-47130

kdump prefixes kdump- to a name of a network interface when its name
matches eth.*. However, the regex is incorrect and matches names like
baremetal*. As a consequence, kdump failed with the following message,

    [  305.950223] kdump.sh[790]: Device "kdump-baremetal" does not exist.
    [  305.992018] kdump[795]: wrong kdumpnic: kdump-baremetal
    [  306.029386] kdump[797]: get_host_ip exited with non-zero status!
    [  306.038085] systemd[1]: kdump-capture.service: Main process exited, code=exited, status=1/FAILURE
    [  306.050082] systemd[1]: kdump-capture.service: Failed with result 'exit-code'.

Fixes: ba7660f ("dracut-module-setup: NIC renamed with prefix "kdump-" for native ethX")
Reported-by: Dima Shtranvasser <dshtranv@redhat.com>
Suggeste-by: Dima Shtranvasser <dshtranv@redhat.com>
Signed-off-by: Coiby Xu <coxu@redhat.com>
This commit is contained in:
Coiby Xu 2024-07-16 16:25:28 +08:00
parent 3893a3d2f2
commit fef93a08a8

View File

@ -326,7 +326,7 @@ kdump_setup_ifname() {
# fadump to kdump. Skip prefixing 'kdump-' in this case as adding
# another prefix may truncate the ifname. Since an ifname with
# 'kdump-' is already persistent, this should be fine.
if [[ $1 =~ eth* ]] && [[ ! $1 =~ ^kdump-* ]]; then
if [[ $1 =~ ^eth.* ]] && [[ ! $1 =~ ^kdump-* ]]; then
_ifname="kdump-$1"
else
_ifname="$1"