From: Roger Pueyo Centelles Date: Wed, 2 Nov 2016 12:18:01 +0000 (+0100) Subject: gre: add different per-protocol prefixes to GRE-TAP IPv4/6 tunnel interfaces. X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c6d3a62919a7f993be625391d8593c84423aa021;p=librecmc%2Flibrecmc.git gre: add different per-protocol prefixes to GRE-TAP IPv4/6 tunnel interfaces. This commit modifies the /lib/netifd/proto/gre.sh script so that, when GRE-TAP tunnels are created, either IPv4 or IPv6, the prefix before the chosen interface name contains the "tap" substring, to differentiate them from non-TAP GRE tunnels. Right now, both GRE and GRE-TAP tunnel (either IPv4 or IPv6) interfaces defined in /etc/config/network are named equally ("gre-"+$ifname or "grev6"+$ifname) upon creation. For instance, the following tunnels: config interface 'tuna' option peeraddr '172.30.22.1' option proto 'gre' config interface 'tunb' option peeraddr '192.168.233.4' option proto 'gretap' config interface 'tunc' option peer6addr 'fdc5:7c9e:e93d:45af::1' option proto 'grev6' config interface 'tund' option peer6addr 'fdc0:6071:1348:31ff::2' option proto 'grev6tap' are named, respectively, "gre-tuna", "gre-tunb", "grev6-tunc" and "grev6-tund". The current change makes that each GRE tunnel interface of the four different types available (gre, gretap, grev6 and grev6tap) gets a different prefix. Therefore, the abovementioned tunnels will be named, respectively: "gre4-tuna", "gre4t-tunb", "gre6-tunc" and "gre6t-tund". This is coherent with other types of virtual interfaces (i.e. PPP, PPPoE, PPPoA) where the whole protocol name is used. For instance, a PPPoA interface named "p1" and a PPPoE interface named "p2" will respectively appear as "pppoa-p1" and "pppoe-p2", not as "ppp-p1" and "ppp-p2"). Since Linux interfaces names are limited to 15 characters, these prefixes leave, for the worst case (TAP tunnels), 9 characters for the actual name. Signed-off-by: Roger Pueyo Centelles --- diff --git a/package/network/config/gre/Makefile b/package/network/config/gre/Makefile index a6b4cac559..90f92d4da7 100644 --- a/package/network/config/gre/Makefile +++ b/package/network/config/gre/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=gre PKG_VERSION:=1 -PKG_RELEASE:=5 +PKG_RELEASE:=6 PKG_LICENSE:=GPL-2.0 include $(INCLUDE_DIR)/package.mk diff --git a/package/network/config/gre/files/gre.sh b/package/network/config/gre/files/gre.sh index 58db1d1381..cd327ea2da 100755 --- a/package/network/config/gre/files/gre.sh +++ b/package/network/config/gre/files/gre.sh @@ -84,7 +84,14 @@ gre_setup() { [ -z "$df" ] && df="1" - gre_generic_setup $cfg $mode $ipaddr $peeraddr "gre-$cfg" + case "$mode" in + gretapip) + gre_generic_setup $cfg $mode $ipaddr $peeraddr "gre4t-$cfg" + ;; + *) + gre_generic_setup $cfg $mode $ipaddr $peeraddr "gre4-$cfg" + ;; + esac } proto_gre_setup() { @@ -102,7 +109,7 @@ proto_gretap_setup() { gre_setup $cfg "gretapip" json_init - json_add_string name "gre-$cfg" + json_add_string name "gre4t-$cfg" json_add_boolean link-ext 0 json_close_object @@ -155,7 +162,14 @@ grev6_setup() { fi } - gre_generic_setup $cfg $mode $ip6addr $peer6addr "grev6-$cfg" + case "$mode" in + gretapip6) + gre_generic_setup $cfg $mode $ip6addr $peer6addr "gre6t-$cfg" + ;; + *) + gre_generic_setup $cfg $mode $ip6addr $peer6addr "gre6-$cfg" + ;; + esac } proto_grev6_setup() { @@ -173,7 +187,7 @@ proto_grev6tap_setup() { grev6_setup $cfg "gretapip6" json_init - json_add_string name "grev6-$cfg" + json_add_string name "gre6t-$cfg" json_add_boolean link-ext 0 json_close_object @@ -203,7 +217,7 @@ proto_gre_teardown() { proto_gretap_teardown() { local cfg="$1" - gretap_generic_teardown "gre-$cfg" + gretap_generic_teardown "gre4t-$cfg" } proto_grev6_teardown() { @@ -213,7 +227,7 @@ proto_grev6_teardown() { proto_grev6tap_teardown() { local cfg="$1" - gretap_generic_teardown "grev6-$cfg" + gretap_generic_teardown "gre6t-$cfg" } gre_generic_init_config() {