Project

General

Profile

Actions

Bug #7452

closed
PD PD

Adding a gateway from interfaces.php does not work

Bug #7452: Adding a gateway from interfaces.php does not work

Added by Phillip Davis over 9 years ago. Updated about 9 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
Gateways
Target version:
Start date:
04/06/2017
Due date:
% Done:

100%

Estimated time:
Plus Target Version:
Release Notes:
Affected Version:
2.4
Affected Architecture:

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.

Forum: https://forum.pfsense.org/index.php?topic=128489.0


Files

IPv4_1.jpg (149 KB) IPv4_1.jpg Define WAN IPv4 + GW page 1 Dan Lundqvist, 06/24/2017 10:25 AM
IPv4_2.jpg (187 KB) IPv4_2.jpg Define WAN IPv4 + GW page 2 Dan Lundqvist, 06/24/2017 10:25 AM
IPv4_3.jpg (56.9 KB) IPv4_3.jpg Define WAN IPv4 + GW page 3 - configured and saved. Dan Lundqvist, 06/24/2017 10:26 AM
IPv6_1.jpg (147 KB) IPv6_1.jpg Define WAN IIPv6 P + GW page 1 Dan Lundqvist, 06/24/2017 10:26 AM
IPv6_2.jpg (186 KB) IPv6_2.jpg Define WAN IIPv6 P + GW page 2 Dan Lundqvist, 06/24/2017 10:26 AM
IPv6_3.jpg (63.5 KB) IPv6_3.jpg Define WAN IIPv6 P + GW page 1 - configured and saved. Dan Lundqvist, 06/24/2017 10:26 AM

PD Updated by Phillip Davis over 9 years ago Actions #2

  • Status changed from New to Feedback
  • % Done changed from 0 to 100

Applied in changeset commit:f3278171b199062279225631903685e608285d3a.

PD Updated by Phillip Davis over 9 years ago Actions #3

See PR https://github.com/pfsense/pfsense/pull/3697 for the same fix for adding an IPv6 gateway.

DL Updated by Dan Lundqvist about 9 years ago Actions #4

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 :/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

DL Updated by Dan Lundqvist about 9 years ago Actions #5

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

JP Updated by Jim Pingle about 9 years ago Actions #6

  • Status changed from Feedback to Resolved
Actions

Also available in: Atom