summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/inc/interfaces.inc3
-rwxr-xr-xsbin/dhclient-script30
2 files changed, 17 insertions, 16 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc
index f5aee01..6be3e27 100644
--- a/etc/inc/interfaces.inc
+++ b/etc/inc/interfaces.inc
@@ -1314,12 +1314,13 @@ function interface_bring_down($interface = "wan", $destroy = false, $ifacecfg =
services_dhcpd_configure('inet6', $track6);
}
+ $old_router = '';
if (file_exists("{$g['tmp_path']}/{$realif}_router"))
$old_router = trim(file_get_contents("{$g['tmp_path']}/{$realif}_router"));
// log_error("Checking for old router states: {$g['tmp_path']}/{$realif}_router = {$old_router}");
if (!empty($old_router)) {
log_error("Clearing states to old gateway {$old_router}.");
- mwexec("/sbin/pfctl -i " . escapeshellarg($realif) . " -Fs -G {$old_router}");
+ mwexec("/sbin/pfctl -i " . escapeshellarg($realif) . " -Fs");
}
/* remove interface up file if it exists */
diff --git a/sbin/dhclient-script b/sbin/dhclient-script
index 8421bfd..0f393a7 100755
--- a/sbin/dhclient-script
+++ b/sbin/dhclient-script
@@ -27,13 +27,14 @@ ROUTE=/sbin/route
SED=/usr/bin/sed
ARP=/usr/sbin/arp
IFCONFIG=/sbin/ifconfig
+PFCTL=/sbin/pfctl
LOCALHOST=127.0.0.1
if [ -x /usr/bin/logger ]; then
LOGGER="/usr/bin/logger -s -p user.notice -t dhclient"
else
- LOGGER=echo
+ LOGGER="echo"
fi
#
@@ -42,11 +43,8 @@ fi
check_hostname() {
current_hostname=`$HOSTNAME`
- if [ -z "$current_hostname" ]; then
- $LOGGER "New Hostname ($interface): $new_host_name"
- $HOSTNAME $new_host_name
- elif [ "$current_hostname" = "$old_host_name" -a \
- "$new_host_name" != "$old_host_name" ]; then
+ if [ -z "$current_hostname" -o \
+ "$current_hostname" != "$new_host_name" ]; then
$LOGGER "New Hostname ($interface): $new_host_name"
$HOSTNAME $new_host_name
fi
@@ -60,28 +58,30 @@ arp_flush() {
delete_old_states() {
$LOGGER "Starting delete_old_states()"
+ _FLUSHED=0
# If the IP changed, remove states from the old one
if [ -f /var/db/${interface}_ip ]; then
- OLD_IP = `cat /var/db/${interface}_ip`
+ OLD_IP=`cat /var/db/${interface}_ip`
$LOGGER "Comparing IPs: Old: ${OLD_IP} New: ${new_ip_address}"
if [ -n "${OLD_IP}" ] && [ "${OLD_IP}" != "${new_ip_address}" ]; then
$LOGGER "Removing states from old IP '${OLD_IP}' (new IP '${new_ip_address}')"
- /sbin/pfctl -i $interface -Fs
- pfctl -K ${OLD_IP}/32
+ ${PFCTL} -i $interface -Fs
+ ${PFCTL} -K ${OLD_IP}/32
+ _FLUSHED=1
fi
fi
# Delete states through old gateway if it's not the same
+ OLD_ROUTER=""
if [ -n "${old_routers}" ]; then
- OLD_ROUTER = $old_routers
- fi
- if [ -z "${OLD_ROUTER}" ] && [ -f /tmp/${interface}_router ]; then
- OLD_ROUTER = `cat /tmp/${interface}_router`
+ OLD_ROUTER=$old_routers
+ elif [ -f /tmp/${interface}_router ]; then
+ OLD_ROUTER=`cat /tmp/${interface}_router`
fi
- if [ -n "${OLD_ROUTER}" ]; then
+ if [ ${_FLUSHED} -eq 0 -a -n "${OLD_ROUTER}" ]; then
$LOGGER "Comparing Routers: Old: ${OLD_ROUTER} New: ${new_routers}"
if [ "${OLD_ROUTER}" != "${new_routers}" ]; then
$LOGGER "Removing states through old gateway '${OLD_ROUTER}' (new gateway '${new_routers}')"
- /sbin/pfctl -i $interface -Fs -G ${OLD_ROUTER}
+ ${PFCTL} -i $interface -Fs
fi
fi
}
OpenPOWER on IntegriCloud