|
|
961b04 |
From c7b21c88d27aace097ce9bc1fc36f4b742858737 Mon Sep 17 00:00:00 2001
|
|
|
961b04 |
From: Pavel Valena <pvalena@redhat.com>
|
|
|
961b04 |
Date: Mon, 22 Nov 2021 16:40:39 +0100
|
|
|
961b04 |
Subject: [PATCH] fix(network): add errors and warnings when network interface
|
|
|
961b04 |
does not exist
|
|
|
961b04 |
|
|
|
961b04 |
End with error, or show a warning when nonexistent device is specified for network setup like
|
|
|
961b04 |
`ip=10.12.8.12::10.12.255.254:255.255.0.0:xk12:eth0:off`.
|
|
|
961b04 |
|
|
|
961b04 |
I've added the error only for `write-ifcfg.sh`, as I think no such setup should be written.
|
|
|
961b04 |
|
|
|
961b04 |
Resolves: #1712424
|
|
|
961b04 |
---
|
|
|
961b04 |
modules.d/35network-legacy/ifup.sh | 6 +++++-
|
|
|
961b04 |
modules.d/35network-legacy/parse-ip-opts.sh | 5 +++++
|
|
|
961b04 |
modules.d/45ifcfg/write-ifcfg.sh | 5 +++++
|
|
|
961b04 |
3 files changed, 15 insertions(+), 1 deletion(-)
|
|
|
961b04 |
|
|
|
961b04 |
diff --git a/modules.d/35network-legacy/ifup.sh b/modules.d/35network-legacy/ifup.sh
|
|
|
961b04 |
index bd560379..0e9a6928 100755
|
|
|
961b04 |
--- a/modules.d/35network-legacy/ifup.sh
|
|
|
961b04 |
+++ b/modules.d/35network-legacy/ifup.sh
|
|
|
961b04 |
@@ -413,7 +413,11 @@ for p in $(getargs ip=); do
|
|
|
961b04 |
|
|
|
961b04 |
# If this option isn't directed at our interface, skip it
|
|
|
961b04 |
if [ -n "$dev" ]; then
|
|
|
961b04 |
- [ "$dev" != "$netif" ] && continue
|
|
|
961b04 |
+ if [ "$dev" != "$netif" ]; then
|
|
|
961b04 |
+ [ ! -e "/sys/class/net/$dev" ] \
|
|
|
961b04 |
+ && warn "Network interface '$dev' does not exist!"
|
|
|
961b04 |
+ continue
|
|
|
961b04 |
+ fi
|
|
|
961b04 |
else
|
|
|
961b04 |
iface_is_enslaved "$netif" && continue
|
|
|
961b04 |
fi
|
|
|
961b04 |
diff --git a/modules.d/35network-legacy/parse-ip-opts.sh b/modules.d/35network-legacy/parse-ip-opts.sh
|
|
|
961b04 |
index 10a2d19b..eea0988c 100755
|
|
|
961b04 |
--- a/modules.d/35network-legacy/parse-ip-opts.sh
|
|
|
961b04 |
+++ b/modules.d/35network-legacy/parse-ip-opts.sh
|
|
|
961b04 |
@@ -96,6 +96,11 @@ for p in $(getargs ip=); do
|
|
|
961b04 |
fi
|
|
|
961b04 |
# IFACES list for later use
|
|
|
961b04 |
IFACES="$IFACES $dev"
|
|
|
961b04 |
+
|
|
|
961b04 |
+ # Interface should exist
|
|
|
961b04 |
+ if [ ! -e "/sys/class/net/$dev" ]; then
|
|
|
961b04 |
+ warn "Network interface '$dev' does not exist"
|
|
|
961b04 |
+ fi
|
|
|
961b04 |
fi
|
|
|
961b04 |
|
|
|
961b04 |
# Do we need to check for specific options?
|
|
|
961b04 |
diff --git a/modules.d/45ifcfg/write-ifcfg.sh b/modules.d/45ifcfg/write-ifcfg.sh
|
|
|
961b04 |
index abd111fc..7e767f15 100755
|
|
|
961b04 |
--- a/modules.d/45ifcfg/write-ifcfg.sh
|
|
|
961b04 |
+++ b/modules.d/45ifcfg/write-ifcfg.sh
|
|
|
961b04 |
@@ -100,6 +100,11 @@ interface_bind() {
|
|
|
961b04 |
local _netif="$1"
|
|
|
961b04 |
local _macaddr="$2"
|
|
|
961b04 |
|
|
|
961b04 |
+ if [ ! -e "/sys/class/net/$_netif" ]; then
|
|
|
961b04 |
+ derror "Cannot find network interface '$_netif'!"
|
|
|
961b04 |
+ return 1
|
|
|
961b04 |
+ fi
|
|
|
961b04 |
+
|
|
|
961b04 |
# see, if we can bind it to some hw parms
|
|
|
961b04 |
if hw_bind "$_netif" "$_macaddr"; then
|
|
|
961b04 |
# only print out DEVICE, if it's user assigned
|
|
|
961b04 |
|