Skip to content

Commit 5c1cab8

Browse files
DerDennisOPfelbinger
authored andcommitted
tests/bgp-simple: add gobgp
1 parent 155464e commit 5c1cab8

File tree

2 files changed

+111
-4
lines changed

2 files changed

+111
-4
lines changed

tests/bgp-simple/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
This configuration sets up a simple BGP test environment with two nodes.
44

55
Node a runs FRRouting (FRR) as a BGP speaker with IPv4 and IPv6 addresses on interface
6-
eth1, while node b runs the BIRD routing daemon configured similarly. Both nodes establish
6+
eth1, while node b runs the BIRD and node c the GoBGP routing daemon configured similarly. All nodes establish
77
BGP peering over IPv4 and IPv6 with each other.

tests/bgp-simple/default.nix

Lines changed: 110 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ ... }:
1+
{ pkgs, ... }:
22
{
33
name = "bgp-simple";
44

@@ -12,7 +12,7 @@
1212
ipv4.addresses = [
1313
{
1414
address = "192.0.2.1";
15-
prefixLength = 30;
15+
prefixLength = 29;
1616
}
1717
];
1818
ipv6.addresses = [
@@ -33,12 +33,17 @@
3333
neighbor 192.0.2.2 remote-as 64497
3434
neighbor 2001:db8::2 remote-as 64497
3535
36+
neighbor 192.0.2.3 remote-as 64498
37+
neighbor 2001:db8::3 remote-as 64498
38+
3639
address-family ipv4 unicast
3740
neighbor 192.0.2.2 activate
41+
neighbor 192.0.2.3 activate
3842
exit-address-family
3943
4044
address-family ipv6 unicast
4145
neighbor 2001:db8::2 activate
46+
neighbor 2001:db8::3 activate
4247
exit-address-family
4348
'';
4449
};
@@ -48,7 +53,7 @@
4853
ipv4.addresses = [
4954
{
5055
address = "192.0.2.2";
51-
prefixLength = 30;
56+
prefixLength = 29;
5257
}
5358
];
5459
ipv6.addresses = [
@@ -106,6 +111,16 @@
106111
};
107112
}
108113
114+
protocol bgp c_v4 {
115+
local as 64497;
116+
neighbor 192.0.2.3 as 64498;
117+
118+
ipv4 {
119+
import all;
120+
export all;
121+
};
122+
}
123+
109124
protocol bgp a_v6 {
110125
local as 64497;
111126
neighbor 2001:db8::1 as 64496;
@@ -115,25 +130,117 @@
115130
export all;
116131
};
117132
}
133+
134+
protocol bgp c_v6 {
135+
local as 64497;
136+
neighbor 2001:db8::3 as 64498;
137+
138+
ipv6 {
139+
import all;
140+
export all;
141+
};
142+
}
118143
'';
119144
};
120145
};
146+
c = {
147+
environment.systemPackages = with pkgs; [ gobgp ];
148+
networking.interfaces.eth1 = {
149+
ipv4.addresses = [
150+
{
151+
address = "192.0.2.3";
152+
prefixLength = 29;
153+
}
154+
];
155+
ipv6.addresses = [
156+
{
157+
address = "2001:db8::3";
158+
prefixLength = 64;
159+
}
160+
];
161+
};
162+
services.gobgpd = {
163+
enable = true;
164+
settings = {
165+
global.config = {
166+
as = 64498;
167+
router-id = "192.0.2.3";
168+
};
169+
neighbors = [
170+
{
171+
config = {
172+
neighbor-address = "192.0.2.1";
173+
peer-as = 64496;
174+
};
175+
afi-safis = [
176+
{
177+
config.afi-safi-name = "ipv4-unicast";
178+
}
179+
];
180+
}
181+
{
182+
config = {
183+
neighbor-address = "192.0.2.2";
184+
peer-as = 64497;
185+
};
186+
afi-safis = [
187+
{
188+
config.afi-safi-name = "ipv4-unicast";
189+
}
190+
];
191+
}
192+
{
193+
config = {
194+
neighbor-address = "2001:db8::1";
195+
peer-as = 64496;
196+
};
197+
afi-safis = [
198+
{
199+
config.afi-safi-name = "ipv6-unicast";
200+
}
201+
];
202+
}
203+
{
204+
config = {
205+
neighbor-address = "2001:db8::2";
206+
peer-as = 64497;
207+
};
208+
afi-safis = [
209+
{
210+
config.afi-safi-name = "ipv6-unicast";
211+
}
212+
];
213+
}
214+
];
215+
};
216+
};
217+
};
121218
};
122219

123220
testScript = ''
124221
start_all()
125222
126223
a.wait_for_unit("network.target")
127224
b.wait_for_unit("network.target")
225+
c.wait_for_unit("network.target")
128226
129227
a.wait_for_unit("frr.service")
130228
b.wait_for_unit("bird.service")
229+
c.wait_for_unit("gobgpd.service")
131230
132231
a.wait_until_succeeds("vtysh -c 'show bgp ipv4 summary' | grep '192.0.2.2.*0\\s*0\\s*N/A'")
232+
a.wait_until_succeeds("vtysh -c 'show bgp ipv4 summary' | grep '192.0.2.3.*0\\s*0\\s*N/A'")
133233
b.wait_until_succeeds("birdc show protocols | grep 'a_v4.*Established'")
234+
b.wait_until_succeeds("birdc show protocols | grep 'c_v4.*Established'")
235+
c.wait_until_succeeds("gobgp neighbor -a 'ipv4' | grep '192.0.2.1.*Establ'")
236+
c.wait_until_succeeds("gobgp neighbor -a 'ipv4' | grep '192.0.2.2.*Establ'")
134237
135238
# IPv6 DAD might need some time to complete for the local link address, which is required by frr
136239
a.wait_until_succeeds("vtysh -c 'show bgp ipv6 summary' | grep '2001:db8::2.*0\\s*0\\s*N/A'")
240+
a.wait_until_succeeds("vtysh -c 'show bgp ipv6 summary' | grep '2001:db8::3.*0\\s*0\\s*N/A'")
137241
b.wait_until_succeeds("birdc show protocols | grep 'a_v6.*Established'")
242+
b.wait_until_succeeds("birdc show protocols | grep 'c_v4.*Established'")
243+
c.wait_until_succeeds("gobgp neighbor -a 'ipv6' | grep '2001:db8::1.*Establ'")
244+
c.wait_until_succeeds("gobgp neighbor -a 'ipv6' | grep '2001:db8::2.*Establ'")
138245
'';
139246
}

0 commit comments

Comments
 (0)