修改默认rt
This commit is contained in:
@@ -324,7 +324,16 @@ impl RouteTable {
|
|||||||
} else {
|
} else {
|
||||||
let len = v.len();
|
let len = v.len();
|
||||||
if len != 0 {
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ pub struct RouteSortKey {
|
|||||||
pub metric: u8,
|
pub metric: u8,
|
||||||
pub rt: i64,
|
pub rt: i64,
|
||||||
}
|
}
|
||||||
const DEFAULT_RT: i64 = 999;
|
const DEFAULT_RT: i64 = 9999;
|
||||||
impl Route {
|
impl Route {
|
||||||
pub fn new(is_tcp: bool, index: usize, addr: SocketAddr, metric: u8, rt: i64) -> Self {
|
pub fn new(is_tcp: bool, index: usize, addr: SocketAddr, metric: u8, rt: i64) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|||||||
Reference in New Issue
Block a user