From: Yann Dirson Date: Tue, 21 Nov 2023 09:11:29 +0000 (+0100) Subject: xenstore_schema_std: index the iface address cache with OS index X-Git-Tag: 0.3.0~11^2~15 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=39098de079b624b347d8c447ebafbb667b48cbd8;p=xen-guest-agent.git xenstore_schema_std: index the iface address cache with OS index Iface name is not always part of a Netlink message, as opposed to the OS index of the interface, and looking up the name following reception of an interface removal notification just does not work. All supported and prospective platforms seem to have a concept of interface OS index, so this should cause no problem and be more efficient. Signed-off-by: Yann Dirson --- diff --git a/src/xenstore_schema_std.rs b/src/xenstore_schema_std.rs index 6edb70a..cdc6e07 100644 --- a/src/xenstore_schema_std.rs +++ b/src/xenstore_schema_std.rs @@ -23,7 +23,7 @@ struct IfaceIpStruct { v4: IfaceIpList, v6: IfaceIpList, } -type IpList = HashMap; +type IpList = HashMap; // pseudo version for xe-daemon compatibility, real agent version in // BuildVersion below @@ -136,7 +136,7 @@ impl XenstoreSchema for Schema { impl Schema { fn munged_address(&mut self, addr: &IpAddr, iface: &NetInterface) -> io::Result { let ip_entry = self.ip_addresses - .entry(iface.name.clone()) // wtf, need cloning string for a lookup!? + .entry(iface.index) .or_insert(IfaceIpStruct{v4: [None; NUM_IFACE_IPS], v6: [None; NUM_IFACE_IPS]}); let ip_list = match addr { IpAddr::V4(_) => &mut ip_entry.v4, IpAddr::V6(_) => &mut ip_entry.v6 };