Add: complete the filter of internal network and downstream
continuous-integration/drone/push Build is passing Details

This commit is contained in:
186526 2022-12-27 15:31:54 +08:00
parent fdc14ca1cc
commit db8827f83e
7 changed files with 54 additions and 48 deletions

View File

@ -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;
}

View 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;
}

View File

@ -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;
};

View File

@ -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;
}

View File

@ -16,13 +16,11 @@ template bgp pub_peer {
};
}
# WIP
template bgp pub_downstream {
local as LOCAL_ASN;
# template bgp pub_downstream {
# local as LOCAL_ASN;
# ipv6 {
# import where downstream_import_filter(6939);
# export where downstream_export_filter(6939);
# };
# }
ipv6 {
import where downstream_import_filter(6939);
export where downstream_export_filter(6939);
};
}

View File

@ -1,23 +1,14 @@
# WIP
# template bgp net186 {
# local as SELFASN;
template bgp net186 {
local as SELFASN;
# interpret communities off;
interpret communities off;
# bfd on;
ipv6 {
next hop self;
# ipv6 {
# next hop self;
gateway direct;
# gateway direct;
# import filter {
# };
# export filter {
# };
# }
# }
import where net186_import_filter(101);
export where net186_import_filter(101);
};
}

View File

@ -1,7 +1,7 @@
# 186526 Network
[![Build Status](https://ci.186526.xyz/api/badges/186526/net186-config/status.svg)](https://ci.186526.xyz/186526/net186-config)
![Bird Version Needed](https://img.shields.io/badge/bird-%3E%3D%202.0.11-blue)
![Bird Version Needed](https://img.shields.io/badge/bird-%3E%3D%202.0.8-blue)
- Experimental global network
- Maintained by 186526 (@real186526)