diff options
author | Jonathan Bauer | 2019-08-26 12:52:19 +0200 |
---|---|---|
committer | Jonathan Bauer | 2019-08-26 12:52:19 +0200 |
commit | 5a45aafe03fbf46157b6b1fe524668e6dc285d42 (patch) | |
tree | c59d474214837322a213870e8e10b489a5ad12bc /builder/modules.d/slx-network/scripts | |
parent | [slx-dmsetup] remove quotes (diff) | |
download | systemd-init-5a45aafe03fbf46157b6b1fe524668e6dc285d42.tar.gz systemd-init-5a45aafe03fbf46157b6b1fe524668e6dc285d42.tar.xz systemd-init-5a45aafe03fbf46157b6b1fe524668e6dc285d42.zip |
[slx-network] initial VLAN support
Diffstat (limited to 'builder/modules.d/slx-network/scripts')
4 files changed, 46 insertions, 12 deletions
diff --git a/builder/modules.d/slx-network/scripts/setup-bootif-network.stage3 b/builder/modules.d/slx-network/scripts/setup-bootif-network.stage3 index 24bf0245..615f7cbe 100755 --- a/builder/modules.d/slx-network/scripts/setup-bootif-network.stage3 +++ b/builder/modules.d/slx-network/scripts/setup-bootif-network.stage3 @@ -32,10 +32,25 @@ set -x ip link set dev "$SLX_PXE_NETIF" up if ! wait_for_iface "$SLX_PXE_NETIF" 100; then - warn "'$SLX_PXE_NETIF' still not up after 10sec ..." + warn "'$SLX_PXE_NETIF' still not up after 10sec ... trying anyway." # TODO handle case where we waited for 10sec and it is still not up fi +# now determine whether we are in bridged/vlan/plain mode +MAIN_NETIF="$SLX_PXE_NETIF" +if [ -n "$SLX_VLAN_ID" ]; then + # create VLAN interface + modprobe 8021q || warn "Loading '8021q' failed - missing module?" + ip link add link "$SLX_PXE_NETIF" name "${SLX_PXE_NETIF}.${SLX_VLAN_ID}" \ + type vlan id "$SLX_VLAN_ID" + ip link set dev "${SLX_PXE_NETIF}.${SLX_VLAN_ID}" up + if wait_for_iface "${SLX_PXE_NETIF}.${SLX_VLAN_ID}"; then + MAIN_NETIF="${SLX_PXE_NETIF}.${SLX_VLAN_ID}" + else + warn "Setting up VLAN '$SLX_VLAN_ID' failed, trying plain..." + fi +fi + if [ -n "$SLX_BRIDGE" ]; then for try in {1..10} ""; do ( @@ -44,12 +59,15 @@ if [ -n "$SLX_BRIDGE" ]; then brctl stp "$SLX_BRIDGE" 0 brctl setfd "$SLX_BRIDGE" 0.000000000001 ip link set addr "$SLX_PXE_MAC" "$SLX_BRIDGE" - brctl addif "$SLX_BRIDGE" "$SLX_PXE_NETIF" + brctl addif "$SLX_BRIDGE" "$MAIN_NETIF" ip link set dev "$SLX_BRIDGE" up wait_for_iface "$SLX_BRIDGE" ) # success? - [ "$?" -eq 0 ] && break + if [ "$?" -eq 0 ]; then + MAIN_NETIF="$SLX_BRIDGE" + break + fi # nope, handle if [ -z "$try" ]; then @@ -61,11 +79,12 @@ if [ -n "$SLX_BRIDGE" ]; then usleep 100000 done fi -# add the IP address on the bridge/boot if + +# finally add the IP address on the main NIC ip addr add \ "${SLX_PXE_CLIENT_IP}/$(ipcalc -s -p "$SLX_PXE_CLIENT_IP" "$SLX_PXE_NETMASK" | sed "s/.*=//")" \ broadcast "$(ipcalc -s -b "$SLX_PXE_CLIENT_IP" "$SLX_PXE_NETMASK" | sed "s/.*=//")" \ - dev "${SLX_BRIDGE:-${SLX_PXE_NETIF}}" + dev "$MAIN_NETIF" if [ "$USE_DHCP_UUID" = "yes" ] && [ -s "/run/system-uuid" ]; then UUID="$(cat /run/system-uuid)" @@ -75,7 +94,7 @@ fi for i in 1 1 1 fail; do [ "$i" = "fail" ] && emergency_shell "DHCP failed 3 times... cannot continue." udhcpc -t 4 -T 3 -f -n -q \ - -i "${SLX_BRIDGE:-${SLX_PXE_NETIF}}" \ + -i "${MAIN_NETIF}" \ "${SLX_PXE_CLIENT_IP:+-r $SLX_PXE_CLIENT_IP}" \ "${UUID:+-x 0x3d:$UUID}" \ -O ntpsrv -O domain -O wpad -O search -O nisdomain \ diff --git a/builder/modules.d/slx-network/scripts/setup-bootif-network.stage4 b/builder/modules.d/slx-network/scripts/setup-bootif-network.stage4 index bd89fec6..17afe798 100755 --- a/builder/modules.d/slx-network/scripts/setup-bootif-network.stage4 +++ b/builder/modules.d/slx-network/scripts/setup-bootif-network.stage4 @@ -14,6 +14,11 @@ if [ -z "$SLX_PXE_NETIF" ] || [ -z "$SLX_PXE_CLIENT_IP" ]; then exit 1 fi +MAIN_NETIF="$SLX_PXE_NETIF" +[ -n "$SLX_VLAN_ID" ] && MAIN_NETIF="${SLX_PXE_NETIF}.${SLX_VLAN_ID}" +[ -n "$SLX_BRIDGE" ] && MAIN_NETIF="${SLX_BRIDGE}" +readonly MAIN_NETIF + # set default options declare -a udhcpc_opts udhcpc_opts+=("-t" "8") @@ -37,14 +42,14 @@ fi mkdir -p /run/udhcpc || echo "Could not create '/run/udhcpc'." udhcpc "${udhcpc_opts[@]}" \ - -i "${SLX_BRIDGE:-${SLX_PXE_NETIF}}" \ + -i "$MAIN_NETIF" \ -r "${SLX_PXE_CLIENT_IP}" \ -s /opt/openslx/scripts/udhcpc-trigger \ - -p "/run/udhcpc/udhcpc.${net_if}.pid" + -p "/run/udhcpc/udhcpc.${MAIN_NETIF}.pid" ret=$? if [ "${ret}" != 0 ]; then - echo "udhcpc" "Could not run 'udhcpc ${udhcpc_opts[*]}' on ${net_if}." + echo "udhcpc" "Could not run 'udhcpc ${udhcpc_opts[*]}' on ${MAIN_NETIF}." fi exit "${ret}" diff --git a/builder/modules.d/slx-network/scripts/udhcpc-trigger.stage3 b/builder/modules.d/slx-network/scripts/udhcpc-trigger.stage3 index 2621b76f..a561ed66 100755 --- a/builder/modules.d/slx-network/scripts/udhcpc-trigger.stage3 +++ b/builder/modules.d/slx-network/scripts/udhcpc-trigger.stage3 @@ -9,8 +9,13 @@ set -x NETWORK_CONF="/run/openslx/network.conf" . "$NETWORK_CONF" +MAIN_NETIF="$SLX_PXE_NETIF" +[ -n "$SLX_VLAN_ID" ] && MAIN_NETIF="${SLX_PXE_NETIF}.${SLX_VLAN_ID}" +[ -n "$SLX_BRIDGE" ] && MAIN_NETIF="$SLX_BRIDGE" +readonly MAIN_NETIF + if [ "x$1" != "xbound" -a "x$1" != "xrenew" ] \ - || [ "x$interface" != "x${SLX_BRIDGE:-${SLX_PXE_NETIF}}" ] \ + || [ "x$interface" != "x${MAIN_NETIF}" ] \ || [ -z "$ip" ]; then exit 0 fi diff --git a/builder/modules.d/slx-network/scripts/udhcpc-trigger.stage4 b/builder/modules.d/slx-network/scripts/udhcpc-trigger.stage4 index b51328ca..0a67526f 100755 --- a/builder/modules.d/slx-network/scripts/udhcpc-trigger.stage4 +++ b/builder/modules.d/slx-network/scripts/udhcpc-trigger.stage4 @@ -12,8 +12,13 @@ if [ -z "$SLX_PXE_NETIF" ] || [ -z "$SLX_PXE_CLIENT_IP" ]; then exit 1 fi +MAIN_NETIF="$SLX_PXE_NETIF" +[ -n "$SLX_VLAN_ID" ] && MAIN_NETIF="${SLX_PXE_NETIF}.${SLX_VLAN_ID}" +[ -n "$SLX_BRIDGE" ] && MAIN_NETIF="$SLX_BRIDGE" +readonly MAIN_NETIF + RESOLV_CONF="/opt/openslx/resolv.conf" -THIS_RESOLV="/run/network/${SLX_PXE_NETIF}.resolv" +THIS_RESOLV="/run/network/${MAIN_NETIF}.resolv" rebuild_resolv_conf () { # Don't do anything if the active resolv.conf is not ours @@ -48,7 +53,7 @@ check_env() { fi # only run for the boot network interface # TODO VLAN support - if [ "$interface" != "${SLX_BRIDGE:-${SLX_PXE_NETIF}}" ]; then + if [ "$interface" != "$MAIN_NETIF" ]; then echo "Ignoring '$interface'..." exit 1 fi |