Skip to content

Commit f047256

Browse files
committed
BGP Large Communities Support
1 parent c4fc8e3 commit f047256

File tree

5 files changed

+52
-3
lines changed

5 files changed

+52
-3
lines changed

app/Bird/Parser/Routes.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ public function __contrust( $data ) {
1313
}
1414

1515
public function parse() {
16-
1716
$routes = [];
1817
$r = [];
1918
$matches = [];
@@ -104,6 +103,16 @@ public function parse() {
104103
}
105104
}
106105
}
106+
else if( preg_match( "/^\s+BGP.large_community:\s+(.+)\s*$/", $line, $matches ) ) {
107+
// BGP.large_community: (999, 1, 111)
108+
// BGP.large_community: (999, 1, 111) (999, 156, 111) (999, 157, 111)
109+
$m = substr( trim( $matches[1] ), 1, -1 );
110+
foreach( explode( ') (', $m ) as $community ) {
111+
if( preg_match( "/^(\d+),\s*(\d+),\s*(\d+)/", trim( $community ), $matches ) ) {
112+
$r['bgp']['large_communities'][] = [ intval( $matches[1] ), intval( $matches[2] ), intval( $matches[3] ) ];
113+
}
114+
}
115+
}
107116
}
108117

109118
// catche the last one:

data/bird-lab/ipv4/rs.conf

+14
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@ protocol bgp R111x1 from PEERS {
3131
source address 192.0.2.100;
3232
neighbor 192.0.2.111 as 111;
3333
table t_R111x1;
34+
35+
import filter {
36+
if ! ( net ~ 172.19.1.0/24 ) then {
37+
bgp_community.add((999,111));
38+
bgp_large_community.add((999,1,111));
39+
}
40+
41+
if ( net ~ 172.17.1.0/24 ) then {
42+
bgp_large_community.add((999,156,111));
43+
bgp_large_community.add((999,157,111));
44+
}
45+
46+
accept;
47+
};
3448
}
3549

3650
### AS222 - Member1

resources/views/lg/route.blade.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,17 @@
9898
<td><strong>BGP :: Communities</strong></td>
9999
<td>
100100
@foreach( $r->bgp->communities as $c )
101-
({{implode(',',$c)}})
101+
({{implode(', ',$c)}})
102+
@endforeach
103+
</td>
104+
</tr>
105+
@endif
106+
@if (isset( $r->bgp->large_communities ))
107+
<tr>
108+
<td><strong>BGP :: Large Communities</strong></td>
109+
<td>
110+
@foreach( $r->bgp->large_communities as $c )
111+
({{implode(', ',$c)}})
102112
@endforeach
103113
</td>
104114
</tr>

resources/views/lg/routes.blade.php

+16
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<th>Next Hop</th>
1414
<th></th>
1515
<th>Metric</th>
16+
<th>Communities?</th>
1617
<th>AS Path</th>
1718
<th></th>
1819
</tr>
@@ -39,6 +40,21 @@
3940
@endif
4041
</td>
4142
<td>{{$r->metric}}</td>
43+
<td>
44+
<span class="badge">
45+
@if( isset( $r->bgp->communities ) )
46+
{{ count( $r->bgp->communities ) }}
47+
@else
48+
0
49+
@endif
50+
</span>
51+
52+
@if( isset( $r->bgp->large_communities ) )
53+
<span class="badge">LC:
54+
{{ count( $r->bgp->large_communities ) }}
55+
</span>
56+
@endif
57+
</td>
4258
<td>
4359
@if( isset($r->bgp->as_path) )
4460
{{implode(' ', $r->bgp->as_path)}}

version.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<?php
22

3-
$_ENV['BIRDSEYE_API_VERSION'] = '1.0.5';
3+
$_ENV['BIRDSEYE_API_VERSION'] = '1.1.0';

0 commit comments

Comments
 (0)