|
1 | | -{ pkgs, ... }: |
| 1 | +{ lib, pkgs, ... }: |
2 | 2 | { |
3 | 3 | name = "bgp-simple"; |
4 | 4 |
|
|
27 | 27 | config = '' |
28 | 28 | ip route 198.51.100.0/25 reject |
29 | 29 | ipv6 route 2001:db8:beef::/48 reject |
30 | | -
|
31 | 30 | router bgp 64496 |
32 | 31 | no bgp ebgp-requires-policy |
33 | 32 | no bgp default ipv4-unicast |
|
184 | 183 | ]; |
185 | 184 | }; |
186 | 185 | }; |
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 | + }; |
193 | 204 | }; |
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" |
237 | 231 | ]; |
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 | + }; |
240 | 280 | }; |
241 | 281 | }; |
242 | 282 | }; |
|
253 | 293 | b.wait_for_unit("bird.service") |
254 | 294 | c.wait_for_unit("gobgpd.service") |
255 | 295 |
|
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'") |
262 | 303 |
|
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'") |
270 | 311 |
|
271 | 312 | with subtest("ensure routes have been installed in fib"): |
272 | 313 | 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") |
274 | 315 | 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") |
278 | 319 | 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") |
280 | 321 | 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") |
284 | 325 | ''; |
285 | 326 | } |
0 commit comments