mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-17 14:58:16 +00:00
Merge pull request #11232 from lifupan/mtu
runtime: add the mtu support for updating routes
This commit is contained in:
@@ -230,6 +230,7 @@ impl From<Route> for types::Route {
|
||||
scope: from.scope,
|
||||
family: protobuf::EnumOrUnknown::new(from.family.into()),
|
||||
flags: from.flags,
|
||||
mtu: from.mtu,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
@@ -245,6 +246,7 @@ impl From<types::Route> for Route {
|
||||
scope: src.scope,
|
||||
family: src.family.unwrap().into(),
|
||||
flags: src.flags,
|
||||
mtu: src.mtu,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -114,6 +114,7 @@ pub struct Route {
|
||||
pub scope: u32,
|
||||
pub family: IPFamily,
|
||||
pub flags: u32,
|
||||
pub mtu: u32,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, PartialEq, Clone, Default)]
|
||||
|
@@ -292,6 +292,8 @@ pub(crate) struct Route {
|
||||
pub scope: u32,
|
||||
#[serde(default)]
|
||||
pub flags: u32,
|
||||
#[serde(default)]
|
||||
pub mtu: u32,
|
||||
}
|
||||
|
||||
impl Route {
|
||||
@@ -369,7 +371,8 @@ mod tests {
|
||||
"source": "172.18.0.1",
|
||||
"gateway": "172.18.31.1",
|
||||
"scope": 0,
|
||||
"flags": 0
|
||||
"flags": 0,
|
||||
"mtu": 1450
|
||||
}],
|
||||
"neighbors": [{
|
||||
"ip_address": "192.168.0.3/16",
|
||||
@@ -402,6 +405,7 @@ mod tests {
|
||||
gateway: "172.18.31.1".to_owned(),
|
||||
scope: 0,
|
||||
flags: 0,
|
||||
mtu: 1450,
|
||||
}],
|
||||
neighbors: vec![ARPNeighbor {
|
||||
ip_address: Some("192.168.0.3/16".to_owned()),
|
||||
|
@@ -75,6 +75,7 @@ impl NetworkInfoFromDan {
|
||||
scope: route.scope,
|
||||
family,
|
||||
flags: route.flags,
|
||||
mtu: route.mtu,
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
@@ -161,6 +162,7 @@ mod tests {
|
||||
gateway: "172.18.31.1".to_owned(),
|
||||
scope: 0,
|
||||
flags: 0,
|
||||
mtu: 1450,
|
||||
}],
|
||||
neighbors: vec![DanARPNeighbor {
|
||||
ip_address: Some("192.168.0.3/16".to_owned()),
|
||||
@@ -197,6 +199,7 @@ mod tests {
|
||||
scope: 0,
|
||||
family: IPFamily::V4,
|
||||
flags: 0,
|
||||
mtu: 1450,
|
||||
}];
|
||||
assert_eq!(routes, network_info.routes().await.unwrap());
|
||||
|
||||
|
@@ -16,7 +16,7 @@ use futures::stream::TryStreamExt;
|
||||
use netlink_packet_route::{
|
||||
self,
|
||||
neighbour::{NeighbourAddress, NeighbourAttribute, NeighbourMessage},
|
||||
route::{RouteAddress, RouteAttribute, RouteMessage},
|
||||
route::{RouteAddress, RouteAttribute, RouteMessage, RouteMetric},
|
||||
};
|
||||
use rtnetlink::{IpVersion, RouteMessageBuilder};
|
||||
|
||||
@@ -200,6 +200,14 @@ fn generate_route(name: &str, route_msg: &RouteMessage) -> Result<Option<Route>>
|
||||
|
||||
route.source = dest.to_string();
|
||||
}
|
||||
RouteAttribute::Metrics(metrics) => {
|
||||
for m in metrics {
|
||||
if let RouteMetric::Mtu(mtu) = m {
|
||||
route.mtu = *mtu;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user