Project

General

Profile

Actions

Bug #5747

closed

interfaces.php - Hitting apply on interface messes DHCPv6 config

Added by Greg M over 8 years ago. Updated over 8 years ago.

Status:
Resolved
Priority:
High
Assignee:
-
Category:
DHCP (IPv6)
Target version:
-
Start date:
01/08/2016
Due date:
% Done:

0%

Estimated time:
Plus Target Version:
Release Notes:
Affected Version:
2.3
Affected Architecture:
All

Description

See screenshots.

When you edit iface to use DHCPv6 IPv6 with all those preferences selected, and when you press save below config is generated:

interface pppoe0 {
send ia-pd 0; # request prefix delegation
request domain-name-servers;
request domain-name;
script "/var/etc/dhcp6c_opt2_script.sh"; # we'd like some nameservers please
};
id-assoc pd 0 {
};

After you click APPLY on pppoe interface above conf dissapears (from /var/etc) and few seconds later newly generated config appears (below one).

interface pppoe0 {
request domain-name-servers;
request domain-name;
script "/var/etc/dhcp6c_opt2_script.sh"; # we'd like some nameservers please
};

So GUI generates good config but apply button messes it up completley.

Workaround is to create own confing file, and use it in "Configuration File Override" in "DHCP6 client configuration" section of the interface.


Files

snip1.JPG (119 KB) snip1.JPG Greg M, 01/08/2016 11:25 AM
snip2.JPG (111 KB) snip2.JPG Greg M, 01/08/2016 11:25 AM
snip3.JPG (158 KB) snip3.JPG Greg M, 01/08/2016 11:25 AM
Actions #1

Updated by Anonymous over 8 years ago

  • Subject changed from Hitting apply on interface messes DHCPv6 config to interfaces.php - Hitting apply on interface messes DHCPv6 config
  • Status changed from New to Assigned
  • Assignee set to Anonymous
Actions #2

Updated by Anonymous over 8 years ago

  • Status changed from Assigned to Feedback
  • Assignee changed from Anonymous to Greg M

Greg,

I am having no luck reproducing this. Perhaps you could give me some more guidance?

On real hardware I select Interfaces->lan4 (which happens to be an unused port on my box) IPv4 is set for static IP, but IPv6 is set up exactly like your screenshots. DHCP6 etc.

I click "Save" and inspect /var/etc/dhcp6c_lan4.conf and it looks good.
I click "Apply" and still the config file looks correct.

I don't see anything in the code that would cause it to change either.

Actions #3

Updated by Jim Pingle over 8 years ago

I also tried and failed to replicate it. Though when I press Save, nothing is written out. It only writes when I click Apply, and when it writes, it's correct.

I don't have an actual PPPoE+IPv6 WAN to test with, however. I've been testing with an identical config with the NIC unplugged (and plugged into a dummy network), even tried unplugging/replugging to see if it behaved differently and it never did. The extra settings are always there.

Actions #4

Updated by Greg M over 8 years ago

