From 39f8a1b6b1cca4bba048b60a2c4187a2aa2f8810 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Fri, 11 Nov 2022 15:54:43 +0200 Subject: [PATCH] system: simplify slightly #5989 In theory we should be able to move the host routes for 6rd and 6to4 easily without repercussion, unless some part of the system tries to reload the interface without calling system_routing_configure(). --- src/etc/inc/interfaces.inc | 12 ++++-------- src/etc/inc/system.inc | 8 +++----- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index 95814741b..a4d96a85a 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -2575,10 +2575,8 @@ function interface_6rd_configure($interface, $wancfg, $update = false) mwexecf('/usr/local/sbin/ifctl -i %s -6rd -a %s', [$stfiface, $rd6brgw]); $gateways = new \OPNsense\Routing\Gateways(legacy_interfaces_details()); - $ip4gateway = $gateways->getInterfaceGateway($interface, "inet"); - if (is_ipaddrv4($ip4gateway)) { - system_host_route($wancfg['gateway-6rd'], $ip4gateway); - } + $ip4gateway = $gateways->getInterfaceGateway($interface, 'inet'); + system_host_route($wancfg['gateway-6rd'], $ip4gateway); link_interface_to_track6($interface, $update); } @@ -2663,10 +2661,8 @@ function interface_6to4_configure($interface, $wancfg, $update = false) mwexecf('/usr/local/sbin/ifctl -i %s -6rd -a %s', [$stfiface, $stfbrgw]); $gateways = new \OPNsense\Routing\Gateways(legacy_interfaces_details()); - $ip4gateway = $gateways->getInterfaceGateway($interface, "inet"); - if (is_ipaddrv4($ip4gateway)) { - system_host_route('192.88.99.1', $ip4gateway); - } + $ip4gateway = $gateways->getInterfaceGateway($interface, 'inet'); + system_host_route('192.88.99.1', $ip4gateway); link_interface_to_track6($interface, $update); } diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc index 7eb5bd704..0893495cd 100644 --- a/src/etc/inc/system.inc +++ b/src/etc/inc/system.inc @@ -498,7 +498,7 @@ function system_hostname_configure($verbose = false) service_log("{$hostname}\n", $verbose); } -function system_host_route($host, $gateway, $delete = true, $add = true) +function system_host_route($host, $gateway) { if (is_ipaddrv4($gateway)) { $family = 'inet'; @@ -508,11 +508,9 @@ function system_host_route($host, $gateway, $delete = true, $add = true) return; } - if ($delete) { - mwexecf('/sbin/route delete -host -%s %s', [$family, $host], true); - } + mwexecf('/sbin/route delete -host -%s %s', [$family, $host], true); - if ($add && $host != $gateway) { + if ($host != $gateway) { mwexecf('/sbin/route add -host -%s %s %s', [$family, $host, $gateway]); } }