ops/nixos/bgp: add support for route collectors

This commit is contained in:
Luke Granger-Brown 2022-04-30 16:47:35 +01:00
parent 8acf275884
commit 04e013b237

View file

@ -31,13 +31,13 @@ let
protocol pipe ${ixName}pipe_4 { protocol pipe ${ixName}pipe_4 {
table ${ixName}4; table ${ixName}4;
peer table master4; 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; export filter bgp_in_${ixName}4;
}; };
protocol pipe ${ixName}pipe_6 { protocol pipe ${ixName}pipe_6 {
table ${ixName}6; table ${ixName}6;
peer table master6; 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; export filter bgp_in_${ixName}6;
}; };
'' + lib.concatImapStringsSep "\n" ( i: v: generateSnippetForRouter (args // { routerNum = i; router = v; }) ) ix.remote.routers; '' + lib.concatImapStringsSep "\n" ( i: v: generateSnippetForRouter (args // { routerNum = i; router = v; }) ) ix.remote.routers;
@ -59,7 +59,7 @@ let
ipv4 { ipv4 {
table ${ixName}4; table ${ixName}4;
import all; 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} ${prefixLimitSnippet ix.remote.prefix_limit.v4}
}; };
}; };
@ -75,7 +75,7 @@ let
ipv6 { ipv6 {
table ${ixName}6; table ${ixName}6;
import all; 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} ${prefixLimitSnippet ix.remote.prefix_limit.v6}
}; };
}; };
@ -151,6 +151,10 @@ in {
type = int; type = int;
default = 100; default = 100;
}; };
is_route_collector = mkOption { # lukegbgp.config.peering.<foo>.remote.is_route_collector
type = bool;
default = false;
};
routers = mkOption { # lukegbgp.config.peering.<foo>.remote.routers routers = mkOption { # lukegbgp.config.peering.<foo>.remote.routers
type = listOf (submodule { type = listOf (submodule {
options = { options = {