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 = {