Support network_address/mask IPv6 install values

Re-add support for network_address and network_mask install values in
Debian.

The boot parameters network_address and network_mask are used to apply
either a default route or static route, based on the presence of the
combined three nexthop_gateway/nexthop_gateway/network_address/
network_mask values.

- nexthop_gateway only: create default route
- nexthop_gateway + network_address + network_mask: create static route

These changes are applied to both the pre-ostree-pull network
configuration (via 'ip' command), and the /etc/network/interfaces.d
ifupdown interface configuration.

Test Plan
PASS:
- Test IPv6 install using only nexthop_gateway value
    - Ensure that the default route is created for the gateway.
    - Validate successful ostree repo pull
    - Ensure that the default route is created via the
    - /etc/network/interfaces.d upon reboot into the ostree repo
    - Validate that communications are established to subcloud, ready
      for ansible bootstrap
- Test IPv4 install using only nexthop_gateway value
    - Full install plus bootstrap, as above
TODO (pending lab requirements):
- Test IPv6 install using nexthop_gateway value, including
  network_address and network_mask values.
- Test IPv4 install using nexthop_gateway value, including
  network_address and network_mask values.

Closes-Bug: 2049543

Signed-off-by: Kyle MacLeod <kyle.macleod@windriver.com>
Change-Id: Iaa543306f035c952f6da8b5d075e6f4d8ac56312
This commit is contained in:
Kyle MacLeod 2023-04-16 22:52:21 -04:00
parent 5a3a5ce8ea
commit 79e8fa6b32
1 changed files with 55 additions and 8 deletions

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2022-2023 Wind River Systems, Inc.
# Copyright (c) 2022-2024 Wind River Systems, Inc.
# SPDX-License-Identifier: Apache-2.0
#
############################################################################
@ -675,6 +675,8 @@ function parse_miniboot_network_params()
BOOTPARAM_IP_ADDR=
BOOTPARAM_VLAN=
BOOTPARAM_GW=
BOOTPARAM_NETWORK_ADDRESS=
BOOTPARAM_NETWORK_MASK=
BOOTPARAM_PREFIX_LEN=
BOOTPARAM_IFNAME=
BOOTPARAM_IP_VER=
@ -690,6 +692,14 @@ function parse_miniboot_network_params()
ipstring=\${arg:3}
ilog "Using ip=\$ipstring"
;;
network_address=*)
BOOTPARAM_NETWORK_ADDRESS=\$(echo \${arg:16} | tr -d '\[\]')
ilog "Using network_address=\${BOOTPARAM_NETWORK_ADDRESS}"
;;
network_mask=*)
BOOTPARAM_NETWORK_MASK=\$(echo \${arg:13} | tr -d '\[\]')
ilog "Using network_mask=\${BOOTPARAM_NETWORK_MASK}"
;;
vlan=*)
vlan=\${arg:5}
ilog "Using vlan=\${vlan}"
@ -743,6 +753,11 @@ function parse_miniboot_network_params()
logmsg="\$logmsg prefix:\$BOOTPARAM_PREFIX_LEN, ifname: \$BOOTPARAM_IFNAME, "
if [ -n "\${BOOTPARAM_GW}" ]; then
logmsg="\$logmsg gw:\$BOOTPARAM_GW, "
if [ -n "\${BOOTPARAM_NETWORK_ADDRESS}" ]; then
logmsg="\$logmsg network_address: \$BOOTPARAM_NETWORK_ADDRESS/\$BOOTPARAM_NETWORK_MASK (static route), "
else
logmsg="\$logmsg (default route), "
fi
fi
logmsg="\$logmsg metric: \$BOOTPARAM_METRIC, dns: \$BOOTPARAM_DNS"
ilog "\$logmsg"
@ -751,6 +766,8 @@ function parse_miniboot_network_params()
export BOOTPARAM_IP_ADDR
export BOOTPARAM_VLAN
export BOOTPARAM_GW
export BOOTPARAM_NETWORK_ADDRESS
export BOOTPARAM_NETWORK_MASK
export BOOTPARAM_PREFIX_LEN
export BOOTPARAM_IFNAME
export BOOTPARAM_IP_VER
@ -1596,14 +1613,21 @@ if [ -z "${mgmt_vlan}" ] ; then
ilog "ip ${BOOTPARAM_IP_VER} link set dev ${mgmt_dev} up"
ip ${BOOTPARAM_IP_VER} link set dev ${mgmt_dev} up
# Set static vs default route based on provided nexthop gateway and network address
if [ -z "${BOOTPARAM_GW}" ]; then
# No gateway
ilog "ip ${BOOTPARAM_IP_VER} route add default dev ${mgmt_dev} ${BOOTPARAM_METRIC}"
ip ${BOOTPARAM_IP_VER} route add default dev ${mgmt_dev} ${BOOTPARAM_METRIC}
else
ilog "Setting up default route:"
ilog "ip ${BOOTPARAM_IP_VER} route add default via ${BOOTPARAM_GW} dev ${mgmt_dev} ${BOOTPARAM_METRIC}"
ip ${BOOTPARAM_IP_VER} route add default via ${BOOTPARAM_GW} dev ${mgmt_dev} ${BOOTPARAM_METRIC}
if [ -z "${BOOTPARAM_NETWORK_ADDRESS}" ]; then
ilog "Setting up default route:"
ilog "ip ${BOOTPARAM_IP_VER} route add default via ${BOOTPARAM_GW} dev ${mgmt_dev} ${BOOTPARAM_METRIC}"
ip ${BOOTPARAM_IP_VER} route add default via ${BOOTPARAM_GW} dev ${mgmt_dev} ${BOOTPARAM_METRIC}
else
ilog "Setting up static route:"
ilog "ip ${BOOTPARAM_IP_VER} route add ${BOOTPARAM_NETWORK_ADDRESS}/${BOOTPARAM_NETWORK_MASK} via ${BOOTPARAM_GW} dev ${mgmt_dev} ${BOOTPARAM_METRIC}"
ip ${BOOTPARAM_IP_VER} route add ${BOOTPARAM_NETWORK_ADDRESS}/${BOOTPARAM_NETWORK_MASK} via ${BOOTPARAM_GW} dev ${mgmt_dev} ${BOOTPARAM_METRIC}
fi
fi
wait_for_interface ${mgmt_dev} 60
ilog "ip addr:"
@ -1641,14 +1665,21 @@ else
ip ${BOOTPARAM_IP_VER} link set up dev ${mgmt_iface}
wait_for_interface ${mgmt_iface} 60
# Set static vs default route based on provided nexthop gateway and network address
if [ -z "${BOOTPARAM_GW}" ]; then
# No gateway
ilog "ip ${BOOTPARAM_IP_VER} route add default dev ${mgmt_iface} ${BOOTPARAM_METRIC}"
ip ${BOOTPARAM_IP_VER} route add default dev ${mgmt_iface} ${BOOTPARAM_METRIC}
else
ilog "Setting up default route:"
ilog "ip ${BOOTPARAM_IP_VER} route add default via ${BOOTPARAM_GW} dev ${mgmt_iface} ${BOOTPARAM_METRIC}"
ip ${BOOTPARAM_IP_VER} route add default via ${BOOTPARAM_GW} dev ${mgmt_iface} ${BOOTPARAM_METRIC}
if [ -z "${BOOTPARAM_NETWORK_ADDRESS}" ]; then
ilog "Setting up default route:"
ilog "ip ${BOOTPARAM_IP_VER} route add default via ${BOOTPARAM_GW} dev ${mgmt_iface} ${BOOTPARAM_METRIC}"
ip ${BOOTPARAM_IP_VER} route add default via ${BOOTPARAM_GW} dev ${mgmt_iface} ${BOOTPARAM_METRIC}
else
ilog "Setting up static route:"
ilog "ip ${BOOTPARAM_IP_VER} route add ${BOOTPARAM_NETWORK_ADDRESS}/${BOOTPARAM_NETWORK_MASK} via ${BOOTPARAM_GW} dev ${mgmt_iface} ${BOOTPARAM_METRIC}"
ip ${BOOTPARAM_IP_VER} route add ${BOOTPARAM_NETWORK_ADDRESS}/${BOOTPARAM_NETWORK_MASK} via ${BOOTPARAM_GW} dev ${mgmt_iface} ${BOOTPARAM_METRIC}
fi
fi
ilog "ip ${BOOTPARAM_IP_VER} addr:"
@ -2756,6 +2787,14 @@ function create_network_interface_file()
local logstr="Creating ${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-${ifname}, ${ipversion}"
[ -n "${vlan}" ] && logstr="${logstr}, vlan interface: ${ifname_vlan}"
[ -n "${BOOTPARAM_GW}" ] && logstr="${logstr}, gw: ${BOOTPARAM_GW}"
if [ -n "${BOOTPARAM_NETWORK_ADDRESS}" ]; then
logstr="${logstr}, network_address: ${BOOTPARAM_NETWORK_ADDRESS}"
fi
if [ -n "${BOOTPARAM_GW}" ] && [ -z "${BOOTPARAM_NETWORK_ADDRESS}" ]; then
logstr="${logstr}, default route"
elif [ -n "${BOOTPARAM_GW}" ] && [ -n "${BOOTPARAM_NETWORK_ADDRESS}" ]; then
logstr="${logstr}, static route"
fi
ilog "${logstr}"
local output
@ -2775,6 +2814,10 @@ function create_network_interface_file()
output="${output} post-up echo 0 > /proc/sys/net/ipv6/conf/${ifname}/autoconf\n"
output="${output} post-up echo 0 > /proc/sys/net/ipv6/conf/${ifname}/accept_ra\n"
output="${output} post-up echo 0 > /proc/sys/net/ipv6/conf/${ifname}/accept_redirects\n"
if [ -n "${BOOTPARAM_GW}" ] && [ -n "${BOOTPARAM_NETWORK_ADDRESS}" ]; then
# Note: BOOTPARAM_NETWORK_MASK is also set - enforced by dcmanager
output="${output} post-up ip ${ip_cmd_flag} route add ${BOOTPARAM_NETWORK_ADDRESS}/${BOOTPARAM_NETWORK_MASK} via ${BOOTPARAM_GW} dev ${ifname} ${BOOTPARAM_METRIC}\n"
fi
echo -e "${output}" > "${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-${ifname}"
else
# CONFIGURE FOR VLAN
@ -2795,13 +2838,17 @@ function create_network_interface_file()
output="${output}iface ${ifname_vlan} ${address_family} static\n"
output="${output} vlan-raw-device ${ifname}\n"
output="${output} address ${BOOTPARAM_IP_ADDR}/${BOOTPARAM_PREFIX_LEN}\n"
if [ -n "${BOOTPARAM_GW}" ]; then
if [ -n "${BOOTPARAM_GW}" ] && [ -z "${BOOTPARAM_NETWORK_ADDRESS}" ]; then
output="${output} gateway ${BOOTPARAM_GW}\n"
fi
output="${output} mtu 1500\n"
output="${output} post-up echo 0 > /proc/sys/net/ipv6/conf/${ifname_vlan}/autoconf\n"
output="${output} post-up echo 0 > /proc/sys/net/ipv6/conf/${ifname_vlan}/accept_ra\n"
output="${output} post-up echo 0 > /proc/sys/net/ipv6/conf/${ifname_vlan}/accept_redirects\n"
if [ -n "${BOOTPARAM_GW}" ] && [ -n "${BOOTPARAM_NETWORK_ADDRESS}" ]; then
# Note: BOOTPARAM_NETWORK_MASK is also set - enforced by dcmanager
output="${output} post-up ip ${ip_cmd_flag} route add ${BOOTPARAM_NETWORK_ADDRESS}/${BOOTPARAM_NETWORK_MASK} via ${BOOTPARAM_GW} dev ${ifname_vlan} ${BOOTPARAM_METRIC}\n"
fi
echo -e "${output}" > "${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-${ifname_vlan}"
fi
}