From 811b576b915e468ef78411ac62975589c6e52379 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Tue, 26 Sep 2017 11:15:06 +0100 Subject: [PATCH] contrib/tripe-ipif.in: Fixing for IPv6. Accept `INET6' addresses from the server; detect IPv6 literals from the configuration file; and adjust the MTU accordingly to compensate for the different IP header lengths. --- contrib/tripe-ipif.in | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/contrib/tripe-ipif.in b/contrib/tripe-ipif.in index d0118a45..3d2aa824 100755 --- a/contrib/tripe-ipif.in +++ b/contrib/tripe-ipif.in @@ -48,7 +48,9 @@ ### field is used (a) by the accompanying `ipif-peers' script to set up the ### peer association, and (b) to determine the correct MTU to set; it ### should have the form ADDRESS[:PORT], where the PORT defaults to 4070 if -### it's not given explicitly. +### it's not given explicitly, and an IPv6 ADDRESS is enclosed in square +### brackets (because of the stupid syntax decision to use colons in IPv6 +### address literals). ### ### Having done all of that, and having configured userv-ipif correctly, ### you should set TRIPE_SLIPIF=.../tripe-ipif and everything should just @@ -108,18 +110,28 @@ case "$remote_ext" in addr=$(tripectl addr $peer) set -- $addr case $1 in - INET) remote_ext=$2 ;; + INET | INET6) remote_af=$1 remote_ext=$2 ;; *) echo >&2 "$quis: unexpected address family \`$1'"; exit 1 ;; esac ;; + \[*\]:*) + remote_af=INET6 + remote_ext=${remote_ext#\[} + remote_ext=${remote_ext%\]:*} + ;; *:*) + remote_af=INET remote_ext=${remote_ext%:*} ;; esac ## Determine the MTU based on the path. pmtu=$(pathmtu $remote_ext) -mtu=$(( $pmtu - 29 - $overhead )) +case $remote_af in + INET) iphdrsz=20 ;; + INET6) iphdrsz=40 ;; +esac +mtu=$(( $pmtu - $iphdrsz - 8 - $overhead - 1 )) ## Obtain the tunnel and run it. now=$(date +"%Y-%m-%d %H:%M:%S") -- 2.11.0