I`ve just tested it.
For me it creates "/var/etc/dhcp6c_opt2.conf" with the following content:

interface pppoe0 {
request domain-name-servers;
request domain-name;
script "/var/etc/dhcp6c_opt2_script.sh"; # we'd like some nameservers please
};

??
Where to look next?

Actions #5

Updated by Anonymous over 8 years ago

What type of system are you running on? Hardware? VMWare ???

Actions #6

Updated by Greg M over 8 years ago

Hardware.
I did upgrade from 2.2.6 via webgui with latest image.

Actions #7

Updated by Greg M over 8 years ago

Hmmm.
If I specify my own config file then /var/etc/dhcp6c_opt2.conf looks like:

interface pppoe0 {
send ia-pd 0; # request prefix delegation
request domain-name-servers;
request domain-name;
script "/var/etc/dhcp6c_opt2_script.sh"; # we'd like some nameservers please
};
id-assoc pd 0 {
};

Which is OK...
Like something is preventing it to write correct params to conf file..

Actions #8

Updated by Anonymous over 8 years ago

OK. Going to be a tough one to find until we can reproduce it.

Would you be comfortable editing the interfaces.php file using diag->edit file?

If so, we might try commenting stuff out to at least detect where the file is being changed. It is a pretty short piece of code.

Actions #9

Updated by Greg M over 8 years ago

Yeah sure :)

Actions #10

Updated by David Wood over 8 years ago

Looking at the definition of DHCP6_Config_File_Advanced() in /etc/inc/interfaces.inc, it's difficult to understand how the original poster's problem is occurring.

It might help to have the relevant entry from the <interfaces> section of the configuration file in both the 'broken' and 'working' states.

Actions #11

Updated by Anonymous over 8 years ago

OK. Then in this code:

if ($_POST['apply']) {
    unset($input_errors);
    if (!is_subsystem_dirty('interfaces')) {
        $input_errors[] = gettext("You have already applied your settings!");
    } else {
        unlink_if_exists("{$g['tmp_path']}/config.cache");
        clear_subsystem_dirty('interfaces');

        if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
            $toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
            foreach ($toapplylist as $ifapply => $ifcfgo) {
                if (isset($config['interfaces'][$ifapply]['enable'])) {
                    interface_bring_down($ifapply, false, $ifcfgo);
                    interface_configure($ifapply, true);
                } else {
                    interface_bring_down($ifapply, true, $ifcfgo);
                    if (isset($config['dhcpd'][$ifapply]['enable']) ||
                        isset($config['dhcpdv6'][$ifapply]['enable'])) {
                        services_dhcpd_configure();
                    }
                }
            }
        }
        /* restart snmp so that it binds to correct address */
XXXX
        services_snmpd_configure();

        /* sync filter configuration */
        setup_gateways_monitor();

        clear_subsystem_dirty('interfaces');

        filter_configure();

        enable_rrd_graphing();

        if (is_subsystem_dirty('staticroutes') && (system_routing_configure() == 0)) {
            clear_subsystem_dirty('staticroutes');
        }
YYYY
    }
    @unlink("{$g['tmp_path']}/.interfaces.apply");
    header("Location: interfaces.php?if={$if}");
    exit;
}

I would start by commenting out everything from my "XXXX" to my "YYYY".

If the file is still broken on "Apply", I would comment out the 13th line down as listed here. "interface_configure($ifapply, true);"

Let's see what that tells us.

Actions #12

Updated by Greg M over 8 years ago

Did it like this:
if ($_POST['apply']) {
unset($input_errors);
if (!is_subsystem_dirty('interfaces')) {
$input_errors[] = gettext("You have already applied your settings!");
} else {
unlink_if_exists("{$g['tmp_path']}/config.cache");
clear_subsystem_dirty('interfaces');

if (file_exists("{$g['tmp_path']}/.interfaces.apply")) {
$toapplylist = unserialize(file_get_contents("{$g['tmp_path']}/.interfaces.apply"));
foreach ($toapplylist as $ifapply => $ifcfgo) {
if (isset($config['interfaces'][$ifapply]['enable'])) {
interface_bring_down($ifapply, false, $ifcfgo);
/* interface_configure($ifapply, true); */
} else {
interface_bring_down($ifapply, true, $ifcfgo);
if (isset($config['dhcpd'][$ifapply]['enable']) ||
isset($config['dhcpdv6'][$ifapply]['enable'])) {
services_dhcpd_configure();
}
}
}
}
/* restart snmp so that it binds to correct address 
services_snmpd_configure();
/* sync filter configuration
setup_gateways_monitor();
clear_subsystem_dirty('interfaces');
filter_configure();
enable_rrd_graphing();
if (is_subsystem_dirty('staticroutes') && (system_routing_configure() == 0)) {
clear_subsystem_dirty('staticroutes');
}*/
}
@unlink("{$g['tmp_path']}/.interfaces.apply");
header("Location: interfaces.php?if={$if}");
exit;

Commenting from XXXX to YYYY no change.
Commenting 13th line AND XXXX to YYYY resulted in no conf being created.
Commenting only 13th line and NOT XXXX to YYYY resulted in no conf being created.

Actions #13

Updated by David Wood over 8 years ago

Steve B - I'm fairly certain that it's the call to interface_configure() that will set in motion the generation of the dhcp6c configuration file, as interface_configure() calls interface_dhcpv6_configure().

The work I've been doing on IPv6 issues (see Issue 1 in https://forum.pfsense.org/index.php?topic=101967.msg584693#msg584693 ) that Greg has been helping test might result in the call to interface_dhcpv6_configure() being deferred on PPPoE interfaces with "Use IPv4 connectivity as parent interface" set (as is normal) until IPv6CP is up, but it's still a call to interface_dhcpv6_configure() that will result in generation of the configuration file for dhcp6c.

I'm wondering if there's some sort of issue with the interface entry on Greg's installation, which is why I suggested sight of that part of the configuration file might help.

Greg - an even easier way to display this information is to use Diagnostics -> Command Prompt to execute the PHP command:
print_r($config['interfaces']);

Actions #14

Updated by Anonymous over 8 years ago

Wow.

That would imply that this 'apply' code block is being executed on save, not just on apply. That is REALLY hard to understand.

Thanks for testing that.

Lets revert the file to its original state, and then comment out just the 18th line: services_dhcpd_configure();

Actions #15

Updated by Greg M over 8 years ago

NOT WORKING

<opt2>
<descr><![CDATA[PPPoE]]></descr>
<if>pppoe0</if>
<spoofmac/>
<enable/>
<ipaddr>pppoe</ipaddr>
<ipaddrv6>dhcp6</ipaddrv6>
<dhcp6-duid></dhcp6-duid>
<dhcp6-ia-pd-len>0</dhcp6-ia-pd-len>
<dhcp6prefixonly/>
<dhcp6usev4iface/>
<adv_dhcp6_interface_statement_send_options>ia-pd 0</adv_dhcp6_interface_statement_send_options>
<adv_dhcp6_interface_statement_request_options>domain-name-servers,domain-name</adv_dhcp6_interface_statement_request_options>
<adv_dhcp6_id_assoc_statement_prefix_enable>yes</adv_dhcp6_id_assoc_statement_prefix_enable>
<adv_dhcp6_id_assoc_statement_prefix_id>0</adv_dhcp6_id_assoc_statement_prefix_id>
<adv_dhcp6_config_file_override_path>/var/etc/dhcp6c_working.conf</adv_dhcp6_config_file_override_path>
</opt2>

WORKING

<opt2>
<descr><![CDATA[PPPoE]]></descr>
<if>pppoe0</if>
<spoofmac/>
<enable/>
<ipaddr>pppoe</ipaddr>
<ipaddrv6>dhcp6</ipaddrv6>
<dhcp6-duid></dhcp6-duid>
<dhcp6-ia-pd-len>0</dhcp6-ia-pd-len>
<dhcp6prefixonly/>
<dhcp6usev4iface/>
<adv_dhcp6_interface_statement_send_options>ia-pd 0</adv_dhcp6_interface_statement_send_options>
<adv_dhcp6_interface_statement_request_options>domain-name-servers,domain-name</adv_dhcp6_interface_statement_request_options>
<adv_dhcp6_id_assoc_statement_prefix_enable>yes</adv_dhcp6_id_assoc_statement_prefix_enable>
<adv_dhcp6_id_assoc_statement_prefix_id>0</adv_dhcp6_id_assoc_statement_prefix_id>
<adv_dhcp6_config_file_override>yes</adv_dhcp6_config_file_override>
<adv_dhcp6_config_file_override_path>/var/etc/dhcp6c_working.conf</adv_dhcp6_config_file_override_path>

Actions #16

Updated by Anonymous over 8 years ago

Thanks David. Yes, it would be interesting to see that config

Actions #17

Updated by Greg M over 8 years ago

Commenting ONLY line 18 results in same non working conf file being generated.

Actions #18

Updated by Greg M over 8 years ago

Posted iface config as well.
I guess you only need opt2 which is my PPPoE.

Actions #19

Updated by Anonymous over 8 years ago

Hmm. Wonder why adv_dhcp6_config_file_override is being set?

Should move back to the forum https://forum.pfsense.org/index.php?topic=105026.0 perhaps? Creating a lot of Redmine noise here.

Actions #20

Updated by Anonymous over 8 years ago

  • Status changed from Feedback to Resolved
  • Assignee deleted (Greg M)
Actions #21

Updated by Anonymous over 8 years ago

I shot-gunned this to save time, but I believe the critical fix was that unlike on other pages where the "Show advanced" button just un-hides a display section, on this page its state is saved to the config file and is used elsewhere in the system. That was not happening correctly.

Actions

Also available in: Atom PDF