tunnel executor: Add support for ip6gretap tunnels

Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
This commit is contained in:
Maximilian Wilhelm 2021-03-25 21:03:27 +01:00
parent 258d397d84
commit bec5fcefce
2 changed files with 28 additions and 7 deletions

View file

@ -23,15 +23,23 @@ esac
# and therefor require 'type' keyword instead of 'mode' # and therefor require 'type' keyword instead of 'mode'
OBJECT="tunnel" OBJECT="tunnel"
TYPE_KW="mode" TYPE_KW="mode"
if [ "${IF_TUNNEL_MODE}" = "gretap" ]; then case "${IF_TUNNEL_MODE}" in
*gretap)
OBJECT="link" OBJECT="link"
TYPE_KW="type" TYPE_KW="type"
fi
# Store tunnel type/mode separaltely and unset input variable to exclude it # Strip possible "ip6" from tunnel mode
# from PARAMS below TUNNEL_MODE="gretap"
TUNNEL_MODE="$IF_TUNNEL_MODE" ;;
unset IF_TUNNEL_MODE
*)
# Store tunnel type/mode separaltely and unset input variable to exclude it
# from PARAMS below
TUNNEL_MODE="$IF_TUNNEL_MODE"
unset IF_TUNNEL_MODE
;;
esac
# Mangle residual IF_TUNNEL_* params into single string # Mangle residual IF_TUNNEL_* params into single string
PARAMS=$(set | sed -E ' PARAMS=$(set | sed -E '

View file

@ -7,7 +7,8 @@ tests_init \
tunnel_bringup \ tunnel_bringup \
tunnel_teardown \ tunnel_teardown \
gretap_up \ gretap_up \
gretap_down gretap_down \
ip6gretap_up
tunnel_bringup_body() { tunnel_bringup_body() {
export MOCK=echo IFACE=tun0 PHASE=create IF_TUNNEL_MODE=gre \ export MOCK=echo IFACE=tun0 PHASE=create IF_TUNNEL_MODE=gre \
@ -50,3 +51,15 @@ gretap_down_body() {
-o match:"ip -4 link del foo" \ -o match:"ip -4 link del foo" \
${EXECUTOR} ${EXECUTOR}
} }
ip6gretap_up_body() {
export MOCK=echo IFACE=foo PHASE=create IF_TUNNEL_MODE=ip6gretap \
IF_TUNNEL_LOCAL=2001:db8::aaaa IF_TUNNEL_REMOTE=2001:db8::eeee
atf_check -s exit:0 \
-o match:"ip -6 link add foo" \
-o match:"type gretap" \
-o match:"local '2001:db8::aaaa'" \
-o match:"remote '2001:db8::eeee'" \
${EXECUTOR}
}