From 04e013b23785747e7f1dd26a555afa9f430bdff8 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Sat, 30 Apr 2022 16:47:35 +0100 Subject: [PATCH] ops/nixos/bgp: add support for route collectors --- ops/nixos/lib/bgp.nix | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ops/nixos/lib/bgp.nix b/ops/nixos/lib/bgp.nix index a33f81fc94..8e3f78d94f 100644 --- a/ops/nixos/lib/bgp.nix +++ b/ops/nixos/lib/bgp.nix @@ -31,13 +31,13 @@ let protocol pipe ${ixName}pipe_4 { table ${ixName}4; peer table master4; - import where ((ro, ${toString ix.local.asn}, ${toString ix.remote.export_community}) ~ bgp_ext_community); + import ${if ix.remote.is_route_collector then "all" else "where ((ro, ${toString ix.local.asn}, ${toString ix.remote.export_community}) ~ bgp_ext_community)"}; export filter bgp_in_${ixName}4; }; protocol pipe ${ixName}pipe_6 { table ${ixName}6; peer table master6; - import where ((ro, ${toString ix.local.asn}, ${toString ix.remote.export_community}) ~ bgp_ext_community); + import ${if ix.remote.is_route_collector then "all" else "where ((ro, ${toString ix.local.asn}, ${toString ix.remote.export_community}) ~ bgp_ext_community)"}; export filter bgp_in_${ixName}6; }; '' + lib.concatImapStringsSep "\n" ( i: v: generateSnippetForRouter (args // { routerNum = i; router = v; }) ) ix.remote.routers; @@ -59,7 +59,7 @@ let ipv4 { table ${ixName}4; import all; - export where ((ro, ${toString ix.local.asn}, 1000) ~ bgp_ext_community); + export ${if ix.remote.is_route_collector then "all" else "where ((ro, ${toString ix.local.asn}, 1000) ~ bgp_ext_community)"}; ${prefixLimitSnippet ix.remote.prefix_limit.v4} }; }; @@ -75,7 +75,7 @@ let ipv6 { table ${ixName}6; import all; - export where ((ro, ${toString ix.local.asn}, 1000) ~ bgp_ext_community); + export ${if ix.remote.is_route_collector then "all" else "where ((ro, ${toString ix.local.asn}, 1000) ~ bgp_ext_community)"}; ${prefixLimitSnippet ix.remote.prefix_limit.v6} }; }; @@ -151,6 +151,10 @@ in { type = int; default = 100; }; + is_route_collector = mkOption { # lukegbgp.config.peering..remote.is_route_collector + type = bool; + default = false; + }; routers = mkOption { # lukegbgp.config.peering..remote.routers type = listOf (submodule { options = {