From 04edb208ee1bd4e011582ab5de425ad9abd4c082 Mon Sep 17 00:00:00 2001 From: 186526 Date: Mon, 9 Jan 2023 22:46:30 +0800 Subject: [PATCH] add global route controller --- lib/10-community-controller.conf | 3 +++ lib/10-community-transit.conf | 1 + lib/20-community-downstream.conf | 1 + lib/20-community-net186.conf | 4 +++- lib/20-community-peer.conf | 1 + 5 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 lib/10-community-controller.conf diff --git a/lib/10-community-controller.conf b/lib/10-community-controller.conf new file mode 100644 index 0000000..d8a027f --- /dev/null +++ b/lib/10-community-controller.conf @@ -0,0 +1,3 @@ +function pub_route_controller_specific() { + if 4837 ~ bgp_path && (200536, 120, 221) ~ bgp_large_community && REGION ~ [200..299] then bgp_local_pref = 114514; +} \ No newline at end of file diff --git a/lib/10-community-transit.conf b/lib/10-community-transit.conf index 1933a10..76ff380 100644 --- a/lib/10-community-transit.conf +++ b/lib/10-community-transit.conf @@ -98,6 +98,7 @@ function transit_import_filter(int ASN) { pub_preprocess_communities(); bgp_local_pref = 400 - bgp_path.len * 10; if LOCAL_ASN ~ bgp_path then bgp_local_pref = 1; + pub_route_controller_specific(); return true; } diff --git a/lib/20-community-downstream.conf b/lib/20-community-downstream.conf index 0367008..cadec90 100644 --- a/lib/20-community-downstream.conf +++ b/lib/20-community-downstream.conf @@ -4,6 +4,7 @@ function downstream_import_filter(int ASN) { pub_add_communities(ASN, 20); pub_preprocess_communities(); bgp_local_pref = 500 - bgp_path.len * 10; + pub_route_controller_specific(); return true; } diff --git a/lib/20-community-net186.conf b/lib/20-community-net186.conf index db57068..8f810c2 100644 --- a/lib/20-community-net186.conf +++ b/lib/20-community-net186.conf @@ -1,7 +1,7 @@ function net186_import_filter(int POPID) int viaRegion; bgppath public_bgp_path; -{ +{ public_bgp_path = delete(bgp_path, [4200000000..4225479999]); if (LOCAL_ASN, 122, REGION) !~ bgp_large_community then bgp_large_community.add((LOCAL_ASN, 122, REGION)); @@ -10,6 +10,8 @@ function net186_import_filter(int POPID) else if bgp_large_community ~ [(LOCAL_ASN, 110, 1), (LOCAL_ASN, 110, 10)] then bgp_local_pref = 400; else bgp_local_pref = 300; + pub_route_controller_specific(); + viaRegion = 0; # Route is via Europe & Africa & Middle East if bgp_large_community ~ [(LOCAL_ASN, 122, 100), (LOCAL_ASN, 122, 300..310), (LOCAL_ASN, 122, 600), (LOCAL_ASN, 121, 100), (LOCAL_ASN, 121, 300..310), (LOCAL_ASN, 121, 600)] || POP ~ [100, 300..310, 600] then viaRegion = viaRegion + 1; diff --git a/lib/20-community-peer.conf b/lib/20-community-peer.conf index be8cb8b..51d91a5 100644 --- a/lib/20-community-peer.conf +++ b/lib/20-community-peer.conf @@ -13,6 +13,7 @@ function direct_peer_import_filter(int ASN) { pub_add_communities(ASN, 0); pub_preprocess_communities(); bgp_local_pref = 500 - bgp_path.len * 10; + pub_route_controller_specific(); return true; }