mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-12 22:58:58 +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,
|
source: from.source,
|
||||||
scope: from.scope,
|
scope: from.scope,
|
||||||
family: protobuf::EnumOrUnknown::new(from.family.into()),
|
family: protobuf::EnumOrUnknown::new(from.family.into()),
|
||||||
|
flags: from.flags,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -242,6 +243,7 @@ impl From<types::Route> for Route {
|
|||||||
source: src.source,
|
source: src.source,
|
||||||
scope: src.scope,
|
scope: src.scope,
|
||||||
family: src.family.unwrap().into(),
|
family: src.family.unwrap().into(),
|
||||||
|
flags: src.flags,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,6 +113,7 @@ pub struct Route {
|
|||||||
pub source: String,
|
pub source: String,
|
||||||
pub scope: u32,
|
pub scope: u32,
|
||||||
pub family: IPFamily,
|
pub family: IPFamily,
|
||||||
|
pub flags: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, PartialEq, Clone, Default)]
|
#[derive(Deserialize, Debug, PartialEq, Clone, Default)]
|
||||||
|
@ -290,6 +290,8 @@ pub(crate) struct Route {
|
|||||||
// Scope
|
// Scope
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub scope: u32,
|
pub scope: u32,
|
||||||
|
#[serde(default)]
|
||||||
|
pub flags: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Route {
|
impl Route {
|
||||||
@ -399,6 +401,7 @@ mod tests {
|
|||||||
source: "172.18.0.1".to_owned(),
|
source: "172.18.0.1".to_owned(),
|
||||||
gateway: "172.18.31.1".to_owned(),
|
gateway: "172.18.31.1".to_owned(),
|
||||||
scope: 0,
|
scope: 0,
|
||||||
|
flags: 0,
|
||||||
}],
|
}],
|
||||||
neighbors: vec![ARPNeighbor {
|
neighbors: vec![ARPNeighbor {
|
||||||
ip_address: Some("192.168.0.3/16".to_owned()),
|
ip_address: Some("192.168.0.3/16".to_owned()),
|
||||||
|
@ -74,6 +74,7 @@ impl NetworkInfoFromDan {
|
|||||||
source: route.source.clone(),
|
source: route.source.clone(),
|
||||||
scope: route.scope,
|
scope: route.scope,
|
||||||
family,
|
family,
|
||||||
|
flags: route.flags,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
@ -159,6 +160,7 @@ mod tests {
|
|||||||
source: "172.18.0.1".to_owned(),
|
source: "172.18.0.1".to_owned(),
|
||||||
gateway: "172.18.31.1".to_owned(),
|
gateway: "172.18.31.1".to_owned(),
|
||||||
scope: 0,
|
scope: 0,
|
||||||
|
flags: 0,
|
||||||
}],
|
}],
|
||||||
neighbors: vec![DanARPNeighbor {
|
neighbors: vec![DanARPNeighbor {
|
||||||
ip_address: Some("192.168.0.3/16".to_owned()),
|
ip_address: Some("192.168.0.3/16".to_owned()),
|
||||||
@ -194,6 +196,7 @@ mod tests {
|
|||||||
source: "172.18.0.1".to_owned(),
|
source: "172.18.0.1".to_owned(),
|
||||||
scope: 0,
|
scope: 0,
|
||||||
family: IPFamily::V4,
|
family: IPFamily::V4,
|
||||||
|
flags: 0,
|
||||||
}];
|
}];
|
||||||
assert_eq!(routes, network_info.routes().await.unwrap());
|
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);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut flags: u32 = 0;
|
||||||
|
for flag in &route_msg.header.flags {
|
||||||
|
flags += u32::from(*flag);
|
||||||
|
}
|
||||||
|
|
||||||
let mut route = Route {
|
let mut route = Route {
|
||||||
scope: u8::from(route_msg.header.scope) as u32,
|
scope: u8::from(route_msg.header.scope) as u32,
|
||||||
device: name.to_string(),
|
device: name.to_string(),
|
||||||
@ -176,6 +181,7 @@ fn generate_route(name: &str, route_msg: &RouteMessage) -> Result<Option<Route>>
|
|||||||
} else {
|
} else {
|
||||||
IPFamily::V6
|
IPFamily::V6
|
||||||
},
|
},
|
||||||
|
flags,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user