initrds: ifup: Do not apply any config if NETAUTO=none

There are three types of value accepted by NETAUTO:

    1) "dhcp" for automatic network settings via DHCP
    2) "up" to bring link up, wait for IPv6 tentative and link up
       operstate
    3) anything else: apply static configuration, wait for IPv6
       tentative and link up operstate

Note that empty ("") value is subset of 3) and we only skip link up
operstate monitoring for it since commit 3e89468cd0
("Don't require link-up on ma1 if NETAUTO is not specified.").

Add fourth case with NETAUTO=none to skip all but NETHW (hardware
address) from boot-config file and support different management
adapter config methods (e.g. Debian network config system).

This also fixes incorrect "return" statement usage outside of function
introduced with commit 3e89468cd0
("Don't require link-up on ma1 if NETAUTO is not specified.") and adds
newline before wait_link_up() to make code more readable.

Signed-off-by: Sergey Popovich <sergey.popovich@ordnance.co>
This commit is contained in:
Sergey Popovich
2018-08-06 08:55:13 +03:00
parent 0106c6a542
commit cdad662745
2 changed files with 7 additions and 2 deletions

View File

@@ -81,6 +81,9 @@ case "${NETAUTO}" in
up)
ifconfig "${NETDEV}" up
;;
none)
exit 0
;;
*)
if [ "${NETIP}" ] && [ "${NETMASK}" ] && [ "${NETIP#*/}" = "${NETIP}" ]; then
NETIP=${NETIP}/$(ipcalc -p -s ${NETIP} ${NETMASK} | sed -n 's/PREFIX=//p')
@@ -118,6 +121,7 @@ for i in $(seq 30); do
fi
sleep 1
done
wait_link_up()
{
local intf=$1
@@ -144,4 +148,5 @@ wait_link_up()
if [ -n "${NETAUTO}" ]; then
wait_link_up $NETDEV 100
fi
return 0
exit 0

View File

@@ -191,7 +191,7 @@ class OnlBootConfigNet(OnlBootConfig):
if not self.is_ip_address(netdns):
raise ValueError("NETDNS=%s is not a valid ip-address" % (netdns))
elif self.keys['NETAUTO'] not in ['dhcp', 'up', '']:
elif self.keys['NETAUTO'] not in ['dhcp', 'up', 'none', '']:
raise ValueError("The NETAUTO value '%s' is invalid." % self.keys['NETAUTO'])
elif self.keys['NETAUTO'] == 'up' and self.NET_REQUIRED:
raise ValueError("NETAUTO is 'up' but non-local networking is required.")