diff --git a/net/frr/Makefile b/net/frr/Makefile index 80745a1e2..4b9b90c4a 100644 --- a/net/frr/Makefile +++ b/net/frr/Makefile @@ -1,5 +1,5 @@ PLUGIN_NAME= frr -PLUGIN_VERSION= 1.4 +PLUGIN_VERSION= 1.5 PLUGIN_COMMENT= The FRRouting Protocol Suite PLUGIN_DEPENDS= frr5 ruby PLUGIN_CONFLICTS= quagga diff --git a/net/frr/src/etc/inc/plugins.inc.d/frr.inc b/net/frr/src/etc/inc/plugins.inc.d/frr.inc index 1f020c5bb..65ec76766 100644 --- a/net/frr/src/etc/inc/plugins.inc.d/frr.inc +++ b/net/frr/src/etc/inc/plugins.inc.d/frr.inc @@ -1,45 +1,50 @@ + * Copyright (C) 2017 Fabian Franz + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -function ospfd_enabled() +function frr_enabled() { - $model = new \OPNsense\Quagga\OSPF(); - if ((string)$model->enabled == '1') { - return true; - } + $model = new \OPNsense\Quagga\General(); + return (string)$model->enabled == '1'; +} - return false; +function frr_carp_enabled() +{ + $model = new \OPNsense\Quagga\General(); + return (string)$model->enabled == '1' && + (string)$model->enablecarp == '1'; } function frr_firewall($fw) { - if (ospfd_enabled()) { - $ospf = new \OPNsense\Quagga\OSPF(); + $ospf = new \OPNsense\Quagga\OSPF(); + + if ((string)$ospf->enabled == '1') { foreach ($ospf->networks->network->__items as $network) { if ((string)$network->enabled == '1') { $fw->registerFilterRule( @@ -81,12 +86,9 @@ function frr_firewall($fw) function frr_services() { - global $config; - $services = array(); - if (isset($config['OPNsense']['quagga']['general']['enabled']) && - $config['OPNsense']['quagga']['general']['enabled'] == 1) { + if (frr_enabled()) { $services[] = array( 'description' => gettext('FRRouting Daemon'), 'configd' => array( diff --git a/net/frr/src/etc/rc.syshook.d/carp/50-frr b/net/frr/src/etc/rc.syshook.d/carp/50-frr new file mode 100755 index 000000000..0c9841529 --- /dev/null +++ b/net/frr/src/etc/rc.syshook.d/carp/50-frr @@ -0,0 +1,60 @@ +#!/usr/local/bin/php + + * Copyright (C) 2004 Scott Ullrich + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +require_once('config.inc'); +require_once('util.inc'); +require_once('plugins.inc.d/frr.inc'); + +if (!frr_carp_enabled()) { + /* nothing to do */ + exit(0); +} + +$subsystem = !empty($argv[1]) ? $argv[1] : ''; +$type = !empty($argv[2]) ? $argv[2] : ''; + +if ($type != 'MASTER' && $type != 'BACKUP') { + log_error("Carp '$type' event unknown from source '{$subsystem}'"); + exit(1); +} + +if (!strstr($subsystem, '@')) { + log_error("Carp '$type' event triggered from wrong source '{$subsystem}'"); + exit(1); +} + +switch ($type) { + case 'MASTER': + shell_exec('/usr/local/etc/rc.d/frr start'); + break; + case 'BACKUP': + shell_exec('/usr/local/etc/rc.d/frr stop'); + break; +}