link executor: Refactor VLAN iface management

Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
This commit is contained in:
Maximilian Wilhelm 2020-09-04 23:21:21 +02:00
parent a59109cb66
commit 0e5ec5b260

View file

@ -43,19 +43,15 @@ pre-up)
ip link add "${IFACE}" type dummy
fi
;;
up|down)
if is_vlan; then
ADD_DEL="add"
[ "$PHASE" = "down" ] && ADD_DEL="delete"
if [ "$PHASE" = "up" -a -e /sys/class/net/$IFACE ]; then
if is_vlan; then
if [ -d "/sys/class/net/${IFACE}" ]; then
exit 0
fi
if [ -z "$MOCK" ]; then
if ! ip link show "$IF_VLAN_RAW_DEVICE" >/dev/null; then
echo "Device $IF_VLAN_RAW_DEVICE for $IFACE does not exist"
if [ -z "${MOCK}" ]; then
if [ ! -d "/sys/class/net/${IF_VLAN_RAW_DEVICE}" ]; then
echo "Underlay device ${IF_VLAN_RAW_DEVICE} for ${IFACE} does not exist"
exit 1
fi
@ -65,10 +61,10 @@ up|down)
fi
fi
${MOCK} ip link $ADD_DEL link "$IF_VLAN_RAW_DEVICE" name "$IFACE" type vlan id "$IF_VLAN_ID"
[ "$PHASE" = "down" ] && exit 0
${MOCK} ip link add link "${IF_VLAN_RAW_DEVICE}" name "${IFACE}" type vlan id "${IF_VLAN_ID}"
fi
;;
up|down)
${MOCK} ip link set $PHASE dev $IFACE $IF_LINK_OPTIONS
# Set alias is configured
@ -77,7 +73,7 @@ up|down)
fi
;;
post-down)
if [ "${IF_LINK_TYPE}" = "dummy" ]; then
if [ "${IF_LINK_TYPE}" = "dummy" -o is_vlan ]; then
if [ -d "/sys/class/net/${IFACE}" ]; then
ip link del "${IFACE}"
fi