Merge pull request #28 from ifupdown-ng/feature/vrf-executor
VRF executor implementation
This commit is contained in:
commit
56323828a9
7 changed files with 84 additions and 2 deletions
3
Makefile
3
Makefile
|
@ -80,7 +80,8 @@ EXECUTOR_SCRIPTS_CORE ?= \
|
||||||
link \
|
link \
|
||||||
|
|
||||||
EXECUTOR_SCRIPTS_OPT ?= \
|
EXECUTOR_SCRIPTS_OPT ?= \
|
||||||
bridge
|
bridge \
|
||||||
|
vrf
|
||||||
|
|
||||||
EXECUTOR_SCRIPTS ?= ${EXECUTOR_SCRIPTS_CORE} ${EXECUTOR_SCRIPTS_OPT}
|
EXECUTOR_SCRIPTS ?= ${EXECUTOR_SCRIPTS_CORE} ${EXECUTOR_SCRIPTS_OPT}
|
||||||
|
|
||||||
|
|
32
executor-scripts/linux/vrf
Executable file
32
executor-scripts/linux/vrf
Executable file
|
@ -0,0 +1,32 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
handle_init() {
|
||||||
|
${MOCK} /sbin/ip link $1 $IFACE type vrf table $IF_VRF_TABLE
|
||||||
|
${MOCK} /sbin/ip rule $1 iif $IFACE table $IF_VRF_TABLE
|
||||||
|
${MOCK} /sbin/ip rule $1 oif $IFACE table $IF_VRF_TABLE
|
||||||
|
}
|
||||||
|
|
||||||
|
handle_member() {
|
||||||
|
${MOCK} /sbin/ip link set $IFACE master $IF_VRF_MEMBER
|
||||||
|
}
|
||||||
|
|
||||||
|
[ -n "$VERBOSE" ] && set -x
|
||||||
|
|
||||||
|
case "$PHASE" in
|
||||||
|
pre-up)
|
||||||
|
[ -n "$IF_VRF_TABLE" ] && handle_init "add"
|
||||||
|
[ -n "$IF_VRF_MEMBER" ] && handle_member
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
post-down)
|
||||||
|
[ -n "$IF_VRF_TABLE" ] && handle_init "del"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
depend)
|
||||||
|
echo "$IF_VRF_MEMBER"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
7
tests/fixtures/vrf.interfaces
vendored
Normal file
7
tests/fixtures/vrf.interfaces
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
iface vrf-red
|
||||||
|
vrf-table 1
|
||||||
|
|
||||||
|
auto eth0
|
||||||
|
iface eth0
|
||||||
|
use dhcp
|
||||||
|
vrf-member vrf-red
|
|
@ -18,7 +18,8 @@ tests_init \
|
||||||
learned_executor \
|
learned_executor \
|
||||||
inheritance_0 \
|
inheritance_0 \
|
||||||
inheritance_1 \
|
inheritance_1 \
|
||||||
implicit_vlan
|
implicit_vlan \
|
||||||
|
vrf_dependency
|
||||||
|
|
||||||
noargs_body() {
|
noargs_body() {
|
||||||
atf_check -s exit:1 -e ignore ifquery -S/dev/null
|
atf_check -s exit:1 -e ignore ifquery -S/dev/null
|
||||||
|
@ -112,3 +113,8 @@ implicit_vlan_body() {
|
||||||
-o match:"use vlan" \
|
-o match:"use vlan" \
|
||||||
ifquery -E $EXECUTORS -i $FIXTURES/vlan.interfaces eth0.8
|
ifquery -E $EXECUTORS -i $FIXTURES/vlan.interfaces eth0.8
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vrf_dependency_body() {
|
||||||
|
atf_check -s exit:0 -o match:"requires vrf-red" \
|
||||||
|
ifquery -E $EXECUTORS_LINUX -i $FIXTURES/vrf.interfaces eth0
|
||||||
|
}
|
||||||
|
|
|
@ -6,3 +6,4 @@ atf_test_program{name='link_test'}
|
||||||
atf_test_program{name='ipv6-ra_test'}
|
atf_test_program{name='ipv6-ra_test'}
|
||||||
atf_test_program{name='dhcp_test'}
|
atf_test_program{name='dhcp_test'}
|
||||||
atf_test_program{name='static_test'}
|
atf_test_program{name='static_test'}
|
||||||
|
atf_test_program{name='vrf_test'}
|
||||||
|
|
34
tests/linux/vrf_test
Executable file
34
tests/linux/vrf_test
Executable file
|
@ -0,0 +1,34 @@
|
||||||
|
#!/usr/bin/env atf-sh
|
||||||
|
|
||||||
|
. $(atf_get_srcdir)/../test_env.sh
|
||||||
|
EXECUTOR="$(atf_get_srcdir)/../../executor-scripts/linux/vrf"
|
||||||
|
|
||||||
|
tests_init \
|
||||||
|
leader_bringup \
|
||||||
|
leader_teardown \
|
||||||
|
member_bringup
|
||||||
|
|
||||||
|
leader_bringup_body() {
|
||||||
|
export MOCK=echo IFACE=vrf-red PHASE=pre-up IF_VRF_TABLE=1 IF_VRF_MEMBER=
|
||||||
|
atf_check -s exit:0 \
|
||||||
|
-o match:'ip link add vrf-red type vrf table 1' \
|
||||||
|
-o match:'ip rule add iif vrf-red table 1' \
|
||||||
|
-o match:'ip rule add oif vrf-red table 1' \
|
||||||
|
${EXECUTOR}
|
||||||
|
}
|
||||||
|
|
||||||
|
leader_teardown_body() {
|
||||||
|
export MOCK=echo IFACE=vrf-red PHASE=post-down IF_VRF_TABLE=1 IF_VRF_MEMBER=
|
||||||
|
atf_check -s exit:0 \
|
||||||
|
-o match:'ip link del vrf-red type vrf table 1' \
|
||||||
|
-o match:'ip rule del iif vrf-red table 1' \
|
||||||
|
-o match:'ip rule del oif vrf-red table 1' \
|
||||||
|
${EXECUTOR}
|
||||||
|
}
|
||||||
|
|
||||||
|
member_bringup_body() {
|
||||||
|
export MOCK=echo IFACE=eth0 PHASE=pre-up IF_VRF_MEMBER=vrf-red IF_VRF_TABLE=
|
||||||
|
atf_check -s exit:0 \
|
||||||
|
-o match:'ip link set eth0 master vrf-red' \
|
||||||
|
${EXECUTOR}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
PATH="$(atf_get_srcdir)/..:$(atf_get_srcdir)/../..:$PATH"
|
PATH="$(atf_get_srcdir)/..:$(atf_get_srcdir)/../..:$PATH"
|
||||||
FIXTURES="$(atf_get_srcdir)/fixtures"
|
FIXTURES="$(atf_get_srcdir)/fixtures"
|
||||||
EXECUTORS="$(atf_get_srcdir)/executors"
|
EXECUTORS="$(atf_get_srcdir)/executors"
|
||||||
|
EXECUTORS_LINUX="$(atf_get_srcdir)/../executor-scripts/linux"
|
||||||
|
|
||||||
tests_init() {
|
tests_init() {
|
||||||
TESTS="$@"
|
TESTS="$@"
|
||||||
|
|
Loading…
Reference in a new issue