2022-12-26 16:16:27 +00:00
|
|
|
function net186_import_filter (int POPID)
|
2022-12-26 15:41:18 +00:00
|
|
|
int viaRegion;
|
|
|
|
bgppath public_bgp_path;
|
|
|
|
{
|
|
|
|
public_bgp_path = delete(bgp_path, [4200000000..4225479999]);
|
|
|
|
|
|
|
|
if filter(bgp_large_community, [(LOCAL_ASN, 120, *)]).len != 0 then bgp_large_community.add((LOCAL_ASN, 120, POP));
|
|
|
|
if filter(bgp_large_community, [(LOCAL_ASN, 121, *)]).len != 0 then bgp_large_community.add((LOCAL_ASN, 121, REGION));
|
|
|
|
if (LOCAL_ASN, 122, REGION) ~ bgp_large_community then bgp_large_community.add((LOCAL_ASN, 122, REGION));
|
|
|
|
# ROUTE_DECIDER Start
|
|
|
|
if (LOCAL_ASN, 110, 2) ~ bgp_large_community then bgp_local_pref = 500;
|
|
|
|
else if (LOCAL_ASN, 110, 1) ~ bgp_large_community then bgp_local_pref = 400;
|
|
|
|
else bgp_local_pref = 300;
|
|
|
|
|
|
|
|
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)] then viaRegion = viaRegion + 1;
|
|
|
|
# Route is via America
|
|
|
|
if bgp_large_community ~ [(LOCAL_ASN, 122, 200..299)] then viaRegion = viaRegion + 1;
|
|
|
|
# Route is via East Asia & Oceania
|
|
|
|
if bgp_large_community ~ [(LOCAL_ASN, 122, 400..500)] then viaRegion = viaRegion + 1;
|
|
|
|
|
2022-12-26 16:39:44 +00:00
|
|
|
if viaRegion > 2 then return false;
|
2022-12-26 15:41:18 +00:00
|
|
|
else if viaRegion = 2 then bgp_local_pref = bgp_local_pref - 50;
|
|
|
|
|
|
|
|
# Route is via China mainland but not advertise in China mainland.
|
2022-12-26 16:39:44 +00:00
|
|
|
if (LOCAL_ASN, 122, 430) ~ bgp_large_community && REGION != 430 && (LOCAL_ASN, 120, 430) ~ bgp_large_community then return false;
|
2022-12-26 15:41:18 +00:00
|
|
|
|
|
|
|
bgp_local_pref = bgp_local_pref - filter(bgp_large_community, [(LOCAL_ASN, 122, *)]).len * 10;
|
|
|
|
};
|
|
|
|
|
2022-12-26 16:39:44 +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 {
|
2022-12-26 16:39:44 +00:00
|
|
|
if (POPID / 10) != (POP / 10) then {
|
|
|
|
return false;
|
2022-12-26 15:41:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|