misakanet-config/lib/20-community-net186.conf

61 lines
2.7 KiB
Plaintext
Raw Normal View History

function net186_import_filter(int POPID)
2022-12-26 15:41:18 +00:00
int viaRegion;
bgppath public_bgp_path;
2023-01-09 14:46:30 +00:00
{
2022-12-26 15:41:18 +00:00
public_bgp_path = delete(bgp_path, [4200000000..4225479999]);
2022-12-27 17:14:15 +00:00
if (LOCAL_ASN, 122, REGION) !~ bgp_large_community then bgp_large_community.add((LOCAL_ASN, 122, REGION));
2023-03-18 06:37:14 +00:00
if public_bgp_path.len = 1 && bgp_large_community !~ [(LOCAL_ASN, 110, 10)] then bgp_local_pref = 501;
2023-02-08 20:37:42 +00:00
else if bgp_large_community ~ [(LOCAL_ASN, 110, 0), (LOCAL_ASN, 110, 2), (LOCAL_ASN, 110, 20)] then bgp_local_pref = 500;
2023-02-18 16:03:54 +00:00
else if bgp_large_community ~ [(LOCAL_ASN, 110, 10)] then bgp_local_pref = 400;
2022-12-26 15:41:18 +00:00
else bgp_local_pref = 300;
2023-01-09 14:46:30 +00:00
pub_route_controller_specific();
2022-12-26 15:41:18 +00:00
viaRegion = 0;
# Route is via Europe & Africa & Middle East
2023-01-09 09:36:50 +00:00
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;
2022-12-31 19:23:34 +00:00
# Route is via or locate America
2023-01-09 09:36:50 +00:00
if bgp_large_community ~ [(LOCAL_ASN, 122, 200..299), (LOCAL_ASN, 121, 200..299)] || POP ~ [200..299] then viaRegion = viaRegion + 1;
2022-12-31 19:23:34 +00:00
# Route is via or locate East Asia & Oceania
2023-01-09 09:36:50 +00:00
if bgp_large_community ~ [(LOCAL_ASN, 122, 400..500), (LOCAL_ASN, 121, 400..500)] || POP ~ [400..500] then viaRegion = viaRegion + 1;
2022-12-26 15:41:18 +00:00
2023-02-18 16:03:54 +00:00
if bgp_large_community !~ [(LOCAL_ASN, 110, 0), (LOCAL_ASN, 110, 2), (LOCAL_ASN, 110, 1)] then bgp_local_pref = bgp_local_pref - 50 * viaRegion;
else bgp_local_pref = bgp_local_pref - 100 * viaRegion;
2022-12-26 15:41:18 +00:00
# Route is via China mainland but not advertise in China mainland.
2023-01-20 08:39:28 +00:00
if (LOCAL_ASN, 122, 430) ~ bgp_large_community && REGION != 430 && (LOCAL_ASN, 121, 430) !~ bgp_large_community then return false;
2022-12-26 15:41:18 +00:00
2022-12-27 17:14:15 +00:00
bgp_local_pref = bgp_local_pref - filter(bgp_large_community, [(LOCAL_ASN, 122, *)]).len * 5;
bgp_local_pref = bgp_local_pref - public_bgp_path.len * 10;
2023-01-05 14:35:58 +00:00
if LOCAL_ASN ~ bgp_path then return false;
2023-01-05 16:14:29 +00:00
2022-12-27 17:14:15 +00:00
return true;
2022-12-26 15:41:18 +00:00
};
function net186_export_filter(int POPID) {
if (65535, 65282) ~ bgp_community then return false;
2022-12-26 15:41:18 +00:00
if (65535, 65283) ~ bgp_community then {
if (POPID / 10) != (POP / 10) then {
return false;
2022-12-26 15:41:18 +00:00
}
}
if (LOCAL_ASN, 125, POP) ~ bgp_large_community then {
return false;
}
if (LOCAL_ASN, 126, REGION) ~ bgp_large_community then {
return false;
}
2022-12-27 17:14:15 +00:00
if bgp_large_community !~ [(LOCAL_ASN, 120, *)] then bgp_large_community.add((LOCAL_ASN, 120, POP));
if bgp_large_community !~ [(LOCAL_ASN, 121, *)] then bgp_large_community.add((LOCAL_ASN, 121, REGION));
2023-02-26 07:28:47 +00:00
if (LOCAL_ASN, 122, REGION) !~ bgp_large_community then bgp_large_community.add((LOCAL_ASN, 122, REGION));
2022-12-27 17:14:15 +00:00
return true;
2022-12-26 15:41:18 +00:00
};