Skip to content

Commit 49bf384

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

1 file changed

Lines changed: 141 additions & 5 deletions

File tree

tests/bgp-extended-nexthop/default.nix

Lines changed: 141 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,116 @@
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+
config = {
146+
global = {
147+
as = 64498;
148+
router-id = "192.0.2.3";
149+
apply-policy = {
150+
default-import-policy = "accept-route";
151+
export-policy-list = [ "c-out" ];
152+
default-export-policy = "reject-route";
153+
};
154+
};
155+
zebra = {
156+
enabled = true;
157+
redistribute-route-type-list = [
158+
"kernel"
159+
"directly-connected"
160+
"static"
161+
];
162+
};
163+
static-paths = {
164+
"unreachable-ipv4".prefix = "203.0.113.0/24";
165+
"unreachable-ipv6".prefix = "2001:db8:dead::/48";
166+
};
167+
neighbors = {
168+
"a" = {
169+
neighbor-address = "fe80::1%eth1";
170+
peer-as = 64496;
171+
afi-safis = {
172+
"ipv4-unicast" = { };
173+
"ipv6-unicast" = { };
174+
};
175+
};
176+
"b" = {
177+
neighbor-address = "fe80::2%eth1";
178+
peer-as = 64497;
179+
afi-safis = {
180+
"ipv4-unicast" = { };
181+
"ipv6-unicast" = { };
182+
};
183+
};
184+
};
185+
defined-sets.prefix-sets = {
186+
"c-out-ipv4".prefix-list = [
187+
{
188+
ip-prefix = "203.0.113.0/24";
189+
masklength-range = "24..32";
190+
}
191+
];
192+
"c-out-ipv6".prefix-list = [
193+
{
194+
ip-prefix = "2001:db8:dead::/48";
195+
masklength-range = "48..128";
196+
}
197+
];
198+
};
199+
policy-definitions."c-out" = {
200+
statements = {
201+
"c-out-ipv4" = {
202+
actions.route-disposition = "accept-route";
203+
conditions = {
204+
match-prefix-set = {
205+
prefix-set = "c-out-ipv4";
206+
match-set-options = "any";
207+
};
208+
};
209+
};
210+
"c-out-ipv6" = {
211+
actions.route-disposition = "accept-route";
212+
conditions = {
213+
match-prefix-set = {
214+
prefix-set = "c-out-ipv6";
215+
match-set-options = "any";
216+
};
217+
};
218+
};
219+
};
220+
};
221+
};
222+
};
223+
};
108224
};
109225

110226
testScript = ''
@@ -117,14 +233,34 @@
117233
b.wait_for_unit("bird.service")
118234
119235
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'")
236+
a.sleep(10)
237+
print(a.succeed("vtysh -c 'show bgp summary'"))
238+
print(c.succeed("gobgp neighbor"))
239+
a.wait_until_succeeds("vtysh -c 'show bgp ipv4 summary' | grep 'fe80::2.*2\\s*3\\s*N/A'")
240+
a.wait_until_succeeds("vtysh -c 'show bgp ipv4 summary' | grep 'fe80::3.*1\\s*3\\s*N/A'")
122241
b.wait_until_succeeds("birdc show protocols | grep 'a.*Established'")
242+
b.wait_until_succeeds("birdc show protocols | grep 'c.*Established'")
243+
c.wait_until_succeeds("gobgp neighbor -a 'ipv4' | grep 'fe80::1%eth1.*Establ.*|.*3.*2'")
244+
c.wait_until_succeeds("gobgp neighbor -a 'ipv4' | grep 'fe80::2%eth1.*Establ.*|.*2.*2'")
245+
246+
# IPv6 DAD might need some time to complete for the local link address, which is required by frr
247+
a.wait_until_succeeds("vtysh -c 'show bgp ipv6 summary' | grep 'fe80::2.*2\\s*3\\s*N/A'")
248+
a.wait_until_succeeds("vtysh -c 'show bgp ipv6 summary' | grep 'fe80::3.*1\\s*3\\s*N/A'")
249+
c.wait_until_succeeds("gobgp neighbor -a 'ipv6' | grep 'fe80::1%eth1.*Establ.*|.*3.*2'")
250+
c.wait_until_succeeds("gobgp neighbor -a 'ipv6' | grep 'fe80::2%eth1.*Establ.*|.*2.*2'")
123251
124252
with subtest("ensure routes have been installed"):
125-
a.succeed("ip route show | grep 198.51.100.128/25")
126253
b.succeed("ip route show | grep 198.51.100.0/25")
127-
a.succeed("ip -6 route show | grep 2001:db8:c0de::/48")
254+
c.succeed("ip route show | grep 198.51.100.0/25")
255+
a.succeed("ip route show | grep 198.51.100.128/25")
256+
# c.succeed("ip route show | grep 198.51.100.128/25")
257+
a.succeed("ip route show | grep 203.0.113.0/24")
258+
b.succeed("ip route show | grep 203.0.113.0/24")
128259
b.succeed("ip -6 route show | grep 2001:db8:beef::/48")
260+
c.succeed("ip -6 route show | grep 2001:db8:beef::/48")
261+
a.succeed("ip -6 route show | grep 2001:db8:c0de::/48")
262+
# c.succeed("ip -6 route show | grep 2001:db8:c0de::/48")
263+
a.succeed("ip -6 route show | grep 2001:db8:dead::/48")
264+
b.succeed("ip -6 route show | grep 2001:db8:dead::/48")
129265
'';
130266
}

0 commit comments

Comments
 (0)