public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx
@ 2023-10-31 17:56 Igor Kulchytskyy via groups.io
  2023-11-01  1:00 ` Mike Maslenkin
  0 siblings, 1 reply; 10+ messages in thread
From: Igor Kulchytskyy via groups.io @ 2023-10-31 17:56 UTC (permalink / raw)
  To: devel@edk2.groups.io; +Cc: Abner Chang, Nickle Wang

Supported function of the driver changed to wait for all newtwork
interface to be installed.
Filer out the network interfaces which are not supported by
Redfish Host Interface.

Cc: Abner Chang <abner.chang@amd.com>
Cc: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Signed-off-by: Igor Kulchytskyy <igork@ami.com>
---
 RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c | 96 ++++++++++++++++++--
 1 file changed, 89 insertions(+), 7 deletions(-)

diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
index 23da3b968f..a88ad55938 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
@@ -322,9 +322,15 @@ GetTargetNetworkInterfaceInternal (
 {
   EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterface;

+  if (IsListEmpty(&mEfiRedfishDiscoverNetworkInterface)) {
+    return NULL;
+  }
+
   ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
   while (TRUE) {
-    if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) == 0) {
+    if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) == 0 &&
+        ((TargetNetworkInterface->IsIpv6 && ThisNetworkInterface->NetworkProtocolType == ProtocolTypeTcp6) ||
+            (!TargetNetworkInterface->IsIpv6 && ThisNetworkInterface->NetworkProtocolType == ProtocolTypeTcp4))) {
       return ThisNetworkInterface;
     }

@@ -354,6 +360,10 @@ GetTargetNetworkInterfaceInternalByController (
 {
   EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterface;

+  if (IsListEmpty(&mEfiRedfishDiscoverNetworkInterface)) {
+    return NULL;
+  }
+
   ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
   while (TRUE) {
     if (ThisNetworkInterface->OpenDriverControllerHandle == ControllerHandle) {
@@ -476,6 +486,38 @@ CheckIsIpVersion6 (
   return FALSE;
 }

+/**
+  This function returns the  IP type supported by the Host Interface
+
+  @retval IP Type
+  //  Unknown=00h,
+  //  Ipv4=01h,
+  //  Ipv6=02h,
+
+**/
+UINT8
+GetHiIpProtocolType()
+{
+  EFI_STATUS                     Status;
+  REDFISH_OVER_IP_PROTOCOL_DATA  *Data;
+  REDFISH_INTERFACE_DATA         *DeviceDescriptor;
+
+  Data             = NULL;
+  DeviceDescriptor = NULL;
+  if (mSmbios == NULL) {
+    Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&mSmbios);
+    if (EFI_ERROR (Status)) {
+      return 0;
+    }
+  }
+  Status = RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescriptor, &Data); // Search for SMBIOS type 42h
+  if (!EFI_ERROR (Status) && (Data != NULL) &&
+      (Data->HostIpAssignmentType == RedfishHostIpAssignmentStatic)) {
+      return Data->HostIpAddressFormat;
+  }
+  return 0;
+}
+
 /**
   This function discover Redfish service through SMBIOS host interface.

@@ -512,6 +554,15 @@ DiscoverRedfishHostInterface (

   Status = RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescriptor, &Data); // Search for SMBIOS type 42h
   if (!EFI_ERROR (Status) && (Data != NULL) && (DeviceDescriptor != NULL)) {
+
+    if (Instance->NetworkInterface->NetworkProtocolType == ProtocolTypeTcp4 && Data->HostIpAddressFormat != REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4) { // IPv4 case
+      DEBUG((DEBUG_ERROR, "%a: Network Interface is IPv4, but Host Interface requires Ipv6\n"));
+      return EFI_UNSUPPORTED;
+    }
+    else if (Instance->NetworkInterface->NetworkProtocolType == ProtocolTypeTcp6 && Data->HostIpAddressFormat != REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6) { // IPv6 case
+      DEBUG((DEBUG_ERROR, "%a: Network Interface is IPv6, but Host Interface requires IPv4\n"));
+      return EFI_UNSUPPORTED;
+    }
     //
     // Check if we can reach out Redfish service using this network interface.
     // Check with MAC address using Device Descriptor Data Device Type 04 and Type 05.
@@ -1102,6 +1153,7 @@ RedfishServiceGetNetworkInterface (
   OUT EFI_REDFISH_DISCOVER_NETWORK_INTERFACE  **NetworkIntfInstances
   )
 {
+  EFI_STATUS                                       Status;
   EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterfaceIntn;
   EFI_REDFISH_DISCOVER_NETWORK_INTERFACE           *ThisNetworkInterface;
   EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL   *RestExInstance;
@@ -1141,6 +1193,16 @@ RedfishServiceGetNetworkInterface (

   ThisNetworkInterfaceIntn = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
   while (TRUE) {
+    // If Get Subnet Info skip this interface
+    Status = NetworkInterfaceGetSubnetInfo (ThisNetworkInterfaceIntn, ImageHandle); // Get subnet info
+    if (EFI_ERROR(Status)) {
+      if (IsNodeAtEnd (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterfaceIntn->Entry)) {
+        break;
+      }
+      ThisNetworkInterfaceIntn = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetNextNode (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterfaceIntn->Entry);
+      continue;
+    }
+
     ThisNetworkInterface->IsIpv6 = FALSE;
     if (CheckIsIpVersion6 (ThisNetworkInterfaceIntn)) {
       ThisNetworkInterface->IsIpv6 = TRUE;
@@ -1260,7 +1322,12 @@ RedfishServiceAcquireService (
       // Get subnet information in case subnet information is not set because
       // RedfishServiceGetNetworkInterfaces hasn't been called yet.
       //
-      NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInternal, ImageHandle);
+      Status1 = NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInternal, ImageHandle);
+      if (EFI_ERROR(Status1)) {
+        DEBUG ((DEBUG_ERROR, "%a: Get subnet information fail.\n", __func__));
+        FreePool(Instance);
+        continue;
+      }
       NewInstance = TRUE;
     }

@@ -1535,7 +1602,7 @@ TestForRequiredProtocols (
   UINT32      *Id;
   UINTN       Index;
   EFI_STATUS  Status;
-  UINTN       ListCount;
+  UINTN       ListCount, SuccessfulCount = 0;

   ListCount = (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL));
   for (Index = 0; Index < ListCount; Index++) {
@@ -1557,13 +1624,14 @@ TestForRequiredProtocols (
                       EFI_OPEN_PROTOCOL_GET_PROTOCOL
                       );
       if (EFI_ERROR (Status)) {
-        if (Index == ListCount - 1) {
-          DEBUG ((DEBUG_INFO, "%a: all required protocols are found on this controller handle: %p.\n", __func__, ControllerHandle));
-          return EFI_SUCCESS;
-        }
+        SuccessfulCount++;
       }
     }
   }
+  if (ListCount == SuccessfulCount) {
+    DEBUG ((DEBUG_INFO, "%a: all required protocols are found on this controller handle: %p.\n", __func__, ControllerHandle));
+    return EFI_SUCCESS;
+  }

   return EFI_UNSUPPORTED;
 }
@@ -1600,10 +1668,24 @@ BuildupNetworkInterface (
   EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL   *RestExInstance;
   EFI_TPL                                          OldTpl;
   BOOLEAN                                          NewNetworkInterfaceInstalled;
+  UINT8                                            IpType;

   NewNetworkInterfaceInstalled = FALSE;
   Index                        = 0;
+
+
+  // Get IP Type to filter out unnecessary network protocol if possible
+  IpType = GetHiIpProtocolType();
+
   do {
+    // Check IP Type and skip an unnecessary network protocol if does not match
+    if (IpType != 0) {
+      if ((gRequiredProtocol[Index].ProtocolType == ProtocolTypeTcp4 && IpType == REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6) ||
+          (gRequiredProtocol[Index].ProtocolType == ProtocolTypeTcp6 && IpType == REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4)) {
+        Index++;
+        continue;
+      }
+    }
     Status = gBS->OpenProtocol (
                     // Already in list?
                     ControllerHandle,
--
2.37.1.windows.1
-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110440): https://edk2.groups.io/g/devel/message/110440
Mute This Topic: https://groups.io/mt/102303105/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx
  2023-10-31 17:56 [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx Igor Kulchytskyy via groups.io
@ 2023-11-01  1:00 ` Mike Maslenkin
  2023-11-01  3:24   ` Igor Kulchytskyy via groups.io
  0 siblings, 1 reply; 10+ messages in thread
From: Mike Maslenkin @ 2023-11-01  1:00 UTC (permalink / raw)
  To: devel, igork; +Cc: Abner Chang, Nickle Wang

Hi Igor

please find my comments below.

On Tue, Oct 31, 2023 at 8:56 PM Igor Kulchytskyy via groups.io
<igork=ami.com@groups.io> wrote:
>
> Supported function of the driver changed to wait for all newtwork
> interface to be installed.
> Filer out the network interfaces which are not supported by
> Redfish Host Interface.
>
> Cc: Abner Chang <abner.chang@amd.com>
> Cc: Nickle Wang <nicklew@nvidia.com>
> Cc: Igor Kulchytskyy <igork@ami.com>
> Signed-off-by: Igor Kulchytskyy <igork@ami.com>
> ---
>  RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c | 96 ++++++++++++++++++--
>  1 file changed, 89 insertions(+), 7 deletions(-)
>
> diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> index 23da3b968f..a88ad55938 100644
> --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> @@ -322,9 +322,15 @@ GetTargetNetworkInterfaceInternal (
>  {
>    EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterface;
>
> +  if (IsListEmpty(&mEfiRedfishDiscoverNetworkInterface)) {
> +    return NULL;
> +  }
> +
>    ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
>    while (TRUE) {
> -    if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) == 0) {
> +    if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) == 0 &&
> +        ((TargetNetworkInterface->IsIpv6 && ThisNetworkInterface->NetworkProtocolType == ProtocolTypeTcp6) ||
> +            (!TargetNetworkInterface->IsIpv6 && ThisNetworkInterface->NetworkProtocolType == ProtocolTypeTcp4))) {
>        return ThisNetworkInterface;
>      }
>
> @@ -354,6 +360,10 @@ GetTargetNetworkInterfaceInternalByController (
>  {
>    EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterface;
>
> +  if (IsListEmpty(&mEfiRedfishDiscoverNetworkInterface)) {
> +    return NULL;
> +  }
> +

I also have these two hunks in my pending list.
But I suggest to add ASSERT to GetTargetNetworkInterfaceInternal, just
because currently it is really impossible situation,
and mEfiRedfishDiscoverNetworkInterface was checked before in scope of
 ValidateTargetNetworkInterface().
Also I wonder why check patch doesn't complain about missed spaces in
"IsListEmpty (&mEfiRedfishDiscoverNetworkInterface)" call for example.

>    ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
>    while (TRUE) {
>      if (ThisNetworkInterface->OpenDriverControllerHandle == ControllerHandle) {
> @@ -476,6 +486,38 @@ CheckIsIpVersion6 (
>    return FALSE;
>  }
>
> +/**
> +  This function returns the  IP type supported by the Host Interface
> +
> +  @retval IP Type
> +  //  Unknown=00h,
> +  //  Ipv4=01h,
> +  //  Ipv6=02h,
> +
> +**/
> +UINT8

STATIC ?

> +GetHiIpProtocolType()
> +{
> +  EFI_STATUS                     Status;
> +  REDFISH_OVER_IP_PROTOCOL_DATA  *Data;
> +  REDFISH_INTERFACE_DATA         *DeviceDescriptor;
> +
> +  Data             = NULL;
> +  DeviceDescriptor = NULL;
> +  if (mSmbios == NULL) {
> +    Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&mSmbios);
> +    if (EFI_ERROR (Status)) {
> +      return 0;

In this driver REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP{4,6}
used and accessible.
so, 0 means  REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN
And these values actually checked in scope of BuildupNetworkInterface() below.

> +    }
> +  }
> +  Status = RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescriptor, &Data); // Search for SMBIOS type 42h
> +  if (!EFI_ERROR (Status) && (Data != NULL) &&
> +      (Data->HostIpAssignmentType == RedfishHostIpAssignmentStatic)) {
> +      return Data->HostIpAddressFormat;
> +  }
> +  return 0;

Same here, 0 is a magic value for
REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN

> +}
> +
>  /**
>    This function discover Redfish service through SMBIOS host interface.
>
> @@ -512,6 +554,15 @@ DiscoverRedfishHostInterface (
>
>    Status = RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescriptor, &Data); // Search for SMBIOS type 42h
>    if (!EFI_ERROR (Status) && (Data != NULL) && (DeviceDescriptor != NULL)) {
> +
> +    if (Instance->NetworkInterface->NetworkProtocolType == ProtocolTypeTcp4 && Data->HostIpAddressFormat != REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4) { // IPv4 case
> +      DEBUG((DEBUG_ERROR, "%a: Network Interface is IPv4, but Host Interface requires Ipv6\n"));

Missed argument for %a format
Missed space "DEBUG (("

> +      return EFI_UNSUPPORTED;
> +    }
> +    else if (Instance->NetworkInterface->NetworkProtocolType == ProtocolTypeTcp6 && Data->HostIpAddressFormat != REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6) { // IPv6 case
> +      DEBUG((DEBUG_ERROR, "%a: Network Interface is IPv6, but Host Interface requires IPv4\n"));

Missed argument for %a format
Missed space "DEBUG (("


> +      return EFI_UNSUPPORTED;
> +    }
>      //
>      // Check if we can reach out Redfish service using this network interface.
>      // Check with MAC address using Device Descriptor Data Device Type 04 and Type 05.
> @@ -1102,6 +1153,7 @@ RedfishServiceGetNetworkInterface (
>    OUT EFI_REDFISH_DISCOVER_NETWORK_INTERFACE  **NetworkIntfInstances
>    )
>  {
> +  EFI_STATUS                                       Status;
>    EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterfaceIntn;
>    EFI_REDFISH_DISCOVER_NETWORK_INTERFACE           *ThisNetworkInterface;
>    EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL   *RestExInstance;
> @@ -1141,6 +1193,16 @@ RedfishServiceGetNetworkInterface (
>
>    ThisNetworkInterfaceIntn = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
>    while (TRUE) {
> +    // If Get Subnet Info skip this interface
> +    Status = NetworkInterfaceGetSubnetInfo (ThisNetworkInterfaceIntn, ImageHandle); // Get subnet info
> +    if (EFI_ERROR(Status)) {
> +      if (IsNodeAtEnd (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterfaceIntn->Entry)) {
> +        break;
> +      }
> +      ThisNetworkInterfaceIntn = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetNextNode (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterfaceIntn->Entry);
> +      continue;
> +    }
> +
>      ThisNetworkInterface->IsIpv6 = FALSE;
>      if (CheckIsIpVersion6 (ThisNetworkInterfaceIntn)) {
>        ThisNetworkInterface->IsIpv6 = TRUE;
> @@ -1260,7 +1322,12 @@ RedfishServiceAcquireService (
>        // Get subnet information in case subnet information is not set because
>        // RedfishServiceGetNetworkInterfaces hasn't been called yet.
>        //
> -      NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInternal, ImageHandle);
> +      Status1 = NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInternal, ImageHandle);
> +      if (EFI_ERROR(Status1)) {
> +        DEBUG ((DEBUG_ERROR, "%a: Get subnet information fail.\n", __func__));
> +        FreePool(Instance);
> +        continue;
> +      }
>        NewInstance = TRUE;
>      }
>
> @@ -1535,7 +1602,7 @@ TestForRequiredProtocols (
>    UINT32      *Id;
>    UINTN       Index;
>    EFI_STATUS  Status;
> -  UINTN       ListCount;
> +  UINTN       ListCount, SuccessfulCount = 0;
>
>    ListCount = (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL));
>    for (Index = 0; Index < ListCount; Index++) {
> @@ -1557,13 +1624,14 @@ TestForRequiredProtocols (
>                        EFI_OPEN_PROTOCOL_GET_PROTOCOL
>                        );
>        if (EFI_ERROR (Status)) {
> -        if (Index == ListCount - 1) {
> -          DEBUG ((DEBUG_INFO, "%a: all required protocols are found on this controller handle: %p.\n", __func__, ControllerHandle));
> -          return EFI_SUCCESS;
> -        }
> +        SuccessfulCount++;
>        }
It may be SuccessfulCount must have one indentation less, i.e in scope
of  upper "if (!EFI_ERROR (Status)) {", not in scope of "if (EFI_ERROR
(Status)) {" in context.

>      }
>    }
> +  if (ListCount == SuccessfulCount) {
> +    DEBUG ((DEBUG_INFO, "%a: all required protocols are found on this controller handle: %p.\n", __func__, ControllerHandle));
> +    return EFI_SUCCESS;
> +  }
>
>    return EFI_UNSUPPORTED;
>  }
> @@ -1600,10 +1668,24 @@ BuildupNetworkInterface (
>    EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL   *RestExInstance;
>    EFI_TPL                                          OldTpl;
>    BOOLEAN                                          NewNetworkInterfaceInstalled;
> +  UINT8                                            IpType;
>
>    NewNetworkInterfaceInstalled = FALSE;
>    Index                        = 0;
> +
> +
> +  // Get IP Type to filter out unnecessary network protocol if possible
> +  IpType = GetHiIpProtocolType();
> +
>    do {
> +    // Check IP Type and skip an unnecessary network protocol if does not match
> +    if (IpType != 0) {

IpType is invariant to this loop.
Eiher we may check it's value before the loop or we can just drop it,
because "&& IpType ==
REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP{4,6}"
is equal to "IpType != 0" Do I miss something?

> +      if ((gRequiredProtocol[Index].ProtocolType == ProtocolTypeTcp4 && IpType == REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6) ||
> +          (gRequiredProtocol[Index].ProtocolType == ProtocolTypeTcp6 && IpType == REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4)) {
> +        Index++;

Ops. You can not do just  { Index++;continue }
You need
{
      Index++;
      if (Index == (sizeof (gRequiredProtocol) / sizeof
(REDFISH_DISCOVER_REQUIRED_PROTOCOL))) {
        break;
      }
      continue;
}

It's a terrible function. I have a patch, that improves this loop:
https://github.com/ghbaccount/edk2/commit/adc3218d3d96083c85cef6c396dde8ddb96530fb

> +        continue;
> +      }
> +    }
>      Status = gBS->OpenProtocol (
>                      // Already in list?
>                      ControllerHandle,
> --
> 2.37.1.windows.1

Regards,
Mike.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110458): https://edk2.groups.io/g/devel/message/110458
Mute This Topic: https://groups.io/mt/102303105/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx
  2023-11-01  1:00 ` Mike Maslenkin
