Skip to content

Commit 9bea35a

Browse files
committed
tests/bgp-extended-nexthop: add gobgp
1 parent 402ba68 commit 9bea35a

File tree

2 files changed

+145
-8
lines changed

2 files changed

+145
-8
lines changed

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/bgp-extended-nexthop/default.nix

Lines changed: 142 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
{ ... }:
1+
{ inputs, ... }:
22
{
33
name = "bgp-extended-nexthop";
44

5+
# required in node c - gobgp module
6+
node.pkgsReadOnly = false;
7+
58
defaults = {
69
networking.firewall.allowedTCPPorts = [ 179 ];
710
};
@@ -29,14 +32,20 @@
2932
neighbor fe80::2 capability extended-nexthop
3033
neighbor fe80::2 interface eth1
3134
35+
neighbor fe80::3 remote-as 64498
36+
neighbor fe80::3 capability extended-nexthop
37+
neighbor fe80::3 interface eth1
38+
3239
address-family ipv4 unicast
3340
network 198.51.100.0/25
3441
neighbor fe80::2 activate
42+
neighbor fe80::3 activate
3543
exit-address-family
3644
3745
address-family ipv6 unicast
3846
network 2001:db8:beef::/48
3947
neighbor fe80::2 activate
48+
neighbor fe80::3 activate
4049
exit-address-family
4150
'';
4251
};
@@ -102,9 +111,117 @@
102111
export all;
103112
};
104113
}
114+
115+
protocol bgp c {
116+
local as 64497;
117+
neighbor fe80::3 as 64498;
118+
interface "eth1";
119+
120+
ipv4 {
121+
extended next hop on;
122+
import all;
123+
export all;
124+
};
125+
126+
ipv6 {
127+
import all;
128+
export all;
129+
};
130+
}
105131
'';
106132
};
107133
};
134+
c = {
135+
imports = [ inputs.gobgp.nixosModules.gobgp ];
136+
networking.interfaces.eth1.ipv6.addresses = [
137+
{
138+
address = "fe80::3";
139+
prefixLength = 64;
140+
}
141+
];
142+
services.gobgpd = {
143+
enable = true;
144+
zebra = true;
145+
validateConfig = false;
146+
config = {
147+
global = {
148+
as = 64498;
149+
router-id = "192.0.2.3";
150+
apply-policy = {
151+
default-import-policy = "accept-route";
152+
export-policy-list = [ "c-out" ];
153+
default-export-policy = "reject-route";
154+
};
155+
};
156+
zebra = {
157+
enabled = true;
158+
redistribute-route-type-list = [
159+
"kernel"
160+
"directly-connected"
161+
"static"
162+
];
163+
};
164+
static-paths = {
165+
"unreachable-ipv4".prefix = "203.0.113.0/24";
166+
"unreachable-ipv6".prefix = "2001:db8:dead::/48";
167+
};
168+
neighbors = {
169+
"a" = {
170+
neighbor-address = "fe80::1%eth1";
171+
peer-as = 64496;
172+
afi-safis = {
173+
"ipv4-unicast" = { };
174+
"ipv6-unicast" = { };
175+
};
176+
};
177+
"b" = {
178+
neighbor-address = "fe80::2%eth1";
179+
peer-as = 64497;
180+
afi-safis = {
181+
"ipv4-unicast" = { };
182+
"ipv6-unicast" = { };
183+
};
184+
};
185+
};
186+
defined-sets.prefix-sets = {
187+
"c-out-ipv4".prefix-list = [
188+
{
189+
ip-prefix = "203.0.113.0/24";
190+
masklength-range = "24..32";
191+
}
192+
];
193+
"c-out-ipv6".prefix-list = [
194+
{
195+
ip-prefix = "2001:db8:dead::/48";
196+
masklength-range = "48..128";
197+
}
198+
];
199+
};
200+
policy-definitions."c-out" = {
201+
statements = {
202+
"c-out-ipv4" = {
203+
actions.route-disposition = "accept-route";
204+
conditions = {
205+
match-prefix-set = {
206+
prefix-set = "c-out-ipv4";
207+
match-set-options = "any";
208+
};
209+
};
210+
};
211+
"c-out-ipv6" = {
212+
actions.route-disposition = "accept-route";
213+
conditions = {
214+
match-prefix-set = {
215+
prefix-set = "c-out-ipv6";
216+
match-set-options = "any";
217+
};
218+
};
219+
};
220+
};
221+
};
222+
};
223+
};
224+
};
108225
};
109226

