Current network address did not change after miniport driver reloaded

Trying to run Address Change HLK test . I am getting some different MAC address while running the test .

I am supporting NDIS_MAC_OPTION_SUPPORTS_MAC_ADDRESS_OVERWRITE in OID_GEN_MAC_OPTIONS OID .

Following are the logs when the test :

Validate MAC options after a device pause/restart

We check for NDIS_MAC_OPTION_SUPPORTS_MAC_ADDRESS_OVERWRITE after a miniport restart because NDIS must preserve this flag across restarts (if it added the flag) for devices that support overwriting the local MAC (which is the purpose of this AddressChange test in general).
Adapter::NdisIOControl

  • Device: Virtual Network Driver
  • Oid: OID_GEN_MAC_OPTIONS
  • Buffer Length: 4
    MAC Options: 0x000002D8
    NDIS_MAC_OPTION_SUPPORTS_MAC_ADDRESS_OVERWRITE is present

Check network addresses on the test adapter after modifying the registry with new network address
Obtain new current address on Virtual Network Driver

Obtain new current address on Virtual Network Driver
Open::NdisRequest

  • Name: Test open for receiving
  • RequestType: QueryInformation
  • OID: OID_802_3_CURRENT_ADDRESS
  • RequestId: 0
  • BufferLength: 6
  • Flags: 0x00000000
  • PortNumber: 0
    Results
  • Status: NDIS_STATUS_SUCCESS (0x0)
  • Bytes Written: 6
  • Bytes Needed: 1737485104

Current address from test adapter is 00-13-EC-08-68-5C
New network address under test is 02-02-04-06-08-02

50009 Current network address did not change after driver was reloaded. The driver should have picked up a new network address from the registry.

Obtain new permanent address on Virtual Network Driver
Open::NdisRequest

  • Name: Test open for receiving
  • RequestType: QueryInformation
  • OID: OID_802_3_PERMANENT_ADDRESS
  • RequestId: 0
  • BufferLength: 6
  • Flags: 0x00000000
  • PortNumber: 0
    Results
  • Status: NDIS_STATUS_SUCCESS (0x0)
  • Bytes Written: 6
  • Bytes Needed: 1737485104

New permanent address from test adapter is 00-13-EC-08-68-5C
Original permanent address is 00-13-EC-08-68-5C

*******************************************************

I am handling the MAC address during initialization of miniport by:

*******************************************************

UCHAR* pMacAddress = NULL;
UINT nMacAddressLength = 0;

NdisReadNetworkAddress(&status, (PVOID*) &pMacAddress, &nMacAddressLength, hConfiguration);

if ((status == NDIS_STATUS_SUCCESS) && (nMacAddressLength == 6)) {
NdisMoveMemory(m_pMiniport->m_aMacAddress, pMacAddress, 6);
}

and handling OID queries by :

******************************************************
MacOptions = NDIS_MAC_OPTION_NO_LOOPBACK | NDIS_MAC_OPTION_FULL_DUPLEX | NDIS_MAC_OPTION_8021P_PRIORITY | NDIS_MAC_OPTION_SUPPORTS_MAC_ADDRESS_OVERWRITE;

case OID_GEN_MAC_OPTIONS:
pInformation = (PVOID)&MacOptions;
ulInformationLength = sizeof(MacOptions);
break;

case OID_802_3_PERMANENT_ADDRESS:
case OID_802_3_CURRENT_ADDRESS:
pInformation = &m_aMacAddress;
ulInformationLength = sizeof(m_aMacAddress);
break;

Why driver can’t get Current network after driver was reloaded ?
Anything missing ? Any suggestions ?

Thanks

> case OID_802_3_PERMANENT_ADDRESS:

case OID_802_3_CURRENT_ADDRESS:
pInformation = &m_aMacAddress;
ulInformationLength = sizeof(m_aMacAddress);
break;

The Permanent address and Current address are two distinct things. Why you return the permanent address when asked for the Current address? This test catches exactly this error.

–pa

yeah. thanks @Pavel A for that information . But i changed handling the OID is like :

***********************************************************
//Initially setting mac address values :
MacAddress[0] = 0x00;
MacAddress[1] = 0x13;
MacAddress[2] = 0xEC;
MacAddress[3] = 0x00;
MacAddress[4] = 0xFA;
MacAddress[5] = 0xCE;

and in miniport initialize function , i am reading the MAc address from registry using :

//setting the initial address as permanent address :

NdisMoveMemory(permanentaddress, pMacAddress, 6);

//reading from registry
NdisReadNetworkAddress(&status, (PVOID*) &pMacAddress, &nMacAddressLength,
hConfiguration);

//and moving this address to current address .
NdisMoveMemory(currentaddress, pMacAddress, 6);

****************************************************

and for OID request i am doing

case OID_802_3_PERMANENT_ADDRESS:
Information = &permanentaddress;
lInformationLength = sizeof(currentaddress);
break;

case OID_802_3_CURRENT_ADDRESS:
Information = &m_aMacAddress;
lInformationLength = sizeof(currentaddress);
break;

But still i am getting failed during this test :

the new logs are :

***********************************

Obtain new current address on Virtual Network Driver
Open::NdisRequest

  • Name: Test open for receiving
  • RequestType: QueryInformation
  • OID: OID_802_3_CURRENT_ADDRESS
  • RequestId: 0
  • BufferLength: 6
  • Flags: 0x00000000
  • PortNumber: 0
    Results
  • Status: NDIS_STATUS_SUCCESS (0x0)
  • Bytes Written: 6
  • Bytes Needed: 868215232

