summaryrefslogtreecommitdiffstats
path: root/RedfishPkg/RedfishDiscoverDxe
diff options
context:
space:
mode:
authorNickle Wang <nicklew@nvidia.com>2023-07-24 21:03:04 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-07-26 00:49:45 +0000
commit25a6745fe886e88fe175a50dcab4562c65b7cea3 (patch)
tree6676bd04e95b6cbed85f7a7ce19c76a767ae9e3d /RedfishPkg/RedfishDiscoverDxe
parentdcf05f958eb409095bf330cf8b8f12fe4c940880 (diff)
downloadedk2-25a6745fe886e88fe175a50dcab4562c65b7cea3.tar.gz
edk2-25a6745fe886e88fe175a50dcab4562c65b7cea3.tar.bz2
edk2-25a6745fe886e88fe175a50dcab4562c65b7cea3.zip
RedfishPkg/RedfishDiscoverDxe: fix netmask check issue
- Add NTOHL() for coverting IP address from EFI_IPv4_ADDRESS to IP4_ADDR so that IP4_IS_VALID_NETMASK() return correct value. - Add DumpIpv4Address() in RedfishDebugLib and print IP address when invalid IP or subnet mask address is detected. Signed-off-by: Nickle Wang <nicklew@nvidia.com> Cc: Abner Chang <abner.chang@amd.com> Cc: Igor Kulchytskyy <igork@ami.com> Cc: Nick Ramirez <nramirez@nvidia.com> Reviewed-by: Igor Kulchytskyy <igork@ami.com> Reviewed-by: Abner Chang <abner.chang@amd.com>
Diffstat (limited to 'RedfishPkg/RedfishDiscoverDxe')
-rw-r--r--RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c11
-rw-r--r--RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.inf2
-rw-r--r--RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h1
3 files changed, 10 insertions, 4 deletions
diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
index 470b4c9e00..17c88ad82d 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
@@ -531,15 +531,17 @@ DiscoverRedfishHostInterface (
IP4_COPY_ADDRESS ((VOID *)&Instance->HostSubnetMask.v4, (VOID *)Data->HostIpMask);
if (EFI_IP4_EQUAL (&Instance->HostIpAddress.v4, &mZeroIp4Addr)) {
- DEBUG ((DEBUG_ERROR, "%a: invalid host IP address: zero address\n", __func__));
+ DEBUG ((DEBUG_ERROR, "%a: invalid host IP address: ", __func__));
+ DumpIpv4Address (DEBUG_ERROR, &Instance->HostIpAddress.v4);
//
// Invalid IP address detected. Change address format to Unknown and use system default address.
//
Instance->HostAddrFormat = REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN;
}
- if (!IP4_IS_VALID_NETMASK (EFI_IP4 (Instance->HostSubnetMask.v4))) {
- DEBUG ((DEBUG_ERROR, "%a: invalid subnet mask address\n", __func__));
+ if (!IP4_IS_VALID_NETMASK (NTOHL (EFI_IP4 (Instance->HostSubnetMask.v4)))) {
+ DEBUG ((DEBUG_ERROR, "%a: invalid subnet mask address: ", __func__));
+ DumpIpv4Address (DEBUG_ERROR, &Instance->HostSubnetMask.v4);
//
// Invalid subnet mast address detected. Change address format to Unknown and use system default address.
//
@@ -553,7 +555,8 @@ DiscoverRedfishHostInterface (
IP4_COPY_ADDRESS ((VOID *)&Instance->TargetIpAddress.v4, (VOID *)Data->RedfishServiceIpAddress);
if (EFI_IP4_EQUAL (&Instance->TargetIpAddress.v4, &mZeroIp4Addr)) {
- DEBUG ((DEBUG_ERROR, "%a: invalid service IP address: zero address\n", __func__));
+ DEBUG ((DEBUG_ERROR, "%a: invalid service IP address: ", __func__));
+ DumpIpv4Address (DEBUG_ERROR, &Instance->TargetIpAddress.v4);
}
} else {
IP6_COPY_ADDRESS ((VOID *)&Instance->TargetIpAddress.v6, (VOID *)Data->RedfishServiceIpAddress);
diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.inf b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.inf
index 345bacf44d..950098bf6a 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.inf
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.inf
@@ -2,6 +2,7 @@
# Implementation of EFI_REDFISH_DISCOVER_PROTOCOL interfaces.
#
# (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
+# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -34,6 +35,7 @@
DebugLib
MemoryAllocationLib
PrintLib
+ RedfishDebugLib
RestExLib
UefiLib
UefiBootServicesTableLib
diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h
index d24c4081d9..01454acc1d 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h
@@ -28,6 +28,7 @@
#include <Library/MemoryAllocationLib.h>
#include <Library/NetLib.h>
#include <Library/PrintLib.h>
+#include <Library/RedfishDebugLib.h>
#include <Library/RestExLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiBootServicesTableLib.h>