Bug #7452
closedAdding a gateway from interfaces.php does not work
100%
Description
After pressing the Add button, actually the new gateway is not created.
It uses AJAX to system_gateways_edit but the code there now expects $_POST['save'] to be set.
Files
Updated by Phillip Davis over 7 years ago
Updated by Phillip Davis over 7 years ago
- Status changed from New to Feedback
- % Done changed from 0 to 100
Applied in changeset f3278171b199062279225631903685e608285d3a.
Updated by Phillip Davis over 7 years ago
See PR https://github.com/pfsense/pfsense/pull/3697 for the same fix for adding an IPv6 gateway.
Updated by Dan Lundqvist over 7 years ago
- File IPv4_1.jpg IPv4_1.jpg added
- File IPv4_2.jpg IPv4_2.jpg added
- File IPv4_3.jpg IPv4_3.jpg added
- File IPv6_1.jpg IPv6_1.jpg added
- File IPv6_2.jpg IPv6_2.jpg added
- File IPv6_3.jpg IPv6_3.jpg added
Hello,
I have tested both IPv4 and IPv6 PR corrections running on fresh "pfSense-CE-2.4.0-BETA-amd64-20170623-1439.iso" install in Virtualbox on amd64.
I used the IP examples from https://forum.pfsense.org/index.php?topic=128489.0 with 200.225.216.153/29 and GW 200.225.216.158 for IPv4
and my own personal IPv6 through TUNNELBROKER. Both gateways was added successfully to the Routing page and was set as defaultgw.
Also verified with "netstat -rn" that they are in fact default gw in the system.
HOWEVER, I had a small issue with a crash seen after adding the IPv4, which was pushed to developers through GUI.
Have repeated it twice. I also seen with IPv6.
In my opinion, I think the PR (the ajax update) that has been supplied for IPv4 and IPv6 seems to work OK so
I think this ticket could be put to OK in that sense HOWEVER, a new #7659 has been created for the program
crash caused by defining IPv4 incl. gateway. Seems like the data in "$gateway_settings4" or "$gateway_settings6"
that is sent to function "save_gateway" in gw.inc is not equal to what it expects.
The error is as follows:
amd64 11.0-RELEASE-p10
FreeBSD 11.0-RELEASE-p10 #141 b9f3af6b8a6(RELENG_2_4): Fri Jun 23 14:46:52 CDT 2017 root@buildbot2.netgate.com:/builder/ce/tmp/obj/builder/ce/tmp/FreeBSD-src/sys/pfSense
Crash report details:
PHP Errors:
[24-Jun-2017 16:20:30 Europe/Stockholm] PHP Warning: Invalid argument supplied for foreach() in /etc/inc/gwlb.inc on line 1739
[24-Jun-2017 16:20:30 Europe/Stockholm] PHP Stack trace:
[24-Jun-2017 16:20:30 Europe/Stockholm] PHP 1. {main}() /usr/local/www/interfaces.php:0
[24-Jun-2017 16:20:30 Europe/Stockholm] PHP 2. save_gateway() /usr/local/www/interfaces.php:1473
No FreeBSD crash data found.
---
The coding in gw.inc where the error occurs.
GW.INC
PHP Warning: Invalid argument supplied for foreach() in /etc/inc/gwlb.inc on line 1739
(the foreach row)
if ($gateway_settings['defaultgw'] "yes" || $gateway_settings['defaultgw'] "on") {
$i = 0;
/* remove the default gateway bits for all gateways with the same address family */
foreach ($a_gateway_item as $gw) {
if ($gateway['ipprotocol'] == $gw['ipprotocol']) {
unset($config['gateways']['gateway_item'][$i]['defaultgw']);
if ($gw['interface'] != $gateway_settings['interface'] && $gw['defaultgw']) {
$reloadif = $gw['interface'];
}
}
$i++;
}
$gateway['defaultgw'] = true;
}
INTERFACES.PHP
PHP 2. save_gateway() /usr/local/www/interfaces.php:1473
if ($_POST['gatewayip4']) {
save_gateway($gateway_settings4);
}
The data in interfaces for "$gatewayip4" is the following in interfaces.php
if ($_POST['gatewayip4']) {
// The user wants to add an IPv4 gateway - validate the settings
$gateway_settings4 = array();
$gateway_settings4['name'] = $_POST['gatewayname4'];
$gateway_settings4['interface'] = $_POST['if'];
$gateway_settings4['gateway'] = $_POST['gatewayip4'];
$gateway_settings4['descr'] = $_POST['gatewaydescr4'];
$gateway_settings4['defaultgw'] = $_POST['defaultgw4'];
Problem (crash) seems to happen every time you save the settings for IPv4 but also on IPv6 (row 1477 in "interfaces.php").
Best regards
Dan Lundqvist
MRZAZ.COM
Updated by Dan Lundqvist over 7 years ago
As mentioned by Philip Davis in #7659 the fix for the crash has now been implemented in https://github.com/pfsense/pfsense/pull/3764
and I have now verified this working OK with 2.4.0-BETA (amd64) built on Wed Jun 28 16:02:43 CDT 2017.
As I previously wrote:
"In my opinion, I think the PR (the ajax update) that has been supplied for IPv4 and IPv6 seems to work OK so I think this ticket could be put to OK."
I think this has been fixed and this ticket can be closed unless someone else has any objections!?
Best regards
Dan Lundqvist
MRZAZ.COM
Stockholm, Sweden