From c4e8018fc99b9407dfbfe43473543446f3f8ddd8 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Thu, 18 Mar 2021 20:20:37 +0100 Subject: [PATCH] Services / DHCPv4 - static entries: add "none" option to gateway setting. Although I really don't like how "none" is a valid option, it will be more consistent with the overal experience. closes https://github.com/opnsense/core/issues/4843 --- src/etc/inc/plugins.inc.d/dhcpd.inc | 2 +- src/www/services_dhcp_edit.php | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/etc/inc/plugins.inc.d/dhcpd.inc b/src/etc/inc/plugins.inc.d/dhcpd.inc index 57485f6e2..abc5ab737 100644 --- a/src/etc/inc/plugins.inc.d/dhcpd.inc +++ b/src/etc/inc/plugins.inc.d/dhcpd.inc @@ -1107,7 +1107,7 @@ EOD; $dhcpdconf .= " option root-path \"{$sm['rootpath']}\";\n"; } - if (!empty($sm['gateway']) && ($sm['gateway'] != $dhcpifconf['gateway'])) { + if (!empty($sm['gateway']) && $sm['gateway'] != "none" && ($sm['gateway'] != $dhcpifconf['gateway'])) { $dhcpdconf .= " option routers {$sm['gateway']};\n"; } diff --git a/src/www/services_dhcp_edit.php b/src/www/services_dhcp_edit.php index d4a7a2228..63df46fd7 100644 --- a/src/www/services_dhcp_edit.php +++ b/src/www/services_dhcp_edit.php @@ -164,7 +164,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { } } - if (!empty($pconfig['gateway']) && !is_ipaddrv4($pconfig['gateway'])) { + if (!empty($pconfig['gateway']) && $pconfig['gateway'] != "none" && !is_ipaddrv4($pconfig['gateway'])) { $input_errors[] = gettext("A valid IP address must be specified for the gateway."); } @@ -173,7 +173,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $input_errors[] = gettext("A valid IP address must be specified for the primary/secondary WINS servers."); } - if (is_subnetv4($parent_net) && !empty($pconfig['gateway'])) { + if (is_subnetv4($parent_net) && $pconfig['gateway'] != "none" && !empty($pconfig['gateway'])) { if (!ip_in_subnet($pconfig['gateway'], $parent_net) && !ip_in_interface_alias_subnet($if, $pconfig['gateway'])) { $input_errors[] = sprintf(gettext("The gateway address %s does not lie within the chosen interface's subnet."), $_POST['gateway']); } @@ -420,7 +420,9 @@ include("head.inc");