opnsense / core

OPNsense GUI, API and systems backend
https://opnsense.org/
BSD 2-Clause "Simplified" License
3.36k stars 753 forks source link

DHCPv6 PD advertisements are not propagated reliably to tracked interfaces #1202

Closed kevemueller closed 8 years ago

kevemueller commented 8 years ago

My provider enabled IPv6 with prefix delegation. OpnSense has everything to configure this on the gateway. The provider sends a ::/64 subnet to the gateway and if asked a different second ::/64 for a local network. The setup is straightforward (although it took me several hours to figure...): WAN/IPv4 PPPoE WAN/IPv6 DHCPv6 WAN/DHCPv6 Use IPv4 connectivity WAN/DHCPv6 Request only a IPv6 prefix

LAN/IPv4 Static LAN/IPv6 Track interface LAN/Track interface/interface WAN LAN/Track interface/ID 0

In a "Connect" scenario, the PPPoE interface comes up. The first IPv6 prefix is assigned to the WAN interface, an autoconfigured IPv6 is picked. The second IPv6 prefix is assigned to the LAN interface, and autoconfigured IPv6 is picked. RADVD is promoting the prefix on LAN, autoconfiguration happens. All shiny.

In a "Reconnect"/"Update" scenario: The provider sends new prefixes (they visibly move together) WAN interface picks up the new prefix and picks a new autoconfigured address on this prefix. The new secondary prefix is NOT propagated to the LAN interface, it retains its address from the old prefix. RADVD configuration /var/etc/radvd.conf is not rewritten with the new prefix. The LAN machines continue to use their old prefix addresses. The gateway still has IPv6, but downstream everything is broken.

Some diagnostics: Update of the GW prefix works, because this comes in as a RA and rtsold handles it. Update of the LAN prefix fails, because this comes in as a dhcp6 advertise. DHCP logs a lot, but does not reveal any address information in the log which would give a hint on what is going on.

Any help on how to continue is appreciated.

kevemueller commented 8 years ago

This one is easier. The problem is not with dhcp6c. OpnSense ends up running two instances of dhcp6c on the same interface which of course messes things.

To reproduce: Enter Interfaces/WAN configuration Click on DHCPv6/Configuration mode => Advanced. Enable Debug if it was unchecked, Disable it if it was checked. Click on DHCPv6/Configuration mode => Basic

Apply the changes.

You will end up having two dhcp6c running on the same interface.

The problem seems to be stemming from the fact that dhcp6c takes a long time to die. OpnSense does not wait for it to finish. When the new dhcp6c starts, the old dhcp6 sometimes zombifies. Causing the problem described above (prefixes not propagated).

fichtner commented 8 years ago

I've added a patch, but I can't test right now so I will ask for feedback when it's verified, thanks!

fichtner commented 8 years ago

@kevemueller could not reproduce the process race, but I've tightened the code according to your suggestion. Seems to generate the same results and should work better for you know. Give it a go via the command line:

# opnsense-patch c852405

(rerunning the patch command will revert back to the original state)

With your ok this can go into 16.7.6.

Cheers, Franco

kevemueller commented 8 years ago

Hi Franco, I have applied the patch, rebooted. IPv6 came up well. Tested the reload by flipping Debug flag. The new behaviour is

Looks like a perfect improvement to me.

Thanks for the great work! Cheers,

fichtner commented 8 years ago

@kevemueller thanks! queued up for 16.7.6 :)