diff --git a/src/runtime-rs/crates/agent/src/kata/trans.rs b/src/runtime-rs/crates/agent/src/kata/trans.rs index 895540c8b0..6cd808054a 100644 --- a/src/runtime-rs/crates/agent/src/kata/trans.rs +++ b/src/runtime-rs/crates/agent/src/kata/trans.rs @@ -228,6 +228,7 @@ impl From for types::Route { source: from.source, scope: from.scope, family: protobuf::EnumOrUnknown::new(from.family.into()), + flags: from.flags, ..Default::default() } } @@ -242,6 +243,7 @@ impl From for Route { source: src.source, scope: src.scope, family: src.family.unwrap().into(), + flags: src.flags, } } } diff --git a/src/runtime-rs/crates/agent/src/types.rs b/src/runtime-rs/crates/agent/src/types.rs index ed4f1cf603..51f2fe3f3e 100644 --- a/src/runtime-rs/crates/agent/src/types.rs +++ b/src/runtime-rs/crates/agent/src/types.rs @@ -113,6 +113,7 @@ pub struct Route { pub source: String, pub scope: u32, pub family: IPFamily, + pub flags: u32, } #[derive(Deserialize, Debug, PartialEq, Clone, Default)] diff --git a/src/runtime-rs/crates/resource/src/network/dan.rs b/src/runtime-rs/crates/resource/src/network/dan.rs index f8638fd8bc..7c8025da34 100644 --- a/src/runtime-rs/crates/resource/src/network/dan.rs +++ b/src/runtime-rs/crates/resource/src/network/dan.rs @@ -290,6 +290,8 @@ pub(crate) struct Route { // Scope #[serde(default)] pub scope: u32, + #[serde(default)] + pub flags: u32, } impl Route { @@ -399,6 +401,7 @@ mod tests { source: "172.18.0.1".to_owned(), gateway: "172.18.31.1".to_owned(), scope: 0, + flags: 0, }], neighbors: vec![ARPNeighbor { ip_address: Some("192.168.0.3/16".to_owned()), diff --git a/src/runtime-rs/crates/resource/src/network/network_info/network_info_from_dan.rs b/src/runtime-rs/crates/resource/src/network/network_info/network_info_from_dan.rs index 4617c9e5ba..9d2adfed0d 100644 --- a/src/runtime-rs/crates/resource/src/network/network_info/network_info_from_dan.rs +++ b/src/runtime-rs/crates/resource/src/network/network_info/network_info_from_dan.rs @@ -74,6 +74,7 @@ impl NetworkInfoFromDan { source: route.source.clone(), scope: route.scope, family, + flags: route.flags, }) }) .collect(); @@ -159,6 +160,7 @@ mod tests { source: "172.18.0.1".to_owned(), gateway: "172.18.31.1".to_owned(), scope: 0, + flags: 0, }], neighbors: vec![DanARPNeighbor { ip_address: Some("192.168.0.3/16".to_owned()), @@ -194,6 +196,7 @@ mod tests { source: "172.18.0.1".to_owned(), scope: 0, family: IPFamily::V4, + flags: 0, }]; assert_eq!(routes, network_info.routes().await.unwrap()); diff --git a/src/runtime-rs/crates/resource/src/network/network_info/network_info_from_link.rs b/src/runtime-rs/crates/resource/src/network/network_info/network_info_from_link.rs index 914d35318e..d46628ec67 100644 --- a/src/runtime-rs/crates/resource/src/network/network_info/network_info_from_link.rs +++ b/src/runtime-rs/crates/resource/src/network/network_info/network_info_from_link.rs @@ -168,6 +168,11 @@ fn generate_route(name: &str, route_msg: &RouteMessage) -> Result> return Ok(None); } + let mut flags: u32 = 0; + for flag in &route_msg.header.flags { + flags += u32::from(*flag); + } + let mut route = Route { scope: u8::from(route_msg.header.scope) as u32, device: name.to_string(), @@ -176,6 +181,7 @@ fn generate_route(name: &str, route_msg: &RouteMessage) -> Result> } else { IPFamily::V6 }, + flags, ..Default::default() };