Merge pull request #41 from ifupdown-ng/bugfix/link-back-to-up-down
Bugfix/link back to up down
This commit is contained in:
commit
b30f84fdbd
2 changed files with 14 additions and 16 deletions
|
@ -29,14 +29,12 @@ is_vlan() {
|
|||
}
|
||||
|
||||
case "$PHASE" in
|
||||
pre-up|post-down)
|
||||
UP_DOWN="${PHASE##*-}"
|
||||
|
||||
up|down)
|
||||
if is_vlan; then
|
||||
ADD_DEL="add"
|
||||
[ "$UP_DOWN" = "down" ] && ADD_DEL="delete"
|
||||
[ "$PHASE" = "down" ] && ADD_DEL="delete"
|
||||
|
||||
if [ "$UP_DOWN" = "up" -a -e /sys/class/net/$IFACE ]; then
|
||||
if [ "$PHASE" = "up" -a -e /sys/class/net/$IFACE ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
@ -53,11 +51,11 @@ pre-up|post-down)
|
|||
fi
|
||||
|
||||
${MOCK} ip link $ADD_DEL link "$IF_VLAN_RAW_DEVICE" name "$IFACE" type vlan id "$IF_VLAN_ID"
|
||||
[ "$UP_DOWN" = "down" ] && exit 0
|
||||
[ "$PHASE" = "down" ] && exit 0
|
||||
|
||||
${MOCK} ip link set $UP_DOWN dev $IFACE $IF_LINK_OPTIONS
|
||||
${MOCK} ip link set $PHASE dev $IFACE $IF_LINK_OPTIONS
|
||||
else
|
||||
${MOCK} ip link set $UP_DOWN dev $IFACE $IF_LINK_OPTIONS
|
||||
${MOCK} ip link set $PHASE dev $IFACE $IF_LINK_OPTIONS
|
||||
fi
|
||||
;;
|
||||
depend)
|
||||
|
|
|
@ -15,51 +15,51 @@ tests_init \
|
|||
vlan_guessed_depend
|
||||
|
||||
up_body() {
|
||||
export IFACE=lo PHASE=pre-up MOCK=echo
|
||||
export IFACE=lo PHASE=up MOCK=echo
|
||||
atf_check -s exit:0 -o match:'ip link set up dev lo' \
|
||||
${EXECUTOR}
|
||||
}
|
||||
|
||||
down_body() {
|
||||
export IFACE=lo PHASE=post-down MOCK=echo
|
||||
export IFACE=lo PHASE=down MOCK=echo
|
||||
atf_check -s exit:0 -o match:'ip link set down dev lo' \
|
||||
${EXECUTOR}
|
||||
}
|
||||
|
||||
mtu_body() {
|
||||
export IFACE=eth0 PHASE=pre-up MOCK=echo IF_MTU=1492
|
||||
export IFACE=eth0 PHASE=up MOCK=echo IF_MTU=1492
|
||||
atf_check -s exit:0 -o match:'ip link set up dev eth0 mtu 1492' \
|
||||
${EXECUTOR}
|
||||
}
|
||||
|
||||
vlan_explicit_up_body() {
|
||||
export IFACE=servers PHASE=pre-up MOCK=echo \
|
||||
export IFACE=servers PHASE=up MOCK=echo \
|
||||
IF_VLAN_RAW_DEVICE="eth0" IF_VLAN_ID="123"
|
||||
atf_check -s exit:0 -o match:'ip link add link eth0 name servers type vlan id 123' \
|
||||
${EXECUTOR}
|
||||
}
|
||||
|
||||
vlan_explicit_down_body() {
|
||||
export IFACE=servers PHASE=post-down MOCK=echo \
|
||||
export IFACE=servers PHASE=down MOCK=echo \
|
||||
IF_VLAN_RAW_DEVICE="eth0" IF_VLAN_ID="123"
|
||||
atf_check -s exit:0 -o match:'ip link delete link eth0 name servers type vlan id 123' \
|
||||
${EXECUTOR}
|
||||
}
|
||||
|
||||
vlan_guessed_up_body() {
|
||||
export IFACE=eth0.8 PHASE=pre-up MOCK=echo
|
||||
export IFACE=eth0.8 PHASE=up MOCK=echo
|
||||
atf_check -s exit:0 -o match:'ip link add link eth0 name eth0.8 type vlan id 8' \
|
||||
${EXECUTOR}
|
||||
}
|
||||
|
||||
vlan_guessed_down_body() {
|
||||
export IFACE=eth0.8 PHASE=post-down MOCK=echo
|
||||
export IFACE=eth0.8 PHASE=down MOCK=echo
|
||||
atf_check -s exit:0 -o match:'ip link delete link eth0 name eth0.8 type vlan id 8' \
|
||||
${EXECUTOR}
|
||||
}
|
||||
|
||||
vlan_explicit_depend_body() {
|
||||
export IFACE=servers PHASE=pre-up MOCK=echo \
|
||||
export IFACE=servers PHASE=up MOCK=echo \
|
||||
IF_VLAN_RAW_DEVICE="eth0" IF_VLAN_ID="123"
|
||||
atf_check -s exit:0 -o match:'eth0' \
|
||||
${EXECUTOR}
|
||||
|
|
Loading…
Reference in a new issue