commit:     90f9fd0cee3284767d42d314683e22eb0613c55f
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Fri Jun  9 23:58:49 2017 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Fri Jun  9 23:58:49 2017 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=90f9fd0c

iproute2: apply ipproto=-6 cleanup.

Case statements for easier reading of ipproto='-6' choice.

Fixes: 
https://github.com/gentoo/netifrc/pull/24/files/60714158b4536d1e5694ec8a45e2cfac56202027#r98297184
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/iproute2.sh | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/net/iproute2.sh b/net/iproute2.sh
index 55c9592..d5612ab 100644
--- a/net/iproute2.sh
+++ b/net/iproute2.sh
@@ -381,10 +381,11 @@ iproute2_pre_start()
                # be passed to iproute2 during tunnel creation.
                # state 'any' does not exist for IPv4
                local ipproto=''
-               [ "${tunnel##mode ipip6}" != "${tunnel}" ] && ipproto='-6'
-               [ "${tunnel##mode ip6ip6}" != "${tunnel}" ] && ipproto='-6'
-               [ "${tunnel##mode ip6gre}" != "${tunnel}" ] && ipproto='-6'
-               [ "${tunnel##mode any}" != "${tunnel}" ] && ipproto='-6'
+               case $tunnel in
+                       *mode\ ipip6*) ipproto='-6' ;;
+                       *mode\ ip6*) ipproto='-6' ;;
+                       *mode\ any*) ipproto='-6' ;;
+               esac
 
                ebegin "Creating tunnel ${IFVAR}"
                veinfo ip ${ipproto} tunnel add ${tunnel} name "${IFACE}"
@@ -396,9 +397,11 @@ iproute2_pre_start()
        eval link=\$iplink_${IFVAR}
        if [ -n "${link}" ]; then
                local ipproto=''
-               [ "${tunnel##mode ip6gre}" != "${tunnel}" ] && ipproto='-6'
-               [ "${tunnel##mode ip6gretap}" != "${tunnel}" ] && ipproto='-6'
-               [ "${tunnel##mode ip6tnl}" != "${tunnel}" ] && ipproto='-6'
+               case $tunnel in
+                       *mode\ ipip6*) ipproto='-6' ;;
+                       *mode\ ip6*) ipproto='-6' ;;
+                       *mode\ any*) ipproto='-6' ;;
+               esac
 
                ebegin "Creating interface ${IFVAR}"
                veinfo ip ${ipproto} link add "${IFACE}" ${link}

Reply via email to