@ 2023-11-01  3:24   ` Igor Kulchytskyy via groups.io
  2023-11-01  9:36     ` Mike Maslenkin
  2023-11-06  2:29     ` Mike Maslenkin
  0 siblings, 2 replies; 10+ messages in thread
From: Igor Kulchytskyy via groups.io @ 2023-11-01  3:24 UTC (permalink / raw)
  To: Mike Maslenkin, devel@edk2.groups.io; +Cc: Abner Chang, Nickle Wang

Hi Mike,
Thank you for review.
Please see my answers below the text.

-----Original Message-----
From: Mike Maslenkin <mike.maslenkin@gmail.com>
Sent: Tuesday, October 31, 2023 9:00 PM
To: devel@edk2.groups.io; Igor Kulchytskyy <igork@ami.com>
Cc: Abner Chang <abner.chang@amd.com>; Nickle Wang <nicklew@nvidia.com>
Subject: [EXTERNAL] Re: [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx


**CAUTION: The e-mail below is from an external source. Please exercise caution before opening attachments, clicking links, or following guidance.**

Hi Igor

please find my comments below.

On Tue, Oct 31, 2023 at 8:56 PM Igor Kulchytskyy via groups.io
<igork=ami.com@groups.io> wrote:
>
> Supported function of the driver changed to wait for all newtwork
> interface to be installed.
> Filer out the network interfaces which are not supported by
> Redfish Host Interface.
>
> Cc: Abner Chang <abner.chang@amd.com>
> Cc: Nickle Wang <nicklew@nvidia.com>
> Cc: Igor Kulchytskyy <igork@ami.com>
> Signed-off-by: Igor Kulchytskyy <igork@ami.com>
> ---
>  RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c | 96 ++++++++++++++++++--
>  1 file changed, 89 insertions(+), 7 deletions(-)
>
> diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> index 23da3b968f..a88ad55938 100644
> --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> @@ -322,9 +322,15 @@ GetTargetNetworkInterfaceInternal (
>  {
>    EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterface;
>
> +  if (IsListEmpty(&mEfiRedfishDiscoverNetworkInterface)) {
> +    return NULL;
> +  }
> +
>    ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
>    while (TRUE) {
> -    if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) == 0) {
> +    if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) == 0 &&
> +        ((TargetNetworkInterface->IsIpv6 && ThisNetworkInterface->NetworkProtocolType == ProtocolTypeTcp6) ||
> +            (!TargetNetworkInterface->IsIpv6 && ThisNetworkInterface->NetworkProtocolType == ProtocolTypeTcp4))) {
>        return ThisNetworkInterface;
>      }
>
> @@ -354,6 +360,10 @@ GetTargetNetworkInterfaceInternalByController (
>  {
>    EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterface;
>
> +  if (IsListEmpty(&mEfiRedfishDiscoverNetworkInterface)) {
> +    return NULL;
> +  }
> +

I also have these two hunks in my pending list.
But I suggest to add ASSERT to GetTargetNetworkInterfaceInternal, just
because currently it is really impossible situation,
and mEfiRedfishDiscoverNetworkInterface was checked before in scope of
 ValidateTargetNetworkInterface().

Igor: Agree.
I also just noticed that even if GetTargetNetworkInterfaceInternal function may return NULL, the return value is not verified on NULL in RedfishServiceAcquireService function.
I think we should add this verification.


Also I wonder why check patch doesn't complain about missed spaces in
"IsListEmpty (&mEfiRedfishDiscoverNetworkInterface)" call for example.

>    ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
>    while (TRUE) {
>      if (ThisNetworkInterface->OpenDriverControllerHandle == ControllerHandle) {
> @@ -476,6 +486,38 @@ CheckIsIpVersion6 (
>    return FALSE;
>  }
>
> +/**
> +  This function returns the  IP type supported by the Host Interface
> +
> +  @retval IP Type
> +  //  Unknown=00h,
> +  //  Ipv4=01h,
> +  //  Ipv6=02h,
> +
> +**/
> +UINT8

STATIC ?
Igor: WHY?

> +GetHiIpProtocolType()
> +{
> +  EFI_STATUS                     Status;
> +  REDFISH_OVER_IP_PROTOCOL_DATA  *Data;
> +  REDFISH_INTERFACE_DATA         *DeviceDescriptor;
> +
> +  Data             = NULL;
> +  DeviceDescriptor = NULL;
> +  if (mSmbios == NULL) {
> +    Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&mSmbios);
> +    if (EFI_ERROR (Status)) {
> +      return 0;

In this driver REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP{4,6}
used and accessible.
so, 0 means  REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN
And these values actually checked in scope of BuildupNetworkInterface() below.
Igor: Thank you. Missed that macro.

> +    }
> +  }
> +  Status = RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescriptor, &Data); // Search for SMBIOS type 42h
> +  if (!EFI_ERROR (Status) && (Data != NULL) &&
> +      (Data->HostIpAssignmentType == RedfishHostIpAssignmentStatic)) {
> +      return Data->HostIpAddressFormat;
> +  }
> +  return 0;

Same here, 0 is a magic value for
REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN

> +}
> +
>  /**
>    This function discover Redfish service through SMBIOS host interface.
>
> @@ -512,6 +554,15 @@ DiscoverRedfishHostInterface (
>
>    Status = RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescriptor, &Data); // Search for SMBIOS type 42h
>    if (!EFI_ERROR (Status) && (Data != NULL) && (DeviceDescriptor != NULL)) {
> +
> +    if (Instance->NetworkInterface->NetworkProtocolType == ProtocolTypeTcp4 && Data->HostIpAddressFormat != REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4) { // IPv4 case
> +      DEBUG((DEBUG_ERROR, "%a: Network Interface is IPv4, but Host Interface requires Ipv6\n"));

Missed argument for %a format
Missed space "DEBUG (("

Igor: Inattentiveness. Thank you.

> +      return EFI_UNSUPPORTED;
> +    }
> +    else if (Instance->NetworkInterface->NetworkProtocolType == ProtocolTypeTcp6 && Data->HostIpAddressFormat != REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6) { // IPv6 case
> +      DEBUG((DEBUG_ERROR, "%a: Network Interface is IPv6, but Host Interface requires IPv4\n"));

Missed argument for %a format
Missed space "DEBUG (("

Igor: Inattentiveness. Thank you.

> +      return EFI_UNSUPPORTED;
> +    }
>      //
>      // Check if we can reach out Redfish service using this network interface.
>      // Check with MAC address using Device Descriptor Data Device Type 04 and Type 05.
> @@ -1102,6 +1153,7 @@ RedfishServiceGetNetworkInterface (
>    OUT EFI_REDFISH_DISCOVER_NETWORK_INTERFACE  **NetworkIntfInstances
>    )
>  {
> +  EFI_STATUS                                       Status;
>    EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterfaceIntn;
>    EFI_REDFISH_DISCOVER_NETWORK_INTERFACE           *ThisNetworkInterface;
>    EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL   *RestExInstance;
> @@ -1141,6 +1193,16 @@ RedfishServiceGetNetworkInterface (
>
>    ThisNetworkInterfaceIntn = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
>    while (TRUE) {
> +    // If Get Subnet Info skip this interface
> +    Status = NetworkInterfaceGetSubnetInfo (ThisNetworkInterfaceIntn, ImageHandle); // Get subnet info
> +    if (EFI_ERROR(Status)) {
> +      if (IsNodeAtEnd (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterfaceIntn->Entry)) {
> +        break;
> +      }
> +      ThisNetworkInterfaceIntn = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetNextNode (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterfaceIntn->Entry);
> +      continue;
> +    }
> +
>      ThisNetworkInterface->IsIpv6 = FALSE;
>      if (CheckIsIpVersion6 (ThisNetworkInterfaceIntn)) {
>        ThisNetworkInterface->IsIpv6 = TRUE;
> @@ -1260,7 +1322,12 @@ RedfishServiceAcquireService (
>        // Get subnet information in case subnet information is not set because
>        // RedfishServiceGetNetworkInterfaces hasn't been called yet.
>        //
> -      NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInternal, ImageHandle);
> +      Status1 = NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInternal, ImageHandle);
> +      if (EFI_ERROR(Status1)) {
> +        DEBUG ((DEBUG_ERROR, "%a: Get subnet information fail.\n", __func__));
> +        FreePool(Instance);
> +        continue;
> +      }
>        NewInstance = TRUE;
>      }
>
> @@ -1535,7 +1602,7 @@ TestForRequiredProtocols (
>    UINT32      *Id;
>    UINTN       Index;
>    EFI_STATUS  Status;
> -  UINTN       ListCount;
> +  UINTN       ListCount, SuccessfulCount = 0;
>
>    ListCount = (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL));
>    for (Index = 0; Index < ListCount; Index++) {
> @@ -1557,13 +1624,14 @@ TestForRequiredProtocols (
>                        EFI_OPEN_PROTOCOL_GET_PROTOCOL
>                        );
>        if (EFI_ERROR (Status)) {
> -        if (Index == ListCount - 1) {
> -          DEBUG ((DEBUG_INFO, "%a: all required protocols are found on this controller handle: %p.\n", __func__, ControllerHandle));
> -          return EFI_SUCCESS;
> -        }
> +        SuccessfulCount++;
>        }
It may be SuccessfulCount must have one indentation less, i.e in scope
of  upper "if (!EFI_ERROR (Status)) {", not in scope of "if (EFI_ERROR
(Status)) {" in context.

Igor: We need TestForRequiredProtocols return SUCCESS when all protocols listed in gRequiredProtocol installed.
When this happened the BuildupNetworkInterface function would be called, and we iterate through gRequiredProtocol array and build network interfaces.
We also install DiscoveredProtocolGuid to prevent BuildupNetworkInterface to be called after that.
If we have SuccessfulCount in scope of  upper "if (!EFI_ERROR (Status)) {", then BuildupNetworkInterface will be called if something installed on that ControllerHandle, like DNS protocol, for example.

>      }
>    }
> +  if (ListCount == SuccessfulCount) {
> +    DEBUG ((DEBUG_INFO, "%a: all required protocols are found on this controller handle: %p.\n", __func__, ControllerHandle));
> +    return EFI_SUCCESS;
> +  }
>
>    return EFI_UNSUPPORTED;
>  }
> @@ -1600,10 +1668,24 @@ BuildupNetworkInterface (
>    EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL   *RestExInstance;
>    EFI_TPL                                          OldTpl;
>    BOOLEAN                                          NewNetworkInterfaceInstalled;
> +  UINT8                                            IpType;
>
>    NewNetworkInterfaceInstalled = FALSE;
>    Index                        = 0;
> +
> +
> +  // Get IP Type to filter out unnecessary network protocol if possible
> +  IpType = GetHiIpProtocolType();
> +
>    do {
> +    // Check IP Type and skip an unnecessary network protocol if does not match
> +    if (IpType != 0) {

IpType is invariant to this loop.
Eiher we may check it's value before the loop or we can just drop it,
because "&& IpType ==
REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP{4,6}"
is equal to "IpType != 0" Do I miss something?

Igor: You are right. Can be dropped.

> +      if ((gRequiredProtocol[Index].ProtocolType == ProtocolTypeTcp4 && IpType == REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6) ||
> +          (gRequiredProtocol[Index].ProtocolType == ProtocolTypeTcp6 && IpType == REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4)) {
> +        Index++;

Ops. You can not do just  { Index++;continue }
You need
{
      Index++;
      if (Index == (sizeof (gRequiredProtocol) / sizeof
(REDFISH_DISCOVER_REQUIRED_PROTOCOL))) {
        break;
      }
      continue;
}

Igor: continue statement causes the program control to pass to the conditional tests. So, Index will be verified in while check.

It's a terrible function. I have a patch, that improves this loop:
https://github.com/ghbaccount/edk2/commit/adc3218d3d96083c85cef6c396dde8ddb96530fb

> +        continue;
> +      }
> +    }
>      Status = gBS->OpenProtocol (
>                      // Already in list?
>                      ControllerHandle,
> --
> 2.37.1.windows.1

Regards,
Mike.
-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110464): https://edk2.groups.io/g/devel/message/110464
Mute This Topic: https://groups.io/mt/102303105/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx
  2023-11-01  3:24   ` Igor Kulchytskyy via groups.io
@ 2023-11-01  9:36     ` Mike Maslenkin
  2023-11-06  2:29     ` Mike Maslenkin
  1 sibling, 0 replies; 10+ messages in thread
From: Mike Maslenkin @ 2023-11-01  9:36 UTC (permalink / raw)
  To: Igor Kulchytskyy; +Cc: devel@edk2.groups.io, Abner Chang, Nickle Wang

