Merge pull request #54 from BarbarossaTM/dummy

Only create dummy interface when missing and remove them on post-down
This commit is contained in:
Ariadne Conill 2020-08-30 15:38:32 -06:00 committed by GitHub
commit ab7ff2b206
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -34,6 +34,13 @@ is_vlan() {
case "$PHASE" in
pre-up)
if [ "${IF_LINK_TYPE}" = "dummy" ]; then
if [ -d "/sys/class/net/${IFACE}" ]; then
iface_type=$(ip -d link show dev "${IFACE}" | head -n3 | tail -n1 | awk '{ print $1 }')
if [ "${iface_type}" = 'dummy' ]; then
exit 0
fi
fi
ip link add "${IFACE}" type dummy
fi
;;
@ -64,6 +71,13 @@ up|down)
${MOCK} ip link set $PHASE dev $IFACE $IF_LINK_OPTIONS
;;
post-down)
if [ "${IF_LINK_TYPE}" = "dummy" ]; then
if [ -d "/sys/class/net/${IFACE}" ]; then
ip link del "${IFACE}"
fi
fi
;;
depend)
if is_vlan; then
echo "$IF_VLAN_RAW_DEVICE"