aboutsummaryrefslogtreecommitdiffstats
path: root/config/quagga_ospfd
diff options
context:
space:
mode:
Diffstat (limited to 'config/quagga_ospfd')
-rw-r--r--config/quagga_ospfd/quagga_ospfd.inc48
-rw-r--r--config/quagga_ospfd/quagga_ospfd.xml9
2 files changed, 55 insertions, 2 deletions
diff --git a/config/quagga_ospfd/quagga_ospfd.inc b/config/quagga_ospfd/quagga_ospfd.inc
index 598d3c00..aabd27a8 100644
--- a/config/quagga_ospfd/quagga_ospfd.inc
+++ b/config/quagga_ospfd/quagga_ospfd.inc
@@ -243,6 +243,20 @@ function quagga_ospfd_install_conf() {
fwrite($fd, $zebraconffile);
fclose($fd);
+ $carp_ip_status_check = "";
+ if (is_ipaddr($ospfd_conf['carpstatusip'])) {
+ $carpcheckinterface = trim(find_carp_interface($ospfd_conf['carpstatusip']));
+ $carp_ip_status_check = <<<EOF
+
+CARP_STATUS=`/sbin/ifconfig {$carpcheckinterface} | /usr/bin/grep carp: | /usr/bin/awk '{print \$2;}'`
+if [ \${CARP_STATUS} != "MASTER" ]; then
+ exit;
+fi
+
+EOF;
+ }
+
+
// Create rc.d file
$rc_file_stop = <<<EOF
if [ -e /var/run/quagga/zebra.pid ]; then
@@ -274,6 +288,7 @@ fi
killall -9 zebra 2>/dev/null
killall -9 ospfd 2>/dev/null
sleep 1
+{$carp_ip_status_check}
/usr/local/sbin/zebra -d -f {$quagga_config_base}/zebra.conf
/usr/local/sbin/ospfd -d -f {$quagga_config_base}/ospfd.conf
EOF;
@@ -290,7 +305,24 @@ EOF;
exec("chmod u+rw,go-rw {$quagga_config_base}/zebra.conf");
// Kick off newly created rc.d script
- exec("/usr/local/etc/rc.d/quagga.sh restart");
+ if (is_ipaddr($ospfd_conf['carpstatusip'])) {
+ $status = quagga_get_carp_status_by_ip($ospfd_conf['carpstatusip']);
+ switch (strtoupper($status)) {
+ // Stop the service if the VIP is in BACKUP or INIT state.
+ case "BACKUP":
+ case "INIT":
+ exec("/usr/local/etc/rc.d/quagga.sh stop");
+ break;
+ // Start the service if the VIP is MASTER state.
+ case "MASTER":
+ // Assume it's up if the status can't be determined.
+ default:
+ exec("/usr/local/etc/rc.d/quagga.sh restart");
+ break;
+ }
+ } else {
+ exec("/usr/local/etc/rc.d/quagga.sh restart");
+ }
// Back to RO mount for NanoBSD and friends
conf_mount_ro();
@@ -345,4 +377,18 @@ function quagga_ospfd_put_raw_config($conffile) {
}
}
+function quagga_get_carp_status_by_ip($ipaddr) {
+ $iface = trim(find_carp_interface($ipaddr));
+ if ($iface) {
+ $status = get_carp_interface_status($iface);
+ // If there is no status for that interface, return null.
+ if (!$status)
+ $status = null;
+ } else {
+ // If there is no VIP by that IP, return null.
+ $status = null;
+ }
+ return $status;
+}
+
?>
diff --git a/config/quagga_ospfd/quagga_ospfd.xml b/config/quagga_ospfd/quagga_ospfd.xml
index 3348dff3..a03f9e3c 100644
--- a/config/quagga_ospfd/quagga_ospfd.xml
+++ b/config/quagga_ospfd/quagga_ospfd.xml
@@ -1,6 +1,6 @@
<packagegui>
<name>quagga_ospfd</name>
- <version>0.5.2</version>
+ <version>0.5.4</version>
<title>Services: Quagga OSPFd</title>
<include_file>/usr/local/pkg/quagga_ospfd.inc</include_file>
<aftersaveredirect>pkg_edit.php?xml=quagga_ospfd.xml&amp;id=0</aftersaveredirect>
@@ -176,6 +176,13 @@
</rowhelperfield>
</rowhelper>
</field>
+ <field>
+ <fielddescr>CARP Status IP</fielddescr>
+ <fieldname>carpstatusip</fieldname>
+ <description>IP address used to determine the CARP status. When the VIP is in BACKUP status, quagga will not be started. &lt;br/&gt;NOTE: Requires changes to /etc/rc.carpmaster to start quagga and /etc/rc.carpbackup to stop quagga or it will not be fully effective.</description>
+ <type>input</type>
+ <size>25</size>
+ </field>
</fields>
<custom_php_resync_config_command>
quagga_ospfd_install_conf();