mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-27 19:35:32 +00:00
runtime-rs: add the route flags support
Get the route entry's flags from the host and pass it into kata-agent to add route entries with flags support. Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
This commit is contained in:
parent
cda6d0e36c
commit
0995c6528e
@ -228,6 +228,7 @@ impl From<Route> 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<types::Route> for Route {
|
||||
source: src.source,
|
||||
scope: src.scope,
|
||||
family: src.family.unwrap().into(),
|
||||
flags: src.flags,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)]
|
||||
|
@ -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()),
|
||||
|
@ -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());
|
||||
|
||||
|
@ -168,6 +168,11 @@ fn generate_route(name: &str, route_msg: &RouteMessage) -> Result<Option<Route>>
|
||||
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<Option<Route>>
|
||||
} else {
|
||||
IPFamily::V6
|
||||
},
|
||||
flags,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user