[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/2] Rework network settings copy code.


  • To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Paul Durrant <xadimgnik@xxxxxxxxx>
  • Date: Fri, 23 Sep 2022 16:11:12 +0100
  • Delivery-date: Fri, 23 Sep 2022 15:11:17 +0000
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

On 22/09/2022 07:58, Owen Smith wrote:
Rather than copying network settings twice (once on save and once on restore),
stash the current network interface guid and network Luid on save and copy
settings from the previous to the new location on restore.
By relying on the current settings, the copy code will always restore the
settings that are current. This will pick up any changes that are made without
requiring a copy from the save.

Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>

Acked-by: Paul Durrant <paul@xxxxxxx>

...with one nit...

---
  src/xenvif/pdo.c      |  93 +++--
  src/xenvif/settings.c | 810 +++++++++++++++++++++++-------------------
  2 files changed, 508 insertions(+), 395 deletions(-)

diff --git a/src/xenvif/pdo.c b/src/xenvif/pdo.c
index b3a4aae..82775b4 100644
--- a/src/xenvif/pdo.c
+++ b/src/xenvif/pdo.c
@@ -1180,6 +1180,45 @@ fail1:
      return status;
  }
+static NTSTATUS
+PdoGetInterfaceLuid(
+    IN  PXENVIF_PDO Pdo,
+    IN  HANDLE      Key,
+    OUT PNET_LUID   Luid
+    )
+{
+    ULONG           Value;
+    NTSTATUS        status;
+
+    UNREFERENCED_PARAMETER(Pdo);
+
+    status = RegistryQueryDwordValue(Key,
+                                     "*IfType",
+                                     &Value);
+    if (!NT_SUCCESS(status))
+        goto fail1;
+
+    Luid->Info.IfType = Value;
+
+    status = RegistryQueryDwordValue(Key,
+                                     "NetLuidIndex",
+                                     &Value);
+    if (!NT_SUCCESS(status))
+        goto fail2;
+
+    Luid->Info.NetLuidIndex = Value;
+
+    return STATUS_SUCCESS;
+
+fail2:
+    Error("fail2\n");
+
+fail1:
+    Error("fail1 (%08x)\n", status);
+
+    return status;
+}
+
  static VOID
  PdoUnplugRequest(
      IN  PXENVIF_PDO Pdo,
@@ -1216,7 +1255,6 @@ PdoStartDevice(
      PIO_STACK_LOCATION  StackLocation;
      HANDLE              SoftwareKey;
      HANDLE              HardwareKey;
-    ULONG               HasSettings;
      GUID                Guid;
      NTSTATUS            status;
@@ -1307,39 +1345,44 @@ PdoStartDevice(
          goto fail9;
      }
- status = RegistryQueryDwordValue(SoftwareKey,
-                                     "HasSettings",
-                                     &HasSettings);
-    if (!NT_SUCCESS(status))
-        HasSettings = 0;
-
-    if (HasSettings == 0) {
-        //
-        // If there is a stack bound then restore any settings that
-        // may have been saved from an aliasing emulated device.
-        //
-        status = PdoGetInterfaceGuid(Pdo, SoftwareKey, &Guid);
+    //
+    // If there is a stack bound then restore any settings that
+    // may have been saved from an aliasing emulated device.

Not *just* an emulated device now IIUC, right?

  Paul





 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.