Add: complete the filter of internal network and downstream
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@ -22,8 +22,9 @@ function pub_add_communities(int ASN; int PeerType) {
|
||||
|
||||
if (LOCAL_ASN, 120, POP) ~ bgp_large_community then bgp_large_community.add((LOCAL_ASN, 120, POP));
|
||||
if (LOCAL_ASN, 121, REGION) ~ bgp_large_community then bgp_large_community.add((LOCAL_ASN, 121, REGION));
|
||||
|
||||
|
||||
# Finished (LOCAL_ASN, 120~130, *);
|
||||
return true;
|
||||
}
|
||||
|
||||
function pub_preprocess_communities() {
|
||||
@ -41,18 +42,10 @@ function pub_preprocess_communities() {
|
||||
bgp_path.prepend(bgp_path.last);
|
||||
}
|
||||
# Finished (LOCAL_ASN, 115, *);
|
||||
return true;
|
||||
}
|
||||
|
||||
function pub_process_communities(int ASN; int PeerType) {
|
||||
|
||||
if (LOCAL_ASN, 125, POP) ~ bgp_large_community then {
|
||||
bgp_community.add((65535, 65282));
|
||||
}
|
||||
|
||||
if (LOCAL_ASN, 126, REGION) ~ bgp_large_community then {
|
||||
bgp_community.add((65535, 65283));
|
||||
}
|
||||
|
||||
if (65535, 65281) ~ bgp_community then return false;
|
||||
if (65535, 65282) ~ bgp_community then return false;
|
||||
if (65535, 65283) ~ bgp_community then return false;
|
||||
@ -71,7 +64,7 @@ function pub_process_communities(int ASN; int PeerType) {
|
||||
} else if (PeerType=20) then {
|
||||
if (LOCAL_ASN, 1, 2) ~ bgp_large_community then return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function transit_import_filter(int ASN) {
|
||||
@ -85,7 +78,7 @@ function transit_export_filter(int ASN) {
|
||||
# Delete Self eBGP Confed Path.
|
||||
bgp_path.delete([4200000000..4225479999]);
|
||||
if !is_valid() then return false;
|
||||
pub_process_communities(ASN, 10);
|
||||
if bgp_path.last !~ DOWNSTREAM_ASN && source = RTS_BGP then return false;
|
||||
return true;
|
||||
if pub_process_communities(ASN, 10) then return true;
|
||||
else return false;
|
||||
}
|
14
lib/20-community-downstream.conf
Normal file
14
lib/20-community-downstream.conf
Normal file
@ -0,0 +1,14 @@
|
||||
function downstream_import_filter(int ASN) {
|
||||
if !is_valid() then return false;
|
||||
if bgp_path.last !~ DOWNSTREAM_ASN then return false;
|
||||
pub_add_communities(ASN, 20);
|
||||
pub_preprocess_communities();
|
||||
return true;
|
||||
}
|
||||
|
||||
function downstream_export_filter(int ASN) {
|
||||
if !is_valid() then return false;
|
||||
bgp_path.delete([4200000000..4225479999]);
|
||||
if pub_process_communities(ASN, 20) then return true;
|
||||
else return false;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
function net186_import_filter (int POPID)
|
||||
function net186_import_filter(int POPID)
|
||||
int viaRegion;
|
||||
bgppath public_bgp_path;
|
||||
{
|
||||
@ -29,7 +29,7 @@ function net186_import_filter (int POPID)
|
||||
bgp_local_pref = bgp_local_pref - filter(bgp_large_community, [(LOCAL_ASN, 122, *)]).len * 10;
|
||||
};
|
||||
|
||||
function net186_export_filter (int POPID) {
|
||||
function net186_export_filter(int POPID) {
|
||||
if (65535, 65282) ~ bgp_community then return false;
|
||||
|
||||
if (65535, 65283) ~ bgp_community then {
|
||||
@ -37,4 +37,14 @@ function net186_export_filter (int POPID) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (LOCAL_ASN, 125, POP) ~ bgp_large_community then {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (LOCAL_ASN, 126, REGION) ~ bgp_large_community then {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
@ -9,17 +9,17 @@ function is_peer_route() {
|
||||
|
||||
function direct_peer_import_filter(int ASN) {
|
||||
if !is_valid() then return false;
|
||||
if !is_peer_route() then return false;
|
||||
pub_add_communities(ASN, 0);
|
||||
pub_preprocess_communities();
|
||||
if !is_peer_route() then return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function direct_peer_export_filter(int ASN) {
|
||||
# Delete Self eBGP Confed Path.
|
||||
bgp_path.delete([4200000000..4225479999]);
|
||||
if !is_valid() then return false;
|
||||
# Delete Self eBGP Confed Path.
|
||||
pub_process_communities(ASN, 10);
|
||||
if !is_peer_route() then return false;
|
||||
return true;
|
||||
if pub_process_communities(ASN, 0) then return true;
|
||||
else return false;
|
||||
}
|
Reference in New Issue
Block a user