On Wed, Nov 1, 2023 at 6:24 AM Igor Kulchytskyy <igork@ami.com> wrote:
>
> Hi Mike,
> Thank you for review.
> Please see my answers below the text.
>
> -----Original Message-----
> From: Mike Maslenkin <mike.maslenkin@gmail.com>
> Sent: Tuesday, October 31, 2023 9:00 PM
> To: devel@edk2.groups.io; Igor Kulchytskyy <igork@ami.com>
> Cc: Abner Chang <abner.chang@amd.com>; Nickle Wang <nicklew@nvidia.com>
> Subject: [EXTERNAL] Re: [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx
>
>
> **CAUTION: The e-mail below is from an external source. Please exercise caution before opening attachments, clicking links, or following guidance.**
>
> Hi Igor
>
> please find my comments below.
>
> On Tue, Oct 31, 2023 at 8:56 PM Igor Kulchytskyy via groups.io
> <igork=ami.com@groups.io> wrote:
> >
> > Supported function of the driver changed to wait for all newtwork
> > interface to be installed.
> > Filer out the network interfaces which are not supported by
> > Redfish Host Interface.
> >
> > Cc: Abner Chang <abner.chang@amd.com>
> > Cc: Nickle Wang <nicklew@nvidia.com>
> > Cc: Igor Kulchytskyy <igork@ami.com>
> > Signed-off-by: Igor Kulchytskyy <igork@ami.com>
> > ---
> >  RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c | 96 ++++++++++++++++++--
> >  1 file changed, 89 insertions(+), 7 deletions(-)
> >
> > diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> > index 23da3b968f..a88ad55938 100644
> > --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> > +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> > @@ -322,9 +322,15 @@ GetTargetNetworkInterfaceInternal (
> >  {
> >    EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterface;
> >
> > +  if (IsListEmpty(&mEfiRedfishDiscoverNetworkInterface)) {
> > +    return NULL;
> > +  }
> > +
> >    ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
> >    while (TRUE) {
> > -    if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) == 0) {
> > +    if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) == 0 &&
> > +        ((TargetNetworkInterface->IsIpv6 && ThisNetworkInterface->NetworkProtocolType == ProtocolTypeTcp6) ||
> > +            (!TargetNetworkInterface->IsIpv6 && ThisNetworkInterface->NetworkProtocolType == ProtocolTypeTcp4))) {
> >        return ThisNetworkInterface;
> >      }
> >
> > @@ -354,6 +360,10 @@ GetTargetNetworkInterfaceInternalByController (
> >  {
> >    EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterface;
> >
> > +  if (IsListEmpty(&mEfiRedfishDiscoverNetworkInterface)) {
> > +    return NULL;
> > +  }
> > +
>
> I also have these two hunks in my pending list.
> But I suggest to add ASSERT to GetTargetNetworkInterfaceInternal, just
> because currently it is really impossible situation,
> and mEfiRedfishDiscoverNetworkInterface was checked before in scope of
>  ValidateTargetNetworkInterface().
>
> Igor: Agree.
> I also just noticed that even if GetTargetNetworkInterfaceInternal function may return NULL, the return value is not verified on NULL in RedfishServiceAcquireService function.
> I think we should add this verification.

Mike: Agreed. I missed that the check in ValidateTargetNetworkInterface is:
if (IsListEmpty (&mEfiRedfishDiscoverNetworkInterface) &&
(TargetNetworkInterface == NULL))
not a just a IsListEmpty.

And ValidateTargetNetworkInterface is called before
GetTargetNetworkInterfaceInternal()...
But for now don't we need to add additional check for the NULL value
returned from GetTargetNetworkInterfaceInternal() in a caller ?
In RedfishServiceAcquireService():
   TargetNetworkInterfaceInternal = GetTargetNetworkInterfaceInternal
(TargetNetworkInterface);

The NULL value of TargetNetworkInterfaceInternal is propagated down.
So on some code branch it can not cause a problems (hopefully because
of same IsListEmpty checks), but it can on another.

>
>
> Also I wonder why check patch doesn't complain about missed spaces in
> "IsListEmpty (&mEfiRedfishDiscoverNetworkInterface)" call for example.
>
> >    ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
> >    while (TRUE) {
> >      if (ThisNetworkInterface->OpenDriverControllerHandle == ControllerHandle) {
> > @@ -476,6 +486,38 @@ CheckIsIpVersion6 (
> >    return FALSE;
> >  }
> >
> > +/**
> > +  This function returns the  IP type supported by the Host Interface
> > +
> > +  @retval IP Type
> > +  //  Unknown=00h,
> > +  //  Ipv4=01h,
> > +  //  Ipv6=02h,
> > +
> > +**/
> > +UINT8
>
> STATIC ?
> Igor: WHY?

Mike: Just because it is local function,  No need to grep over
RedfishPkg to find all its implementations if any.

>
> > +GetHiIpProtocolType()
> > +{
> > +  EFI_STATUS                     Status;
> > +  REDFISH_OVER_IP_PROTOCOL_DATA  *Data;
> > +  REDFISH_INTERFACE_DATA         *DeviceDescriptor;
> > +
> > +  Data             = NULL;
> > +  DeviceDescriptor = NULL;
> > +  if (mSmbios == NULL) {
> > +    Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&mSmbios);
> > +    if (EFI_ERROR (Status)) {
> > +      return 0;
>
> In this driver REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP{4,6}
> used and accessible.
> so, 0 means  REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN
> And these values actually checked in scope of BuildupNetworkInterface() below.
> Igor: Thank you. Missed that macro.
>
> > +    }
> > +  }
> > +  Status = RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescriptor, &Data); // Search for SMBIOS type 42h
> > +  if (!EFI_ERROR (Status) && (Data != NULL) &&
> > +      (Data->HostIpAssignmentType == RedfishHostIpAssignmentStatic)) {
> > +      return Data->HostIpAddressFormat;
> > +  }
> > +  return 0;
>
> Same here, 0 is a magic value for
> REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN
>
> > +}
> > +
> >  /**
> >    This function discover Redfish service through SMBIOS host interface.
> >
> > @@ -512,6 +554,15 @@ DiscoverRedfishHostInterface (
> >
> >    Status = RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescriptor, &Data); // Search for SMBIOS type 42h
> >    if (!EFI_ERROR (Status) && (Data != NULL) && (DeviceDescriptor != NULL)) {
> > +
> > +    if (Instance->NetworkInterface->NetworkProtocolType == ProtocolTypeTcp4 && Data->HostIpAddressFormat != REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4) { // IPv4 case
> > +      DEBUG((DEBUG_ERROR, "%a: Network Interface is IPv4, but Host Interface requires Ipv6\n"));
>
> Missed argument for %a format
> Missed space "DEBUG (("
>
> Igor: Inattentiveness. Thank you.
>
> > +      return EFI_UNSUPPORTED;
> > +    }
> > +    else if (Instance->NetworkInterface->NetworkProtocolType == ProtocolTypeTcp6 && Data->HostIpAddressFormat != REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6) { // IPv6 case
> > +      DEBUG((DEBUG_ERROR, "%a: Network Interface is IPv6, but Host Interface requires IPv4\n"));
>
> Missed argument for %a format
> Missed space "DEBUG (("
>
> Igor: Inattentiveness. Thank you.
>
> > +      return EFI_UNSUPPORTED;
> > +    }
> >      //
> >      // Check if we can reach out Redfish service using this network interface.
> >      // Check with MAC address using Device Descriptor Data Device Type 04 and Type 05.
> > @@ -1102,6 +1153,7 @@ RedfishServiceGetNetworkInterface (
> >    OUT EFI_REDFISH_DISCOVER_NETWORK_INTERFACE  **NetworkIntfInstances
> >    )
> >  {
> > +  EFI_STATUS                                       Status;
> >    EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterfaceIntn;
> >    EFI_REDFISH_DISCOVER_NETWORK_INTERFACE           *ThisNetworkInterface;
> >    EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL   *RestExInstance;
> > @@ -1141,6 +1193,16 @@ RedfishServiceGetNetworkInterface (
> >
> >    ThisNetworkInterfaceIntn = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
> >    while (TRUE) {
> > +    // If Get Subnet Info skip this interface
> > +    Status = NetworkInterfaceGetSubnetInfo (ThisNetworkInterfaceIntn, ImageHandle); // Get subnet info
> > +    if (EFI_ERROR(Status)) {
> > +      if (IsNodeAtEnd (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterfaceIntn->Entry)) {
> > +        break;
> > +      }
> > +      ThisNetworkInterfaceIntn = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetNextNode (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterfaceIntn->Entry);
> > +      continue;
> > +    }
> > +
> >      ThisNetworkInterface->IsIpv6 = FALSE;
> >      if (CheckIsIpVersion6 (ThisNetworkInterfaceIntn)) {
> >        ThisNetworkInterface->IsIpv6 = TRUE;
> > @@ -1260,7 +1322,12 @@ RedfishServiceAcquireService (
> >        // Get subnet information in case subnet information is not set because
> >        // RedfishServiceGetNetworkInterfaces hasn't been called yet.
> >        //
> > -      NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInternal, ImageHandle);
> > +      Status1 = NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInternal, ImageHandle);
> > +      if (EFI_ERROR(Status1)) {
> > +        DEBUG ((DEBUG_ERROR, "%a: Get subnet information fail.\n", __func__));
> > +        FreePool(Instance);
> > +        continue;
> > +      }
> >        NewInstance = TRUE;
> >      }
> >
> > @@ -1535,7 +1602,7 @@ TestForRequiredProtocols (
> >    UINT32      *Id;
> >    UINTN       Index;
> >    EFI_STATUS  Status;
> > -  UINTN       ListCount;
> > +  UINTN       ListCount, SuccessfulCount = 0;
> >
> >    ListCount = (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL));
> >    for (Index = 0; Index < ListCount; Index++) {
> > @@ -1557,13 +1624,14 @@ TestForRequiredProtocols (
> >                        EFI_OPEN_PROTOCOL_GET_PROTOCOL
> >                        );
> >        if (EFI_ERROR (Status)) {
> > -        if (Index == ListCount - 1) {
> > -          DEBUG ((DEBUG_INFO, "%a: all required protocols are found on this controller handle: %p.\n", __func__, ControllerHandle));
> > -          return EFI_SUCCESS;
> > -        }
> > +        SuccessfulCount++;
> >        }
> It may be SuccessfulCount must have one indentation less, i.e in scope
> of  upper "if (!EFI_ERROR (Status)) {", not in scope of "if (EFI_ERROR
> (Status)) {" in context.
>
> Igor: We need TestForRequiredProtocols return SUCCESS when all protocols listed in gRequiredProtocol installed.
> When this happened the BuildupNetworkInterface function would be called, and we iterate through gRequiredProtocol array and build network interfaces.
> We also install DiscoveredProtocolGuid to prevent BuildupNetworkInterface to be called after that.
> If we have SuccessfulCount in scope of  upper "if (!EFI_ERROR (Status)) {", then BuildupNetworkInterface will be called if something installed on that ControllerHandle, like DNS protocol, for example.
>
> >      }
> >    }
> > +  if (ListCount == SuccessfulCount) {
> > +    DEBUG ((DEBUG_INFO, "%a: all required protocols are found on this controller handle: %p.\n", __func__, ControllerHandle));
> > +    return EFI_SUCCESS;
> > +  }
> >
> >    return EFI_UNSUPPORTED;
> >  }
> > @@ -1600,10 +1668,24 @@ BuildupNetworkInterface (
> >    EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL   *RestExInstance;
> >    EFI_TPL                                          OldTpl;
> >    BOOLEAN                                          NewNetworkInterfaceInstalled;
> > +  UINT8                                            IpType;
> >
> >    NewNetworkInterfaceInstalled = FALSE;
> >    Index                        = 0;
> > +
> > +
> > +  // Get IP Type to filter out unnecessary network protocol if possible
> > +  IpType = GetHiIpProtocolType();
> > +
> >    do {
> > +    // Check IP Type and skip an unnecessary network protocol if does not match
> > +    if (IpType != 0) {
>
> IpType is invariant to this loop.
> Eiher we may check it's value before the loop or we can just drop it,
> because "&& IpType ==
> REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP{4,6}"
> is equal to "IpType != 0" Do I miss something?
>
> Igor: You are right. Can be dropped.
>
> > +      if ((gRequiredProtocol[Index].ProtocolType == ProtocolTypeTcp4 && IpType == REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6) ||
> > +          (gRequiredProtocol[Index].ProtocolType == ProtocolTypeTcp6 && IpType == REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4)) {
> > +        Index++;
>
> Ops. You can not do just  { Index++;continue }
> You need
> {
>       Index++;
>       if (Index == (sizeof (gRequiredProtocol) / sizeof
> (REDFISH_DISCOVER_REQUIRED_PROTOCOL))) {
>         break;
>       }
>       continue;
> }
>
> Igor: continue statement causes the program control to pass to the conditional tests. So, Index will be verified in while check.

Mike: Please disregard my comment :)
Definitely yes. I messed things up a bit, when I saw that this complex
loop become a bit more complex.
It's not clear why original code contains those checks and explicit breaks.

So, I rewrote this do while, to a simple for() iterating on index <
ARRAY_SIZE() similar to loop in TestForRequiredProtocols()


>
> It's a terrible function. I have a patch, that improves this loop:
> https://github.com/ghbaccount/edk2/commit/adc3218d3d96083c85cef6c396dde8ddb96530fb
>
> > +        continue;
> > +      }
> > +    }
> >      Status = gBS->OpenProtocol (
> >                      // Already in list?
> >                      ControllerHandle,
> > --
> > 2.37.1.windows.1
>
> Regards,
> Mike.
> -The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.

Regards,
Mike.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110472): https://edk2.groups.io/g/devel/message/110472
Mute This Topic: https://groups.io/mt/102303105/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx
  2023-11-01  3:24   ` Igor Kulchytskyy via groups.io
  2023-11-01  9:36     ` Mike Maslenkin
@ 2023-11-06  2:29     ` Mike Maslenkin
  2023-11-06 14:14       ` Igor Kulchytskyy via groups.io
       [not found]       ` <17950E34B0AB455C.12603@groups.io>
  1 sibling, 2 replies; 10+ messages in thread
From: Mike Maslenkin @ 2023-11-06  2:29 UTC (permalink / raw)
  To: Igor Kulchytskyy; +Cc: devel@edk2.groups.io, Abner Chang, Nickle Wang

[-- Attachment #1: Type: text/plain, Size: 12832 bytes --]

Hi Igor

I want to return to my initial comments regarding this patch.
Please, find my comments below.


> On 1. 11. 2023., at 06:24, Igor Kulchytskyy <igork@ami.com> wrote:
> 
> Hi Mike,
> Thank you for review.
> Please see my answers below the text.
> 
> -----Original Message-----
> From: Mike Maslenkin <mike.maslenkin@gmail.com>
> Sent: Tuesday, October 31, 2023 9:00 PM
> To: devel@edk2.groups.io; Igor Kulchytskyy <igork@ami.com>
> Cc: Abner Chang <abner.chang@amd.com>; Nickle Wang <nicklew@nvidia.com>
> Subject: [EXTERNAL] Re: [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx
> 
> 
> **CAUTION: The e-mail below is from an external source. Please exercise caution before opening attachments, clicking links, or following guidance.**
> 
> Hi Igor
> 
> please find my comments below.
> 
> On Tue, Oct 31, 2023 at 8:56 PM Igor Kulchytskyy via groups.io
> <igork=ami.com@groups.io> wrote:
>> 
>> Supported function of the driver changed to wait for all newtwork
>> interface to be installed.
>> Filer out the network interfaces which are not supported by
>> Redfish Host Interface.
>> 
>> Cc: Abner Chang <abner.chang@amd.com>
>> Cc: Nickle Wang <nicklew@nvidia.com>
>> Cc: Igor Kulchytskyy <igork@ami.com>
>> Signed-off-by: Igor Kulchytskyy <igork@ami.com>
>> ---
>> RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c | 96 ++++++++++++++++++--
>> 1 file changed, 89 insertions(+), 7 deletions(-)
>> 
>> diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
>> index 23da3b968f..a88ad55938 100644
>> --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
>> +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
>> @@ -322,9 +322,15 @@ GetTargetNetworkInterfaceInternal (
>> {
>>   EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterface;
>> 
>> +  if (IsListEmpty(&mEfiRedfishDiscoverNetworkInterface)) {
>> +    return NULL;
>> +  }
>> +
>>   ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
>>   while (TRUE) {
>> -    if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) == 0) {
>> +    if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) == 0 &&
>> +        ((TargetNetworkInterface->IsIpv6 && ThisNetworkInterface->NetworkProtocolType == ProtocolTypeTcp6) ||
>> +            (!TargetNetworkInterface->IsIpv6 && ThisNetworkInterface->NetworkProtocolType == ProtocolTypeTcp4))) {
>>       return ThisNetworkInterface;
>>     }
>> 
>> @@ -354,6 +360,10 @@ GetTargetNetworkInterfaceInternalByController (
>> {
>>   EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterface;
>> 
>> +  if (IsListEmpty(&mEfiRedfishDiscoverNetworkInterface)) {
>> +    return NULL;
>> +  }
>> +
> 
> I also have these two hunks in my pending list.
> But I suggest to add ASSERT to GetTargetNetworkInterfaceInternal, just
> because currently it is really impossible situation,
> and mEfiRedfishDiscoverNetworkInterface was checked before in scope of
> ValidateTargetNetworkInterface().
> 
> Igor: Agree.
> I also just noticed that even if GetTargetNetworkInterfaceInternal function may return NULL, the return value is not verified on NULL in RedfishServiceAcquireService function.
> I think we should add this verification.
> 
> 
> Also I wonder why check patch doesn't complain about missed spaces in
> "IsListEmpty (&mEfiRedfishDiscoverNetworkInterface)" call for example.
> 
>>   ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
>>   while (TRUE) {
>>     if (ThisNetworkInterface->OpenDriverControllerHandle == ControllerHandle) {
>> @@ -476,6 +486,38 @@ CheckIsIpVersion6 (
>>   return FALSE;
>> }
>> 
>> +/**
>> +  This function returns the  IP type supported by the Host Interface
>> +
>> +  @retval IP Type
>> +  //  Unknown=00h,
>> +  //  Ipv4=01h,
>> +  //  Ipv6=02h,
>> +
>> +**/
>> +UINT8
> 
> STATIC ?
> Igor: WHY?
> 

I remembered discussion about STATIC functions usage and why it isn't common in edk2.
AFAIR it was because of difficulties with source level debugging for the case when it could be inlined.
BTW I won't insist on this here.


>> +GetHiIpProtocolType()
>> +{
>> +  EFI_STATUS                     Status;
>> +  REDFISH_OVER_IP_PROTOCOL_DATA  *Data;
>> +  REDFISH_INTERFACE_DATA         *DeviceDescriptor;
>> +
>> +  Data             = NULL;
>> +  DeviceDescriptor = NULL;
>> +  if (mSmbios == NULL) {
>> +    Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&mSmbios);
>> +    if (EFI_ERROR (Status)) {
>> +      return 0;
> 
> In this driver REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP{4,6}
> used and accessible.
> so, 0 means  REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN
> And these values actually checked in scope of BuildupNetworkInterface() below.
> Igor: Thank you. Missed that macro.
> 
>> +    }
>> +  }
>> +  Status = RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescriptor, &Data); // Search for SMBIOS type 42h
>> +  if (!EFI_ERROR (Status) && (Data != NULL) &&
>> +      (Data->HostIpAssignmentType == RedfishHostIpAssignmentStatic)) {
>> +      return Data->HostIpAddressFormat;
>> +  }
>> +  return 0;
> 
> Same here, 0 is a magic value for
> REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN
> 
>> +}
>> +
>> /**
>>   This function discover Redfish service through SMBIOS host interface.
>> 
>> @@ -512,6 +554,15 @@ DiscoverRedfishHostInterface (
>> 
>>   Status = RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescriptor, &Data); // Search for SMBIOS type 42h
>>   if (!EFI_ERROR (Status) && (Data != NULL) && (DeviceDescriptor != NULL)) {
>> +
>> +    if (Instance->NetworkInterface->NetworkProtocolType == ProtocolTypeTcp4 && Data->HostIpAddressFormat != REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4) { // IPv4 case
>> +      DEBUG((DEBUG_ERROR, "%a: Network Interface is IPv4, but Host Interface requires Ipv6\n"));
> 
> Missed argument for %a format
> Missed space "DEBUG (("
> 
> Igor: Inattentiveness. Thank you.
> 
>> +      return EFI_UNSUPPORTED;
>> +    }
>> +    else if (Instance->NetworkInterface->NetworkProtocolType == ProtocolTypeTcp6 && Data->HostIpAddressFormat != REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6) { // IPv6 case
>> +      DEBUG((DEBUG_ERROR, "%a: Network Interface is IPv6, but Host Interface requires IPv4\n"));
> 
> Missed argument for %a format
> Missed space "DEBUG (("
> 
> Igor: Inattentiveness. Thank you.
> 
>> +      return EFI_UNSUPPORTED;
>> +    }
>>     //
>>     // Check if we can reach out Redfish service using this network interface.
>>     // Check with MAC address using Device Descriptor Data Device Type 04 and Type 05.
>> @@ -1102,6 +1153,7 @@ RedfishServiceGetNetworkInterface (
>>   OUT EFI_REDFISH_DISCOVER_NETWORK_INTERFACE  **NetworkIntfInstances
>>   )
>> {
>> +  EFI_STATUS                                       Status;
>>   EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterfaceIntn;
>>   EFI_REDFISH_DISCOVER_NETWORK_INTERFACE           *ThisNetworkInterface;
>>   EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL   *RestExInstance;
>> @@ -1141,6 +1193,16 @@ RedfishServiceGetNetworkInterface (
>> 
>>   ThisNetworkInterfaceIntn = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
>>   while (TRUE) {
>> +    // If Get Subnet Info skip this interface
>> +    Status = NetworkInterfaceGetSubnetInfo (ThisNetworkInterfaceIntn, ImageHandle); // Get subnet info
>> +    if (EFI_ERROR(Status)) {
>> +      if (IsNodeAtEnd (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterfaceIntn->Entry)) {
>> +        break;
>> +      }
>> +      ThisNetworkInterfaceIntn = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetNextNode (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterfaceIntn->Entry);
>> +      continue;
>> +    }
>> +
>>     ThisNetworkInterface->IsIpv6 = FALSE;
>>     if (CheckIsIpVersion6 (ThisNetworkInterfaceIntn)) {
>>       ThisNetworkInterface->IsIpv6 = TRUE;
>> @@ -1260,7 +1322,12 @@ RedfishServiceAcquireService (
>>       // Get subnet information in case subnet information is not set because
>>       // RedfishServiceGetNetworkInterfaces hasn't been called yet.
>>       //
>> -      NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInternal, ImageHandle);
>> +      Status1 = NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInternal, ImageHandle);
>> +      if (EFI_ERROR(Status1)) {
>> +        DEBUG ((DEBUG_ERROR, "%a: Get subnet information fail.\n", __func__));
>> +        FreePool(Instance);
>> +        continue;
>> +      }
>>       NewInstance = TRUE;
>>     }
>> 
>> @@ -1535,7 +1602,7 @@ TestForRequiredProtocols (
>>   UINT32      *Id;
>>   UINTN       Index;
>>   EFI_STATUS  Status;
>> -  UINTN       ListCount;
>> +  UINTN       ListCount, SuccessfulCount = 0;
>> 
>>   ListCount = (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL));
>>   for (Index = 0; Index < ListCount; Index++) {
>> @@ -1557,13 +1624,14 @@ TestForRequiredProtocols (
>>                       EFI_OPEN_PROTOCOL_GET_PROTOCOL
>>                       );
>>       if (EFI_ERROR (Status)) {
>> -        if (Index == ListCount - 1) {
>> -          DEBUG ((DEBUG_INFO, "%a: all required protocols are found on this controller handle: %p.\n", __func__, ControllerHandle));
>> -          return EFI_SUCCESS;
>> -        }
>> +        SuccessfulCount++;
>>       }
> It may be SuccessfulCount must have one indentation less, i.e in scope
> of  upper "if (!EFI_ERROR (Status)) {", not in scope of "if (EFI_ERROR
> (Status)) {" in context.
> 
> Igor: We need TestForRequiredProtocols return SUCCESS when all protocols listed in gRequiredProtocol installed.
> When this happened the BuildupNetworkInterface function would be called, and we iterate through gRequiredProtocol array and build network interfaces.
> We also install DiscoveredProtocolGuid to prevent BuildupNetworkInterface to be called after that.
> If we have SuccessfulCount in scope of  upper "if (!EFI_ERROR (Status)) {", then BuildupNetworkInterface will be called if something installed on that ControllerHandle, like DNS protocol, for example.

Yes, I understand this... but it's still illogical, taking in account variable name. I mean  if (EFI_ERROR (Status)) {SuccessfulCount++};

Here we increase SuccessfulCount for the case  "Cond1 && !Cond2", and return EFI_SUCCESS only if it is true for all gRequiredProtocol entries, i.e 3 times.

Wouldn't it be better to rewrite this code to smth like the following:

{
  UINT32      *Id;
  UINTN       Index;
  EFI_STATUS  Status;

  for (Index = 0; Index < ARRAY_SIZE (gRequiredProtocol); Index++) {
    Status = gBS->OpenProtocol (
                    ControllerHandle,
                    gRequiredProtocol[Index].RequiredServiceBindingProtocolGuid,
                    NULL,
                    This->DriverBindingHandle,
                    ControllerHandle,
                    EFI_OPEN_PROTOCOL_TEST_PROTOCOL
                    );
    if (EFI_ERROR (Status)) {
      return EFI_UNSUPPORTED;
    }

    Status = gBS->OpenProtocol (
                    ControllerHandle,
                    gRequiredProtocol[Index].DiscoveredProtocolGuid,
                    (VOID **)&Id,
                    This->DriverBindingHandle,
                    ControllerHandle,
                    EFI_OPEN_PROTOCOL_GET_PROTOCOL
                    );
    if (!EFI_ERROR (Status)) {
      // Already installed
      return EFI_UNSUPPORTED;
    }
  }

  DEBUG ((DEBUG_MANAGEABILITY, "%a: all required protocols are found on this controller handle: %p.\n", __func__, ControllerHandle));
  return EFI_SUCCESS;
}

?
No unnecessary variables, less indentation + this function is called from RedfishDiscoverDriverBindingSupported(), i.e very often, so we just reduce number of useless loop iterations and OpenProtocol() calls.

Regards,
Mike.




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110694): https://edk2.groups.io/g/devel/message/110694
Mute This Topic: https://groups.io/mt/102303105/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 32716 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx
  2023-11-06  2:29     ` Mike Maslenkin
@ 2023-11-06 14:14       ` Igor Kulchytskyy via groups.io
       [not found]       ` <17950E34B0AB455C.12603@groups.io>
  1 sibling, 0 replies; 10+ messages in thread
From: Igor Kulchytskyy via groups.io @ 2023-11-06 14:14 UTC (permalink / raw)
  To: M M; +Cc: devel@edk2.groups.io, Abner Chang, Nickle Wang

[-- Attachment #1: Type: text/plain, Size: 13548 bytes --]

Hi Mike,
See my comments below.
Thank you,
Igor
P.S.
“There is no limits to perfection”

From: M M <mike.maslenkin@gmail.com>
Sent: Sunday, November 05, 2023 9:30 PM
To: Igor Kulchytskyy <igork@ami.com>
Cc: devel@edk2.groups.io; Abner Chang <abner.chang@amd.com>; Nickle Wang <nicklew@nvidia.com>
Subject: Re: [EXTERNAL] [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx

Hi Igor

I want to return to my initial comments regarding this patch.
Please, find my comments below.



On 1. 11. 2023., at 06:24, Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>> wrote:

Hi Mike,
Thank you for review.
Please see my answers below the text.

-----Original Message-----
From: Mike Maslenkin <mike.maslenkin@gmail.com<mailto:mike.maslenkin@gmail.com>>
Sent: Tuesday, October 31, 2023 9:00 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>>
Cc: Abner Chang <abner.chang@amd.com<mailto:abner.chang@amd.com>>; Nickle Wang <nicklew@nvidia.com<mailto:nicklew@nvidia.com>>
Subject: [EXTERNAL] Re: [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx


**CAUTION: The e-mail below is from an external source. Please exercise caution before opening attachments, clicking links, or following guidance.**

Hi Igor

please find my comments below.

On Tue, Oct 31, 2023 at 8:56 PM Igor Kulchytskyy via groups.io<http://groups.io/>
<igork=ami.com@groups.io<mailto:igork=ami.com@groups.io>> wrote:


Supported function of the driver changed to wait for all newtwork
interface to be installed.
Filer out the network interfaces which are not supported by
Redfish Host Interface.

Cc: Abner Chang <abner.chang@amd.com<mailto:abner.chang@amd.com>>
Cc: Nickle Wang <nicklew@nvidia.com<mailto:nicklew@nvidia.com>>
Cc: Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>>
Signed-off-by: Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>>
---
RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c | 96 ++++++++++++++++++--
1 file changed, 89 insertions(+), 7 deletions(-)

diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
index 23da3b968f..a88ad55938 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
@@ -322,9 +322,15 @@ GetTargetNetworkInterfaceInternal (
{
  EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterface;

+  if (IsListEmpty(&mEfiRedfishDiscoverNetworkInterface)) {
+    return NULL;
+  }
+
  ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
  while (TRUE) {
-    if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) == 0) {
+    if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) == 0 &&
+        ((TargetNetworkInterface->IsIpv6 && ThisNetworkInterface->NetworkProtocolType == ProtocolTypeTcp6) ||
+            (!TargetNetworkInterface->IsIpv6 && ThisNetworkInterface->NetworkProtocolType == ProtocolTypeTcp4))) {
      return ThisNetworkInterface;
    }

@@ -354,6 +360,10 @@ GetTargetNetworkInterfaceInternalByController (
{
  EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterface;

+  if (IsListEmpty(&mEfiRedfishDiscoverNetworkInterface)) {
+    return NULL;
+  }
+

I also have these two hunks in my pending list.
But I suggest to add ASSERT to GetTargetNetworkInterfaceInternal, just
because currently it is really impossible situation,
and mEfiRedfishDiscoverNetworkInterface was checked before in scope of
ValidateTargetNetworkInterface().

Igor: Agree.
I also just noticed that even if GetTargetNetworkInterfaceInternal function may return NULL, the return value is not verified on NULL in RedfishServiceAcquireService function.
I think we should add this verification.


Also I wonder why check patch doesn't complain about missed spaces in
"IsListEmpty (&mEfiRedfishDiscoverNetworkInterface)" call for example.


  ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
  while (TRUE) {
    if (ThisNetworkInterface->OpenDriverControllerHandle == ControllerHandle) {
@@ -476,6 +486,38 @@ CheckIsIpVersion6 (
  return FALSE;
}

+/**
+  This function returns the  IP type supported by the Host Interface
+
+  @retval IP Type
+  //  Unknown=00h,
+  //  Ipv4=01h,
+  //  Ipv6=02h,
+
+**/
+UINT8

STATIC ?
Igor: WHY?

I remembered discussion about STATIC functions usage and why it isn't common in edk2.
AFAIR it was because of difficulties with source level debugging for the case when it could be inlined.
BTW I won't insist on this here.



+GetHiIpProtocolType()
+{
+  EFI_STATUS                     Status;
+  REDFISH_OVER_IP_PROTOCOL_DATA  *Data;
+  REDFISH_INTERFACE_DATA         *DeviceDescriptor;
+
+  Data             = NULL;
+  DeviceDescriptor = NULL;
+  if (mSmbios == NULL) {
+    Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&mSmbios);
+    if (EFI_ERROR (Status)) {
+      return 0;

In this driver REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP{4,6}
used and accessible.
so, 0 means  REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN
And these values actually checked in scope of BuildupNetworkInterface() below.
Igor: Thank you. Missed that macro.


+    }
+  }
+  Status = RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescriptor, &Data); // Search for SMBIOS type 42h
+  if (!EFI_ERROR (Status) && (Data != NULL) &&
+      (Data->HostIpAssignmentType == RedfishHostIpAssignmentStatic)) {
+      return Data->HostIpAddressFormat;
+  }
+  return 0;

