Skip to content

Commit

Permalink
interfaces: pick proper route for stf tunnels
Browse files Browse the repository at this point in the history
PR: https://forum.opnsense.org/index.php?topic=20260.0

(cherry picked from commit f4e2728)
(cherry picked from commit 866ec6d)
  • Loading branch information
fichtner committed Jan 25, 2021
1 parent fae2d57 commit 30645c7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/opnsense/mvc/app/library/OPNsense/Routing/Gateways.php
Expand Up @@ -200,6 +200,7 @@ public function getGateways()
foreach (["inet", "inet6"] as $ipproto) {
// filename suffix and interface type as defined in the interface
$descr = !empty($ifcfg['descr']) ? $ifcfg['descr'] : $ifname;
$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";
Expand All @@ -211,12 +212,12 @@ public function getGateways()
"name" => strtoupper("{$descr}_{$ctype}"),
"descr" => "Interface " . strtoupper("{$descr}_{$ctype}") . " Gateway",
"monitor_disable" => true, // disable monitoring by default
"if" => $ifcfg['if'],
"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 {
Expand All @@ -237,14 +238,14 @@ public function getGateways()
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']}_router" . $fsuffix)) {
$thisconf['gateway'] = trim(@file_get_contents("/tmp/{$ifcfg['if']}_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

Expand Down

0 comments on commit 30645c7

Please sign in to comment.