From: Thomas Blume Date: Wed, 22 Jul 2020 07:34:42 +0000 (+0200) Subject: 35network-legacy: simplify fallback dhcp setup X-Git-Tag: 051~113 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3f5bf54fbffdc3516a08c9329b4be80b06761c7a;p=thirdparty%2Fdracut.git 35network-legacy: simplify fallback dhcp setup suppress redundant calls to network setup combine code for "no ip option directed at our interface" and "No ip lines default to dhcp" correct evaluation of return code for creating did-setup files fix application of "load_ipv6" call to ipv6 setup only Reference: bsc#1173402 --- diff --git a/modules.d/35network-legacy/ifup.sh b/modules.d/35network-legacy/ifup.sh index c05ccc1bc..b1ae52ea5 100755 --- a/modules.d/35network-legacy/ifup.sh +++ b/modules.d/35network-legacy/ifup.sh @@ -376,23 +376,6 @@ else fi -# No ip lines default to dhcp -ip=$(getarg ip) - -if [ -z "$NO_AUTO_DHCP" ] && [ -z "$ip" ]; then - if [ "$netroot" = "dhcp6" ]; then - do_dhcp -6 - else - do_dhcp -4 - fi - - for s in $(getargs nameserver); do - [ -n "$s" ] || continue - echo nameserver $s >> /tmp/net.$netif.resolv.conf - done -fi - - # Specific configuration, spin through the kernel command line # looking for ip= lines for p in $(getargs ip=); do @@ -473,21 +456,39 @@ done # no ip option directed at our interface? if [ -z "$NO_AUTO_DHCP" ] && [ ! -e /tmp/net.${netif}.up ]; then + ret=1 if [ -e /tmp/net.bootdev ]; then BOOTDEV=$(cat /tmp/net.bootdev) if [ "$netif" = "$BOOTDEV" ] || [ "$BOOTDEV" = "$(cat /sys/class/net/${netif}/address)" ]; then - load_ipv6 do_dhcp + ret=$? fi else - if getargs 'ip=dhcp6'; then + # No ip lines, no bootdev -> default to dhcp + ip=$(getarg ip) + + if getargs 'ip=dhcp6' || [ -z "$ip" -a "$netroot" = "dhcp6" ]; then load_ipv6 do_dhcp -6 + ret=$? fi - if getargs 'ip=dhcp'; then + if getargs 'ip=dhcp' || [ -z "$ip" -a "$netroot" != "dhcp6" ]; then do_dhcp -4 + ret=$? fi fi + + for s in $(getargs nameserver); do + [ -n "$s" ] || continue + echo nameserver $s >> /tmp/net.$netif.resolv.conf + done + + if [ "$ret" -eq 0 ] && [ -n "$(ls /tmp/leaseinfo.${netif}*)" ]; then + > /tmp/net.${netif}.did-setup + if [ -e /sys/class/net/${netif}/address ]; then + > /tmp/net.$(cat /sys/class/net/${netif}/address).did-setup + fi + fi fi exit 0