This commit is contained in:
2026-06-12 18:11:53 +08:00
parent df8194442f
commit 0d1a650fa5

View File

@@ -1,4 +1,4 @@
# 社区属性转换与本地优先级修正函数(Local Pref 200封顶版)
# 社区属性转换与本地优先级修正函数(BIRD 2.18 纯净稳定版)
function function_inet_community_make(){
# 1. 从上游收到的路由 => 赋予兜底优先级 (Local Pref = 100)
if bgp_large_community ~ [(LOCAL_ASN, 10100, 0)] then {
@@ -26,9 +26,11 @@ function function_inet_community_make(){
# 4. 下游客户发来的路由 => 赋予高优先级 (Local Pref = 180)
if bgp_large_community ~ [(LOCAL_ASN, 10100, 4)] then {
bgp_local_pref = 180;
bgp_large_community.add([
(LOCAL_ASN, 2, 1), (LOCAL_ASN, 2, 2), (LOCAL_ASN, 2, 3), (LOCAL_ASN, 2, 4)
]);
# 修复BIRD 的 add 不支持中括号批量加,必须拆开单次调用
bgp_large_community.add((LOCAL_ASN, 2, 1));
bgp_large_community.add((LOCAL_ASN, 2, 2));
bgp_large_community.add((LOCAL_ASN, 2, 3));
bgp_large_community.add((LOCAL_ASN, 2, 4));
bgp_large_community.delete((LOCAL_ASN, 10100, 4));
return true;
}
@@ -36,7 +38,12 @@ function function_inet_community_make(){
# 5. 自身宣告的前缀 => 赋予最高级封顶 (Local Pref = 200)
if bgp_large_community ~ [(LOCAL_ASN, 200, 0)] then {
bgp_local_pref = 200;
bgp_large_community.add([(LOCAL_ASN, 2, 0..4)]);
# 修复:拆开单独 add
bgp_large_community.add((LOCAL_ASN, 2, 0));
bgp_large_community.add((LOCAL_ASN, 2, 1));
bgp_large_community.add((LOCAL_ASN, 2, 2));
bgp_large_community.add((LOCAL_ASN, 2, 3));
bgp_large_community.add((LOCAL_ASN, 2, 4));
bgp_large_community.delete((LOCAL_ASN, 200, 0));
return true;
}
@@ -44,7 +51,6 @@ function function_inet_community_make(){
return false;
}
# 社区安全检查/清理(全量通配版)
function function_inet_bgp_community_clear(){
# 使用 [ (ASN, Data1, *) ] 语法,直接清空该分类下的所有子标记