summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorRenato Botelho <garga@FreeBSD.org>2013-01-15 18:01:57 -0200
committerRenato Botelho <garga@FreeBSD.org>2013-01-15 18:02:17 -0200
commit9111e5fd88f284bd6f66a24a270af9d9fea1b6c7 (patch)
treed4823bd3d08968bde626e69041a523242c83e2bb /etc
parenta74260cb3f4811212d6fb4d5ebc0b231bdfa52a6 (diff)
downloadpfsense-9111e5fd88f284bd6f66a24a270af9d9fea1b6c7.zip
pfsense-9111e5fd88f284bd6f66a24a270af9d9fea1b6c7.tar.gz
When a interface type is changed, old configuration remains. When moving from static ip to ppp, it kepts the static ip configured on interface, when moving from ppp to static ip, it doesn't kill mpd. Implement interface_clean() to make sure only current configuration is in place
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/interfaces.inc56
1 files changed, 56 insertions, 0 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc
index 270428e..797df0c 100644
--- a/etc/inc/interfaces.inc
+++ b/etc/inc/interfaces.inc
@@ -1061,6 +1061,60 @@ function interface_vip_bring_down($vip) {
}
}
+function interface_cleanup($interface = "wan") {
+ global $config, $g;
+
+ if (!isset($config['interfaces'][$interface]))
+ return;
+
+ $ifcfg = $config['interfaces'][$interface];
+
+ $ppp_types = array("ppp", "pppoe", "pptp", "l2tp");
+
+ $realifs = array(get_real_interface($interface));
+
+ if (in_array($ifcfg['ipaddr'], $ppp_types)) {
+ if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) {
+ foreach ($config['ppps']['ppp'] as $pppid => $ppp) {
+ if (get_real_interface($interface) == $ppp['if']) {
+ $realifs = array();
+ $ports = explode(',',$ppp['ports']);
+ foreach($ports as $port) {
+ $realifs[] = get_real_interface($port);
+ }
+ }
+ }
+ }
+ }
+
+ foreach ($ppp_types as $type) {
+ if (($ifcfg['ipaddr'] != $type) && file_exists("{$g['varrun_path']}/{$type}_{$interface}.pid")) {
+ killbypid("{$g['varrun_path']}/{$type}_{$interface}.pid");
+ sleep(2);
+ }
+ }
+
+ if (!in_array($ifcfg['ipaddr'], $ppp_types))
+ unlink_if_exists("{$g['varetc_path']}/mpd_{$interface}.conf");
+
+ if ($ifcfg['ipaddr'] != "dhcp") {
+ foreach($realifs as $realif) {
+ $pid = find_dhclient_process($realif);
+ if($pid)
+ mwexec("/bin/kill {$pid}");
+ sleep(1);
+ }
+ unlink_if_exists("{$g['varetc_path']}/dhclient_{$interface}.conf");
+ }
+
+ if (!is_ipaddrv4($ifcfg['ipaddr'])) {
+ foreach($realifs as $realif) {
+ mwexec("/sbin/ifconfig " . escapeshellarg($realif) . " delete", true);
+ mwexec("/usr/sbin/arp -d -i {$realif} -a");
+ }
+ }
+}
+
function interface_bring_down($interface = "wan", $destroy = false) {
global $config, $g;
@@ -1072,6 +1126,8 @@ function interface_bring_down($interface = "wan", $destroy = false) {
$realif = get_real_interface($interface);
+ interface_cleanup($interface);
+
switch ($ifcfg['ipaddr']) {
case "ppp":
case "pppoe":
OpenPOWER on IntegriCloud