Skip to content

Commit 9cde550

Browse files
committed
tests/bgp-simple: GoGBP with Zebra Integration
1 parent a28d94d commit 9cde550

File tree

1 file changed

+115
-74
lines changed

1 file changed

+115
-74
lines changed

tests/bgp-simple/default.nix

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

@@ -27,7 +27,6 @@
2727
config = ''
2828
ip route 198.51.100.0/25 reject
2929
ipv6 route 2001:db8:beef::/48 reject
30-
3130
router bgp 64496
3231
no bgp ebgp-requires-policy
3332
no bgp default ipv4-unicast
@@ -184,59 +183,100 @@
184183
];
185184
};
186185
};
187-
services.gobgpd = {
188-
enable = true;
189-
settings = {
190-
global.config = {
191-
as = 64498;
192-
router-id = "192.0.2.3";
186+
users = {
187+
groups.gobgpd = { };
188+
users.gobgpd = {
189+
description = "GoBGP Daemon User";
190+
isSystemUser = true;
191+
group = "gobgpd";
192+
};
193+
};
194+
systemd = {
195+
services = {
196+
frr.postStart = "${pkgs.acl}/bin/setfacl -m u:gobgpd:rwx /run/frr/zserv.api";
197+
gobgpd = {
198+
after = [ "frr.service" ];
199+
serviceConfig = {
200+
DynamicUser = lib.mkForce false;
201+
User = "gobgpd";
202+
Group = "gobgpd";
203+
};
193204
};
194-
neighbors = [
195-
{
196-
config = {
197-
neighbor-address = "192.0.2.1";
198-
peer-as = 64496;
199-
};
200-
afi-safis = [
201-
{
202-
config.afi-safi-name = "ipv4-unicast";
203-
}
204-
];
205-
}
206-
{
207-
config = {
208-
neighbor-address = "192.0.2.2";
209-
peer-as = 64497;
210-
};
211-
afi-safis = [
212-
{
213-
config.afi-safi-name = "ipv4-unicast";
214-
}
215-
];
216-
}
217-
{
218-
config = {
219-
neighbor-address = "2001:db8::1";
220-
peer-as = 64496;
221-
};
222-
afi-safis = [
223-
{
224-
config.afi-safi-name = "ipv6-unicast";
225-
}
226-
];
227-
}
228-
{
229-
config = {
230-
neighbor-address = "2001:db8::2";
231-
peer-as = 64497;
232-
};
233-
afi-safis = [
234-
{
235-
config.afi-safi-name = "ipv6-unicast";
236-
}
205+
};
206+
};
207+
services = {
208+
# any frr service will do, we just need the zebra socket
209+
# a upstream module modification to frr would be better
210+
frr.sharpd.enable = true;
211+
gobgpd = {
212+
enable = true;
213+
settings = {
214+
global.config = {
215+
as = 64498;
216+
router-id = "192.0.2.3";
217+
};
218+
global.apply-policy.config = {
219+
default-import-policy = "accept-route";
220+
default-export-policy = "accept-route";
221+
};
222+
zebra.config = {
223+
enabled = true;
224+
software-name = "frr10.3";
225+
version = 6;
226+
url = "unix:/run/frr/zserv.api";
227+
redistribute-route-type-list = [
228+
"kernel"
229+
"directly-connected"
230+
"static"
237231
];
238-
}
239-
];
232+
};
233+
neighbors = [
234+
{
235+
config = {
236+
neighbor-address = "192.0.2.1";
237+
peer-as = 64496;
238+
};
239+
afi-safis = [
240+
{
241+
config.afi-safi-name = "ipv4-unicast";
242+
}
243+
];
244+
}
245+
{
246+
config = {
247+
neighbor-address = "192.0.2.2";
248+
peer-as = 64497;
249+
};
250+
afi-safis = [
251+
{
252+
config.afi-safi-name = "ipv4-unicast";
253+
}
254+
];
255+
}
256+
{
257+
config = {
258+
neighbor-address = "2001:db8::1";
259+
peer-as = 64496;
260+
};
261+
afi-safis = [
262+
{
263+
config.afi-safi-name = "ipv6-unicast";
264+
}
265+
];
266+
}
267+
{
268+
config = {
269+
neighbor-address = "2001:db8::2";
270+
peer-as = 64497;
271+
};
272+
afi-safis = [
273+
{
274+
config.afi-safi-name = "ipv6-unicast";
275+
}
276+
];
277+
}
278+
];
279+
};
240280
};
241281
};
242282
};
@@ -253,33 +293,34 @@
253293
b.wait_for_unit("bird.service")
254294
c.wait_for_unit("gobgpd.service")
255295
256-
a.wait_until_succeeds("vtysh -c 'show bgp ipv4 summary' | grep '192.0.2.2.*1\\s*2\\s*N/A'")
257-
a.wait_until_succeeds("vtysh -c 'show bgp ipv4 summary' | grep '192.0.2.3.*1\\s*2\\s*N/A'")
258-
b.wait_until_succeeds("birdc show protocols | grep 'a_v4.*Established'")
259-
b.wait_until_succeeds("birdc show protocols | grep 'c_v4.*Established'")
260-
c.wait_until_succeeds("gobgp neighbor -a 'ipv4' | grep '192.0.2.1.*Establ'")
261-
c.wait_until_succeeds("gobgp neighbor -a 'ipv4' | grep '192.0.2.2.*Establ'")
296+
with subtest("ensure bgp sessions are established"):
297+
a.wait_until_succeeds("vtysh -c 'show bgp ipv4 summary' | grep '192.0.2.2.*1\\s*2\\s*N/A'")
298+
a.wait_until_succeeds("vtysh -c 'show bgp ipv4 summary' | grep '192.0.2.3.*1\\s*2\\s*N/A'")
299+
b.wait_until_succeeds("birdc show protocols | grep 'a_v4.*Established'")
300+
b.wait_until_succeeds("birdc show protocols | grep 'c_v4.*Established'")
301+
c.wait_until_succeeds("gobgp neighbor -a 'ipv4' | grep '192.0.2.1.*Establ.*|.*2.*2'")
302+
c.wait_until_succeeds("gobgp neighbor -a 'ipv4' | grep '192.0.2.2.*Establ.*|.*2.*2'")
262303
263-
# IPv6 DAD might need some time to complete for the local link address, which is required by frr
264-
a.wait_until_succeeds("vtysh -c 'show bgp ipv6 summary' | grep '2001:db8::2.*1\\s*2\\s*N/A'")
265-
a.wait_until_succeeds("vtysh -c 'show bgp ipv6 summary' | grep '2001:db8::3.*1\\s*2\\s*N/A'")
266-
b.wait_until_succeeds("birdc show protocols | grep 'a_v6.*Established'")
267-
b.wait_until_succeeds("birdc show protocols | grep 'c_v4.*Established'")
268-
c.wait_until_succeeds("gobgp neighbor -a 'ipv6' | grep '2001:db8::1.*Establ'")
269-
c.wait_until_succeeds("gobgp neighbor -a 'ipv6' | grep '2001:db8::2.*Establ'")
304+
# IPv6 DAD might need some time to complete for the local link address, which is required by frr
305+
a.wait_until_succeeds("vtysh -c 'show bgp ipv6 summary' | grep '2001:db8::2.*1\\s*2\\s*N/A'")
306+
a.wait_until_succeeds("vtysh -c 'show bgp ipv6 summary' | grep '2001:db8::3.*1\\s*2\\s*N/A'")
307+
b.wait_until_succeeds("birdc show protocols | grep 'a_v6.*Established'")
308+
b.wait_until_succeeds("birdc show protocols | grep 'c_v4.*Established'")
309+
c.wait_until_succeeds("gobgp neighbor -a 'ipv6' | grep '2001:db8::1.*Establ.*|.*2.*2'")
310+
c.wait_until_succeeds("gobgp neighbor -a 'ipv6' | grep '2001:db8::2.*Establ.*|.*2.*2'")
270311
271312
with subtest("ensure routes have been installed in fib"):
272313
b.succeed("ip route show | grep 198.51.100.0/25")
273-
# c.succeed("ip route show | grep 198.51.100.0/25")
314+
c.succeed("ip route show | grep 198.51.100.0/25")
274315
a.succeed("ip route show | grep 198.51.100.128/25")
275-
# c.succeed("ip route show | grep 198.51.100.128/25")
276-
# a.succeed("ip route show | grep 203.0.113.0/24")
277-
# b.succeed("ip route show | grep 203.0.113.0/24")
316+
c.succeed("ip route show | grep 198.51.100.128/25")
317+
a.succeed("ip route show | grep 203.0.113.0/24")
318+
b.succeed("ip route show | grep 203.0.113.0/24")
278319
b.succeed("ip -6 route show | grep 2001:db8:beef::/48")
279-
# c.succeed("ip -6 route show | grep 2001:db8:beef::/48")
320+
c.succeed("ip -6 route show | grep 2001:db8:beef::/48")
280321
a.succeed("ip -6 route show | grep 2001:db8:c0de::/48")
281-
# c.succeed("ip -6 route show | grep 2001:db8:c0de::/48")
282-
# a.succeed("ip -6 route show | grep 2001:db8:dead::/48")
283-
# b.succeed("ip -6 route show | grep 2001:db8:dead::/48")
322+
c.succeed("ip -6 route show | grep 2001:db8:c0de::/48")
323+
a.succeed("ip -6 route show | grep 2001:db8:dead::/48")
324+
b.succeed("ip -6 route show | grep 2001:db8:dead::/48")
284325
'';
285326
}

0 commit comments

Comments
 (0)