|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [win-pv-devel] [PATCH 2/2] Advertise MAC address information in the registry
Because XENNET's co-installer is again taking responsibility for messing
with network settings it needs to be able to figure out which VIF instance
corresponds to which emulated device, and the only way it can do that is
by MAC address.
This patch therefore restores the old 'Addresses' subkey under XENVIF's
service key and populates it with REG_SZ values named with PDO names and
containing hex encoded ':' separated MAC address octets.
Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
src/xenvif/driver.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
src/xenvif/driver.h | 5 +++++
src/xenvif/pdo.c | 41 +++++++++++++++++++++++++++++++++--------
3 files changed, 86 insertions(+), 8 deletions(-)
diff --git a/src/xenvif/driver.c b/src/xenvif/driver.c
index 66962e0..db17f2e 100644
--- a/src/xenvif/driver.c
+++ b/src/xenvif/driver.c
@@ -46,6 +46,7 @@
typedef struct _XENVIF_DRIVER {
PDRIVER_OBJECT DriverObject;
HANDLE ParametersKey;
+ HANDLE AddressesKey;
BOOLEAN NeedReboot;
} XENVIF_DRIVER, *PXENVIF_DRIVER;
@@ -117,6 +118,30 @@ DriverGetParametersKey(
return __DriverGetParametersKey();
}
+static FORCEINLINE VOID
+__DriverSetAddressesKey(
+ IN HANDLE Key
+ )
+{
+ Driver.AddressesKey = Key;
+}
+
+static FORCEINLINE HANDLE
+__DriverGetAddressesKey(
+ VOID
+ )
+{
+ return Driver.AddressesKey;
+}
+
+HANDLE
+DriverGetAddressesKey(
+ VOID
+ )
+{
+ return __DriverGetAddressesKey();
+}
+
#define MAXNAMELEN 128
static FORCEINLINE VOID
@@ -214,6 +239,7 @@ DriverUnload(
IN PDRIVER_OBJECT DriverObject
)
{
+ HANDLE AddressesKey;
HANDLE ParametersKey;
ASSERT3P(DriverObject, ==, __DriverGetDriverObject());
@@ -222,6 +248,11 @@ DriverUnload(
Driver.NeedReboot = FALSE;
+ AddressesKey = __DriverGetAddressesKey();
+ __DriverSetAddressesKey(NULL);
+
+ RegistryCloseKey(AddressesKey);
+
ParametersKey = __DriverGetParametersKey();
__DriverSetParametersKey(NULL);
@@ -328,6 +359,7 @@ DriverEntry(
{
HANDLE ServiceKey;
HANDLE ParametersKey;
+ HANDLE AddressesKey;
ULONG Index;
NTSTATUS status;
@@ -368,6 +400,15 @@ DriverEntry(
__DriverSetParametersKey(ParametersKey);
+ status = RegistryCreateSubKey(ServiceKey,
+ "Addresses",
+ REG_OPTION_VOLATILE,
+ &AddressesKey);
+ if (!NT_SUCCESS(status))
+ goto fail4;
+
+ __DriverSetAddressesKey(AddressesKey);
+
RegistryCloseKey(ServiceKey);
DriverObject->DriverExtension->AddDevice = AddDevice;
@@ -382,6 +423,13 @@ DriverEntry(
return STATUS_SUCCESS;
+fail4:
+ Error("fail4\n");
+
+ __DriverSetParametersKey(NULL);
+
+ RegistryCloseKey(ParametersKey);
+
fail3:
Error("fail3\n");
diff --git a/src/xenvif/driver.h b/src/xenvif/driver.h
index c045583..b2f1615 100644
--- a/src/xenvif/driver.h
+++ b/src/xenvif/driver.h
@@ -47,6 +47,11 @@ DriverGetParametersKey(
VOID
);
+extern HANDLE
+DriverGetAddressesKey(
+ VOID
+ );
+
extern VOID
DriverRequestReboot(
VOID
diff --git a/src/xenvif/pdo.c b/src/xenvif/pdo.c
index 3fbf980..33a75ae 100644
--- a/src/xenvif/pdo.c
+++ b/src/xenvif/pdo.c
@@ -730,16 +730,30 @@ __PdoSetPermanentAddress(
IN PCHAR Buffer
)
{
+ ANSI_STRING Ansi[2];
NTSTATUS status;
status = __PdoParseAddress(Buffer, &Pdo->PermanentAddress);
if (!NT_SUCCESS(status))
goto fail1;
- Info("%s: %s\n", __PdoGetName(Pdo), Buffer);
+ RtlZeroMemory(Ansi, sizeof (ANSI_STRING) * 2);
+ RtlInitAnsiString(&Ansi[0], Buffer);
+
+ status = RegistryUpdateSzValue(DriverGetAddressesKey(),
+ __PdoGetName(Pdo),
+ REG_SZ,
+ Ansi);
+ if (!NT_SUCCESS(status))
+ goto fail2;
+
+ Info("%s: %Z\n", __PdoGetName(Pdo), &Ansi[0]);
return STATUS_SUCCESS;
+fail2:
+ Error("fail2\n");
+
fail1:
Error("fail1 (%08x)\n", status);
@@ -762,6 +776,17 @@ PdoGetPermanentAddress(
return __PdoGetPermanentAddress(Pdo);
}
+static FORCEINLINE VOID
+__PdoClearPermanentAddress(
+ IN PXENVIF_PDO Pdo
+ )
+{
+ (VOID) RegistryDeleteValue(DriverGetAddressesKey(),
+ __PdoGetName(Pdo));
+
+ RtlZeroMemory(&Pdo->PermanentAddress, sizeof (ETHERNET_ADDRESS));
+}
+
static FORCEINLINE NTSTATUS
__PdoSetSoftwareKey(
IN PXENVIF_PDO Pdo
@@ -827,7 +852,7 @@ PdoSetFriendlyName(
{
PANSI_STRING DriverDesc;
CHAR Buffer[MAXNAMELEN];
- ANSI_STRING FriendlyName[2];
+ ANSI_STRING Ansi[2];
NTSTATUS status;
status = RegistryQuerySzValue(__PdoGetSoftwareKey(Pdo),
@@ -846,17 +871,17 @@ PdoSetFriendlyName(
if (!NT_SUCCESS(status))
goto fail2;
- RtlZeroMemory(FriendlyName, sizeof (ANSI_STRING) * 2);
- RtlInitAnsiString(&FriendlyName[0], Buffer);
+ RtlZeroMemory(Ansi, sizeof (ANSI_STRING) * 2);
+ RtlInitAnsiString(&Ansi[0], Buffer);
status = RegistryUpdateSzValue(__PdoGetHardwareKey(Pdo),
"FriendlyName",
REG_SZ,
- FriendlyName);
+ Ansi);
if (!NT_SUCCESS(status))
goto fail3;
- Info("%Z\n", &FriendlyName[0]);
+ Info("%s: %Z\n", __PdoGetName(Pdo), &Ansi[0]);
RegistryFreeSzValue(DriverDesc);
@@ -2734,7 +2759,7 @@ fail7:
fail6:
Error("fail6\n");
- RtlZeroMemory(&Pdo->PermanentAddress, sizeof (ETHERNET_ADDRESS));
+ __PdoClearPermanentAddress(Pdo);
fail5:
Error("fail5\n");
@@ -2817,7 +2842,7 @@ PdoDestroy(
RtlFreeUnicodeString(&Pdo->ContainerID);
RtlZeroMemory(&Pdo->ContainerID, sizeof (UNICODE_STRING));
- RtlZeroMemory(&Pdo->PermanentAddress, sizeof (ETHERNET_ADDRESS));
+ __PdoClearPermanentAddress(Pdo);
ThreadAlert(Pdo->DevicePowerThread);
ThreadJoin(Pdo->DevicePowerThread);
--
2.1.1
_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |