Skip to content

Commit 806f701

Browse files
committed
BGP Confederation plugin
Minimal skeleton for discussion * Should BGP confederation peers be defined as a new type of neighbor? (e.g. `confed`)
1 parent b380d17 commit 806f701

File tree

5 files changed

+93
-0
lines changed

5 files changed

+93
-0
lines changed

docs/module/bgp.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Even more BGP features are implemented in the following plugins:
5050
* [bgp.originate](../plugins/bgp.originate.md): creates loopback interfaces instead of static routes to originate additional IPv4 or IPv6 prefixes
5151
* [ebgp.multihop](../plugins/ebgp.multihop.md): implements multihop EBGP sessions.
5252
* [bgp.domain](../plugins/bgp.domain.md): allows you to build topologies that reuse the same BGP ASN in different network parts.
53+
* [bgp.confederation](../plugins/bgp.confederation.md): allows you to configure BGP confederations.
5354

5455
(bgp-platform)=
5556
## Platform Support
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
bgp:
3+
no_propagate:
4+
confederation:
5+
attributes:
6+
_confed_members:
7+
members:
8+
type: list
9+
_required: True
10+
_subtype: asn
11+
# Future: potential route maps, policies, settings etc. associated with the confederation
12+
13+
global:
14+
confederation:
15+
type: dict
16+
_keytype: asn
17+
_subtype: _confed_members
18+
19+
devices:
20+
frr.features.bgp.confederation: True
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
!
2+
router bgp {{ bgp.as }}
3+
bgp confederation identifier {{ bgp.confederation.as }}
4+
bgp confederation peers {{ bgp.confederation.peers|join(' ') }}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import typing
2+
from box import Box
3+
from netsim import api
4+
from netsim.utils import log
5+
6+
_config_name = 'bgp.confederation'
7+
_requires = [ 'bgp' ]
8+
9+
def post_transform(topology: Box) -> None:
10+
global _config_name
11+
confed = topology.get('bgp.confederation')
12+
if not confed:
13+
return
14+
15+
for n, ndata in topology.nodes.items():
16+
if 'bgp' not in ndata.module: # Skip nodes not running BGP
17+
continue
18+
19+
bgp_as = ndata.get('bgp.as')
20+
for casn,cdata in confed.items():
21+
members = cdata.get('members',[])
22+
if bgp_as in members:
23+
ndata.bgp.confederation['as'] = casn
24+
ndata.bgp.confederation.peers = [ m for m in members if m!=bgp_as ]
25+
api.node_config(ndata,_config_name) # Remember that we have to do extra configuration
26+
27+
for nb in ndata.get('bgp.neighbors',[]): # Update remote AS used by ebgp peers
28+
neighbor = topology.nodes[ nb.name ]
29+
for nb2 in neighbor.get('bgp.neighbors',[]):
30+
if nb2.name == n and nb2.type=='ebgp':
31+
nb2['as'] = casn
32+
33+
# TODO: Apply ibgp type community exchange, confed is really a new type of ebgp peer
34+
35+
break
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
plugin: [ bgp.confederation ]
3+
module: [ bgp ]
4+
5+
bgp.confederation:
6+
65000:
7+
members: [ 65001, 65002 ]
8+
9+
groups:
10+
_auto_create: True
11+
12+
confed:
13+
members: [ c1, c2 ]
14+
15+
ext:
16+
members: [ e1 ]
17+
device: frr
18+
provider: clab
19+
20+
nodes:
21+
c1:
22+
bgp.as: 65001
23+
c2:
24+
bgp.as: 65002
25+
device: frr
26+
provider: clab
27+
e1:
28+
bgp.as: 65003
29+
30+
links:
31+
- c1-c2
32+
- c1-e1
33+
- c2-e1

0 commit comments

Comments
 (0)