From ba2ad348ffd8c0df29b8343a31b4baff31b4c9fc Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Tue, 18 Aug 2020 16:10:48 -0600 Subject: [PATCH] executor scripts: add vrf executor --- Makefile | 3 ++- executor-scripts/linux/vrf | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100755 executor-scripts/linux/vrf diff --git a/Makefile b/Makefile index ef9acff..3874745 100644 --- a/Makefile +++ b/Makefile @@ -80,7 +80,8 @@ EXECUTOR_SCRIPTS_CORE ?= \ link \ EXECUTOR_SCRIPTS_OPT ?= \ - bridge + bridge \ + vrf EXECUTOR_SCRIPTS ?= ${EXECUTOR_SCRIPTS_CORE} ${EXECUTOR_SCRIPTS_OPT} diff --git a/executor-scripts/linux/vrf b/executor-scripts/linux/vrf new file mode 100755 index 0000000..2696d0f --- /dev/null +++ b/executor-scripts/linux/vrf @@ -0,0 +1,25 @@ +#!/bin/sh +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 + ;; +post-down) + [ -n "$IF_VRF_TABLE" ] && handle_init "del" + ;; +*) + exit 0 + ;; +esac