mirror of
https://github.com/netbirdio/plugins.git
synced 2026-05-22 18:44:07 -07:00
net/frr: add community-lists to BGP (#2078)
This commit is contained in:
@@ -14,6 +14,7 @@ Plugin Changelog
|
||||
1.18
|
||||
|
||||
* Add description fields to BGP tabs
|
||||
* Add BGP community-lists
|
||||
|
||||
1.17
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/**
|
||||
* Copyright (C) 2015 - 2017 Deciso B.V.
|
||||
* Copyright (C) 2017 Fabian Franz
|
||||
* Copyright (C) 2017 Michael Muenz <m.muenz@gmail.com>
|
||||
* Copyright (C) 2017 - 2020 Michael Muenz <m.muenz@gmail.com>
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -136,6 +136,34 @@ class BgpController extends ApiMutableModelControllerBase
|
||||
return $this->setBase('prefixlist', 'prefixlists.prefixlist', $uuid);
|
||||
}
|
||||
|
||||
public function searchCommunitylistAction()
|
||||
{
|
||||
return $this->searchBase(
|
||||
'communitylists.communitylist',
|
||||
array("enabled", "description", "number", "seqnumber", "action", "community" )
|
||||
);
|
||||
}
|
||||
public function getCommunitylistAction($uuid = null)
|
||||
{
|
||||
$this->sessionClose();
|
||||
return $this->getBase('communitylist', 'communitylists.communitylist', $uuid);
|
||||
}
|
||||
|
||||
public function addCommunitylistAction()
|
||||
{
|
||||
return $this->addBase('communitylist', 'communitylists.communitylist');
|
||||
}
|
||||
|
||||
public function delCommunitylistAction($uuid)
|
||||
{
|
||||
return $this->delBase('communitylists.communitylist', $uuid);
|
||||
}
|
||||
|
||||
public function setCommunitylistAction($uuid)
|
||||
{
|
||||
return $this->setBase('communitylist', 'communitylists.communitylist', $uuid);
|
||||
}
|
||||
|
||||
public function searchRoutemapAction()
|
||||
{
|
||||
return $this->searchBase(
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
Copyright (C) 2017 Fabian Franz
|
||||
Copyright (C) 2017 Michael Muenz <m.muenz@gmail.com>
|
||||
Copyright (C) 2017 - 2020 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:
|
||||
@@ -33,6 +33,7 @@ class BgpController extends \OPNsense\Base\IndexController
|
||||
$this->view->formDialogEditBGPNeighbor = $this->getForm("dialogEditBGPNeighbor");
|
||||
$this->view->formDialogEditBGPASPaths = $this->getForm("dialogEditBGPASPath");
|
||||
$this->view->formDialogEditBGPPrefixLists = $this->getForm("dialogEditBGPPrefixLists");
|
||||
$this->view->formDialogEditBGPCommunityLists = $this->getForm("dialogEditBGPCommunityLists");
|
||||
$this->view->formDialogEditBGPRouteMaps = $this->getForm("dialogEditBGPRouteMaps");
|
||||
$this->view->pick('OPNsense/Quagga/bgp');
|
||||
}
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>communitylist.enabled</id>
|
||||
<label>Enabled</label>
|
||||
<type>checkbox</type>
|
||||
<help>Enable / Disable</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>communitylist.description</id>
|
||||
<label>Description</label>
|
||||
<type>text</type>
|
||||
<help>Add an optional description for this Community-List.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>communitylist.number</id>
|
||||
<label>Number</label>
|
||||
<type>text</type>
|
||||
<help>Set the number of your Community-List. 1-99 are stardard lists while 100-500 are expanded lists.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>communitylist.seqnumber</id>
|
||||
<label>Sequence Number</label>
|
||||
<type>text</type>
|
||||
<help>The ACL sequence number (10-99)</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>communitylist.action</id>
|
||||
<label>Action</label>
|
||||
<type>select_multiple</type>
|
||||
<help>Set permit for match or deny to negate the rule.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>communitylist.community</id>
|
||||
<label>Community</label>
|
||||
<type>text</type>
|
||||
<help>The community you want to match. You can also regex and it is not validated so please be careful.</help>
|
||||
</field>
|
||||
</form>
|
||||
+8
@@ -44,6 +44,14 @@
|
||||
<style>tokenize</style>
|
||||
<allownew>true</allownew>
|
||||
<help>Select the Prefix List.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>routemap.match3</id>
|
||||
<label>Community List</label>
|
||||
<type>select_multiple</type>
|
||||
<style>tokenize</style>
|
||||
<allownew>true</allownew>
|
||||
<help>Select the Community List.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>routemap.set</id>
|
||||
|
||||
@@ -202,6 +202,43 @@
|
||||
</network>
|
||||
</prefixlist>
|
||||
</prefixlists>
|
||||
<communitylists>
|
||||
<communitylist type="ArrayField">
|
||||
<enabled type="BooleanField">
|
||||
<default>1</default>
|
||||
<Required>Y</Required>
|
||||
</enabled>
|
||||
<description type="TextField">
|
||||
<default></default>
|
||||
<Required>N</Required>
|
||||
</description>
|
||||
<number type="IntegerField">
|
||||
<default></default>
|
||||
<Required>Y</Required>
|
||||
<MinimumValue>1</MinimumValue>
|
||||
<MaximumValue>500</MaximumValue>
|
||||
<ValidationMessage>Set a number between 1 and 500.</ValidationMessage>
|
||||
</number>
|
||||
<seqnumber type="IntegerField">
|
||||
<default></default>
|
||||
<Required>Y</Required>
|
||||
<MinimumValue>10</MinimumValue>
|
||||
<MaximumValue>99</MaximumValue>
|
||||
</seqnumber>
|
||||
<action type="OptionField">
|
||||
<default></default>
|
||||
<Required>Y</Required>
|
||||
<OptionValues>
|
||||
<permit>Permit</permit>
|
||||
<deny>Deny</deny>
|
||||
</OptionValues>
|
||||
</action>
|
||||
<community type="TextField">
|
||||
<default></default>
|
||||
<Required>Y</Required>
|
||||
</community>
|
||||
</communitylist>
|
||||
</communitylists>
|
||||
<routemaps>
|
||||
<routemap type="ArrayField">
|
||||
<enabled type="BooleanField">
|
||||
@@ -256,6 +293,18 @@
|
||||
<Multiple>N</Multiple>
|
||||
<Required>N</Required>
|
||||
</match2>
|
||||
<match3 type="ModelRelationField">
|
||||
<Model>
|
||||
<template>
|
||||
<source>OPNsense.quagga.bgp</source>
|
||||
<items>communitylists.communitylist</items>
|
||||
<display>number</display>
|
||||
</template>
|
||||
</Model>
|
||||
<ValidationMessage>Related item not found</ValidationMessage>
|
||||
<Multiple>N</Multiple>
|
||||
<Required>N</Required>
|
||||
</match3>
|
||||
<set type="TextField">
|
||||
<Required>N</Required>
|
||||
</set>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
OPNsense® is Copyright © 2014 – 2017 by Deciso B.V.
|
||||
Copyright (C) 2017 Fabian Franz
|
||||
Copyright (C) 2017 Michael Muenz <m.muenz@gmail.com>
|
||||
Copyright (C) 2017 - 2020 Michael Muenz <m.muenz@gmail.com>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
@@ -33,6 +33,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
<li><a data-toggle="tab" href="#neighbors">{{ lang._('Neighbors') }}</a></li>
|
||||
<li><a data-toggle="tab" href="#aspaths">{{ lang._('AS Path Lists') }}</a></li>
|
||||
<li><a data-toggle="tab" href="#prefixlists">{{ lang._('Prefix Lists') }}</a></li>
|
||||
<li><a data-toggle="tab" href="#communitylists">{{ lang._('Community Lists') }}</a></li>
|
||||
<li><a data-toggle="tab" href="#routemaps">{{ lang._('Route Maps') }}</a></li>
|
||||
</ul>
|
||||
<div class="tab-content content-box tab-content">
|
||||
@@ -130,6 +131,34 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
<div id="communitylists" class="tab-pane fade in">
|
||||
<table id="grid-communitylists" class="table table-responsive" data-editDialog="DialogEditBGPCommunityLists">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-column-id="enabled" data-type="string" data-formatter="rowtoggle" data-sortable="false">{{ lang._('Enabled') }}</th>
|
||||
<th data-column-id="number" data-type="string" data-visible="true" data-sortable="true">{{ lang._('Number') }}</th>
|
||||
<th data-column-id="description" data-type="string" data-visible="true">{{ lang._('Description') }}</th>
|
||||
<th data-column-id="seqnumber" data-type="string" data-visible="true" data-sortable="true">{{ lang._('Secquence Number') }}</th>
|
||||
<th data-column-id="action" data-type="string" data-visible="true" data-sortable="false">{{ lang._('Action') }}</th>
|
||||
<th data-column-id="community" data-type="string" data-visible="true" data-sortable="false">{{ lang._('Community') }}</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="5"></td>
|
||||
<td>
|
||||
<button data-action="add" type="button" class="btn btn-xs btn-default"><span class="fa fa-plus"></span></button>
|
||||
<!-- <button data-action="deleteSelected" type="button" class="btn btn-xs btn-default"><span class="fa fa-trash-o"></span></button> -->
|
||||
<button type="button" class="btn btn-xs reload_btn btn-primary"><span class="fa fa-refresh reloadAct_progress"></span> {{ lang._('Reload Service') }}</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
<div id="routemaps" class="tab-pane fade in">
|
||||
<table id="grid-routemaps" class="table table-responsive" data-editDialog="DialogEditBGPRouteMaps">
|
||||
<thead>
|
||||
@@ -141,6 +170,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
<th data-column-id="id" data-type="string" data-visible="true">{{ lang._('ID') }}</th>
|
||||
<th data-column-id="match" data-type="string" data-visible="true">{{ lang._('AS Path List') }}</th>
|
||||
<th data-column-id="match2" data-type="string" data-visible="true">{{ lang._('Prefix List') }}</th>
|
||||
<th data-column-id="match3" data-type="string" data-visible="true">{{ lang._('Community List') }}</th>
|
||||
<th data-column-id="set" data-type="string" data-visible="true">{{ lang._('Set') }}</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>
|
||||
@@ -225,6 +255,16 @@ $(document).ready(function() {
|
||||
'options':{selection:false, multiSelect:false}
|
||||
}
|
||||
);
|
||||
$("#grid-communitylists").UIBootgrid(
|
||||
{ 'search':'/api/quagga/bgp/searchCommunitylist',
|
||||
'get':'/api/quagga/bgp/getCommunitylist/',
|
||||
'set':'/api/quagga/bgp/setCommunitylist/',
|
||||
'add':'/api/quagga/bgp/addCommunitylist/',
|
||||
'del':'/api/quagga/bgp/delCommunitylist/',
|
||||
'toggle':'/api/quagga/bgp/toggleCommunitylist/',
|
||||
'options':{selection:false, multiSelect:false}
|
||||
}
|
||||
);
|
||||
$("#grid-routemaps").UIBootgrid(
|
||||
{ 'search':'/api/quagga/bgp/searchRoutemap',
|
||||
'get':'/api/quagga/bgp/getRoutemap/',
|
||||
@@ -241,4 +281,5 @@ $(document).ready(function() {
|
||||
{{ partial("layout_partials/base_dialog",['fields':formDialogEditBGPNeighbor,'id':'DialogEditBGPNeighbor','label':lang._('Edit Neighbor')])}}
|
||||
{{ partial("layout_partials/base_dialog",['fields':formDialogEditBGPASPaths,'id':'DialogEditBGPASPaths','label':lang._('Edit AS Paths')])}}
|
||||
{{ partial("layout_partials/base_dialog",['fields':formDialogEditBGPPrefixLists,'id':'DialogEditBGPPrefixLists','label':lang._('Edit Prefix Lists')])}}
|
||||
{{ partial("layout_partials/base_dialog",['fields':formDialogEditBGPCommunityLists,'id':'DialogEditBGPCommunityLists','label':lang._('Edit Community Lists')])}}
|
||||
{{ partial("layout_partials/base_dialog",['fields':formDialogEditBGPRouteMaps,'id':'DialogEditBGPRouteMaps','label':lang._('Edit Route Maps')])}}
|
||||
|
||||
@@ -180,6 +180,14 @@ bgp as-path access-list {{ aspath.number }} {{ aspath.action }} {{ aspath.as }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
!
|
||||
{% if helpers.exists('OPNsense.quagga.bgp.communitylists.communitylist') %}
|
||||
{% for communitylist in helpers.sortDictList(OPNsense.quagga.bgp.communitylists.communitylist, 'number' ) %}
|
||||
{% if communitylist.enabled == '1' %}
|
||||
bgp community-list {{ communitylist.number }} seq {{ communitylist.seqnumber }} {{ communitylist.action }} {{ communitylist.community }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
!
|
||||
{% if helpers.exists('OPNsense.quagga.bgp.routemaps.routemap') %}
|
||||
{% for routemap in helpers.sortDictList(OPNsense.quagga.bgp.routemaps.routemap, 'name', 'id' ) %}
|
||||
{% if routemap.enabled == '1' %}
|
||||
@@ -205,6 +213,14 @@ route-map {{ routemap.name }} {{ routemap.action }} {{ routemap.id }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if routemap.match3|default("") != "" %}
|
||||
{% for communitylist in routemap.match3.split(",") %}
|
||||
{% set communitylist_data = helpers.getUUID(communitylist) %}
|
||||
{% if 'match3' in routemap and routemap.match3 != '' %}
|
||||
match community {{ communitylist_data.number }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if routemap.set|default("") != '' and routemap.match2|default("") != '' %}
|
||||
set {{ routemap.set }}
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user