From fe8fc3cc6bc4cae4204f7855932638c3bf6f0b3d Mon Sep 17 00:00:00 2001 From: 186526 Date: Tue, 27 Dec 2022 00:39:44 +0800 Subject: [PATCH] Fix: try to let config work Change: use import where FUNCTION instead of import filter FILTER Fix: fix error in lib/community-net186.conf --- lib/community-net186.conf | 17 ++++++----------- lib/community-peer.conf | 12 ++++++------ lib/community-transit.conf | 22 +++++++++++----------- protocol/external_network.conf | 12 ++++++------ 4 files changed, 29 insertions(+), 34 deletions(-) diff --git a/lib/community-net186.conf b/lib/community-net186.conf index 6064b65..9e86baf 100644 --- a/lib/community-net186.conf +++ b/lib/community-net186.conf @@ -20,26 +20,21 @@ function net186_import_filter (int POPID) # Route is via East Asia & Oceania if bgp_large_community ~ [(LOCAL_ASN, 122, 400..500)] then viaRegion = viaRegion + 1; - if viaRegion > 2 then reject; + if viaRegion > 2 then return false; else if viaRegion = 2 then bgp_local_pref = bgp_local_pref - 50; - else if viaRegion then bgp_local_pref = 0; # Route is via China mainland but not advertise in China mainland. - if (LOCAL_ASN, 122, 430) ~ bgp_large_community && REGION != 430 && (LOCAL_ASN, 120, 430) ~ bgp_large_community then { - reject; - } + if (LOCAL_ASN, 122, 430) ~ bgp_large_community && REGION != 430 && (LOCAL_ASN, 120, 430) ~ bgp_large_community then return false; bgp_local_pref = bgp_local_pref - filter(bgp_large_community, [(LOCAL_ASN, 122, *)]).len * 10; }; -function net186_export_filter (POPID) { - if (65535, 65282) ~ bgp_community then { - reject; - } +function net186_export_filter (int POPID) { + if (65535, 65282) ~ bgp_community then return false; if (65535, 65283) ~ bgp_community then { - if (POPID % 10) != (POP % 10) then { - reject; + if (POPID / 10) != (POP / 10) then { + return false; } } }; \ No newline at end of file diff --git a/lib/community-peer.conf b/lib/community-peer.conf index 3bc8033..5bfcd32 100644 --- a/lib/community-peer.conf +++ b/lib/community-peer.conf @@ -8,18 +8,18 @@ function is_peer_route() { } function direct_peer_import_filter(int ASN) { - if !is_valid() then reject; + if !is_valid() then return false; pub_add_communities(ASN, 0); pub_preprocess_communities(); - if !is_peer_route() then reject; - accept; + if !is_peer_route() then return false; + return true; } function direct_peer_export_filter(int ASN) { - if !is_valid() then reject; + if !is_valid() then return false; # Delete Self eBGP Confed Path. bgp_path.delete([4200000000..4225479999]); pub_process_communities(ASN, 10); - if !is_peer_route() then reject; - accept; + if !is_peer_route() then return false; + return true; } \ No newline at end of file diff --git a/lib/community-transit.conf b/lib/community-transit.conf index 8930e9e..577f150 100644 --- a/lib/community-transit.conf +++ b/lib/community-transit.conf @@ -54,39 +54,39 @@ function pub_process_communities(int ASN, int type) { bgp_community.add((65535, 65283)); } - if (65535, 65281) ~ bgp_community then reject; - if (65535, 65282) ~ bgp_community then reject; - if (65535, 65283) ~ bgp_community then reject; + if (65535, 65281) ~ bgp_community then return false; + if (65535, 65282) ~ bgp_community then return false; + if (65535, 65283) ~ bgp_community then return false; if (LOCAL_ASN, 2, ASN) ~ bgp_large_community then reject # PEER if (type<10) then { - if (LOCAL_ASN, 1, 1) ~ bgp_large_community then reject; + if (LOCAL_ASN, 1, 1) ~ bgp_large_community then return false; # UPSTREAM } else if (type=10) then { - if (LOCAL_ASN, 1, 0) ~ bgp_large_community then reject; + if (LOCAL_ASN, 1, 0) ~ bgp_large_community then return false; # DOWNSTREAM } else if (type=20) then { - if (LOCAL_ASN, 1, 2) ~ bgp_large_community then reject; + if (LOCAL_ASN, 1, 2) ~ bgp_large_community then return false; } } function transit_import_filter(int ASN) { - if !is_valid() then reject; + if !is_valid() then return false; pub_add_communities(ASN, 10); pub_preprocess_communities(); - accept; + return true; } function transit_export_filter(int ASN) { - if !is_valid() then reject; + if !is_valid() then return false; # Delete Self eBGP Confed Path. bgp_path.delete([4200000000..4225479999]); pub_process_communities(ASN, 10); - if bgp_path.last !~ DOWNSTREAM_ASN then reject; - accept; + if bgp_path.last !~ DOWNSTREAM_ASN then return false; + return true; } \ No newline at end of file diff --git a/protocol/external_network.conf b/protocol/external_network.conf index 872711d..a43eabb 100644 --- a/protocol/external_network.conf +++ b/protocol/external_network.conf @@ -1,8 +1,8 @@ template bgp pub_transit { local as LOCAL_ASN; ipv6 { - import filter transit_import_filter(6939); - export filter transit_export_filter(6939); + import where transit_import_filter(6939); + export where transit_export_filter(6939); } } @@ -10,8 +10,8 @@ template bgp pub_peer { local as LOCAL_ASN; ipv6 { - import filter direct_peer_import_filter(6939); - export filter direct_peer_export_filter(6939); + import where direct_peer_import_filter(6939); + export where direct_peer_export_filter(6939); } } @@ -19,7 +19,7 @@ template bgp pub_downstream { local as LOCAL_ASN; ipv6 { - import filter downstream_import_filter(6939); - export filter downstream_export_filter(6939); + import where downstream_import_filter(6939); + export where downstream_export_filter(6939); } } \ No newline at end of file