link executor: Only gather and set IFACE_OPTIONS on up.

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

View file

@ -4,10 +4,6 @@ set -e
[ -n "$VERBOSE" ] && set -x [ -n "$VERBOSE" ] && set -x
IF_LINK_OPTIONS="$IF_LINK_OPTIONS"
[ -n "$IF_MTU" ] && IF_LINK_OPTIONS="$IF_LINK_OPTIONS mtu $IF_MTU"
[ -n "$IF_HWADDRESS" ] && IF_LINK_OPTIONS="$IF_LINK_OPTIONS address $IF_HWADDRESS"
is_vlan() { is_vlan() {
case "$IFACE" in case "$IFACE" in
*#*) return 1 ;; *#*) return 1 ;;
@ -64,14 +60,21 @@ pre-up)
${MOCK} ip link add link "${IF_VLAN_RAW_DEVICE}" name "${IFACE}" type vlan id "${IF_VLAN_ID}" ${MOCK} ip link add link "${IF_VLAN_RAW_DEVICE}" name "${IFACE}" type vlan id "${IF_VLAN_ID}"
fi fi
;; ;;
up|down) up)
${MOCK} ip link set $PHASE dev $IFACE $IF_LINK_OPTIONS IF_LINK_OPTIONS="$IF_LINK_OPTIONS"
[ -n "$IF_MTU" ] && IF_LINK_OPTIONS="$IF_LINK_OPTIONS mtu $IF_MTU"
[ -n "$IF_HWADDRESS" ] && IF_LINK_OPTIONS="$IF_LINK_OPTIONS address $IF_HWADDRESS"
${MOCK} ip link set up dev "${IFACE}" ${IF_LINK_OPTIONS}
# Set alias is configured # Set alias is configured
if [ "${IF_ALIAS}" ]; then if [ "${IF_ALIAS}" ]; then
${MOCK} ip link set alias "${IF_ALIAS}" dev "${IFACE}" ${MOCK} ip link set alias "${IF_ALIAS}" dev "${IFACE}"
fi fi
;; ;;
down)
${MOCK} ip link set down dev "${IFACE}"
;;
post-down) post-down)
if [ "${IF_LINK_TYPE}" = "dummy" -o is_vlan ]; then if [ "${IF_LINK_TYPE}" = "dummy" -o is_vlan ]; then
if [ -d "/sys/class/net/${IFACE}" ]; then if [ -d "/sys/class/net/${IFACE}" ]; then