net/frr: Add BFD support (#2326)

This commit is contained in:
Michael
2021-04-12 08:49:30 +02:00
committed by GitHub
parent efddc02352
commit 0e22f6a366
14 changed files with 355 additions and 3 deletions
+1 -2
View File
@@ -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
+4
View File
@@ -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
@@ -0,0 +1,75 @@
<?php
/*
* Copyright (C) 2015-2017 Deciso B.V.
* Copyright (C) 2017 Fabian Franz
* Copyright (C) 2017-2021 Michael Muenz <m.muenz@gmail.com>
* 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);
}
}
@@ -0,0 +1,39 @@
<?php
/*
* Copyright (C) 2017 Fabian Franz
* Copyright (C) 2017-2021 Michael Muenz <m.muenz@gmail.com>
* 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');
}
}
@@ -0,0 +1,8 @@
<form>
<field>
<id>bfd.enabled</id>
<label>Enable</label>
<type>checkbox</type>
<help>This will activate the BFD service.</help>
</field>
</form>
@@ -0,0 +1,19 @@
<form>
<field>
<id>neighbor.enabled</id>
<label>Enabled</label>
<type>checkbox</type>
</field>
<field>
<id>neighbor.description</id>
<label>Description</label>
<type>text</type>
<help>Set an optional description for this neighbor.</help>
</field>
<field>
<id>neighbor.address</id>
<label>Peer-IP</label>
<type>text</type>
<help>Specify the IP of your neighbor.</help>
</field>
</form>
@@ -26,7 +26,7 @@
</field>
<field>
<id>general.sysloglevel</id>
<label>log level</label>
<label>Log Level</label>
<type>dropdown</type>
<help>This is the detail level of the log. A higher level means more data is logged.</help>
</field>
@@ -0,0 +1,31 @@
<?php
namespace OPNsense\Quagga;
use OPNsense\Base\BaseModel;
/*
Copyright (C) 2017 Fabian Franz
Copyright (C) 2017 - 2021 Michael Muenz <m.muenz@gmail.com>
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
{
}
@@ -0,0 +1,27 @@
<model>
<mount>//OPNsense/quagga/bfd</mount>
<description>BFD configuration</description>
<version>1.0.0</version>
<items>
<enabled type="BooleanField">
<default>0</default>
<Required>Y</Required>
</enabled>
<neighbors>
<neighbor type="ArrayField">
<enabled type="BooleanField">
<default>1</default>
<Required>Y</Required>
</enabled>
<description type="TextField">
<default></default>
<Required>N</Required>
</description>
<address type="NetworkField">
<default></default>
<Required>Y</Required>
</address>
</neighbor>
</neighbors>
</items>
</model>
@@ -6,6 +6,7 @@
<OSPFv3 VisibleName="OSPFv3" cssClass="fa fa-map fa-fw" url="/ui/quagga/ospf6/index" order="25" />
<!--<ISIS VisibleName="IS-IS" cssClass="fa fa-bolt fa-fw" url="/ui/quagga/isis/index" order="30" />-->
<BGP VisibleName="BGP" cssClass="fa fa-globe fa-fw" url="/ui/quagga/bgp/index" order="40" />
<BFD VisibleName="BFD" cssClass="fa fa-exchange fa-fw" url="/ui/quagga/bfd/index" order="50" />
<Diagnostics VisibleName="Diagnostics" cssClass="fa fa-medkit fa-fw" order="50">
<General VisibleName="General" url="/ui/quagga/diagnostics/general" order="1" />
<OSPF VisibleName="OSPF" url="/ui/quagga/diagnostics/ospf" order="20" />
@@ -0,0 +1,118 @@
{#
OPNsense® is Copyright © 2014 2017 by Deciso B.V.
Copyright (C) 2017 Fabian Franz
Copyright (C) 2017 - 2021 Michael Muenz <m.muenz@gmail.com>
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.
#}
<!-- Navigation bar -->
<ul class="nav nav-tabs" data-tabs="tabs" id="maintabs">
<li class="active"><a data-toggle="tab" href="#general">{{ lang._('General') }}</a></li>
<li><a data-toggle="tab" href="#neighbors">{{ lang._('Neighbors') }}</a></li>
</ul>
<div class="tab-content content-box tab-content">
<div id="general" class="tab-pane fade in active">
<div class="content-box" style="padding-bottom: 1.5em;">
{{ partial("layout_partials/base_form",['fields':bfdForm,'id':'frm_bfd_settings'])}}
<div class="col-md-12">
<hr />
<button class="btn btn-primary" id="saveAct" type="button"><b>{{ lang._('Save') }}</b> <i id="saveAct_progress"></i></button>
</div>
</div>
</div>
<div id="neighbors" class="tab-pane fade in">
<table id="grid-neighbors" class="table table-responsive" data-editDialog="DialogEditBFDNeighbor">
<thead>
<tr>
<th data-column-id="enabled" data-type="string" data-formatter="rowtoggle">{{ lang._('Enabled') }}</th>
<th data-column-id="description" data-type="string" data-visible="true">{{ lang._('Description') }}</th>
<th data-column-id="address" data-type="string" data-visible="true">{{ lang._('Neighbor Address') }}</th>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">{{ lang._('ID') }}</th>
<th data-column-id="commands" data-formatter="commands" data-sortable="false">{{ lang._('Commands') }}</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<td colspan="10"></td>
<td colspan="1">
<button data-action="add" type="button" class="btn btn-xs btn-default"><span class="fa fa-plus"></span></button>
<button type="button" class="btn btn-xs reload_btn btn-primary"><span class="fa fa-refresh reloadAct_progress"></span></button>
</td>
</tr>
</tfoot>
</table>
</div>
</div>
<script>
function quagga_update_status() {
updateServiceControlUI('quagga');
}
$(document).ready(function() {
var data_get_map = {'frm_bfd_settings':"/api/quagga/bfd/get"};
mapDataToFormUI(data_get_map).done(function(data){
formatTokenizersUI();
$('.selectpicker').selectpicker('refresh');
});
quagga_update_status();
// link save button to API set action
$("#saveAct").click(function(){
saveFormToEndpoint(url="/api/quagga/bfd/set",formid='frm_bfd_settings',callback_ok=function(){
$("#saveAct_progress").addClass("fa fa-spinner fa-pulse");
ajaxCall(url="/api/quagga/service/reconfigure", sendData={}, callback=function(data,status) {
quagga_update_status();
$("#saveAct_progress").removeClass("fa fa-spinner fa-pulse");
});
});
});
/* allow a user to manually reload the service (for forms which do not do it automatically) */
$('.reload_btn').click(function reload_handler() {
$(".reloadAct_progress").addClass("fa-spin");
ajaxCall(url="/api/quagga/service/reconfigure", sendData={}, callback=function(data,status) {
quagga_update_status();
$(".reloadAct_progress").removeClass("fa-spin");
});
});
$("#grid-neighbors").UIBootgrid(
{ 'search':'/api/quagga/bfd/searchNeighbor',
'get':'/api/quagga/bfd/getNeighbor/',
'set':'/api/quagga/bfd/setNeighbor/',
'add':'/api/quagga/bfd/addNeighbor/',
'del':'/api/quagga/bfd/delNeighbor/',
'toggle':'/api/quagga/bfd/toggleNeighbor/',
'options':{selection:false, multiSelect:false}
}
);
});
</script>
{{ partial("layout_partials/base_dialog",['fields':formDialogEditBFDNeighbor,'id':'DialogEditBFDNeighbor','label':lang._('Edit Neighbor')])}}
@@ -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
@@ -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 %}
@@ -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 %}{%