Skip to content

Commit

Permalink
fix(network): add errors and warnings when network interface does not…
Browse files Browse the repository at this point in the history
… exist

End with error, or show a warning when nonexistent device is specified for network setup like
`ip=10.12.8.12::10.12.255.254:255.255.0.0:xk12:eth0:off`.

I've added the error only for `write-ifcfg.sh`, as I think no such setup should be written.

Resolves: #1712424
  • Loading branch information
pvalena authored and johannbg committed Nov 25, 2021
1 parent 5b18b06 commit 7938935
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
6 changes: 5 additions & 1 deletion modules.d/35network-legacy/ifup.sh
Expand Up @@ -446,7 +446,11 @@ for p in $(getargs ip=); do

# If this option isn't directed at our interface, skip it
if [ -n "$dev" ]; then
[ "$dev" != "$netif" ] && continue
if [ "$dev" != "$netif" ]; then
[ ! -e "/sys/class/net/$dev" ] \
&& warn "Network interface '$dev' does not exist!"
continue
fi
else
iface_is_enslaved "$netif" && continue
fi
Expand Down
5 changes: 5 additions & 0 deletions modules.d/35network-legacy/parse-ip-opts.sh
Expand Up @@ -97,6 +97,11 @@ for p in $(getargs ip=); do
fi
# IFACES list for later use
IFACES="$IFACES $dev"

# Interface should exist
if [ ! -e "/sys/class/net/$dev" ]; then
warn "Network interface '$dev' does not exist"
fi
fi

# Do we need to check for specific options?
Expand Down
5 changes: 5 additions & 0 deletions modules.d/45ifcfg/write-ifcfg.sh
Expand Up @@ -103,6 +103,11 @@ interface_bind() {
local _netif="$1"
local _macaddr="$2"

if [ ! -e "/sys/class/net/$_netif" ]; then
derror "Cannot find network interface '$_netif'!"
return 1
fi

# see, if we can bind it to some hw parms
if hw_bind "$_netif" "$_macaddr"; then
# only print out DEVICE, if it's user assigned
Expand Down

0 comments on commit 7938935

Please sign in to comment.