diff --git a/bird/parser.go b/bird/parser.go index aaf41e7..717922a 100644 --- a/bird/parser.go +++ b/bird/parser.go @@ -323,7 +323,7 @@ func parseRouteLines(lines []string, position int, ch chan<- blockParsed) { joinLines := func() { for c := i+1; c < len(lines); c++ { if strings.HasPrefix(lines[c], "\x09\x09") { - line += lines[c][3:] + line += lines[c][2:] i++ } else { break diff --git a/bird/parser_test.go b/bird/parser_test.go index 81d5bc2..54d93cd 100644 --- a/bird/parser_test.go +++ b/bird/parser_test.go @@ -93,8 +93,56 @@ func runTestForIpv4WithFile(file string, t *testing.T) { gateway: "1.2.3.16", asPath: []string{"1340"}, community: [][]int64{ - {65011, 3}, - {9033, 3251}, + {0, 5464}, + {0, 8339}, + {0, 8741}, + {0, 8823}, + {0, 12387}, + {0, 13101}, + {0, 16097}, + {0, 16316}, + {0, 20546}, + {0, 20686}, + {0, 20723}, + {0, 21083}, + {0, 21385}, + {0, 24940}, + {0, 25504}, + {0, 28876}, + {0, 29545}, + {0, 30058}, + {0, 31103}, + {0, 31400}, + {0, 39090}, + {0, 39392}, + {0, 39912}, + {0, 42473}, + {0, 43957}, + {0, 44453}, + {0, 47297}, + {0, 47692}, + {0, 48200}, + {0, 50629}, + {0, 51191}, + {0, 51839}, + {0, 51852}, + {0, 54113}, + {0, 56719}, + {0, 57957}, + {0, 60517}, + {0, 60574}, + {0, 61303}, + {0, 62297}, + {0, 62336}, + {0, 62359}, + {33891, 33892}, + {33891, 50673}, + {48793, 48793}, + {50673, 500}, + {65101, 11077}, + {65102, 11000}, + {65103, 724}, + {65104, 150}, }, largeCommunities: [][]int64{ {9033, 65666, 12}, @@ -208,8 +256,56 @@ func runTestForIpv6WithFile(file string, t *testing.T) { gateway: "fe80:ffff:ffff::1", asPath: []string{"15169"}, community: [][]int64{ - {9033, 3001}, - {65000, 680}, + {0, 5464}, + {0, 8339}, + {0, 8741}, + {0, 8823}, + {0, 12387}, + {0, 13101}, + {0, 16097}, + {0, 16316}, + {0, 20546}, + {0, 20686}, + {0, 20723}, + {0, 21083}, + {0, 21385}, + {0, 24940}, + {0, 25504}, + {0, 28876}, + {0, 29545}, + {0, 30058}, + {0, 31103}, + {0, 31400}, + {0, 39090}, + {0, 39392}, + {0, 39912}, + {0, 42473}, + {0, 43957}, + {0, 44453}, + {0, 47297}, + {0, 47692}, + {0, 48200}, + {0, 50629}, + {0, 51191}, + {0, 51839}, + {0, 51852}, + {0, 54113}, + {0, 56719}, + {0, 57957}, + {0, 60517}, + {0, 60574}, + {0, 61303}, + {0, 62297}, + {0, 62336}, + {0, 62359}, + {33891, 33892}, + {33891, 50673}, + {48793, 48793}, + {50673, 500}, + {65101, 11077}, + {65102, 11000}, + {65103, 724}, + {65104, 150}, }, largeCommunities: [][]int64{ {48821, 0, 2000}, diff --git a/test/routes_bird1_ipv4.sample b/test/routes_bird1_ipv4.sample index 8689cce..e56318c 100644 --- a/test/routes_bird1_ipv4.sample +++ b/test/routes_bird1_ipv4.sample @@ -5,7 +5,8 @@ BIRD 1.6.3 ready. BGP.as_path: 1340 BGP.next_hop: 1.2.3.16 BGP.local_pref: 100 - BGP.community: (65011,3) (9033,3251) + BGP.community: (0,5464) (0,8339) (0,8741) (0,8823) (0,12387) (0,13101) (0,16097) (0,16316) (0,20546) (0,20686) (0,20723) (0,21083) (0,21385) (0,24940) (0,25504) (0,28876) (0,29545) (0,30058) (0,31103) (0,31400) (0,39090) (0,39392) (0,39912) (0,42473) (0,43957) (0,44453) (0,47297) (0,47692) (0,48200) (0,50629) (0,51191) (0,51839) (0,51852) (0,54113) (0,56719) (0,57957) (0,60517) (0,60574) (0,61303) (0,62297) (0,62336) (0,62359) (33891,33892) (33891,50673) (48793,48793) (50673,500) + (65101,11077) (65102,11000) (65103,724) (65104,150) BGP.large_community: (9033, 65666, 12) (9033, 65666, 9) BGP.ext_community: (rt, 48858, 50) 200.0.0.0/24 via 1.2.3.15 on eno7 [ID8497_AS1339 2017-06-21 08:17:31] * (100) [AS1339i] diff --git a/test/routes_bird1_ipv6.sample b/test/routes_bird1_ipv6.sample index 1f52769..246cc53 100644 --- a/test/routes_bird1_ipv6.sample +++ b/test/routes_bird1_ipv6.sample @@ -1,30 +1,31 @@ BIRD 1.6.3 ready. 2001:4860::/32 via fe80:ffff:ffff::1 on eth2 [upstream1 2018-01-14 14:32:47 from fe80:ffff:ffff::1] * (100) [AS15169i] - Type: BGP unicast univ - BGP.origin: IGP - BGP.as_path: 15169 - BGP.next_hop: fe80:ffff:ffff::1 - BGP.med: 0 - BGP.local_pref: 500 - BGP.community: (9033,3001) (65000,680) - BGP.large_community: (48821, 0, 2000) (48821, 0, 2100) - BGP.ext_community: (ro, 21414, 52001) (ro, 21414, 52004) (ro, 21414, 64515) - via fe80:ffff:ffff::2 on eth3 [upstream2 2018-01-14 14:33:52] (100) [AS15169i] - Type: BGP unicast univ - BGP.origin: IGP - BGP.as_path: 50629 15169 - BGP.next_hop: fe80:ffff:ffff::2 - BGP.med: 71 - BGP.local_pref: 100 - BGP.community: (50629,200) (50629,201) - BGP.large_community: (48821, 0, 3000) (48821, 0, 3100) - BGP.ext_community: (ro, 21414, 52001) (ro, 21414, 52004) (ro, 21414, 64515) + Type: BGP unicast univ + BGP.origin: IGP + BGP.as_path: 15169 + BGP.next_hop: fe80:ffff:ffff::1 + BGP.med: 0 + BGP.local_pref: 500 + BGP.community: (0,5464) (0,8339) (0,8741) (0,8823) (0,12387) (0,13101) (0,16097) (0,16316) (0,20546) (0,20686) (0,20723) (0,21083) (0,21385) (0,24940) (0,25504) (0,28876) (0,29545) (0,30058) (0,31103) (0,31400) (0,39090) (0,39392) (0,39912) (0,42473) (0,43957) (0,44453) (0,47297) (0,47692) (0,48200) (0,50629) (0,51191) (0,51839) (0,51852) (0,54113) (0,56719) (0,57957) (0,60517) (0,60574) (0,61303) (0,62297) (0,62336) (0,62359) (33891,33892) (33891,50673) (48793,48793) (50673,500) + (65101,11077) (65102,11000) (65103,724) (65104,150) + BGP.large_community: (48821, 0, 2000) (48821, 0, 2100) + BGP.ext_community: (ro, 21414, 52001) (ro, 21414, 52004) (ro, 21414, 64515) + via fe80:ffff:ffff::2 on eth3 [upstream2 2018-01-14 14:33:52] (100) [AS15169i] + Type: BGP unicast univ + BGP.origin: IGP + BGP.as_path: 50629 15169 + BGP.next_hop: fe80:ffff:ffff::2 + BGP.med: 71 + BGP.local_pref: 100 + BGP.community: (50629,200) (50629,201) + BGP.large_community: (48821, 0, 3000) (48821, 0, 3100) + BGP.ext_community: (ro, 21414, 52001) (ro, 21414, 52004) (ro, 21414, 64515) 2001:678:1e0::/48 via fe80:ffff:ffff::2 on eth2 [upstream2 2018-01-14 15:04:17 from 2001:678:1e0::2] * (100) [AS202739i] - Type: BGP unicast univ - BGP.origin: IGP - BGP.as_path: 202739 - BGP.next_hop: 2001:678:1e0::2 - BGP.local_pref: 5000 - BGP.community: (48821,2000) (48821,2100) - BGP.large_community: (48821, 0, 2000) (48821, 0, 2100) - BGP.ext_community: (unknown 0x4300, 0, 1) + Type: BGP unicast univ + BGP.origin: IGP + BGP.as_path: 202739 + BGP.next_hop: 2001:678:1e0::2 + BGP.local_pref: 5000 + BGP.community: (48821,2000) (48821,2100) + BGP.large_community: (48821, 0, 2000) (48821, 0, 2100) + BGP.ext_community: (unknown 0x4300, 0, 1) diff --git a/test/routes_bird2_ipv4.sample b/test/routes_bird2_ipv4.sample index 71d7ef3..a566130 100644 --- a/test/routes_bird2_ipv4.sample +++ b/test/routes_bird2_ipv4.sample @@ -6,7 +6,8 @@ BIRD 1.6.3 ready. BGP.as_path: 1340 BGP.next_hop: 1.2.3.16 BGP.local_pref: 100 - BGP.community: (65011,3) (9033,3251) + BGP.community: (0,5464) (0,8339) (0,8741) (0,8823) (0,12387) (0,13101) (0,16097) (0,16316) (0,20546) (0,20686) (0,20723) (0,21083) (0,21385) (0,24940) (0,25504) (0,28876) (0,29545) (0,30058) (0,31103) (0,31400) (0,39090) (0,39392) (0,39912) (0,42473) (0,43957) (0,44453) (0,47297) (0,47692) (0,48200) (0,50629) (0,51191) (0,51839) (0,51852) (0,54113) (0,56719) (0,57957) (0,60517) (0,60574) (0,61303) (0,62297) (0,62336) (0,62359) (33891,33892) (33891,50673) (48793,48793) (50673,500) + (65101,11077) (65102,11000) (65103,724) (65104,150) BGP.large_community: (9033, 65666, 12) (9033, 65666, 9) BGP.ext_community: (rt, 48858, 50) 200.0.0.0/24 unicast [ID8497_AS1339 2017-06-21 08:17:31] * (100) [AS1339i] diff --git a/test/routes_bird2_ipv6.sample b/test/routes_bird2_ipv6.sample index e6c864c..02dd130 100644 --- a/test/routes_bird2_ipv6.sample +++ b/test/routes_bird2_ipv6.sample @@ -7,7 +7,8 @@ BIRD 2.0.0 ready. BGP.next_hop: fe80:ffff:ffff::1 BGP.med: 0 BGP.local_pref: 500 - BGP.community: (9033,3001) (65000,680) + BGP.community: (0,5464) (0,8339) (0,8741) (0,8823) (0,12387) (0,13101) (0,16097) (0,16316) (0,20546) (0,20686) (0,20723) (0,21083) (0,21385) (0,24940) (0,25504) (0,28876) (0,29545) (0,30058) (0,31103) (0,31400) (0,39090) (0,39392) (0,39912) (0,42473) (0,43957) (0,44453) (0,47297) (0,47692) (0,48200) (0,50629) (0,51191) (0,51839) (0,51852) (0,54113) (0,56719) (0,57957) (0,60517) (0,60574) (0,61303) (0,62297) (0,62336) (0,62359) (33891,33892) (33891,50673) (48793,48793) (50673,500) + (65101,11077) (65102,11000) (65103,724) (65104,150) BGP.large_community: (48821, 0, 2000) (48821, 0, 2100) BGP.ext_community: (ro, 21414, 52001) (ro, 21414, 52004) (ro, 21414, 64515) unicast [upstream2 2018-01-14 13:07:26 from fe80:ffff:ffff::2] (100/?) [AS15169i]