summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2013-12-02 21:12:31 +0000
committerErmal <eri@pfsense.org>2013-12-02 21:12:31 +0000
commit77411fa70dcdd0bd7831b8f6d87187e8563200ef (patch)
tree58ad62bef6d6ca628bdd8dd52b3b64311871929c
parentaa87cf1108532f083761a5d2da4ff518cc398356 (diff)
downloadpfsense-77411fa70dcdd0bd7831b8f6d87187e8563200ef.zip
pfsense-77411fa70dcdd0bd7831b8f6d87187e8563200ef.tar.gz
Correct CARP events on devd and the argument processing on called scripts
-rw-r--r--etc/devd.conf10
-rwxr-xr-xetc/rc.carpbackup17
-rwxr-xr-xetc/rc.carpmaster21
3 files changed, 32 insertions, 16 deletions
diff --git a/etc/devd.conf b/etc/devd.conf
index 30f3cc5..c84b774 100644
--- a/etc/devd.conf
+++ b/etc/devd.conf
@@ -14,16 +14,14 @@ options {
# CARP notify hooks. This will call carpup/carpdown with the
# interface (carp0, carp1) as the first parameter.
notify 100 {
- match "system" "IFNET";
- match "type" "LINK_UP";
- match "subsystem" "[a-zA-Z0-9_]+_vip[0-9]+";
+ match "system" "CARP";
+ match "type" "MASTER";
action "/etc/rc.carpmaster $subsystem";
};
notify 100 {
- match "system" "IFNET";
- match "type" "LINK_DOWN";
- match "subsystem" "[a-zA-Z0-9_]+_vip[0-9]+";
+ match "system" "CARP";
+ match "type" "BACKUP";
action "/etc/rc.carpbackup $subsystem";
};
diff --git a/etc/rc.carpbackup b/etc/rc.carpbackup
index d463d45..0068589 100755
--- a/etc/rc.carpbackup
+++ b/etc/rc.carpbackup
@@ -35,21 +35,30 @@ require_once("notices.inc");
require_once("openvpn.inc");
require_once("interfaces.inc");
-$notificationmsg = sprintf('Carp cluster member "%2$s (%1$s)" has resumed the state "BACKUP"',$argv[1],convert_friendly_interface_to_friendly_descr($argv[1]));
+$argument = str_replace("\n", "", $argv[1]);
+if (!strstr($argument, "@"))
+ log_error("Carp MASTER event triggered from wrong source {$argument}");
+
+list($vhid, $iface) = explode("@", $argument);
+
+$friendly = convert_real_interface_to_friendly_interface_name($iface);
+$friendly_descr = convert_friendly_interface_to_friendly_descr($friendly);
+$notificationmsg = sprintf('Carp cluster member "%2$s (%1$s)" has resumed the state "BACKUP"', $argument, $friendly_descr);
notify_via_smtp($notificationmsg);
notify_via_growl($notificationmsg);
+log_error($notificationmsg);
/* Stop OpenVPN clients running on this VIP, since multiple active OpenVPN clients on a CARP cluster can be problematic. */
global $config;
if (is_array($config['openvpn']) && is_array($config['openvpn']['openvpn-client'])) {
foreach ($config['openvpn']['openvpn-client'] as $settings) {
- if ($settings['interface'] == $argv[1]) {
- log_error("Stopping OpenVPN instance on {$settings['interface']} because of transition to CARP backup.");
+ if ($settings['interface'] == $friendly) {
+ log_error("Stopping OpenVPN client instance on {$friendly_descr} because of transition to CARP backup.");
openvpn_restart('client', $settings);
}
}
}
-?> \ No newline at end of file
+?>
diff --git a/etc/rc.carpmaster b/etc/rc.carpmaster
index 50db028..d4c122e 100755
--- a/etc/rc.carpmaster
+++ b/etc/rc.carpmaster
@@ -35,28 +35,37 @@ require_once("notices.inc");
require_once("openvpn.inc");
require_once("interfaces.inc");
-$notificationmsg = sprintf('Carp cluster member "%2$s (%1$s)" has resumed the state "MASTER"',$argv[1],convert_friendly_interface_to_friendly_descr($argv[1]));
+$argument = str_replace("\n", "", $argv[1]);
+if (!strstr($argument, "@"))
+ log_error("Carp MASTER event triggered from wrong source {$argument}");
+
+list($vhid, $iface) = explode("@", $argument);
+
+$friendly = convert_real_interface_to_friendly_interface_name($iface);
+$friendly_descr = convert_friendly_interface_to_friendly_descr($friendly);
+$notificationmsg = sprintf('Carp cluster member "%2$s (%1$s)" has resumed the state "MASTER"', $argument, $friendly_descr);
notify_via_smtp($notificationmsg);
notify_via_growl($notificationmsg);
+log_error($notificationmsg);
/* Start OpenVPN clients running on this VIP, since they should be in the stopped state while the VIP is CARP Backup. */
global $config;
if (is_array($config['openvpn']) && is_array($config['openvpn']['openvpn-client'])) {
foreach ($config['openvpn']['openvpn-client'] as $settings) {
- if ($settings['interface'] == $argv[1]) {
- log_error("Starting OpenVPN instance on {$settings['interface']} because of transition to CARP master.");
+ if ($settings['interface'] == $friendly) {
+ log_error("Starting OpenVPN client instance on {$friendly_descr} because of transition to CARP master.");
openvpn_restart('client', $settings);
}
}
}
if (is_array($config['openvpn']) && is_array($config['openvpn']['openvpn-server'])) {
foreach ($config['openvpn']['openvpn-server'] as $settings) {
- if ($settings['interface'] == $argv[1]) {
- log_error("Starting OpenVPN instance on {$settings['interface']} because of transition to CARP master.");
+ if ($settings['interface'] == $friendly) {
+ log_error("Starting OpenVPN instance on {$friendly_descr} because of transition to CARP master.");
openvpn_restart('server', $settings);
}
}
}
-?> \ No newline at end of file
+?>
OpenPOWER on IntegriCloud