Same here, 0 is a magic value for
REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN


+}
+
/**
  This function discover Redfish service through SMBIOS host interface.

@@ -512,6 +554,15 @@ DiscoverRedfishHostInterface (

  Status = RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescriptor, &Data); // Search for SMBIOS type 42h
  if (!EFI_ERROR (Status) && (Data != NULL) && (DeviceDescriptor != NULL)) {
+
+    if (Instance->NetworkInterface->NetworkProtocolType == ProtocolTypeTcp4 && Data->HostIpAddressFormat != REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4) { // IPv4 case
+      DEBUG((DEBUG_ERROR, "%a: Network Interface is IPv4, but Host Interface requires Ipv6\n"));

Missed argument for %a format
Missed space "DEBUG (("

Igor: Inattentiveness. Thank you.


+      return EFI_UNSUPPORTED;
+    }
+    else if (Instance->NetworkInterface->NetworkProtocolType == ProtocolTypeTcp6 && Data->HostIpAddressFormat != REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6) { // IPv6 case
+      DEBUG((DEBUG_ERROR, "%a: Network Interface is IPv6, but Host Interface requires IPv4\n"));

Missed argument for %a format
Missed space "DEBUG (("

Igor: Inattentiveness. Thank you.


+      return EFI_UNSUPPORTED;
+    }
    //
    // Check if we can reach out Redfish service using this network interface.
    // Check with MAC address using Device Descriptor Data Device Type 04 and Type 05.
@@ -1102,6 +1153,7 @@ RedfishServiceGetNetworkInterface (
  OUT EFI_REDFISH_DISCOVER_NETWORK_INTERFACE  **NetworkIntfInstances
  )
{
+  EFI_STATUS                                       Status;
  EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterfaceIntn;
  EFI_REDFISH_DISCOVER_NETWORK_INTERFACE           *ThisNetworkInterface;
  EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL   *RestExInstance;
@@ -1141,6 +1193,16 @@ RedfishServiceGetNetworkInterface (

  ThisNetworkInterfaceIntn = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
  while (TRUE) {
+    // If Get Subnet Info skip this interface
+    Status = NetworkInterfaceGetSubnetInfo (ThisNetworkInterfaceIntn, ImageHandle); // Get subnet info
+    if (EFI_ERROR(Status)) {
+      if (IsNodeAtEnd (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterfaceIntn->Entry)) {
+        break;
+      }
+      ThisNetworkInterfaceIntn = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetNextNode (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterfaceIntn->Entry);
+      continue;
+    }
+
    ThisNetworkInterface->IsIpv6 = FALSE;
    if (CheckIsIpVersion6 (ThisNetworkInterfaceIntn)) {
      ThisNetworkInterface->IsIpv6 = TRUE;
@@ -1260,7 +1322,12 @@ RedfishServiceAcquireService (
      // Get subnet information in case subnet information is not set because
      // RedfishServiceGetNetworkInterfaces hasn't been called yet.
      //
-      NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInternal, ImageHandle);
+      Status1 = NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInternal, ImageHandle);
+      if (EFI_ERROR(Status1)) {
+        DEBUG ((DEBUG_ERROR, "%a: Get subnet information fail.\n", __func__));
+        FreePool(Instance);
+        continue;
+      }
      NewInstance = TRUE;
    }

@@ -1535,7 +1602,7 @@ TestForRequiredProtocols (
  UINT32      *Id;
  UINTN       Index;
  EFI_STATUS  Status;
-  UINTN       ListCount;
+  UINTN       ListCount, SuccessfulCount = 0;

  ListCount = (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL));
  for (Index = 0; Index < ListCount; Index++) {
@@ -1557,13 +1624,14 @@ TestForRequiredProtocols (
                      EFI_OPEN_PROTOCOL_GET_PROTOCOL
                      );
      if (EFI_ERROR (Status)) {
-        if (Index == ListCount - 1) {
-          DEBUG ((DEBUG_INFO, "%a: all required protocols are found on this controller handle: %p.\n", __func__, ControllerHandle));
-          return EFI_SUCCESS;
-        }
+        SuccessfulCount++;
      }
It may be SuccessfulCount must have one indentation less, i.e in scope
of  upper "if (!EFI_ERROR (Status)) {", not in scope of "if (EFI_ERROR
(Status)) {" in context.

Igor: We need TestForRequiredProtocols return SUCCESS when all protocols listed in gRequiredProtocol installed.
When this happened the BuildupNetworkInterface function would be called, and we iterate through gRequiredProtocol array and build network interfaces.
We also install DiscoveredProtocolGuid to prevent BuildupNetworkInterface to be called after that.
If we have SuccessfulCount in scope of  upper "if (!EFI_ERROR (Status)) {", then BuildupNetworkInterface will be called if something installed on that ControllerHandle, like DNS protocol, for example.

Yes, I understand this... but it's still illogical, taking in account variable name. I mean  if (EFI_ERROR (Status)) {SuccessfulCount++};

Here we increase SuccessfulCount for the case  "Cond1 && !Cond2", and return EFI_SUCCESS only if it is true for all gRequiredProtocol entries, i.e 3 times.

Wouldn't it be better to rewrite this code to smth like the following:

{
  UINT32      *Id;
  UINTN       Index;
  EFI_STATUS  Status;

  for (Index = 0; Index < ARRAY_SIZE (gRequiredProtocol); Index++) {
    Status = gBS->OpenProtocol (
                    ControllerHandle,
                    gRequiredProtocol[Index].RequiredServiceBindingProtocolGuid,
                    NULL,
                    This->DriverBindingHandle,
                    ControllerHandle,
                    EFI_OPEN_PROTOCOL_TEST_PROTOCOL
                    );
    if (EFI_ERROR (Status)) {
      return EFI_UNSUPPORTED;
    }

    Status = gBS->OpenProtocol (
                    ControllerHandle,
                    gRequiredProtocol[Index].DiscoveredProtocolGuid,
                    (VOID **)&Id,
                    This->DriverBindingHandle,
                    ControllerHandle,
                    EFI_OPEN_PROTOCOL_GET_PROTOCOL
                    );
    if (!EFI_ERROR (Status)) {
      // Already installed
      return EFI_UNSUPPORTED;
    }
  }

  DEBUG ((DEBUG_MANAGEABILITY, "%a: all required protocols are found on this controller handle: %p.\n", __func__, ControllerHandle));
  return EFI_SUCCESS;
}

?
No unnecessary variables, less indentation + this function is called from RedfishDiscoverDriverBindingSupported(), i.e very often, so we just reduce number of useless loop iterations and OpenProtocol() calls.

Igor: I agree, the optimization you suggested is good.


Regards,
Mike.


-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110750): https://edk2.groups.io/g/devel/message/110750
Mute This Topic: https://groups.io/mt/102303105/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 32627 bytes --]

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx
       [not found]       ` <17950E34B0AB455C.12603@groups.io>
@ 2023-11-06 18:53         ` Igor Kulchytskyy via groups.io
  2023-11-07  1:51           ` Chang, Abner via groups.io
  0 siblings, 1 reply; 10+ messages in thread
From: Igor Kulchytskyy via groups.io @ 2023-11-06 18:53 UTC (permalink / raw)
  To: devel@edk2.groups.io, Igor Kulchytskyy, M M; +Cc: Abner Chang, Nickle Wang

[-- Attachment #1: Type: text/plain, Size: 14868 bytes --]

Hi Nickle and Abner,
What is your opinion – should we have GetHiIpProtocolType fuction as a static one?
Thank you,
Igor

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Igor Kulchytskyy via groups.io
Sent: Monday, November 6, 2023 9:14 AM
To: M M <mike.maslenkin@gmail.com>
Cc: devel@edk2.groups.io; Abner Chang <abner.chang@amd.com>; Nickle Wang <nicklew@nvidia.com>
Subject: [EXTERNAL] Re: [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx


**CAUTION: The e-mail below is from an external source. Please exercise caution before opening attachments, clicking links, or following guidance.**
Hi Mike,
See my comments below.
Thank you,
Igor
P.S.
“There is no limits to perfection”

From: M M <mike.maslenkin@gmail.com<mailto:mike.maslenkin@gmail.com>>
Sent: Sunday, November 05, 2023 9:30 PM
To: Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Abner Chang <abner.chang@amd.com<mailto:abner.chang@amd.com>>; Nickle Wang <nicklew@nvidia.com<mailto:nicklew@nvidia.com>>
Subject: Re: [EXTERNAL] [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx

Hi Igor

I want to return to my initial comments regarding this patch.
Please, find my comments below.


On 1. 11. 2023., at 06:24, Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>> wrote:

Hi Mike,
Thank you for review.
Please see my answers below the text.

-----Original Message-----
From: Mike Maslenkin <mike.maslenkin@gmail.com<mailto:mike.maslenkin@gmail.com>>
Sent: Tuesday, October 31, 2023 9:00 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>>
Cc: Abner Chang <abner.chang@amd.com<mailto:abner.chang@amd.com>>; Nickle Wang <nicklew@nvidia.com<mailto:nicklew@nvidia.com>>
Subject: [EXTERNAL] Re: [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx


**CAUTION: The e-mail below is from an external source. Please exercise caution before opening attachments, clicking links, or following guidance.**

Hi Igor

please find my comments below.

On Tue, Oct 31, 2023 at 8:56 PM Igor Kulchytskyy via groups.io<http://groups.io/>
<igork=ami.com@groups.io<mailto:igork=ami.com@groups.io>> wrote:

Supported function of the driver changed to wait for all newtwork
interface to be installed.
Filer out the network interfaces which are not supported by
Redfish Host Interface.

Cc: Abner Chang <abner.chang@amd.com<mailto:abner.chang@amd.com>>
Cc: Nickle Wang <nicklew@nvidia.com<mailto:nicklew@nvidia.com>>
Cc: Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>>
Signed-off-by: Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>>
---
RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c | 96 ++++++++++++++++++--
1 file changed, 89 insertions(+), 7 deletions(-)

diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
index 23da3b968f..a88ad55938 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
@@ -322,9 +322,15 @@ GetTargetNetworkInterfaceInternal (
{
  EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterface;

+  if (IsListEmpty(&mEfiRedfishDiscoverNetworkInterface)) {
+    return NULL;
+  }
+
  ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
  while (TRUE) {
-    if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) == 0) {
+    if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) == 0 &&
+        ((TargetNetworkInterface->IsIpv6 && ThisNetworkInterface->NetworkProtocolType == ProtocolTypeTcp6) ||
+            (!TargetNetworkInterface->IsIpv6 && ThisNetworkInterface->NetworkProtocolType == ProtocolTypeTcp4))) {
      return ThisNetworkInterface;
    }

@@ -354,6 +360,10 @@ GetTargetNetworkInterfaceInternalByController (
{
  EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterface;

+  if (IsListEmpty(&mEfiRedfishDiscoverNetworkInterface)) {
+    return NULL;
+  }
+

I also have these two hunks in my pending list.
But I suggest to add ASSERT to GetTargetNetworkInterfaceInternal, just
because currently it is really impossible situation,
and mEfiRedfishDiscoverNetworkInterface was checked before in scope of
ValidateTargetNetworkInterface().

Igor: Agree.
I also just noticed that even if GetTargetNetworkInterfaceInternal function may return NULL, the return value is not verified on NULL in RedfishServiceAcquireService function.
I think we should add this verification.


Also I wonder why check patch doesn't complain about missed spaces in
"IsListEmpty (&mEfiRedfishDiscoverNetworkInterface)" call for example.

  ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
  while (TRUE) {
    if (ThisNetworkInterface->OpenDriverControllerHandle == ControllerHandle) {
@@ -476,6 +486,38 @@ CheckIsIpVersion6 (
  return FALSE;
}

+/**
+  This function returns the  IP type supported by the Host Interface
+
+  @retval IP Type
+  //  Unknown=00h,
+  //  Ipv4=01h,
+  //  Ipv6=02h,
+
+**/
+UINT8

