From 866ec6df7480caab476f2624d71f3d2c66258596 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Sun, 24 Jan 2021 19:43:30 +0100 Subject: [PATCH] interfaces: stf interface name comes from config, not system PR: https://forum.opnsense.org/index.php?topic=20260.0 --- .../mvc/app/library/OPNsense/Routing/Gateways.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/opnsense/mvc/app/library/OPNsense/Routing/Gateways.php b/src/opnsense/mvc/app/library/OPNsense/Routing/Gateways.php index d17bc382c..62510f861 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Routing/Gateways.php +++ b/src/opnsense/mvc/app/library/OPNsense/Routing/Gateways.php @@ -200,7 +200,7 @@ class Gateways foreach (["inet", "inet6"] as $ipproto) { // filename suffix and interface type as defined in the interface $descr = !empty($ifcfg['descr']) ? $ifcfg['descr'] : $ifname; - $isuffix = $ipproto == 'inet6' && in_array($ifcfg['ipaddrv6'], ['6to4', '6rd']) ? '_stf' : ''; + $realif = $ipproto == 'inet6' && in_array($ifcfg['ipaddrv6'], ['6to4', '6rd']) ? "{$ifname}_stf" : $ifcfg['if']; $fsuffix = $ipproto == "inet6" ? "v6" : ""; $ctype = self::convertType($ipproto, $ifcfg); $ctype = $ctype != null ? $ctype : "GW"; @@ -212,12 +212,12 @@ class Gateways "name" => strtoupper("{$descr}_{$ctype}"), "descr" => "Interface " . strtoupper("{$descr}_{$ctype}") . " Gateway", "monitor_disable" => true, // disable monitoring by default - "if" => "{$ifcfg['if']}{$isuffix}", + "if" => $realif, "dynamic" => true, "virtual" => true ]; // set default priority - if (strstr($ifcfg['if'], 'gre') || strstr($ifcfg['if'], 'gif') || strstr($ifcfg['if'], 'ovpn')) { + if (strstr($realif, 'gre') || strstr($realif, 'gif') || strstr($realif, 'ovpn')) { // consider tunnel type interfaces least attractive by default $thisconf['priority'] = 255; } else { @@ -238,14 +238,14 @@ class Gateways if (!empty($thisconf['virtual']) && in_array($thisconf['name'], $reservednames)) { // if name is already taken, don't try to add a new (virtual) entry null; - } elseif (file_exists("/tmp/{$ifcfg['if']}{$isuffix}_router{$fsuffix}")) { - $thisconf['gateway'] = trim(@file_get_contents("/tmp/{$ifcfg['if']}{$isuffix}_router{$fsuffix}")); + } elseif (file_exists("/tmp/{$realif}_router{$fsuffix}")) { + $thisconf['gateway'] = trim(@file_get_contents("/tmp/{$realif}_router{$fsuffix}")); if (empty($thisconf['monitor_disable']) && empty($thisconf['monitor'])) { $thisconf['monitor'] = $thisconf['gateway']; } $gwkey = $this->newKey($thisconf['priority'], !empty($thisconf['defaultgw'])); $this->cached_gateways[$gwkey] = $thisconf; - } elseif (!empty($ifcfg['gateway_interface']) || substr($ifcfg['if'], 0, 5) == "ovpnc") { + } elseif (!empty($ifcfg['gateway_interface']) || substr($realif, 0, 5) == 'ovpnc') { // XXX: ditch ovpnc in a major upgrade in the future, supersede with interface setting // gateway_interface