From cfc2bdf89cc965e2bd23b4148148157643287064 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Sat, 13 Apr 2024 17:59:05 +0200 Subject: [PATCH] Squashed commit of the following: commit 5087edf5211a41dc903c4ceca90e39c2d36616f6 Author: Ad Schellevis Date: Sat Apr 13 17:56:09 2024 +0200 net/frr - style cleanups for https://github.com/opnsense/plugins/pull/3759 , including the use of https://github.com/opnsense/core/commit/2d45b78f744059089078d56b3c108765b2d23608 to return all fields on search for the controller in question. commit c121bb855d29cbb8cbf649b234d642c2120faa8c Author: Franco Fichtner Date: Tue Mar 5 17:23:56 2024 +0100 net/frr: bump revision for change commit 0091d4679d237dfb7d67f9817c65a040c1207d51 Author: Franco Fichtner Date: Tue Feb 6 09:02:13 2024 +0100 net/frr: wrap up next version commit 41d7c2d12203ef5abdc15c8634c986f95e955f27 Author: Michael Date: Fri Jan 26 06:42:52 2024 +0100 Update bgpd.conf commit 63e4be87d070c8847582bf50186b2438b33f49ee Author: Michael Date: Fri Jan 12 16:56:01 2024 +0100 Update bgp.xml commit 22880d7d4d248f4e8e00296d180572b0839b9a5a Author: Michael Date: Fri Jan 12 16:50:16 2024 +0100 Update bgpd.conf commit e5b5ee38198d13dfb1be995acd75c7eb98fbb113 Author: Michael Date: Fri Jan 12 16:44:26 2024 +0100 Update bgpd.conf commit f7d7630d76766425aab780d7f1712d52dc9d8a08 Author: Michael Date: Fri Jan 12 16:42:43 2024 +0100 add distance commit 30e479ee559a04a9c32d53ce46db77899b5555ab Author: Michael Date: Fri Jan 12 16:22:25 2024 +0100 Update bgpd.conf commit fbc89c7aeb88b73ac155e49b85a097bd2d527b7e Author: Michael Date: Fri Jan 12 09:38:47 2024 +0100 Update BGP.xml commit f18d80733661da36ffc6bf1c0c7006b211a6b21c Author: Michael Date: Fri Jan 12 09:36:21 2024 +0100 Update BGP.xml commit b10a53ac52f3d1c38be90d389892eb390ef0439a Author: Michael Date: Fri Jan 12 08:33:33 2024 +0100 typos commit fd2d9d71b11e801ad52bb66e08be61aa1622917e Author: Michael Date: Fri Jan 12 07:58:49 2024 +0100 bgp-group support --- net/frr/pkg-descr | 4 + .../OPNsense/Quagga/Api/BgpController.php | 83 +++++++------- .../OPNsense/Quagga/BgpController.php | 3 +- .../controllers/OPNsense/Quagga/forms/bgp.xml | 7 ++ .../Quagga/forms/dialogEditBGPNeighbor.xml | 6 ++ .../Quagga/forms/dialogEditBGPPeergroups.xml | 59 ++++++++++ .../mvc/app/models/OPNsense/Quagga/BGP.xml | 93 +++++++++++++++- .../mvc/app/views/OPNsense/Quagga/bgp.volt | 101 ++++++++++++------ .../templates/OPNsense/Quagga/bgpd.conf | 59 ++++++++++ 9 files changed, 336 insertions(+), 79 deletions(-) create mode 100644 net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/forms/dialogEditBGPPeergroups.xml diff --git a/net/frr/pkg-descr b/net/frr/pkg-descr index 78f2520ca..e07ba5402 100644 --- a/net/frr/pkg-descr +++ b/net/frr/pkg-descr @@ -14,6 +14,10 @@ Plugin Changelog 1.39 +* Add plain password authentication to OSPF +* Set multihop value to 255 (contributed by Cogan Ng Jun Lin) +* Add distance to BGP +* Add BGP peer-group support * Add plain password authentication to OSPF * Set multihop value to 255 (contributed by Cogan Ng Jun Lin) diff --git a/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/Api/BgpController.php b/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/Api/BgpController.php index 79de7caf4..2d1759dce 100644 --- a/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/Api/BgpController.php +++ b/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/Api/BgpController.php @@ -1,9 +1,9 @@ + * Copyright (C) 2017-2024 Michael Muenz * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -39,32 +39,11 @@ class BgpController extends ApiMutableModelControllerBase public function searchNeighborAction() { - return $this->searchBase( - 'neighbors.neighbor', - array("enabled", - "description", - "address", - "remoteas", - "password", - "localip", - "updatesource", - "nexthopself", - "multihop", - "keepalive", - "holddown", - "connecttimer", - "defaultoriginate", - "asoverride", - "linkedPrefixlistIn", - "linkedPrefixlistOut", - "linkedRoutemapIn", - "linkedRoutemapOut") - ); + return $this->searchBase('neighbors.neighbor'); } public function getNeighborAction($uuid = null) { - $this->sessionClose(); return $this->getBase('neighbor', 'neighbors.neighbor', $uuid); } @@ -85,15 +64,11 @@ class BgpController extends ApiMutableModelControllerBase public function searchAspathAction() { - return $this->searchBase( - 'aspaths.aspath', - array("enabled", "description", "number", "action", "as" ) - ); + return $this->searchBase('aspaths.aspath'); } public function getAspathAction($uuid = null) { - $this->sessionClose(); return $this->getBase('aspath', 'aspaths.aspath', $uuid); } @@ -114,14 +89,11 @@ class BgpController extends ApiMutableModelControllerBase public function searchPrefixlistAction() { - return $this->searchBase( - 'prefixlists.prefixlist', - array("enabled", "description", "name", "seqnumber", "action", "network" ) - ); + return $this->searchBase('prefixlists.prefixlist'); } + public function getPrefixlistAction($uuid = null) { - $this->sessionClose(); return $this->getBase('prefixlist', 'prefixlists.prefixlist', $uuid); } @@ -142,14 +114,11 @@ class BgpController extends ApiMutableModelControllerBase public function searchCommunitylistAction() { - return $this->searchBase( - 'communitylists.communitylist', - array("enabled", "description", "number", "seqnumber", "action", "community" ) - ); + return $this->searchBase('communitylists.communitylist'); } + public function getCommunitylistAction($uuid = null) { - $this->sessionClose(); return $this->getBase('communitylist', 'communitylists.communitylist', $uuid); } @@ -170,15 +139,11 @@ class BgpController extends ApiMutableModelControllerBase public function searchRoutemapAction() { - return $this->searchBase( - 'routemaps.routemap', - array("enabled", "description", "name", "action", "id", "match", "match2", "set") - ); + return $this->searchBase('routemaps.routemap'); } public function getRoutemapAction($uuid = null) { - $this->sessionClose(); return $this->getBase('routemap', 'routemaps.routemap', $uuid); } @@ -197,6 +162,31 @@ class BgpController extends ApiMutableModelControllerBase return $this->setBase('routemap', 'routemaps.routemap', $uuid); } + public function searchPeergroupAction() + { + return $this->searchBase('peergroups.peergroup'); + } + + public function getPeergroupAction($uuid = null) + { + return $this->getBase('peergroup', 'peergroups.peergroup', $uuid); + } + + public function addPeergroupAction() + { + return $this->addBase('peergroup', 'peergroups.peergroup'); + } + + public function delPeergroupAction($uuid) + { + return $this->delBase('peergroups.peergroup', $uuid); + } + + public function setPeergroupAction($uuid) + { + return $this->setBase('peergroup', 'peergroups.peergroup', $uuid); + } + public function toggleCommunitylistAction($uuid) { return $this->toggleBase('communitylists.communitylist', $uuid); @@ -221,4 +211,9 @@ class BgpController extends ApiMutableModelControllerBase { return $this->toggleBase('routemaps.routemap', $uuid); } + + public function togglePeergroupAction($uuid) + { + return $this->toggleBase('peergroups.peergroup', $uuid); + } } diff --git a/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/BgpController.php b/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/BgpController.php index 373d4bea4..0b34cfd6c 100644 --- a/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/BgpController.php +++ b/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/BgpController.php @@ -2,7 +2,7 @@ /* * Copyright (C) 2017 Fabian Franz - * Copyright (C) 2017-2020 Michael Muenz + * Copyright (C) 2017-2024 Michael Muenz * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -38,6 +38,7 @@ class BgpController extends \OPNsense\Base\IndexController $this->view->formDialogEditBGPPrefixLists = $this->getForm("dialogEditBGPPrefixLists"); $this->view->formDialogEditBGPCommunityLists = $this->getForm("dialogEditBGPCommunityLists"); $this->view->formDialogEditBGPRouteMaps = $this->getForm("dialogEditBGPRouteMaps"); + $this->view->formDialogEditBGPPeergroups = $this->getForm("dialogEditBGPPeergroups"); $this->view->pick('OPNsense/Quagga/bgp'); } } diff --git a/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/forms/bgp.xml b/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/forms/bgp.xml index 37b182e1a..8cb5f9759 100644 --- a/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/forms/bgp.xml +++ b/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/forms/bgp.xml @@ -11,6 +11,13 @@ text Your AS Number here + + bgp.distance + + text + true + BGP routes usually have an administrative distance of 20. Here you can adjust these values, e.g. when you want to prefer OSPF learned routes. + bgp.routerid diff --git a/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/forms/dialogEditBGPNeighbor.xml b/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/forms/dialogEditBGPNeighbor.xml index 4a30acbe7..7b326faec 100644 --- a/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/forms/dialogEditBGPNeighbor.xml +++ b/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/forms/dialogEditBGPNeighbor.xml @@ -169,4 +169,10 @@ dropdown Route-Map for outbound direction + + neighbor.peergroup + + dropdown + Peer Group this neighbor belongs to. + diff --git a/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/forms/dialogEditBGPPeergroups.xml b/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/forms/dialogEditBGPPeergroups.xml new file mode 100644 index 000000000..ea19cf0c0 --- /dev/null +++ b/net/frr/src/opnsense/mvc/app/controllers/OPNsense/Quagga/forms/dialogEditBGPPeergroups.xml @@ -0,0 +1,59 @@ +
+ + peergroup.enabled + + checkbox + + + peergroup.name + + text + Specify the name of this peergroup. + + + peergroup.remoteas + + text + Remote AS for tthis peergroup. + + + peergroup.updatesource + + dropdown + FRR documentation for more information.]]> + + + peergroup.nexthopself + + checkbox + + + peergroup.defaultoriginate + + checkbox + + + peergroup.linkedPrefixlistIn + + dropdown + Prefix-List for inbound direction. + + + peergroup.linkedPrefixlistOut + + dropdown + Prefix-List for outbound direction. + + + peergroup.linkedRoutemapIn + + dropdown + Route-Map for inbound direction. + + + peergroup.linkedRoutemapOut + + dropdown + Route-Map for outbound direction. + +
diff --git a/net/frr/src/opnsense/mvc/app/models/OPNsense/Quagga/BGP.xml b/net/frr/src/opnsense/mvc/app/models/OPNsense/Quagga/BGP.xml index 63f305963..a7239218e 100644 --- a/net/frr/src/opnsense/mvc/app/models/OPNsense/Quagga/BGP.xml +++ b/net/frr/src/opnsense/mvc/app/models/OPNsense/Quagga/BGP.xml @@ -1,7 +1,7 @@ //OPNsense/quagga/bgp BGP Routing configuration - 1.0.8 + 1.0.9 0 @@ -13,6 +13,10 @@ 1 4294967295 + + 1 + 255 + N /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/ @@ -60,8 +64,6 @@ Y - - Y 1 4294967295 @@ -211,7 +213,19 @@ N N - + + + + + Related Peer Group item not found + N + + @@ -395,5 +409,76 @@ + + + + 1 + Y + + + Y + + + Y + 1 + 4294967295 + + + Y + + /^(?!0).*$/ + /^(?!group).*$/ + + + + + + + + + Related Prefix-List item not found + + + + + + Related Prefix-List item not found + N + N + + + + + + Related Route-Map item not found + + + + + + Related Route-Map item not found + + + diff --git a/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/bgp.volt b/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/bgp.volt index 6fe6af7ac..82e62cfe6 100644 --- a/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/bgp.volt +++ b/net/frr/src/opnsense/mvc/app/views/OPNsense/Quagga/bgp.volt @@ -1,6 +1,6 @@ {# -OPNsense® is Copyright © 2014 – 2017 by Deciso B.V. +OPNsense® is Copyright © 2014 – 2024 by Deciso B.V. Copyright (C) 2017 Fabian Franz Copyright (C) 2017 - 2020 Michael Muenz All rights reserved. @@ -35,6 +35,7 @@ POSSIBILITY OF SUCH DAMAGE.
  • {{ lang._('Prefix Lists') }}
  • {{ lang._('Community Lists') }}
  • {{ lang._('Route Maps') }}
  • +
  • {{ lang._('Peer Groups') }}
  • @@ -51,13 +52,13 @@ POSSIBILITY OF SUCH DAMAGE. {{ lang._('Enabled') }} - {{ lang._('Description') }} - {{ lang._('Neighbor Address') }} - {{ lang._('Remote AS') }} - {{ lang._('Prefix List inbound') }} - {{ lang._('Prefix List outbound') }} - {{ lang._('Route Map inbound') }} - {{ lang._('Route Map outbound') }} + {{ lang._('Description') }} + {{ lang._('Neighbor Address') }} + {{ lang._('Remote AS') }} + {{ lang._('Prefix List inbound') }} + {{ lang._('Prefix List outbound') }} + {{ lang._('Route Map inbound') }} + {{ lang._('Route Map outbound') }} {{ lang._('ID') }} {{ lang._('Commands') }} @@ -81,10 +82,10 @@ POSSIBILITY OF SUCH DAMAGE. {{ lang._('Enabled') }} - {{ lang._('Description') }} - {{ lang._('Number') }} - {{ lang._('Action') }} - {{ lang._('AS Number') }} + {{ lang._('Description') }} + {{ lang._('Number') }} + {{ lang._('Action') }} + {{ lang._('AS Number') }} {{ lang._('ID') }} {{ lang._('Commands') }} @@ -108,11 +109,11 @@ POSSIBILITY OF SUCH DAMAGE. {{ lang._('Enabled') }} - {{ lang._('Name') }} - {{ lang._('Description') }} - {{ lang._('Sequence Number') }} - {{ lang._('Action') }} - {{ lang._('Network') }} + {{ lang._('Name') }} + {{ lang._('Description') }} + {{ lang._('Sequence Number') }} + {{ lang._('Action') }} + {{ lang._('Network') }} {{ lang._('ID') }} {{ lang._('Commands') }} @@ -136,11 +137,11 @@ POSSIBILITY OF SUCH DAMAGE. {{ lang._('Enabled') }} - {{ lang._('Number') }} - {{ lang._('Description') }} - {{ lang._('Secquence Number') }} - {{ lang._('Action') }} - {{ lang._('Community') }} + {{ lang._('Number') }} + {{ lang._('Description') }} + {{ lang._('Secquence Number') }} + {{ lang._('Action') }} + {{ lang._('Community') }} {{ lang._('ID') }} {{ lang._('Commands') }} @@ -164,14 +165,14 @@ POSSIBILITY OF SUCH DAMAGE. {{ lang._('Enabled') }} - {{ lang._('Name') }} - {{ lang._('Description') }} - {{ lang._('Action') }} - {{ lang._('ID') }} - {{ lang._('AS Path List') }} - {{ lang._('Prefix List') }} - {{ lang._('Community List') }} - {{ lang._('Set') }} + {{ lang._('Name') }} + {{ lang._('Description') }} + {{ lang._('Action') }} + {{ lang._('ID') }} + {{ lang._('AS Path List') }} + {{ lang._('Prefix List') }} + {{ lang._('Community List') }} + {{ lang._('Set') }} {{ lang._('ID') }} {{ lang._('Commands') }} @@ -189,6 +190,35 @@ POSSIBILITY OF SUCH DAMAGE.
    +
    + + + + + + + + + + + + + + + + + + + + + + + +
    {{ lang._('Enabled') }}{{ lang._('Name') }}{{ lang._('Next Hop Self') }}{{ lang._('Default Originate') }}{{ lang._('Prefix List inbound') }}{{ lang._('Prefix List outbound') }}{{ lang._('Route Map inbound') }}{{ lang._('Route Map outbound') }}{{ lang._('ID') }}{{ lang._('Commands') }}
    + + +
    +
    @@ -283,3 +323,4 @@ $(document).ready(function() { {{ 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')])}} +{{ partial("layout_partials/base_dialog",['fields':formDialogEditBGPPeergroups,'id':'DialogEditBGPPeergroups','label':lang._('Edit Peer Groups')])}} diff --git a/net/frr/src/opnsense/service/templates/OPNsense/Quagga/bgpd.conf b/net/frr/src/opnsense/service/templates/OPNsense/Quagga/bgpd.conf index ef975a7f3..12fc2b9a7 100644 --- a/net/frr/src/opnsense/service/templates/OPNsense/Quagga/bgpd.conf +++ b/net/frr/src/opnsense/service/templates/OPNsense/Quagga/bgpd.conf @@ -59,10 +59,65 @@ router bgp {{ OPNsense.quagga.bgp.asnumber }} {% if helpers.exists('OPNsense.quagga.bgp.routerid') and OPNsense.quagga.bgp.routerid != '' %} bgp router-id {{ OPNsense.quagga.bgp.routerid }} {% endif %} +{% if helpers.exists('OPNsense.quagga.bgp.distance') and OPNsense.quagga.bgp.distance != '' %} + distance bgp {{ OPNsense.quagga.bgp.distance }} {{ OPNsense.quagga.bgp.distance }} {{ OPNsense.quagga.bgp.distance }} +{% endif %} +{% for peergroup in helpers.toList('OPNsense.quagga.bgp.peergroups.peergroup') %} +{% if peergroup.enabled == '1' %} + neighbor {{ peergroup.name }} peer-group +{% if 'remoteas' in peergroup and peergroup.remoteas != '' %} + neighbor {{ peergroup.name }} remote-as {{ peergroup.remoteas }} +{% endif %} +{% if peergroup.updatesource|default('0') == '1' %} + neighbor {{ peergroup.name }} update-source {{ physical_interface(peergroup.updatesource) }} +{% endif %} + neighbor {{ peergroup.name }} activate +{% if peergroup.nexthopself|default('0') == '1' %} + neighbor {{ peergroup.name }} next-hop-self +{% endif %} +{% if peergroup.defaultoriginate|default('0') == '1' %} + neighbor {{ peergroup.name }} default-originate +{% endif %} +{% if peergroup.linkedPrefixlistIn|default("") != "" %} +{% for prefixlist in peergroup.linkedPrefixlistIn.split(",") %} +{% set prefixlist2_data = helpers.getUUID(prefixlist) %} +{% if prefixlist2_data != {} and prefixlist2_data.enabled == '1' %} + neighbor {{ peergroup.name }} prefix-list {{ prefixlist2_data.name }} in +{% endif %} +{% endfor %} +{% endif %} +{% if peergroup.linkedPrefixlistOut|default("") != "" %} +{% for prefixlist in peergroup.linkedPrefixlistOut.split(",") %} +{% set prefixlist_data = helpers.getUUID(prefixlist) %} +{% if prefixlist_data != {} and prefixlist_data.enabled == '1' %} + neighbor {{ peergroup.name }} prefix-list {{ prefixlist_data.name }} out +{% endif %} +{% endfor %} +{% endif %} +{% if peergroup.linkedRoutemapIn|default("") != "" %} +{% for aspath in peergroup.linkedRoutemapIn.split(",") %} +{% set routemap2_data = helpers.getUUID(aspath) %} +{% if routemap2_data != {} and routemap2_data.enabled == '1' %} + neighbor {{ peergroup.name }} route-map {{ routemap2_data.name }} in +{% endif %} +{% endfor %} +{% endif %} +{% if peergroup.linkedRoutemapOut|default("") != "" %} +{% for aspath in peergroup.linkedRoutemapOut.split(",") %} +{% set routemap_data = helpers.getUUID(aspath) %} +{% if routemap_data != {} and routemap_data.enabled == '1' %} + neighbor {{ peergroup.name }} route-map {{ routemap_data.name }} out +{% endif %} +{% endfor %} +{% endif %} +{% endif %} +{% endfor %} {% if helpers.exists('OPNsense.quagga.bgp.neighbors.neighbor') %} {% for neighbor in helpers.toList('OPNsense.quagga.bgp.neighbors.neighbor') %} {% if neighbor.enabled == '1' %} +{% if 'remoteas' in neighbor and neighbor.remoteas != '' %} neighbor {{ neighbor.address }} remote-as {{ neighbor.remoteas }} +{% endif %} {% if neighbor.bfd|default('') == '1' %} neighbor {{ neighbor.address }} bfd {% endif %} @@ -95,6 +150,10 @@ router bgp {{ OPNsense.quagga.bgp.asnumber }} {% if 'attributeunchanged' in neighbor and neighbor.attributeunchanged != '' %} neighbor {{ neighbor.address }} attribute-unchanged {{ neighbor.attributeunchanged }} {% endif %} +{% if neighbor.peergroup|default('') != '' %} +{% set pgname = helpers.getUUID(neighbor.peergroup) %} + neighbor {{ neighbor.address }} peer-group {{ pgname.name }} +{% endif %} {% endif %} {% endfor %} {% endif %}