STATIC ?
Igor: WHY?

I remembered discussion about STATIC functions usage and why it isn't common in edk2.
AFAIR it was because of difficulties with source level debugging for the case when it could be inlined.
BTW I won't insist on this here.


+GetHiIpProtocolType()
+{
+  EFI_STATUS                     Status;
+  REDFISH_OVER_IP_PROTOCOL_DATA  *Data;
+  REDFISH_INTERFACE_DATA         *DeviceDescriptor;
+
+  Data             = NULL;
+  DeviceDescriptor = NULL;
+  if (mSmbios == NULL) {
+    Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&mSmbios);
+    if (EFI_ERROR (Status)) {
+      return 0;

In this driver REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP{4,6}
used and accessible.
so, 0 means  REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN
And these values actually checked in scope of BuildupNetworkInterface() below.
Igor: Thank you. Missed that macro.

+    }
+  }
+  Status = RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescriptor, &Data); // Search for SMBIOS type 42h
+  if (!EFI_ERROR (Status) && (Data != NULL) &&
+      (Data->HostIpAssignmentType == RedfishHostIpAssignmentStatic)) {
+      return Data->HostIpAddressFormat;
+  }
+  return 0;

Same here, 0 is a magic value for
REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN

+}
+
/**
  This function discover Redfish service through SMBIOS host interface.

@@ -512,6 +554,15 @@ DiscoverRedfishHostInterface (

  Status = RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescriptor, &Data); // Search for SMBIOS type 42h
  if (!EFI_ERROR (Status) && (Data != NULL) && (DeviceDescriptor != NULL)) {
+
+    if (Instance->NetworkInterface->NetworkProtocolType == ProtocolTypeTcp4 && Data->HostIpAddressFormat != REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4) { // IPv4 case
+      DEBUG((DEBUG_ERROR, "%a: Network Interface is IPv4, but Host Interface requires Ipv6\n"));

Missed argument for %a format
Missed space "DEBUG (("

Igor: Inattentiveness. Thank you.

+      return EFI_UNSUPPORTED;
+    }
+    else if (Instance->NetworkInterface->NetworkProtocolType == ProtocolTypeTcp6 && Data->HostIpAddressFormat != REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6) { // IPv6 case
+      DEBUG((DEBUG_ERROR, "%a: Network Interface is IPv6, but Host Interface requires IPv4\n"));

Missed argument for %a format
Missed space "DEBUG (("

Igor: Inattentiveness. Thank you.

+      return EFI_UNSUPPORTED;
+    }
    //
    // Check if we can reach out Redfish service using this network interface.
    // Check with MAC address using Device Descriptor Data Device Type 04 and Type 05.
@@ -1102,6 +1153,7 @@ RedfishServiceGetNetworkInterface (
  OUT EFI_REDFISH_DISCOVER_NETWORK_INTERFACE  **NetworkIntfInstances
  )
{
+  EFI_STATUS                                       Status;
  EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterfaceIntn;
  EFI_REDFISH_DISCOVER_NETWORK_INTERFACE           *ThisNetworkInterface;
  EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL   *RestExInstance;
@@ -1141,6 +1193,16 @@ RedfishServiceGetNetworkInterface (

  ThisNetworkInterfaceIntn = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
  while (TRUE) {
+    // If Get Subnet Info skip this interface
+    Status = NetworkInterfaceGetSubnetInfo (ThisNetworkInterfaceIntn, ImageHandle); // Get subnet info
+    if (EFI_ERROR(Status)) {
+      if (IsNodeAtEnd (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterfaceIntn->Entry)) {
+        break;
+      }
+      ThisNetworkInterfaceIntn = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetNextNode (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterfaceIntn->Entry);
+      continue;
+    }
+
    ThisNetworkInterface->IsIpv6 = FALSE;
    if (CheckIsIpVersion6 (ThisNetworkInterfaceIntn)) {
      ThisNetworkInterface->IsIpv6 = TRUE;
@@ -1260,7 +1322,12 @@ RedfishServiceAcquireService (
      // Get subnet information in case subnet information is not set because
      // RedfishServiceGetNetworkInterfaces hasn't been called yet.
      //
-      NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInternal, ImageHandle);
+      Status1 = NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInternal, ImageHandle);
+      if (EFI_ERROR(Status1)) {
+        DEBUG ((DEBUG_ERROR, "%a: Get subnet information fail.\n", __func__));
+        FreePool(Instance);
+        continue;
+      }
      NewInstance = TRUE;
    }

@@ -1535,7 +1602,7 @@ TestForRequiredProtocols (
  UINT32      *Id;
  UINTN       Index;
  EFI_STATUS  Status;
-  UINTN       ListCount;
+  UINTN       ListCount, SuccessfulCount = 0;

  ListCount = (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL));
  for (Index = 0; Index < ListCount; Index++) {
@@ -1557,13 +1624,14 @@ TestForRequiredProtocols (
                      EFI_OPEN_PROTOCOL_GET_PROTOCOL
                      );
      if (EFI_ERROR (Status)) {
-        if (Index == ListCount - 1) {
-          DEBUG ((DEBUG_INFO, "%a: all required protocols are found on this controller handle: %p.\n", __func__, ControllerHandle));
-          return EFI_SUCCESS;
-        }
+        SuccessfulCount++;
      }
It may be SuccessfulCount must have one indentation less, i.e in scope
of  upper "if (!EFI_ERROR (Status)) {", not in scope of "if (EFI_ERROR
(Status)) {" in context.

Igor: We need TestForRequiredProtocols return SUCCESS when all protocols listed in gRequiredProtocol installed.
When this happened the BuildupNetworkInterface function would be called, and we iterate through gRequiredProtocol array and build network interfaces.
We also install DiscoveredProtocolGuid to prevent BuildupNetworkInterface to be called after that.
If we have SuccessfulCount in scope of  upper "if (!EFI_ERROR (Status)) {", then BuildupNetworkInterface will be called if something installed on that ControllerHandle, like DNS protocol, for example.

Yes, I understand this... but it's still illogical, taking in account variable name. I mean  if (EFI_ERROR (Status)) {SuccessfulCount++};

Here we increase SuccessfulCount for the case  "Cond1 && !Cond2", and return EFI_SUCCESS only if it is true for all gRequiredProtocol entries, i.e 3 times.

Wouldn't it be better to rewrite this code to smth like the following:

{
  UINT32      *Id;
  UINTN       Index;
  EFI_STATUS  Status;

  for (Index = 0; Index < ARRAY_SIZE (gRequiredProtocol); Index++) {
    Status = gBS->OpenProtocol (
                    ControllerHandle,
                    gRequiredProtocol[Index].RequiredServiceBindingProtocolGuid,
                    NULL,
                    This->DriverBindingHandle,
                    ControllerHandle,
                    EFI_OPEN_PROTOCOL_TEST_PROTOCOL
                    );
    if (EFI_ERROR (Status)) {
      return EFI_UNSUPPORTED;
    }

    Status = gBS->OpenProtocol (
                    ControllerHandle,
                    gRequiredProtocol[Index].DiscoveredProtocolGuid,
                    (VOID **)&Id,
                    This->DriverBindingHandle,
                    ControllerHandle,
                    EFI_OPEN_PROTOCOL_GET_PROTOCOL
                    );
    if (!EFI_ERROR (Status)) {
      // Already installed
      return EFI_UNSUPPORTED;
    }
  }

  DEBUG ((DEBUG_MANAGEABILITY, "%a: all required protocols are found on this controller handle: %p.\n", __func__, ControllerHandle));
  return EFI_SUCCESS;
}

?
No unnecessary variables, less indentation + this function is called from RedfishDiscoverDriverBindingSupported(), i.e very often, so we just reduce number of useless loop iterations and OpenProtocol() calls.

Igor: I agree, the optimization you suggested is good.


Regards,
Mike.


-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.

-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110753): https://edk2.groups.io/g/devel/message/110753
Mute This Topic: https://groups.io/mt/102303105/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 71954 bytes --]

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx
  2023-11-06 18:53         ` Igor Kulchytskyy via groups.io
@ 2023-11-07  1:51           ` Chang, Abner via groups.io
  2023-11-07  2:37             ` Igor Kulchytskyy via groups.io
       [not found]             ` <179536C42C301843.25348@groups.io>
  0 siblings, 2 replies; 10+ messages in thread
From: Chang, Abner via groups.io @ 2023-11-07  1:51 UTC (permalink / raw)
  To: Igor Kulchytskyy, devel@edk2.groups.io, M M; +Cc: Nickle Wang

[-- Attachment #1: Type: text/plain, Size: 15970 bytes --]

[AMD Official Use Only - General]

I would say to have static for a function used by module is a good coding practice and reduce the compile errors for the duplicated function naming, and maybe other advantages I am not quite sure.
But from edk2 C coding standard spec perspective, in 5.4.2.2.2, it says function should not be declared STATIC.
So my opinion is just keep the function without STATIC.

Abner


From: Igor Kulchytskyy <igork@ami.com>
Sent: Tuesday, November 7, 2023 2:54 AM
To: devel@edk2.groups.io; Igor Kulchytskyy <igork@ami.com>; M M <mike.maslenkin@gmail.com>
Cc: Chang, Abner <Abner.Chang@amd.com>; Nickle Wang <nicklew@nvidia.com>
Subject: RE: [EXTERNAL] Re: [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Hi Nickle and Abner,
What is your opinion – should we have GetHiIpProtocolType fuction as a static one?
Thank you,
Igor

From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Igor Kulchytskyy via groups.io
Sent: Monday, November 6, 2023 9:14 AM
To: M M <mike.maslenkin@gmail.com<mailto:mike.maslenkin@gmail.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Abner Chang <abner.chang@amd.com<mailto:abner.chang@amd.com>>; Nickle Wang <nicklew@nvidia.com<mailto:nicklew@nvidia.com>>
Subject: [EXTERNAL] Re: [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx


**CAUTION: The e-mail below is from an external source. Please exercise caution before opening attachments, clicking links, or following guidance.**
Hi Mike,
See my comments below.
Thank you,
Igor
P.S.
“There is no limits to perfection”

From: M M <mike.maslenkin@gmail.com<mailto:mike.maslenkin@gmail.com>>
Sent: Sunday, November 05, 2023 9:30 PM
To: Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Abner Chang <abner.chang@amd.com<mailto:abner.chang@amd.com>>; Nickle Wang <nicklew@nvidia.com<mailto:nicklew@nvidia.com>>
Subject: Re: [EXTERNAL] [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx

Hi Igor

I want to return to my initial comments regarding this patch.
Please, find my comments below.


On 1. 11. 2023., at 06:24, Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>> wrote:

Hi Mike,
Thank you for review.
Please see my answers below the text.

-----Original Message-----
From: Mike Maslenkin <mike.maslenkin@gmail.com<mailto:mike.maslenkin@gmail.com>>
Sent: Tuesday, October 31, 2023 9:00 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>>
Cc: Abner Chang <abner.chang@amd.com<mailto:abner.chang@amd.com>>; Nickle Wang <nicklew@nvidia.com<mailto:nicklew@nvidia.com>>
Subject: [EXTERNAL] Re: [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx


**CAUTION: The e-mail below is from an external source. Please exercise caution before opening attachments, clicking links, or following guidance.**

Hi Igor

please find my comments below.

On Tue, Oct 31, 2023 at 8:56 PM Igor Kulchytskyy via groups.io<http://groups.io/>
<igork=ami.com@groups.io<mailto:igork=ami.com@groups.io>> wrote:

Supported function of the driver changed to wait for all newtwork
interface to be installed.
Filer out the network interfaces which are not supported by
Redfish Host Interface.

Cc: Abner Chang <abner.chang@amd.com<mailto:abner.chang@amd.com>>
Cc: Nickle Wang <nicklew@nvidia.com<mailto:nicklew@nvidia.com>>
Cc: Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>>
Signed-off-by: Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>>
---
RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c | 96 ++++++++++++++++++--
1 file changed, 89 insertions(+), 7 deletions(-)

diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
index 23da3b968f..a88ad55938 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
@@ -322,9 +322,15 @@ GetTargetNetworkInterfaceInternal (
{
  EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterface;

+  if (IsListEmpty(&mEfiRedfishDiscoverNetworkInterface)) {
+    return NULL;
+  }
+
  ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
  while (TRUE) {
-    if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) == 0) {
+    if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) == 0 &&
+        ((TargetNetworkInterface->IsIpv6 && ThisNetworkInterface->NetworkProtocolType == ProtocolTypeTcp6) ||
+            (!TargetNetworkInterface->IsIpv6 && ThisNetworkInterface->NetworkProtocolType == ProtocolTypeTcp4))) {
      return ThisNetworkInterface;
    }

@@ -354,6 +360,10 @@ GetTargetNetworkInterfaceInternalByController (
{
  EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterface;

+  if (IsListEmpty(&mEfiRedfishDiscoverNetworkInterface)) {
+    return NULL;
+  }
+

I also have these two hunks in my pending list.
But I suggest to add ASSERT to GetTargetNetworkInterfaceInternal, just
because currently it is really impossible situation,
and mEfiRedfishDiscoverNetworkInterface was checked before in scope of
ValidateTargetNetworkInterface().

Igor: Agree.
I also just noticed that even if GetTargetNetworkInterfaceInternal function may return NULL, the return value is not verified on NULL in RedfishServiceAcquireService function.
I think we should add this verification.


Also I wonder why check patch doesn't complain about missed spaces in
"IsListEmpty (&mEfiRedfishDiscoverNetworkInterface)" call for example.

  ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
  while (TRUE) {
    if (ThisNetworkInterface->OpenDriverControllerHandle == ControllerHandle) {
@@ -476,6 +486,38 @@ CheckIsIpVersion6 (
  return FALSE;
}

+/**
+  This function returns the  IP type supported by the Host Interface
+
+  @retval IP Type
+  //  Unknown=00h,
+  //  Ipv4=01h,
+  //  Ipv6=02h,
+
+**/
+UINT8

