From 0e22f6a36611f93725fdabd1eac2a29271269b29 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 12 Apr 2021 08:49:30 +0200 Subject: [PATCH] net/frr: Add BFD support (#2326) --- net/frr/Makefile | 3 +- net/frr/pkg-descr | 4 + .../OPNsense/Quagga/Api/BfdController.php | 75 +++++++++++ .../OPNsense/Quagga/BfdController.php | 39 ++++++ .../controllers/OPNsense/Quagga/forms/bfd.xml | 8 ++ .../Quagga/forms/dialogEditBFDNeighbor.xml | 19 +++ .../OPNsense/Quagga/forms/general.xml | 2 +- .../mvc/app/models/OPNsense/Quagga/BFD.php | 31 +++++ .../mvc/app/models/OPNsense/Quagga/BFD.xml | 27 ++++ .../app/models/OPNsense/Quagga/Menu/Menu.xml | 1 + .../mvc/app/views/OPNsense/Quagga/bfd.volt | 118 ++++++++++++++++++ .../templates/OPNsense/Quagga/+TARGETS | 1 + .../templates/OPNsense/Quagga/bfdd.conf | 29 +++++ .../service/templates/OPNsense/Quagga/frr | 1 + 14 files changed, 355 insertions(+), 3 deletions(-) create mode 100644 net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/Api/BfdController.php create mode 100644 net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/BfdController.php create mode 100644 net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/forms/bfd.xml create mode 100644 net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/forms/dialogEditBFDNeighbor.xml create mode 100644 net/frr/src/opnsense/mvc/app/models/OPNsense/Quagga/BFD.php create mode 100644 net/frr/src/opnsense/mvc/app/models/OPNsense/Quagga/BFD.xml create mode 100644 net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/bfd.volt create mode 100644 net/frr/src/opnsense/service/templates/OPNsense/Quagga/bfdd.conf diff --git a/net/frr/Makefile b/net/frr/Makefile index 11c964bfd..7aa041dd2 100644 --- a/net/frr/Makefile +++ b/net/frr/Makefile @@ -1,6 +1,5 @@ PLUGIN_NAME= frr -PLUGIN_VERSION= 1.21 -PLUGIN_REVISION= 3 +PLUGIN_VERSION= 1.22 PLUGIN_COMMENT= The FRRouting Protocol Suite PLUGIN_DEPENDS= frr7 PLUGIN_MAINTAINER= franz.fabian.94@gmail.com diff --git a/net/frr/pkg-descr b/net/frr/pkg-descr index c0da55615..a5aa793d9 100644 --- a/net/frr/pkg-descr +++ b/net/frr/pkg-descr @@ -11,6 +11,10 @@ switching and routing, Internet access routers, and Internet peering. Plugin Changelog ================ +1.22 + +* Add BFD support + 1.21 * Deprecate Ruby parser for FRR diagnostic output, remove Ruby dependency diff --git a/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/Api/BfdController.php b/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/Api/BfdController.php new file mode 100644 index 000000000..4904f54c0 --- /dev/null +++ b/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/Api/BfdController.php @@ -0,0 +1,75 @@ + + * 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. + */ + +namespace OPNsense\Quagga\Api; + +use OPNsense\Base\ApiMutableModelControllerBase; + +class BfdController extends ApiMutableModelControllerBase +{ + protected static $internalModelName = 'bfd'; + protected static $internalModelClass = '\OPNsense\Quagga\BFD'; + + public function searchNeighborAction() + { + return $this->searchBase( + 'neighbors.neighbor', + array("enabled", + "description", + "address") + ); + } + + public function getNeighborAction($uuid = null) + { + $this->sessionClose(); + return $this->getBase('neighbor', 'neighbors.neighbor', $uuid); + } + + public function addNeighborAction() + { + return $this->addBase('neighbor', 'neighbors.neighbor'); + } + + public function delNeighborAction($uuid) + { + return $this->delBase('neighbors.neighbor', $uuid); + } + + public function setNeighborAction($uuid) + { + return $this->setBase('neighbor', 'neighbors.neighbor', $uuid); + } + + public function toggleNeighborAction($uuid) + { + return $this->toggleBase('neighbors.neighbor', $uuid); + } +} diff --git a/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/BfdController.php b/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/BfdController.php new file mode 100644 index 000000000..93575aa03 --- /dev/null +++ b/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/BfdController.php @@ -0,0 +1,39 @@ + + * 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. + */ + +namespace OPNsense\Quagga; + +class BfdController extends \OPNsense\Base\IndexController +{ + public function indexAction() + { + $this->view->bfdForm = $this->getForm("bfd"); + $this->view->formDialogEditBFDNeighbor = $this->getForm("dialogEditBFDNeighbor"); + $this->view->pick('OPNsense/Quagga/bfd'); + } +} diff --git a/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/forms/bfd.xml b/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/forms/bfd.xml new file mode 100644 index 000000000..a0233c4cf --- /dev/null +++ b/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/forms/bfd.xml @@ -0,0 +1,8 @@ +
+ + bfd.enabled + + checkbox + This will activate the BFD service. + +
diff --git a/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/forms/dialogEditBFDNeighbor.xml b/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/forms/dialogEditBFDNeighbor.xml new file mode 100644 index 000000000..4a76e64a9 --- /dev/null +++ b/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/forms/dialogEditBFDNeighbor.xml @@ -0,0 +1,19 @@ +
+ + neighbor.enabled + + checkbox + + + neighbor.description + + text + Set an optional description for this neighbor. + + + neighbor.address + + text + Specify the IP of your neighbor. + +
diff --git a/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/forms/general.xml b/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/forms/general.xml index 29c3e7bd7..926afe40f 100644 --- a/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/forms/general.xml +++ b/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/forms/general.xml @@ -26,7 +26,7 @@ general.sysloglevel - + dropdown This is the detail level of the log. A higher level means more data is logged. diff --git a/net/frr/src/opnsense/mvc/app/models/OPNsense/Quagga/BFD.php b/net/frr/src/opnsense/mvc/app/models/OPNsense/Quagga/BFD.php new file mode 100644 index 000000000..39313ae57 --- /dev/null +++ b/net/frr/src/opnsense/mvc/app/models/OPNsense/Quagga/BFD.php @@ -0,0 +1,31 @@ + + 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. +*/ +class BFD extends BaseModel +{ +} diff --git a/net/frr/src/opnsense/mvc/app/models/OPNsense/Quagga/BFD.xml b/net/frr/src/opnsense/mvc/app/models/OPNsense/Quagga/BFD.xml new file mode 100644 index 000000000..df4e256b7 --- /dev/null +++ b/net/frr/src/opnsense/mvc/app/models/OPNsense/Quagga/BFD.xml @@ -0,0 +1,27 @@ + + //OPNsense/quagga/bfd + BFD configuration + 1.0.0 + + + 0 + Y + + + + + 1 + Y + + + + N + +
+ + Y +
+
+
+
+
diff --git a/net/frr/src/opnsense/mvc/app/models/OPNsense/Quagga/Menu/Menu.xml b/net/frr/src/opnsense/mvc/app/models/OPNsense/Quagga/Menu/Menu.xml index e294cc115..450399f57 100644 --- a/net/frr/src/opnsense/mvc/app/models/OPNsense/Quagga/Menu/Menu.xml +++ b/net/frr/src/opnsense/mvc/app/models/OPNsense/Quagga/Menu/Menu.xml @@ -6,6 +6,7 @@ + diff --git a/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/bfd.volt b/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/bfd.volt new file mode 100644 index 000000000..3c56ad63e --- /dev/null +++ b/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/bfd.volt @@ -0,0 +1,118 @@ +{# + +OPNsense® is Copyright © 2014 – 2017 by Deciso B.V. +Copyright (C) 2017 Fabian Franz +Copyright (C) 2017 - 2021 Michael Muenz +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. + +#} + + +
+
+
+ {{ partial("layout_partials/base_form",['fields':bfdForm,'id':'frm_bfd_settings'])}} +
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + +
{{ lang._('Enabled') }}{{ lang._('Description') }}{{ lang._('Neighbor Address') }}{{ lang._('ID') }}{{ lang._('Commands') }}
+ + +
+
+
+ + + +{{ partial("layout_partials/base_dialog",['fields':formDialogEditBFDNeighbor,'id':'DialogEditBFDNeighbor','label':lang._('Edit Neighbor')])}} diff --git a/net/frr/src/opnsense/service/templates/OPNsense/Quagga/+TARGETS b/net/frr/src/opnsense/service/templates/OPNsense/Quagga/+TARGETS index a09b88d86..30b11bedb 100644 --- a/net/frr/src/opnsense/service/templates/OPNsense/Quagga/+TARGETS +++ b/net/frr/src/opnsense/service/templates/OPNsense/Quagga/+TARGETS @@ -1,3 +1,4 @@ +bfdd.conf:/usr/local/etc/frr/bfdd.conf bgpd.conf:/usr/local/etc/frr/bgpd.conf ospfd.conf:/usr/local/etc/frr/ospfd.conf ospfd_carp.conf:/usr/local/etc/frr/ospfd_carp.conf diff --git a/net/frr/src/opnsense/service/templates/OPNsense/Quagga/bfdd.conf b/net/frr/src/opnsense/service/templates/OPNsense/Quagga/bfdd.conf new file mode 100644 index 000000000..8b1365263 --- /dev/null +++ b/net/frr/src/opnsense/service/templates/OPNsense/Quagga/bfdd.conf @@ -0,0 +1,29 @@ +{% if helpers.exists('OPNsense.quagga.bfd.enabled') and OPNsense.quagga.bfd.enabled == '1' %} +! +! Zebra configuration saved from vty +! 2017/03/03 20:21:04 +! +{% if helpers.exists('OPNsense.quagga.general') %} +{% if helpers.exists('OPNsense.quagga.general.enablesyslog') and OPNsense.quagga.general.enablesyslog == '1' %} +log syslog {{ OPNsense.quagga.general.sysloglevel }} +{% endif %} +{% if helpers.exists('OPNsense.quagga.general.profile') %} +frr defaults {{ OPNsense.quagga.general.profile }} +{% endif %} +{% endif %} +! +! +! +line vty +! +! +bfd +{% if helpers.exists('OPNsense.quagga.bfd.neighbors.neighbor') %} +{% for neighbor in helpers.toList('OPNsense.quagga.bfd.neighbors.neighbor') %} +{% if neighbor.enabled == '1' %} + peer {{ neighbor.address }} +{% endif %} +{% endfor %} +{% endif %} +! +{% endif %} diff --git a/net/frr/src/opnsense/service/templates/OPNsense/Quagga/frr b/net/frr/src/opnsense/service/templates/OPNsense/Quagga/frr index f119450b6..2163fb73a 100644 --- a/net/frr/src/opnsense/service/templates/OPNsense/Quagga/frr +++ b/net/frr/src/opnsense/service/templates/OPNsense/Quagga/frr @@ -7,6 +7,7 @@ start_precmd="ifconfig | grep 'carp: MASTER'" frr_daemons="zebra{% if helpers.exists('OPNsense.quagga.ospf.enabled') and OPNsense.quagga.ospf.enabled == '1' %} ospfd{% endif %}{% if helpers.exists('OPNsense.quagga.rip.enabled') and OPNsense.quagga.rip.enabled == '1' %} ripd{% endif %}{% +if helpers.exists('OPNsense.quagga.bfd.enabled') and OPNsense.quagga.bfd.enabled == '1' %} bfdd{% endif %}{% if helpers.exists('OPNsense.quagga.bgp.enabled') and OPNsense.quagga.bgp.enabled == '1' %} bgpd{% endif %}{% if helpers.exists('OPNsense.quagga.ospf6.enabled') and OPNsense.quagga.ospf6.enabled == '1' %} ospf6d{% endif %}{% if helpers.exists('OPNsense.quagga.ripng.enabled') and OPNsense.quagga.ripng.enabled == '1' %} ripngd{% endif %}{%