修改默认rt

This commit is contained in:
lbl8603
2024-05-01 14:50:00 +08:00
parent e73ed238cd
commit 1130f69a82
2 changed files with 11 additions and 2 deletions
+10 -1
View File
@@ -324,7 +324,16 @@ impl RouteTable {
} else {
let len = v.len();
if len != 0 {
return Ok(v[index % len].0);
let route = &v[index % len].0;
// 跳过默认rt的路由(一般是刚加入的),这有助于提升稳定性
if route.rt != DEFAULT_RT {
return Ok(*route);
}
for (route, _) in v {
if route.rt != DEFAULT_RT {
return Ok(*route);
}
}
}
}
}
+1 -1
View File
@@ -68,7 +68,7 @@ pub struct RouteSortKey {
pub metric: u8,
pub rt: i64,
}
const DEFAULT_RT: i64 = 999;
const DEFAULT_RT: i64 = 9999;
impl Route {
pub fn new(is_tcp: bool, index: usize, addr: SocketAddr, metric: u8, rt: i64) -> Self {
Self {