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>
---
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.