Current address from test adapter is 00-13-EC-08-68-5C
New network address under test is 02-02-04-06-08-02
50009 Current network address did not change after driver was reloaded. The driver should have picked up a new network address from the registry.
Obtain new permanent address on Virtual Network Driver
Open::NdisRequest

  • Name: Test open for receiving
  • RequestType: QueryInformation
  • OID: OID_802_3_PERMANENT_ADDRESS
  • RequestId: 0
  • BufferLength: 6
  • Flags: 0x00000000
  • PortNumber: 0
    Results
  • Status: NDIS_STATUS_SUCCESS (0x0)
  • Bytes Written: 6
  • Bytes Needed: 868215232

New permanent address from test adapter is 00-13-EC-00-FA-CE
Original permanent address is 00-13-EC-00-FA-CE

**********************************************************************************

Testing that packets were sent from Virtual Network Driver to Virtual Network Driver and received at NEW destination address 02-02-04-06-08-02
EndPoint::GetSendResults

  • Name: SuppDeviceSimpleCommHelper_EndPoint
    Results from sending packets on support adapter Virtual Network Driver:
    Actual Packets: 250
    Expected Packets: 250
    EndPoint::GetReceiveResults
  • Name: TestDeviceSimpleCommHelper_EndPoint
    Results from receiving packets on test adapter Virtual Network Driver:
    Actual Packets: 0
    Expected Packets: 237
    50032 Test adapter Virtual Network Driver received less than the expected percentage of packets sent.
    Test adapter is expected to receive 237 packets, (95 percent of 250 packets sent from Support adapter Virtual Network Driver)
    Please check that your hardware has been programmed with the new network address it read from the registry.

***************************************

Still getting Current network address did not change after driver was reloaded. The driver should have picked up a new network address from the registry error ? Still i am missing anything ?

Any suggestions or possible solution ?

Maybe there’s still some problem in your code. C is a subtle language :slight_smile:

//setting the initial address as permanent address :
NdisMoveMemory(permanentaddress, pMacAddress, 6);

//reading from registry
NdisReadNetworkAddress(&status, (PVOID*) &pMacAddress, &nMacAddressLength,
hConfiguration);

//and moving this address to current address .
NdisMoveMemory(currentaddress, pMacAddress, 6);

****************************************************

and for OID request i am doing

case OID_802_3_PERMANENT_ADDRESS:
Information = &permanentaddress;
lInformationLength = sizeof(currentaddress);
break;

case OID_802_3_CURRENT_ADDRESS:
Information = &m_aMacAddress;

Try this:

case OID_802_3_CURRENT_ADDRESS:
Information = currentaddress;

– pa

Thanks @Pavel A for your valuable suggestions .

UCHAR MacAddress[6];
UCHAR permanentaddress[6];
UCHAR currentaddress[6];

//Initially setting mac address values :
MacAddress[0] = 0x00;
MacAddress[1] = 0x13;
MacAddress[2] = 0xEC;
MacAddress[3] = 0x00;
MacAddress[4] = 0xFA;
MacAddress[5] = 0xCE;

This is the whole cpde for getting mac address i done :
************************************************
//setting permanent address

NdisMoveMemory(permanentaddress, MacAddress, 6);

//reading from registry
NdisReadNetworkAddress(&status, (PVOID*) &Address, &nMacAddressLength,
Configuration);

//and moving this address to current address .
NdisMoveMemory(currentaddress, pMacAddress, 6);

NdisMoveMemory(ndisMiniportAdapterGeneralAttributes.PermanentMacAddress, permanentaddress, 6);
NdisMoveMemory(ndisMiniportAdapterGeneralAttributes.CurrentMacAddress, currentaddress, 6);

case OID_802_3_PERMANENT_ADDRESS:
Information = &permanentaddress;
lInformationLength = sizeof(permanentaddress);
break;

case OID_802_3_CURRENT_ADDRESS:
Information = &currentaddress;
lInformationLength = sizeof(currentaddress);
break;

******************************************************

When i change to

case OID_802_3_CURRENT_ADDRESS:
Information = currentaddress;
lInformationLength = sizeof(currentaddress);
break;

that error is solved . But still getting 2 errors

Unable to stop driver, status is NDIS_STATUS (0xE000020B) and also eceived less than the expected percentage of packets sent.

log :
====------------------------------------------------

PnpManager::StopDriver

  • Instance ID: ROOT\NET\0000
    PnpManager::DoPropertyChange: Failed either SetupDiCallClassInstaller or SetupDiSetClassInstallParams. NT_STATUS (0xE000020B)
    50015 Unable to stop driver, status is NDIS_STATUS (0xE000020B)

EndPoint::GetSendResults

  • Name: SuppDeviceSimpleCommHelper_EndPoint
    Results from sending packets on support adapter Virtual Network Driver:
    Actual Packets: 250
    Expected Packets: 250
    EndPoint::GetReceiveResults
  • Name: TestDeviceSimpleCommHelper_EndPoint
    Results from receiving packets on test adapter Virtual Network Driver:
    Actual Packets: 92
    Expected Packets: 237
    50032 Test adapter Virtual Network Driver received less than the expected percentage of packets sent.
    Test adapter is expected to receive 237 packets, (95 percent of 250 packets sent from Support adapter Virtual Network Driver)
    Please check that your hardware has been programmed with the new network address it read from the registry.

======================================

Any idea ? Any suggestions ?

This adapter development for VPN related thing . I am using virtual miniport adapter . it has a predefined MAC address first and after connection it get a another MAC address from server . Any suggestions ?