110227
testScript = ''
@@ -117,14 +234,34 @@
117234
b.wait_for_unit("bird.service")
118235
119236
with subtest("ensure bgp sessions are established"):
120-
a.wait_until_succeeds("vtysh -c 'show bgp ipv4 summary' | grep 'fe80::2.*1\\s*2\\s*N/A'")
121-
a.wait_until_succeeds("vtysh -c 'show bgp ipv6 summary' | grep 'fe80::2.*1\\s*2\\s*N/A'")
237+
a.sleep(10)
238+
print(a.succeed("vtysh -c 'show bgp summary'"))
239+
print(c.succeed("gobgp neighbor"))
240+
a.wait_until_succeeds("vtysh -c 'show bgp ipv4 summary' | grep 'fe80::2.*2\\s*3\\s*N/A'")
241+
a.wait_until_succeeds("vtysh -c 'show bgp ipv4 summary' | grep 'fe80::3.*1\\s*3\\s*N/A'")
122242
b.wait_until_succeeds("birdc show protocols | grep 'a.*Established'")
243+
b.wait_until_succeeds("birdc show protocols | grep 'c.*Established'")
244+
c.wait_until_succeeds("gobgp neighbor -a 'ipv4' | grep 'fe80::1%eth1.*Establ.*|.*3.*2'")
245+
c.wait_until_succeeds("gobgp neighbor -a 'ipv4' | grep 'fe80::2%eth1.*Establ.*|.*2.*2'")
246+
247+
# IPv6 DAD might need some time to complete for the local link address, which is required by frr
248+
a.wait_until_succeeds("vtysh -c 'show bgp ipv6 summary' | grep 'fe80::2.*2\\s*3\\s*N/A'")
249+
a.wait_until_succeeds("vtysh -c 'show bgp ipv6 summary' | grep 'fe80::3.*1\\s*3\\s*N/A'")
250+
c.wait_until_succeeds("gobgp neighbor -a 'ipv6' | grep 'fe80::1%eth1.*Establ.*|.*3.*2'")
251+
c.wait_until_succeeds("gobgp neighbor -a 'ipv6' | grep 'fe80::2%eth1.*Establ.*|.*2.*2'")
123252
124253
with subtest("ensure routes have been installed"):
125-
a.succeed("ip route show | grep 198.51.100.128/25")
126254
b.succeed("ip route show | grep 198.51.100.0/25")
127-
a.succeed("ip -6 route show | grep 2001:db8:c0de::/48")
255+
c.succeed("ip route show | grep 198.51.100.0/25")
256+
a.succeed("ip route show | grep 198.51.100.128/25")
257+
# c.succeed("ip route show | grep 198.51.100.128/25")
258+
a.succeed("ip route show | grep 203.0.113.0/24")
259+
b.succeed("ip route show | grep 203.0.113.0/24")
128260
b.succeed("ip -6 route show | grep 2001:db8:beef::/48")
261+
c.succeed("ip -6 route show | grep 2001:db8:beef::/48")
262+
a.succeed("ip -6 route show | grep 2001:db8:c0de::/48")
263+
# c.succeed("ip -6 route show | grep 2001:db8:c0de::/48")
264+
a.succeed("ip -6 route show | grep 2001:db8:dead::/48")
265+
b.succeed("ip -6 route show | grep 2001:db8:dead::/48")
129266
'';
130267
}

0 commit comments

Comments
 (0)