Skip to content

Commit f9ed607

Browse files
authored
Fix: Add VRF information to BGP neighbor data (ipspace#2639)
1 parent 34fe4a1 commit f9ed607

File tree

6 files changed

+32
-14
lines changed

6 files changed

+32
-14
lines changed

netsim/modules/bgp.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ def build_ebgp_sessions(node: Box, sessions: Box, topology: Box) -> None:
304304
extra_data.ifindex = l.ifindex
305305
if 'bgp' in ngb_ifdata and isinstance(ngb_ifdata.bgp,Box): # Copy neighbor BGP interface attributes into neighbor data
306306
extra_data = ngb_ifdata.bgp + extra_data # ... useful for things like BGP roles
307+
if isinstance(ngb_ifdata.get('vrf',None),str): # Are we attached to the neighbor's VRF?
308+
extra_data._vrf = ngb_ifdata.vrf
307309

308310
# Figure out whether both neighbors have IPv6 LLA and/or unnumbered IPv4 interfaces
309311
#

tests/topology/expected/bgp-vrf-local-as.yml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ nodes:
236236
connected:
237237
auto: true
238238
neighbors:
239-
- activate:
239+
- _vrf: blue
240+
activate:
240241
ipv4: true
241242
as: 65000
242243
ifindex: 2
@@ -258,7 +259,8 @@ nodes:
258259
connected:
259260
auto: true
260261
neighbors:
261-
- activate:
262+
- _vrf: red
263+
activate:
262264
ipv4: true
263265
as: 65000
264266
ifindex: 3
@@ -495,22 +497,25 @@ nodes:
495497
connected:
496498
auto: true
497499
neighbors:
498-
- activate:
500+
- _vrf: red
501+
activate:
499502
ipv4: true
500503
as: 65001
501504
ifindex: 4
502505
ipv4: 10.1.0.1
503506
local_as: 65002
504507
name: r2
505508
type: ebgp
506-
- activate:
509+
- _vrf: blue
510+
activate:
507511
ipv4: true
508512
as: 65100
509513
ifindex: 5
510514
ipv4: 10.1.0.5
511515
name: r1
512516
type: ebgp
513-
- activate:
517+
- _vrf: blue
518+
activate:
514519
ipv4: true
515520
as: 65101
516521
ifindex: 7
@@ -533,22 +538,25 @@ nodes:
533538
connected:
534539
auto: true
535540
neighbors:
536-
- activate:
541+
- _vrf: blue
542+
activate:
537543
ipv4: true
538544
as: 65002
539545
ifindex: 3
540546
ipv4: 10.1.0.2
541547
local_as: 65001
542548
name: r2
543549
type: ebgp
544-
- activate:
550+
- _vrf: red
551+
activate:
545552
ipv4: true
546553
as: 65100
547554
ifindex: 6
548555
ipv4: 10.1.0.9
549556
name: r1
550557
type: ebgp
551-
- activate:
558+
- _vrf: red
559+
activate:
552560
ipv4: true
553561
as: 65101
554562
ifindex: 8
@@ -690,7 +698,8 @@ nodes:
690698
connected:
691699
auto: true
692700
neighbors:
693-
- activate:
701+
- _vrf: blue
702+
activate:
694703
ipv4: true
695704
as: 65000
696705
ifindex: 2
@@ -712,7 +721,8 @@ nodes:
712721
connected:
713722
auto: true
714723
neighbors:
715-
- activate:
724+
- _vrf: red
725+
activate:
716726
ipv4: true
717727
as: 65000
718728
ifindex: 3

tests/topology/expected/ebgp.utils.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ nodes:
303303
auto: true
304304
neighbors:
305305
- _src_vrf: red
306+
_vrf: red
306307
activate:
307308
ipv4: true
308309
as: 65002
@@ -455,6 +456,7 @@ nodes:
455456
auto: true
456457
neighbors:
457458
- _src_vrf: red
459+
_vrf: red
458460
activate:
459461
ipv4: true
460462
allowas_in: 1

tests/topology/expected/vrf-igp.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,8 @@ nodes:
666666
- extended
667667
ipv4: true
668668
neighbors:
669-
- activate:
669+
- _vrf: red
670+
activate:
670671
ipv4: true
671672
as: 65000
672673
ifindex: 1

tests/topology/expected/vrf-routing-blocks.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,8 @@ nodes:
406406
connected:
407407
auto: true
408408
neighbors:
409-
- activate:
409+
- _vrf: b_1
410+
activate:
410411
ipv4: true
411412
as: 65001
412413
ifindex: 7
@@ -1080,7 +1081,8 @@ nodes:
10801081
connected:
10811082
auto: true
10821083
neighbors:
1083-
- activate:
1084+
- _vrf: b_1
1085+
activate:
10841086
ipv4: true
10851087
as: 65000
10861088
ifindex: 1

tests/topology/expected/vrf.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,8 @@ nodes:
294294
ipv4: true
295295
ipv6: true
296296
neighbors:
297-
- activate:
297+
- _vrf: red
298+
activate:
298299
ipv4: true
299300
ipv6: true
300301
as: 65000

0 commit comments

Comments
 (0)