From 27eb5b251e39dbbf526c3bf8d05ce36b5275972b Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Wed, 17 Aug 2022 02:30:09 +0100 Subject: [PATCH] blade-router: tweak export filter to drop local communities --- ops/nixos/lib/bgp.nix | 16 ++++++++++++++-- ops/nixos/lib/blade-router.nix | 8 ++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ops/nixos/lib/bgp.nix b/ops/nixos/lib/bgp.nix index f2baa8a3f7..4086f96c2f 100644 --- a/ops/nixos/lib/bgp.nix +++ b/ops/nixos/lib/bgp.nix @@ -30,6 +30,18 @@ let bgp_local_pref = ${toString ix.remote.bgp_local_pref}; accept; } + filter bgp_export_${ixName}4 + { + if ! ((ro, ${toString ix.local.asn}, 1000) ~ bgp_ext_community) then reject; + bgp_ext_community.delete([(ro, ${toString ix.local.asn}, *)]); + accept; + } + filter bgp_export_${ixName}6 + { + if ! ((ro, ${toString ix.local.asn}, 1000) ~ bgp_ext_community) then reject; + bgp_ext_community.delete([(ro, ${toString ix.local.asn}, *)]); + accept; + } protocol pipe ${ixName}pipe_4 { table ${ixName}4; peer table master4; @@ -61,7 +73,7 @@ let ipv4 { table ${ixName}4; import all; - export ${if ix.remote.is_route_collector then "all" else "where ((ro, ${toString ix.local.asn}, 1000) ~ bgp_ext_community)"}; + export ${if ix.remote.is_route_collector then "all" else "filter bgp_export_${ixName}4"}; ${prefixLimitSnippet ix.remote.prefix_limit.v4} }; }; @@ -77,7 +89,7 @@ let ipv6 { table ${ixName}6; import all; - export ${if ix.remote.is_route_collector then "all" else "where ((ro, ${toString ix.local.asn}, 1000) ~ bgp_ext_community)"}; + export ${if ix.remote.is_route_collector then "all" else "filter bgp_export_${ixName}6"}; ${prefixLimitSnippet ix.remote.prefix_limit.v6} }; }; diff --git a/ops/nixos/lib/blade-router.nix b/ops/nixos/lib/blade-router.nix index 7e431f9397..6534109cc2 100644 --- a/ops/nixos/lib/blade-router.nix +++ b/ops/nixos/lib/blade-router.nix @@ -349,10 +349,10 @@ in v4 = "195.66.225.6"; v6 = "2001:7f8:4::3f94:2"; }]; - }]; - bgp_local_pref = 120; - prefix_limit.v4 = 1000; - prefix_limit.v6 = 200; + bgp_local_pref = 120; + prefix_limit.v4 = 1000; + prefix_limit.v6 = 200; + }; }; export.v4 = [ "92.118.28.0/24" ]; export.v6 = [ "2a09:a441::/32" ];