]> xenbits.xensource.com Git - xen-guest-agent.git/commitdiff
xenstore_schema_std: index the iface address cache with OS index
authorYann Dirson <yann.dirson@vates.fr>
Tue, 21 Nov 2023 09:11:29 +0000 (10:11 +0100)
committerYann Dirson <yann.dirson@vates.fr>
Fri, 8 Dec 2023 09:59:46 +0000 (10:59 +0100)
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 <yann.dirson@vates.fr>
src/xenstore_schema_std.rs

index 6edb70a893021ed7443a3f2f6fd00c89177cffa1..cdc6e0710be5830c9b378945804e9b80fe37babe 100644 (file)
@@ -23,7 +23,7 @@ struct IfaceIpStruct {
     v4: IfaceIpList,
     v6: IfaceIpList,
 }
-type IpList = HashMap<String, IfaceIpStruct>;
+type IpList = HashMap<u32, IfaceIpStruct>;
 
 // 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<String> {
         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 };