From 903e608c23353a910e949090cba9cd18c4a30a77 Mon Sep 17 00:00:00 2001 From: Alex Lyn Date: Tue, 19 Aug 2025 20:09:20 +0800 Subject: [PATCH] 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 --- src/runtime-rs/crates/resource/src/manager_inner.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/runtime-rs/crates/resource/src/manager_inner.rs b/src/runtime-rs/crates/resource/src/manager_inner.rs index ad83848825..c898da56d1 100644 --- a/src/runtime-rs/crates/resource/src/manager_inner.rs +++ b/src/runtime-rs/crates/resource/src/manager_inner.rs @@ -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 = all_neighbors + .iter() + .filter(|n| n.state == NUD_PERMANENT as i32) + .cloned() + .collect(); if !neighbors.is_empty() { info!(sl!(), "update neighbors {:?}", neighbors); self.agent