Merge pull request #11698 from Apokleos/filter-arpneibhors

runtime-rs: Add only static ARP entries with handle_neighours
This commit is contained in:
Fupan Li 2025-08-20 14:05:20 +08:00 committed by GitHub
commit b748688e69
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,7 +6,7 @@
use std::{collections::HashMap, sync::Arc, thread};
use agent::{types::Device, Agent, OnlineCPUMemRequest, Storage};
use agent::{types::Device, ARPNeighbor, Agent, OnlineCPUMemRequest, Storage};
use anyhow::{anyhow, Context, Ok, Result};
use async_trait::async_trait;
use hypervisor::{
@ -22,6 +22,7 @@ use kata_types::{
config::{hypervisor::TopologyConfigInfo, TomlConfig},
mount::{adjust_rootfs_mounts, KATA_IMAGE_FORCE_GUEST_PULL},
};
use libc::NUD_PERMANENT;
use oci::{Linux, LinuxCpu, LinuxResources};
use oci_spec::runtime::{self as oci, LinuxDeviceType};
use persist::sandbox_persist::Persist;
@ -260,7 +261,14 @@ impl ResourceManagerInner {
}
async fn handle_neighbours(&self, network: &dyn Network) -> Result<()> {
let neighbors = network.neighs().await.context("neighs")?;
let all_neighbors = network.neighs().await.context("neighs")?;
// We add only static ARP entries
let neighbors: Vec<ARPNeighbor> = all_neighbors
.iter()
.filter(|n| n.state == NUD_PERMANENT as i32)
.cloned()
.collect();
if !neighbors.is_empty() {
info!(sl!(), "update neighbors {:?}", neighbors);
self.agent