STATIC ?
Igor: WHY?

I remembered discussion about STATIC functions usage and why it isn't common in edk2.
AFAIR it was because of difficulties with source level debugging for the case when it could be inlined.
BTW I won't insist on this here.


+GetHiIpProtocolType()
+{
+  EFI_STATUS                     Status;
+  REDFISH_OVER_IP_PROTOCOL_DATA  *Data;
+  REDFISH_INTERFACE_DATA         *DeviceDescriptor;
+
+  Data             = NULL;
+  DeviceDescriptor = NULL;
+  if (mSmbios == NULL) {
+    Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&mSmbios);
+    if (EFI_ERROR (Status)) {
+      return 0;

In this driver REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP{4,6}
used and accessible.
so, 0 means  REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN
And these values actually checked in scope of BuildupNetworkInterface() below.
Igor: Thank you. Missed that macro.

+    }
+  }
+  Status = RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescriptor, &Data); // Search for SMBIOS type 42h
+  if (!EFI_ERROR (Status) && (Data != NULL) &&
+      (Data->HostIpAssignmentType == RedfishHostIpAssignmentStatic)) {
+      return Data->HostIpAddressFormat;
+  }
+  return 0;

Same here, 0 is a magic value for
REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN

+}
+
/**
  This function discover Redfish service through SMBIOS host interface.

@@ -512,6 +554,15 @@ DiscoverRedfishHostInterface (

  Status = RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescriptor, &Data); // Search for SMBIOS type 42h
  if (!EFI_ERROR (Status) && (Data != NULL) && (DeviceDescriptor != NULL)) {
+
+    if (Instance->NetworkInterface->NetworkProtocolType == ProtocolTypeTcp4 && Data->HostIpAddressFormat != REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4) { // IPv4 case
+      DEBUG((DEBUG_ERROR, "%a: Network Interface is IPv4, but Host Interface requires Ipv6\n"));

Missed argument for %a format
Missed space "DEBUG (("

Igor: Inattentiveness. Thank you.

+      return EFI_UNSUPPORTED;
+    }
+    else if (Instance->NetworkInterface->NetworkProtocolType == ProtocolTypeTcp6 && Data->HostIpAddressFormat != REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6) { // IPv6 case
+      DEBUG((DEBUG_ERROR, "%a: Network Interface is IPv6, but Host Interface requires IPv4\n"));

Missed argument for %a format
Missed space "DEBUG (("

Igor: Inattentiveness. Thank you.

+      return EFI_UNSUPPORTED;
+    }
    //
    // Check if we can reach out Redfish service using this network interface.
    // Check with MAC address using Device Descriptor Data Device Type 04 and Type 05.
@@ -1102,6 +1153,7 @@ RedfishServiceGetNetworkInterface (
  OUT EFI_REDFISH_DISCOVER_NETWORK_INTERFACE  **NetworkIntfInstances
  )
{
+  EFI_STATUS                                       Status;
  EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterfaceIntn;
  EFI_REDFISH_DISCOVER_NETWORK_INTERFACE           *ThisNetworkInterface;
  EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL   *RestExInstance;
@@ -1141,6 +1193,16 @@ RedfishServiceGetNetworkInterface (

  ThisNetworkInterfaceIntn = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
  while (TRUE) {
+    // If Get Subnet Info skip this interface
+    Status = NetworkInterfaceGetSubnetInfo (ThisNetworkInterfaceIntn, ImageHandle); // Get subnet info
+    if (EFI_ERROR(Status)) {
+      if (IsNodeAtEnd (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterfaceIntn->Entry)) {
+        break;
+      }
+      ThisNetworkInterfaceIntn = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetNextNode (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterfaceIntn->Entry);
+      continue;
+    }
+
    ThisNetworkInterface->IsIpv6 = FALSE;
    if (CheckIsIpVersion6 (ThisNetworkInterfaceIntn)) {
      ThisNetworkInterface->IsIpv6 = TRUE;
@@ -1260,7 +1322,12 @@ RedfishServiceAcquireService (
      // Get subnet information in case subnet information is not set because
      // RedfishServiceGetNetworkInterfaces hasn't been called yet.
      //
-      NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInternal, ImageHandle);
+      Status1 = NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInternal, ImageHandle);
+      if (EFI_ERROR(Status1)) {
+        DEBUG ((DEBUG_ERROR, "%a: Get subnet information fail.\n", __func__));
+        FreePool(Instance);
+        continue;
+      }
      NewInstance = TRUE;
    }

@@ -1535,7 +1602,7 @@ TestForRequiredProtocols (
  UINT32      *Id;
  UINTN       Index;
  EFI_STATUS  Status;
-  UINTN       ListCount;
+  UINTN       ListCount, SuccessfulCount = 0;

  ListCount = (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL));
  for (Index = 0; Index < ListCount; Index++) {
@@ -1557,13 +1624,14 @@ TestForRequiredProtocols (
                      EFI_OPEN_PROTOCOL_GET_PROTOCOL
                      );
      if (EFI_ERROR (Status)) {
-        if (Index == ListCount - 1) {
-          DEBUG ((DEBUG_INFO, "%a: all required protocols are found on this controller handle: %p.\n", __func__, ControllerHandle));
-          return EFI_SUCCESS;
-        }
+        SuccessfulCount++;
      }
It may be SuccessfulCount must have one indentation less, i.e in scope
of  upper "if (!EFI_ERROR (Status)) {", not in scope of "if (EFI_ERROR
(Status)) {" in context.

Igor: We need TestForRequiredProtocols return SUCCESS when all protocols listed in gRequiredProtocol installed.
When this happened the BuildupNetworkInterface function would be called, and we iterate through gRequiredProtocol array and build network interfaces.
We also install DiscoveredProtocolGuid to prevent BuildupNetworkInterface to be called after that.
If we have SuccessfulCount in scope of  upper "if (!EFI_ERROR (Status)) {", then BuildupNetworkInterface will be called if something installed on that ControllerHandle, like DNS protocol, for example.

Yes, I understand this... but it's still illogical, taking in account variable name. I mean  if (EFI_ERROR (Status)) {SuccessfulCount++};

Here we increase SuccessfulCount for the case  "Cond1 && !Cond2", and return EFI_SUCCESS only if it is true for all gRequiredProtocol entries, i.e 3 times.

Wouldn't it be better to rewrite this code to smth like the following:

{
  UINT32      *Id;
  UINTN       Index;
  EFI_STATUS  Status;

  for (Index = 0; Index < ARRAY_SIZE (gRequiredProtocol); Index++) {
    Status = gBS->OpenProtocol (
                    ControllerHandle,
                    gRequiredProtocol[Index].RequiredServiceBindingProtocolGuid,
                    NULL,
                    This->DriverBindingHandle,
                    ControllerHandle,
                    EFI_OPEN_PROTOCOL_TEST_PROTOCOL
                    );
    if (EFI_ERROR (Status)) {
      return EFI_UNSUPPORTED;
    }

    Status = gBS->OpenProtocol (
                    ControllerHandle,
                    gRequiredProtocol[Index].DiscoveredProtocolGuid,
                    (VOID **)&Id,
                    This->DriverBindingHandle,
                    ControllerHandle,
                    EFI_OPEN_PROTOCOL_GET_PROTOCOL
                    );
    if (!EFI_ERROR (Status)) {
      // Already installed
      return EFI_UNSUPPORTED;
    }
  }

  DEBUG ((DEBUG_MANAGEABILITY, "%a: all required protocols are found on this controller handle: %p.\n", __func__, ControllerHandle));
  return EFI_SUCCESS;
}

?
No unnecessary variables, less indentation + this function is called from RedfishDiscoverDriverBindingSupported(), i.e very often, so we just reduce number of useless loop iterations and OpenProtocol() calls.

Igor: I agree, the optimization you suggested is good.


Regards,
Mike.


-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.

-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110781): https://edk2.groups.io/g/devel/message/110781
Mute This Topic: https://groups.io/mt/102303105/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 38110 bytes --]

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx
  2023-11-07  1:51           ` Chang, Abner via groups.io
@ 2023-11-07  2:37             ` Igor Kulchytskyy via groups.io
       [not found]             ` <179536C42C301843.25348@groups.io>
  1 sibling, 0 replies; 10+ messages in thread
From: Igor Kulchytskyy via groups.io @ 2023-11-07  2:37 UTC (permalink / raw)
  To: Chang, Abner, devel@edk2.groups.io, M M; +Cc: Nickle Wang

[-- Attachment #1: Type: text/plain, Size: 17257 bytes --]

Hi Abner,
Thanks for the explanation!
Will keep it without static.
Best regards,
Igor


Get Outlook for Android<https://aka.ms/AAb9ysg>
________________________________
From: Chang, Abner <Abner.Chang@amd.com>
Sent: Monday, November 6, 2023 8:51:18 PM
To: Igor Kulchytskyy <igork@ami.com>; devel@edk2.groups.io <devel@edk2.groups.io>; M M <mike.maslenkin@gmail.com>
Cc: Nickle Wang <nicklew@nvidia.com>
Subject: RE: [EXTERNAL] Re: [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx


[AMD Official Use Only - General]


I would say to have static for a function used by module is a good coding practice and reduce the compile errors for the duplicated function naming, and maybe other advantages I am not quite sure.

But from edk2 C coding standard spec perspective, in 5.4.2.2.2, it says function should not be declared STATIC.

So my opinion is just keep the function without STATIC.



Abner





From: Igor Kulchytskyy <igork@ami.com>
Sent: Tuesday, November 7, 2023 2:54 AM
To: devel@edk2.groups.io; Igor Kulchytskyy <igork@ami.com>; M M <mike.maslenkin@gmail.com>
Cc: Chang, Abner <Abner.Chang@amd.com>; Nickle Wang <nicklew@nvidia.com>
Subject: RE: [EXTERNAL] Re: [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx



Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.



Hi Nickle and Abner,

What is your opinion – should we have GetHiIpProtocolType fuction as a static one?

Thank you,

Igor



From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Igor Kulchytskyy via groups.io
Sent: Monday, November 6, 2023 9:14 AM
To: M M <mike.maslenkin@gmail.com<mailto:mike.maslenkin@gmail.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Abner Chang <abner.chang@amd.com<mailto:abner.chang@amd.com>>; Nickle Wang <nicklew@nvidia.com<mailto:nicklew@nvidia.com>>
Subject: [EXTERNAL] Re: [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx





**CAUTION: The e-mail below is from an external source. Please exercise caution before opening attachments, clicking links, or following guidance.**

Hi Mike,

See my comments below.

Thank you,

Igor

P.S.

“There is no limits to perfection”



From: M M <mike.maslenkin@gmail.com<mailto:mike.maslenkin@gmail.com>>
Sent: Sunday, November 05, 2023 9:30 PM
To: Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Abner Chang <abner.chang@amd.com<mailto:abner.chang@amd.com>>; Nickle Wang <nicklew@nvidia.com<mailto:nicklew@nvidia.com>>
Subject: Re: [EXTERNAL] [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx



Hi Igor



I want to return to my initial comments regarding this patch.

Please, find my comments below.





On 1. 11. 2023., at 06:24, Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>> wrote:



Hi Mike,
Thank you for review.
Please see my answers below the text.

-----Original Message-----
From: Mike Maslenkin <mike.maslenkin@gmail.com<mailto:mike.maslenkin@gmail.com>>
Sent: Tuesday, October 31, 2023 9:00 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>>
Cc: Abner Chang <abner.chang@amd.com<mailto:abner.chang@amd.com>>; Nickle Wang <nicklew@nvidia.com<mailto:nicklew@nvidia.com>>
Subject: [EXTERNAL] Re: [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx


**CAUTION: The e-mail below is from an external source. Please exercise caution before opening attachments, clicking links, or following guidance.**

Hi Igor

please find my comments below.

On Tue, Oct 31, 2023 at 8:56 PM Igor Kulchytskyy via groups.io<http://groups.io/>
<igork=ami.com@groups.io<mailto:igork=ami.com@groups.io>> wrote:

Supported function of the driver changed to wait for all newtwork
interface to be installed.
Filer out the network interfaces which are not supported by
Redfish Host Interface.

Cc: Abner Chang <abner.chang@amd.com<mailto:abner.chang@amd.com>>
Cc: Nickle Wang <nicklew@nvidia.com<mailto:nicklew@nvidia.com>>
Cc: Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>>
Signed-off-by: Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>>
---
RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c | 96 ++++++++++++++++++--
1 file changed, 89 insertions(+), 7 deletions(-)

diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
index 23da3b968f..a88ad55938 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
@@ -322,9 +322,15 @@ GetTargetNetworkInterfaceInternal (
{
  EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterface;

+  if (IsListEmpty(&mEfiRedfishDiscoverNetworkInterface)) {
+    return NULL;
+  }
+
  ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
  while (TRUE) {
-    if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) == 0) {
+    if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) == 0 &&
+        ((TargetNetworkInterface->IsIpv6 && ThisNetworkInterface->NetworkProtocolType == ProtocolTypeTcp6) ||
+            (!TargetNetworkInterface->IsIpv6 && ThisNetworkInterface->NetworkProtocolType == ProtocolTypeTcp4))) {
      return ThisNetworkInterface;
    }

@@ -354,6 +360,10 @@ GetTargetNetworkInterfaceInternalByController (
{
  EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterface;

+  if (IsListEmpty(&mEfiRedfishDiscoverNetworkInterface)) {
+    return NULL;
+  }
+

I also have these two hunks in my pending list.
But I suggest to add ASSERT to GetTargetNetworkInterfaceInternal, just
because currently it is really impossible situation,
and mEfiRedfishDiscoverNetworkInterface was checked before in scope of
ValidateTargetNetworkInterface().

Igor: Agree.
I also just noticed that even if GetTargetNetworkInterfaceInternal function may return NULL, the return value is not verified on NULL in RedfishServiceAcquireService function.
I think we should add this verification.


Also I wonder why check patch doesn't complain about missed spaces in
"IsListEmpty (&mEfiRedfishDiscoverNetworkInterface)" call for example.


  ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
  while (TRUE) {
    if (ThisNetworkInterface->OpenDriverControllerHandle == ControllerHandle) {
@@ -476,6 +486,38 @@ CheckIsIpVersion6 (
  return FALSE;
}

+/**
+  This function returns the  IP type supported by the Host Interface
+
+  @retval IP Type
+  //  Unknown=00h,
+  //  Ipv4=01h,
+  //  Ipv6=02h,
+
+**/
+UINT8

