Fix state kill ordering in rc.newwanip. Fixes #4674

Move state kill to after new rules and routing have been setup.
Otherwise there is a race condition where new states could be created
before the new rules and routing are in place.
This commit is contained in:
jim-p 2019-08-26 15:24:34 -04:00
parent 0bdd1774a1
commit 86e6e0bcff

View File

@ -205,18 +205,6 @@ if (platform_booting() && !in_array(substr($interface_real, 0, 3), array("ppp",
* could be failing back in which case we need to switch IPs back anyhow.
*/
if (!is_ipaddr($oldip) || $curwanip != $oldip || !is_ipaddrv4($config['interfaces'][$interface]['ipaddr'])) {
/* IP changed, kill states accordingly */
if ($curwanip != $oldip) {
if (isset($config['system']['ip_change_kill_states'])) {
log_error("IP Address has changed, killing all states (ip_change_kill_states is set).");
pfSense_kill_states($oldip);
filter_flush_state_table();
} else {
log_error("IP Address has changed, killing states on former IP Address $oldip.");
pfSense_kill_states($oldip);
}
}
/*
* Some services (e.g. dyndns, see ticket #4066) depend on
* filter_configure() to be called before, otherwise pass out
@ -232,6 +220,18 @@ if (!is_ipaddr($oldip) || $curwanip != $oldip || !is_ipaddrv4($config['interface
/* reconfigure static routes (kernel may have deleted them) */
system_routing_configure($interface);
/* If the IP address changed, kill old states after rules and routing have been updated */
if ($curwanip != $oldip) {
if (isset($config['system']['ip_change_kill_states'])) {
log_error("IP Address has changed, killing all states (ip_change_kill_states is set).");
pfSense_kill_states($oldip);
filter_flush_state_table();
} else {
log_error("IP Address has changed, killing states on former IP Address $oldip.");
pfSense_kill_states($oldip);
}
}
/* reload unbound */
services_unbound_configure();