From 9cc74b58c40c27967bf145c4b217e417228ed583 Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Wed, 19 Aug 2020 02:46:04 -0600 Subject: [PATCH] interface-file: remap legacy ifupdown & ifupdown2 tunnel parameters --- executor-scripts/linux/tunnel | 30 ++++++++++++++++++++++++++++++ libifupdown/interface-file.c | 7 ++++++- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100755 executor-scripts/linux/tunnel diff --git a/executor-scripts/linux/tunnel b/executor-scripts/linux/tunnel new file mode 100755 index 0000000..07c6141 --- /dev/null +++ b/executor-scripts/linux/tunnel @@ -0,0 +1,30 @@ +#!/bin/sh + +# Based on alpine's tunnel configuration script. +# Copyright (c) 2017 Kaarle Ritvanen + +PARAMS=$(set | sed -E ' + s/^IF_TUNNEL_([A-Z0-9_]+)=(.+)/\1\n\2/ + ta + d + :a + h + y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ + P + g + s/.*\n// + ') + +[ "$PARAMS" ] || exit 0 + +case "$PHASE" in +pre-up) + eval ip tunnel add $IFACE $PARAMS + ;; +post-down) + ip tunnel del $IFACE + ;; +depend) + echo "$IF_TUNNEL_DEV" + ;; +esac diff --git a/libifupdown/interface-file.c b/libifupdown/interface-file.c index 82a3328..69a7b42 100644 --- a/libifupdown/interface-file.c +++ b/libifupdown/interface-file.c @@ -24,9 +24,14 @@ struct remap_token { const char *alternative; }; +/* this list must be in alphabetical order for bsearch */ static const struct remap_token tokens[] = { + {"endpoint", "tunnel-remote"}, /* legacy ifupdown */ + {"local", "tunnel-local"}, /* legacy ifupdown */ {"provider", "ppp-provider"}, /* legacy ifupdown, ifupdown2 */ - {"vrf", "vrf-member"}, + {"tunnel-endpoint", "tunnel-remote"}, /* ifupdown2 */ + {"tunnel-physdev", "tunnel-dev"}, /* ifupdown2 */ + {"vrf", "vrf-member"}, /* ifupdown2 */ }; static int