network: Add check for VLAN already added

This commit is contained in:
tschettervictor
2025-03-04 11:32:51 -07:00
committed by GitHub
parent d7e12d698e
commit 4793f1cf88

View File

@@ -432,7 +432,7 @@ case "${ACTION}" in
else
validate_ip "${IP}"
fi
if [ "${VNET_JAIL}" -eq 1 ]; then
if [ "${VNET_JAIL}" -eq 1 ] && [ -n "${VLAN_ID}" ]; then
if ifconfig -g bridge | grep -owq "${INTERFACE}"; then
error_exit "\"${INTERFACE}\" is a bridge interface."
else
@@ -441,7 +441,7 @@ case "${ACTION}" in
bastille start "${TARGET}"
fi
fi
elif [ "${BRIDGE_VNET_JAIL}" -eq 1 ]; then
elif [ "${BRIDGE_VNET_JAIL}" -eq 1 ] && [ -n "${VLAN_ID}" ]; then
if ! ifconfig -g bridge | grep -owq "${INTERFACE}"; then
error_exit "\"${INTERFACE}\" is not a bridge interface."
else
@@ -459,6 +459,11 @@ case "${ACTION}" in
bastille start "${TARGET}"
fi
fi
elif { [ "${VNET_JAIL}" -eq 1 ] && [ -n "${VLAN_ID}" ]; } || \
{ [ "${BRIDGE_VNET_JAIL}" -eq 1 ] && [ -n "${VLAN_ID}" ]; } then
if grep -Eq "ifconfig_vnet[0-9]+_${VLAN_ID}" "${bastille_jailsdir}/${TARGET}/root/etc/rc.conf"; then
error_exit "VLAN has already been added: VLAN ${VLAN_ID}"
fi
fi
;;
remove|delete)