STATIC ?
Igor: WHY?



I remembered discussion about STATIC functions usage and why it isn't common in edk2.

AFAIR it was because of difficulties with source level debugging for the case when it could be inlined.

BTW I won't insist on this here.





+GetHiIpProtocolType()
+{
+  EFI_STATUS                     Status;
+  REDFISH_OVER_IP_PROTOCOL_DATA  *Data;
+  REDFISH_INTERFACE_DATA         *DeviceDescriptor;
+
+  Data             = NULL;
+  DeviceDescriptor = NULL;
+  if (mSmbios == NULL) {
+    Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&mSmbios);
+    if (EFI_ERROR (Status)) {
+      return 0;

In this driver REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP{4,6}
used and accessible.
so, 0 means  REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN
And these values actually checked in scope of BuildupNetworkInterface() below.
Igor: Thank you. Missed that macro.


+    }
+  }
+  Status = RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescriptor, &Data); // Search for SMBIOS type 42h
+  if (!EFI_ERROR (Status) && (Data != NULL) &&
+      (Data->HostIpAssignmentType == RedfishHostIpAssignmentStatic)) {
+      return Data->HostIpAddressFormat;
+  }
+  return 0;

Same here, 0 is a magic value for
REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN


+}
+
/**
  This function discover Redfish service through SMBIOS host interface.

@@ -512,6 +554,15 @@ DiscoverRedfishHostInterface (

  Status = RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescriptor, &Data); // Search for SMBIOS type 42h
  if (!EFI_ERROR (Status) && (Data != NULL) && (DeviceDescriptor != NULL)) {
+
+    if (Instance->NetworkInterface->NetworkProtocolType == ProtocolTypeTcp4 && Data->HostIpAddressFormat != REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4) { // IPv4 case
+      DEBUG((DEBUG_ERROR, "%a: Network Interface is IPv4, but Host Interface requires Ipv6\n"));

Missed argument for %a format
Missed space "DEBUG (("

Igor: Inattentiveness. Thank you.


+      return EFI_UNSUPPORTED;
+    }
+    else if (Instance->NetworkInterface->NetworkProtocolType == ProtocolTypeTcp6 && Data->HostIpAddressFormat != REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6) { // IPv6 case
+      DEBUG((DEBUG_ERROR, "%a: Network Interface is IPv6, but Host Interface requires IPv4\n"));

Missed argument for %a format
Missed space "DEBUG (("

Igor: Inattentiveness. Thank you.


+      return EFI_UNSUPPORTED;
+    }
    //
    // Check if we can reach out Redfish service using this network interface.
    // Check with MAC address using Device Descriptor Data Device Type 04 and Type 05.
@@ -1102,6 +1153,7 @@ RedfishServiceGetNetworkInterface (
  OUT EFI_REDFISH_DISCOVER_NETWORK_INTERFACE  **NetworkIntfInstances
  )
{
+  EFI_STATUS                                       Status;
  EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterfaceIntn;
  EFI_REDFISH_DISCOVER_NETWORK_INTERFACE           *ThisNetworkInterface;
  EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL   *RestExInstance;
@@ -1141,6 +1193,16 @@ RedfishServiceGetNetworkInterface (

  ThisNetworkInterfaceIntn = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
  while (TRUE) {
+    // If Get Subnet Info skip this interface
+    Status = NetworkInterfaceGetSubnetInfo (ThisNetworkInterfaceIntn, ImageHandle); // Get subnet info
+    if (EFI_ERROR(Status)) {
+      if (IsNodeAtEnd (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterfaceIntn->Entry)) {
+        break;
+      }
+      ThisNetworkInterfaceIntn = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetNextNode (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterfaceIntn->Entry);
+      continue;
+    }
+
    ThisNetworkInterface->IsIpv6 = FALSE;
    if (CheckIsIpVersion6 (ThisNetworkInterfaceIntn)) {
      ThisNetworkInterface->IsIpv6 = TRUE;
@@ -1260,7 +1322,12 @@ RedfishServiceAcquireService (
      // Get subnet information in case subnet information is not set because
      // RedfishServiceGetNetworkInterfaces hasn't been called yet.
      //
-      NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInternal, ImageHandle);
+      Status1 = NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInternal, ImageHandle);
+      if (EFI_ERROR(Status1)) {
+        DEBUG ((DEBUG_ERROR, "%a: Get subnet information fail.\n", __func__));
+        FreePool(Instance);
+        continue;
+      }
      NewInstance = TRUE;
    }

@@ -1535,7 +1602,7 @@ TestForRequiredProtocols (
  UINT32      *Id;
  UINTN       Index;
  EFI_STATUS  Status;
-  UINTN       ListCount;
+  UINTN       ListCount, SuccessfulCount = 0;

  ListCount = (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL));
  for (Index = 0; Index < ListCount; Index++) {
@@ -1557,13 +1624,14 @@ TestForRequiredProtocols (
                      EFI_OPEN_PROTOCOL_GET_PROTOCOL
                      );
      if (EFI_ERROR (Status)) {
-        if (Index == ListCount - 1) {
-          DEBUG ((DEBUG_INFO, "%a: all required protocols are found on this controller handle: %p.\n", __func__, ControllerHandle));
-          return EFI_SUCCESS;
-        }
+        SuccessfulCount++;
      }

It may be SuccessfulCount must have one indentation less, i.e in scope
of  upper "if (!EFI_ERROR (Status)) {", not in scope of "if (EFI_ERROR
(Status)) {" in context.

Igor: We need TestForRequiredProtocols return SUCCESS when all protocols listed in gRequiredProtocol installed.
When this happened the BuildupNetworkInterface function would be called, and we iterate through gRequiredProtocol array and build network interfaces.
We also install DiscoveredProtocolGuid to prevent BuildupNetworkInterface to be called after that.
If we have SuccessfulCount in scope of  upper "if (!EFI_ERROR (Status)) {", then BuildupNetworkInterface will be called if something installed on that ControllerHandle, like DNS protocol, for example.



Yes, I understand this... but it's still illogical, taking in account variable name. I mean  if (EFI_ERROR (Status)) {SuccessfulCount++};



Here we increase SuccessfulCount for the case  "Cond1 && !Cond2", and return EFI_SUCCESS only if it is true for all gRequiredProtocol entries, i.e 3 times.



Wouldn't it be better to rewrite this code to smth like the following:



{

  UINT32      *Id;

  UINTN       Index;

  EFI_STATUS  Status;



  for (Index = 0; Index < ARRAY_SIZE (gRequiredProtocol); Index++) {

    Status = gBS->OpenProtocol (

                    ControllerHandle,

                    gRequiredProtocol[Index].RequiredServiceBindingProtocolGuid,

                    NULL,

                    This->DriverBindingHandle,

                    ControllerHandle,

                    EFI_OPEN_PROTOCOL_TEST_PROTOCOL

                    );

    if (EFI_ERROR (Status)) {

      return EFI_UNSUPPORTED;

    }



    Status = gBS->OpenProtocol (

                    ControllerHandle,

                    gRequiredProtocol[Index].DiscoveredProtocolGuid,

                    (VOID **)&Id,

                    This->DriverBindingHandle,

                    ControllerHandle,

                    EFI_OPEN_PROTOCOL_GET_PROTOCOL

                    );

    if (!EFI_ERROR (Status)) {

      // Already installed

      return EFI_UNSUPPORTED;

    }

  }



  DEBUG ((DEBUG_MANAGEABILITY, "%a: all required protocols are found on this controller handle: %p.\n", __func__, ControllerHandle));

  return EFI_SUCCESS;

}



?

No unnecessary variables, less indentation + this function is called from RedfishDiscoverDriverBindingSupported(), i.e very often, so we just reduce number of useless loop iterations and OpenProtocol() calls.



Igor: I agree, the optimization you suggested is good.





Regards,

Mike.





-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.



-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.

-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110784): https://edk2.groups.io/g/devel/message/110784
Mute This Topic: https://groups.io/mt/102303105/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 37718 bytes --]

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx
       [not found]             ` <179536C42C301843.25348@groups.io>
@ 2023-11-07  5:05               ` Igor Kulchytskyy via groups.io
  0 siblings, 0 replies; 10+ messages in thread
From: Igor Kulchytskyy via groups.io @ 2023-11-07  5:05 UTC (permalink / raw)
  To: devel@edk2.groups.io, Igor Kulchytskyy, Chang, Abner, M M; +Cc: Nickle Wang

[-- Attachment #1: Type: text/plain, Size: 18823 bytes --]

I changed TestForRequiredProtocols function as Mike suggested.
I also kept GetHiIpProtocolType function without STATIC.
Resend pull request with those changes.
Thank you,
Igor

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Igor Kulchytskyy via groups.io
Sent: Monday, November 6, 2023 9:37 PM
To: Chang, Abner <Abner.Chang@amd.com>; devel@edk2.groups.io; M M <mike.maslenkin@gmail.com>
Cc: Nickle Wang <nicklew@nvidia.com>
Subject: [EXTERNAL] Re: [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx


**CAUTION: The e-mail below is from an external source. Please exercise caution before opening attachments, clicking links, or following guidance.**
Hi Abner,
Thanks for the explanation!
Will keep it without static.
Best regards,
Igor


Get Outlook for Android<https://aka.ms/AAb9ysg>
________________________________
From: Chang, Abner <Abner.Chang@amd.com<mailto:Abner.Chang@amd.com>>
Sent: Monday, November 6, 2023 8:51:18 PM
To: Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>>; devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>>; M M <mike.maslenkin@gmail.com<mailto:mike.maslenkin@gmail.com>>
Cc: Nickle Wang <nicklew@nvidia.com<mailto:nicklew@nvidia.com>>
Subject: RE: [EXTERNAL] Re: [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx


[AMD Official Use Only - General]


I would say to have static for a function used by module is a good coding practice and reduce the compile errors for the duplicated function naming, and maybe other advantages I am not quite sure.

But from edk2 C coding standard spec perspective, in 5.4.2.2.2, it says function should not be declared STATIC.

So my opinion is just keep the function without STATIC.



Abner





From: Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>>
Sent: Tuesday, November 7, 2023 2:54 AM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>>; M M <mike.maslenkin@gmail.com<mailto:mike.maslenkin@gmail.com>>
Cc: Chang, Abner <Abner.Chang@amd.com<mailto:Abner.Chang@amd.com>>; Nickle Wang <nicklew@nvidia.com<mailto:nicklew@nvidia.com>>
Subject: RE: [EXTERNAL] Re: [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx



Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.



Hi Nickle and Abner,

What is your opinion – should we have GetHiIpProtocolType fuction as a static one?

Thank you,

Igor



From: devel@edk2.groups.io<mailto:devel@edk2.groups.io> <devel@edk2.groups.io<mailto:devel@edk2.groups.io>> On Behalf Of Igor Kulchytskyy via groups.io
Sent: Monday, November 6, 2023 9:14 AM
To: M M <mike.maslenkin@gmail.com<mailto:mike.maslenkin@gmail.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Abner Chang <abner.chang@amd.com<mailto:abner.chang@amd.com>>; Nickle Wang <nicklew@nvidia.com<mailto:nicklew@nvidia.com>>
Subject: [EXTERNAL] Re: [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx





**CAUTION: The e-mail below is from an external source. Please exercise caution before opening attachments, clicking links, or following guidance.**

Hi Mike,

See my comments below.

Thank you,

Igor

P.S.

“There is no limits to perfection”



From: M M <mike.maslenkin@gmail.com<mailto:mike.maslenkin@gmail.com>>
Sent: Sunday, November 05, 2023 9:30 PM
To: Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>>
Cc: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Abner Chang <abner.chang@amd.com<mailto:abner.chang@amd.com>>; Nickle Wang <nicklew@nvidia.com<mailto:nicklew@nvidia.com>>
Subject: Re: [EXTERNAL] [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx



Hi Igor



I want to return to my initial comments regarding this patch.

Please, find my comments below.





On 1. 11. 2023., at 06:24, Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>> wrote:



Hi Mike,
Thank you for review.
Please see my answers below the text.

-----Original Message-----
From: Mike Maslenkin <mike.maslenkin@gmail.com<mailto:mike.maslenkin@gmail.com>>
Sent: Tuesday, October 31, 2023 9:00 PM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>; Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>>
Cc: Abner Chang <abner.chang@amd.com<mailto:abner.chang@amd.com>>; Nickle Wang <nicklew@nvidia.com<mailto:nicklew@nvidia.com>>
Subject: [EXTERNAL] Re: [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx


**CAUTION: The e-mail below is from an external source. Please exercise caution before opening attachments, clicking links, or following guidance.**

Hi Igor

please find my comments below.

On Tue, Oct 31, 2023 at 8:56 PM Igor Kulchytskyy via groups.io<http://groups.io/>
<igork=ami.com@groups.io<mailto:igork=ami.com@groups.io>> wrote:

Supported function of the driver changed to wait for all newtwork
interface to be installed.
Filer out the network interfaces which are not supported by
Redfish Host Interface.

Cc: Abner Chang <abner.chang@amd.com<mailto:abner.chang@amd.com>>
Cc: Nickle Wang <nicklew@nvidia.com<mailto:nicklew@nvidia.com>>
Cc: Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>>
Signed-off-by: Igor Kulchytskyy <igork@ami.com<mailto:igork@ami.com>>
---
RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c | 96 ++++++++++++++++++--
1 file changed, 89 insertions(+), 7 deletions(-)

diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
index 23da3b968f..a88ad55938 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
@@ -322,9 +322,15 @@ GetTargetNetworkInterfaceInternal (
{
  EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterface;

+  if (IsListEmpty(&mEfiRedfishDiscoverNetworkInterface)) {
+    return NULL;
+  }
+
  ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
  while (TRUE) {
-    if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) == 0) {
+    if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNetworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) == 0 &&
+        ((TargetNetworkInterface->IsIpv6 && ThisNetworkInterface->NetworkProtocolType == ProtocolTypeTcp6) ||
+            (!TargetNetworkInterface->IsIpv6 && ThisNetworkInterface->NetworkProtocolType == ProtocolTypeTcp4))) {
      return ThisNetworkInterface;
    }

@@ -354,6 +360,10 @@ GetTargetNetworkInterfaceInternalByController (
{
  EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterface;

+  if (IsListEmpty(&mEfiRedfishDiscoverNetworkInterface)) {
+    return NULL;
+  }
+

I also have these two hunks in my pending list.
But I suggest to add ASSERT to GetTargetNetworkInterfaceInternal, just
because currently it is really impossible situation,
and mEfiRedfishDiscoverNetworkInterface was checked before in scope of
ValidateTargetNetworkInterface().

Igor: Agree.
I also just noticed that even if GetTargetNetworkInterfaceInternal function may return NULL, the return value is not verified on NULL in RedfishServiceAcquireService function.
I think we should add this verification.


Also I wonder why check patch doesn't complain about missed spaces in
"IsListEmpty (&mEfiRedfishDiscoverNetworkInterface)" call for example.

  ThisNetworkInterface = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
  while (TRUE) {
    if (ThisNetworkInterface->OpenDriverControllerHandle == ControllerHandle) {
@@ -476,6 +486,38 @@ CheckIsIpVersion6 (
  return FALSE;
}

+/**
+  This function returns the  IP type supported by the Host Interface
+
+  @retval IP Type
+  //  Unknown=00h,
+  //  Ipv4=01h,
+  //  Ipv6=02h,
+
+**/
+UINT8

