summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/inc/interfaces.inc12
-rwxr-xr-xusr/local/www/carp_status.php9
2 files changed, 17 insertions, 4 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc
index 30e57cc..806dc51 100644
--- a/etc/inc/interfaces.inc
+++ b/etc/inc/interfaces.inc
@@ -2315,6 +2315,18 @@ function find_ip_interface($ip)
}
/*
+ * find_number_of_created_carp_interfaces: return the number of carp interfaces
+ */
+function find_number_of_created_carp_interfaces() {
+ return `/sbin/ifconfig | grep "carp:" | wc -l`;
+}
+
+function get_all_carp_interfaces() {
+ $ints = str_replace("\n", " ", `ifconfig | grep "carp:" -B2 | grep ": flag" | cut -d: -f1`);
+ return $ints;
+}
+
+/*
* find_carp_interface($ip): return the carp interface where an ip is defined
*/
function find_carp_interface($ip) {
diff --git a/usr/local/www/carp_status.php b/usr/local/www/carp_status.php
index f2dd95a..1792f5d 100755
--- a/usr/local/www/carp_status.php
+++ b/usr/local/www/carp_status.php
@@ -54,11 +54,12 @@ unset($interface_ip_arr_cache);
$status = get_carp_status();
if($_POST['disablecarp'] <> "") {
if($status == true) {
- $carp_counter=find_number_of_created_carp_interfaces();
+ $carp_ints = get_all_carp_interfaces();
mwexec("/sbin/sysctl net.inet.carp.allow=0");
- for($x=0; $x<$carp_counter; $x++) {
- mwexec("/sbin/ifconfig carp{$x} down");
- mwexec("/sbin/ifconfig carp{$x} destroy");
+ $carp_counter = find_number_of_created_carp_interfaces();
+ foreach($carp_ints as $int) {
+ mwexec("/sbin/ifconfig $int down");
+ mwexec("/sbin/ifconfig $int destroy");
}
$savemsg = "{$carp_counter} IPs have been disabled.";
} else {
OpenPOWER on IntegriCloud