From e6d53a4f8e53d5c4ea30d9afccbc9c5e843b5f16 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Thu, 11 Aug 2022 14:26:35 +0200 Subject: [PATCH] interfaces: employ gre trick here for gif as well Also try to pin 128 bit net to use that immediately as the configuration is already correct. --- src/etc/inc/interfaces.inc | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index ee2ae6cbe..80cc8da83 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -591,7 +591,7 @@ function _interfaces_gre_configure($gre) } if (is_ipaddrv6($gre['tunnel-local-addr']) || is_ipaddrv6($gre['tunnel-remote-addr'])) { /* check if destination is local to source and if not we need the traditional point-to-point setup */ - if (ip_in_subnet($gre['tunnel-remote-addr'], "{$gre['tunnel-local-addr']}/{$gre['tunnel-remote-net']}")) { + if ($gre['tunnel-remote-net'] != '128' && ip_in_subnet($gre['tunnel-remote-addr'], "{$gre['tunnel-local-addr']}/{$gre['tunnel-remote-net']}")) { mwexecf('/sbin/ifconfig %s inet6 %s prefixlen %s', [ $gre['greif'], $gre['tunnel-local-addr'], @@ -680,12 +680,20 @@ function _interfaces_gif_configure($gif) mwexecf('/sbin/ifconfig %s tunnel %s %s', array($gif['gifif'], $realifip, $gif['remote-addr'])); } if (is_ipaddrv6($gif['tunnel-local-addr']) || is_ipaddrv6($gif['tunnel-remote-addr'])) { - mwexecf('/sbin/ifconfig %s inet6 %s %s prefixlen %s', [ - $gif['gifif'], - $gif['tunnel-local-addr'], - $gif['tunnel-remote-addr'], - '128', - ]); + /* check if destination is local to source and if not we need the traditional point-to-point setup */ + if ($gif['tunnel-remote-net'] != '128' && ip_in_subnet($gif['tunnel-remote-addr'], "{$gif['tunnel-local-addr']}/{$gif['tunnel-remote-net']}")) { + mwexecf('/sbin/ifconfig %s inet6 %s prefixlen %s', [ + $gif['gifif'], + $gif['tunnel-local-addr'], + $gif['tunnel-remote-net'], + ]); + } else { + mwexecf('/sbin/ifconfig %s inet6 %s %s prefixlen 128', [ + $gif['gifif'], + $gif['tunnel-local-addr'], + $gif['tunnel-remote-addr'], + ]); + } } else { mwexecf('/sbin/ifconfig %s inet6 ifdisabled', [$gif['gifif']]); mwexecf('/sbin/ifconfig %s %s %s netmask %s', [