Skip to content

Commit 1b4462b

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

File tree

2 files changed

+142
-10
lines changed

2 files changed

+142
-10
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: 139 additions & 7 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
};
@@ -73,14 +82,12 @@
7382
}
7483
7584
protocol static static4 {
76-
vrf "vrf0";
7785
ipv4;
7886
7987
route 198.51.100.128/25 unreachable;
8088
}
8189
8290
protocol static static6 {
83-
vrf "vrf0";
8491
ipv6;
8592
8693
route 2001:db8:c0de::/48 unreachable;
@@ -102,9 +109,117 @@
102109
export all;
103110
};
104111
}
112+
113+
protocol bgp c {
114+
local as 64497;
115+
neighbor fe80::3 as 64498;
116+
interface "eth1";
117+
118+
ipv4 {
119+
extended next hop on;
120+
import all;
121+
export all;
122+
};
123+
124+
ipv6 {
125+
import all;
126+
export all;
127+
};
128+
}
105129
'';
106130
};
107131
};
132+
c = {
133+
imports = [ inputs.gobgp.nixosModules.gobgp ];
134+
networking.interfaces.eth1.ipv6.addresses = [
135+
{
136+
address = "fe80::3";
137+
prefixLength = 64;
138+
}
139+
];
140+
services.gobgpd = {
141+
enable = true;
142+
zebra = true;
143+
validateConfig = false;
144+
config = {
145+
global = {
146+
as = 64498;
147+
router-id = "192.0.2.3";
148+
apply-policy = {
149+
default-import-policy = "accept-route";
150+
export-policy-list = [ "c-out" ];
151+
default-export-policy = "reject-route";
152+
};
153+
};
154+
zebra = {
155+
enabled = true;
156+
redistribute-route-type-list = [
157+
"kernel"
158+
"directly-connected"
159+
"static"
160+
];
161+
};
162+
static-paths = {
163+
"unreachable-ipv4".prefix = "203.0.113.0/24";
164+
"unreachable-ipv6".prefix = "2001:db8:dead::/48";
165+
};
166+
neighbors = {
167+
"a" = {
168+
neighbor-address = "fe80::1%eth1";
169+
peer-as = 64496;
170+
afi-safis = {
171+
"ipv4-unicast" = { };
172+
"ipv6-unicast" = { };
173+
};
174+
};
175+
"b" = {
176+
neighbor-address = "fe80::2%eth1";
177+
peer-as = 64497;
178+
afi-safis = {
179+
"ipv4-unicast" = { };
180+
"ipv6-unicast" = { };
181+
};
182+
};
183+
};
184+
defined-sets.prefix-sets = {
185+
"c-out-ipv4".prefix-list = [
186+
{
187+
ip-prefix = "203.0.113.0/24";
188+
masklength-range = "24..32";
189+
}
190+
];
191+
"c-out-ipv6".prefix-list = [
192+
{
193+
ip-prefix = "2001:db8:dead::/48";
194+
masklength-range = "48..128";
195+
}
196+
];
197+
};
198+
policy-definitions."c-out" = {
199+
statements = {
200+
"c-out-ipv4" = {
201+
actions.route-disposition = "accept-route";
202+
conditions = {
203+
match-prefix-set = {
204+
prefix-set = "c-out-ipv4";
205+
match-set-options = "any";
206+
};
207+
};
208+
};
209+
"c-out-ipv6" = {
210+
actions.route-disposition = "accept-route";
211+
conditions = {
212+
match-prefix-set = {
213+
prefix-set = "c-out-ipv6";
214+
match-set-options = "any";
215+
};
216+
};
217+
};
218+
};
219+
};
220+
};
221+
};
222+
};
108223
};
109224

110225
testScript = ''
@@ -117,14 +232,31 @@
117232
b.wait_for_unit("bird.service")
118233
119234
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'")
235+
a.wait_until_succeeds("vtysh -c 'show bgp ipv4 summary' | grep 'fe80::2.*2\\s*3\\s*N/A'")
236+
a.wait_until_succeeds("vtysh -c 'show bgp ipv4 summary' | grep 'fe80::3.*1\\s*3\\s*N/A'")
122237
b.wait_until_succeeds("birdc show protocols | grep 'a.*Established'")
238+
b.wait_until_succeeds("birdc show protocols | grep 'c.*Established'")
239+
c.wait_until_succeeds("gobgp neighbor -a 'ipv4' | grep 'fe80::1%eth1.*Establ.*|.*3.*2'")
240+
c.wait_until_succeeds("gobgp neighbor -a 'ipv4' | grep 'fe80::2%eth1.*Establ.*|.*2.*2'")
241+
242+
# IPv6 DAD might need some time to complete for the local link address, which is required by frr
243+
a.wait_until_succeeds("vtysh -c 'show bgp ipv6 summary' | grep 'fe80::2.*2\\s*3\\s*N/A'")
244+
a.wait_until_succeeds("vtysh -c 'show bgp ipv6 summary' | grep 'fe80::3.*1\\s*3\\s*N/A'")
245+
c.wait_until_succeeds("gobgp neighbor -a 'ipv6' | grep 'fe80::1%eth1.*Establ.*|.*3.*2'")
246+
c.wait_until_succeeds("gobgp neighbor -a 'ipv6' | grep 'fe80::2%eth1.*Establ.*|.*2.*2'")
123247
124248
with subtest("ensure routes have been installed"):
125-
a.succeed("ip route show | grep 198.51.100.128/25")
126249
b.succeed("ip route show | grep 198.51.100.0/25")
127-
a.succeed("ip -6 route show | grep 2001:db8:c0de::/48")
250+
c.succeed("ip route show | grep 198.51.100.0/25")
251+
a.succeed("ip route show | grep 198.51.100.128/25")
252+
c.succeed("ip route show | grep 198.51.100.128/25")
253+
a.succeed("ip route show | grep 203.0.113.0/24")
254+
b.succeed("ip route show | grep 203.0.113.0/24")
128255
b.succeed("ip -6 route show | grep 2001:db8:beef::/48")
256+
c.succeed("ip -6 route show | grep 2001:db8:beef::/48")
257+
a.succeed("ip -6 route show | grep 2001:db8:c0de::/48")
258+
c.succeed("ip -6 route show | grep 2001:db8:c0de::/48")
259+
a.succeed("ip -6 route show | grep 2001:db8:dead::/48")
260+
b.succeed("ip -6 route show | grep 2001:db8:dead::/48")
129261
'';
130262
}

0 commit comments

Comments
 (0)