From 4494f5cf24fefcf32bab12243578b1ff263a3c65 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Fri, 12 Apr 2019 11:55:43 +0200 Subject: [PATCH] Routing, gateways. in services.inc/services_dhcpdv4_configure() remove the need for return_gateways_array(), related to https://github.com/opnsense/core/issues/2279 --- src/etc/inc/services.inc | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/etc/inc/services.inc b/src/etc/inc/services.inc index 848119fc5..64653ec62 100644 --- a/src/etc/inc/services.inc +++ b/src/etc/inc/services.inc @@ -498,17 +498,6 @@ authoritative; EOD; $dhcpdifs = array(); - $add_routers = false; - $gateways_arr = return_gateways_array(); - /* only add a routers line if the system has any IPv4 gateway at all */ - /* a static route has a gateway, manually overriding this field always works */ - foreach ($gateways_arr as $gwitem) { - if ($gwitem['ipprotocol'] == "inet") { - $add_routers = true; - break; - } - } - /* loop through and determine if we need to setup * failover peer "bleh" entries */ @@ -805,15 +794,15 @@ EOPP; } // End of settings inside pools - if (!empty($dhcpifconf['gateway']) && $dhcpifconf['gateway'] != "none") { - $routers = $dhcpifconf['gateway']; - $add_routers = true; - } elseif (!empty($dhcpifconf['gateway']) && $dhcpifconf['gateway'] == "none") { - $add_routers = false; - } else { + if (!empty($dhcpifconf['gateway'])) { + $routers = $dhcpifconf['gateway'] != "none" ? $dhcpifconf['gateway'] : null; + } elseif ((new \OPNsense\Routing\Gateways(legacy_interfaces_details()))->hasGateways("inet")) { + // by default, add interface address in "option routers" $routers = $ifcfgip; + } else { + $routers = null; } - if ($add_routers) { + if (!empty($routers)) { $dhcpdconf .= " option routers {$routers};\n"; }