STATIC ?
Igor: WHY?



I remembered discussion about STATIC functions usage and why it isn't common in edk2.

AFAIR it was because of difficulties with source level debugging for the case when it could be inlined.

BTW I won't insist on this here.





+GetHiIpProtocolType()
+{
+  EFI_STATUS                     Status;
+  REDFISH_OVER_IP_PROTOCOL_DATA  *Data;
+  REDFISH_INTERFACE_DATA         *DeviceDescriptor;
+
+  Data             = NULL;
+  DeviceDescriptor = NULL;
+  if (mSmbios == NULL) {
+    Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&mSmbios);
+    if (EFI_ERROR (Status)) {
+      return 0;

In this driver REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP{4,6}
used and accessible.
so, 0 means  REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN
And these values actually checked in scope of BuildupNetworkInterface() below.
Igor: Thank you. Missed that macro.

+    }
+  }
+  Status = RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescriptor, &Data); // Search for SMBIOS type 42h
+  if (!EFI_ERROR (Status) && (Data != NULL) &&
+      (Data->HostIpAssignmentType == RedfishHostIpAssignmentStatic)) {
+      return Data->HostIpAddressFormat;
+  }
+  return 0;

Same here, 0 is a magic value for
REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN

+}
+
/**
  This function discover Redfish service through SMBIOS host interface.

@@ -512,6 +554,15 @@ DiscoverRedfishHostInterface (

  Status = RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescriptor, &Data); // Search for SMBIOS type 42h
  if (!EFI_ERROR (Status) && (Data != NULL) && (DeviceDescriptor != NULL)) {
+
+    if (Instance->NetworkInterface->NetworkProtocolType == ProtocolTypeTcp4 && Data->HostIpAddressFormat != REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4) { // IPv4 case
+      DEBUG((DEBUG_ERROR, "%a: Network Interface is IPv4, but Host Interface requires Ipv6\n"));

Missed argument for %a format
Missed space "DEBUG (("

Igor: Inattentiveness. Thank you.

+      return EFI_UNSUPPORTED;
+    }
+    else if (Instance->NetworkInterface->NetworkProtocolType == ProtocolTypeTcp6 && Data->HostIpAddressFormat != REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6) { // IPv6 case
+      DEBUG((DEBUG_ERROR, "%a: Network Interface is IPv6, but Host Interface requires IPv4\n"));

Missed argument for %a format
Missed space "DEBUG (("

Igor: Inattentiveness. Thank you.

+      return EFI_UNSUPPORTED;
+    }
    //
    // Check if we can reach out Redfish service using this network interface.
    // Check with MAC address using Device Descriptor Data Device Type 04 and Type 05.
@@ -1102,6 +1153,7 @@ RedfishServiceGetNetworkInterface (
  OUT EFI_REDFISH_DISCOVER_NETWORK_INTERFACE  **NetworkIntfInstances
  )
{
+  EFI_STATUS                                       Status;
  EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL  *ThisNetworkInterfaceIntn;
  EFI_REDFISH_DISCOVER_NETWORK_INTERFACE           *ThisNetworkInterface;
  EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL   *RestExInstance;
@@ -1141,6 +1193,16 @@ RedfishServiceGetNetworkInterface (

  ThisNetworkInterfaceIntn = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface);
  while (TRUE) {
+    // If Get Subnet Info skip this interface
+    Status = NetworkInterfaceGetSubnetInfo (ThisNetworkInterfaceIntn, ImageHandle); // Get subnet info
+    if (EFI_ERROR(Status)) {
+      if (IsNodeAtEnd (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterfaceIntn->Entry)) {
+        break;
+      }
+      ThisNetworkInterfaceIntn = (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *)GetNextNode (&mEfiRedfishDiscoverNetworkInterface, &ThisNetworkInterfaceIntn->Entry);
+      continue;
+    }
+
    ThisNetworkInterface->IsIpv6 = FALSE;
    if (CheckIsIpVersion6 (ThisNetworkInterfaceIntn)) {
      ThisNetworkInterface->IsIpv6 = TRUE;
@@ -1260,7 +1322,12 @@ RedfishServiceAcquireService (
      // Get subnet information in case subnet information is not set because
      // RedfishServiceGetNetworkInterfaces hasn't been called yet.
      //
-      NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInternal, ImageHandle);
+      Status1 = NetworkInterfaceGetSubnetInfo (TargetNetworkInterfaceInternal, ImageHandle);
+      if (EFI_ERROR(Status1)) {
+        DEBUG ((DEBUG_ERROR, "%a: Get subnet information fail.\n", __func__));
+        FreePool(Instance);
+        continue;
+      }
      NewInstance = TRUE;
    }

@@ -1535,7 +1602,7 @@ TestForRequiredProtocols (
  UINT32      *Id;
  UINTN       Index;
  EFI_STATUS  Status;
-  UINTN       ListCount;
+  UINTN       ListCount, SuccessfulCount = 0;

  ListCount = (sizeof (gRequiredProtocol) / sizeof (REDFISH_DISCOVER_REQUIRED_PROTOCOL));
  for (Index = 0; Index < ListCount; Index++) {
@@ -1557,13 +1624,14 @@ TestForRequiredProtocols (
                      EFI_OPEN_PROTOCOL_GET_PROTOCOL
                      );
      if (EFI_ERROR (Status)) {
-        if (Index == ListCount - 1) {
-          DEBUG ((DEBUG_INFO, "%a: all required protocols are found on this controller handle: %p.\n", __func__, ControllerHandle));
-          return EFI_SUCCESS;
-        }
+        SuccessfulCount++;
      }

It may be SuccessfulCount must have one indentation less, i.e in scope
of  upper "if (!EFI_ERROR (Status)) {", not in scope of "if (EFI_ERROR
(Status)) {" in context.

Igor: We need TestForRequiredProtocols return SUCCESS when all protocols listed in gRequiredProtocol installed.
When this happened the BuildupNetworkInterface function would be called, and we iterate through gRequiredProtocol array and build network interfaces.
We also install DiscoveredProtocolGuid to prevent BuildupNetworkInterface to be called after that.
If we have SuccessfulCount in scope of  upper "if (!EFI_ERROR (Status)) {", then BuildupNetworkInterface will be called if something installed on that ControllerHandle, like DNS protocol, for example.



Yes, I understand this... but it's still illogical, taking in account variable name. I mean  if (EFI_ERROR (Status)) {SuccessfulCount++};



Here we increase SuccessfulCount for the case  "Cond1 && !Cond2", and return EFI_SUCCESS only if it is true for all gRequiredProtocol entries, i.e 3 times.



Wouldn't it be better to rewrite this code to smth like the following:



{

  UINT32      *Id;

  UINTN       Index;

  EFI_STATUS  Status;



  for (Index = 0; Index < ARRAY_SIZE (gRequiredProtocol); Index++) {

    Status = gBS->OpenProtocol (

                    ControllerHandle,

                    gRequiredProtocol[Index].RequiredServiceBindingProtocolGuid,

                    NULL,

                    This->DriverBindingHandle,

                    ControllerHandle,

                    EFI_OPEN_PROTOCOL_TEST_PROTOCOL

                    );

    if (EFI_ERROR (Status)) {

      return EFI_UNSUPPORTED;

    }



    Status = gBS->OpenProtocol (

                    ControllerHandle,

                    gRequiredProtocol[Index].DiscoveredProtocolGuid,

                    (VOID **)&Id,

                    This->DriverBindingHandle,

                    ControllerHandle,

                    EFI_OPEN_PROTOCOL_GET_PROTOCOL

                    );

    if (!EFI_ERROR (Status)) {

      // Already installed

      return EFI_UNSUPPORTED;

    }

  }



  DEBUG ((DEBUG_MANAGEABILITY, "%a: all required protocols are found on this controller handle: %p.\n", __func__, ControllerHandle));

  return EFI_SUCCESS;

}



?

No unnecessary variables, less indentation + this function is called from RedfishDiscoverDriverBindingSupported(), i.e very often, so we just reduce number of useless loop iterations and OpenProtocol() calls.



Igor: I agree, the optimization you suggested is good.





Regards,

Mike.





-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.

-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.
-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.

-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110798): https://edk2.groups.io/g/devel/message/110798
Mute This Topic: https://groups.io/mt/102303105/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 80440 bytes --]

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-11-07  5:06 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-31 17:56 [edk2-devel] [PATCH] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx Igor Kulchytskyy via groups.io
2023-11-01  1:00 ` Mike Maslenkin
2023-11-01  3:24   ` Igor Kulchytskyy via groups.io
2023-11-01  9:36     ` Mike Maslenkin
2023-11-06  2:29     ` Mike Maslenkin
2023-11-06 14:14       ` Igor Kulchytskyy via groups.io
     [not found]       ` <17950E34B0AB455C.12603@groups.io>
2023-11-06 18:53         ` Igor Kulchytskyy via groups.io
2023-11-07  1:51           ` Chang, Abner via groups.io
2023-11-07  2:37             ` Igor Kulchytskyy via groups.io
     [not found]             ` <179536C42C301843.25348@groups.io>
2023-11-07  5:05               ` Igor Kulchytskyy via groups.io

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox