runtime-rs: Add only static ARP entries with handle_neighours

To make it aligned with runtime-go, we need add only static ARP
entries into the targets.

Fixes #11697

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
This commit is contained in:
Alex Lyn
2025-08-19 20:09:20 +08:00
parent c92bb1aa88
commit 903e608c23

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