From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id ADEC2940F74 for ; Tue, 25 Jul 2023 02:24:15 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=WpP49CpzsitVbDEHm8cNp/JVX9iySqOcyfcfAc9OWLQ=; c=relaxed/simple; d=groups.io; h=X-Received:X-Received:ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:X-Received:X-Received:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:X-MS-Has-Attach:X-MS-TNEF-Correlator:x-ms-publictraffictype:x-ms-traffictypediagnostic:x-ms-office365-filtering-correlation-id:x-ms-exchange-senderadcheck:x-ms-exchange-antispam-relay:x-microsoft-antispam-message-info:x-ms-exchange-antispam-messagedata-chunkcount:x-ms-exchange-antispam-messagedata-0:MIME-Version:X-OriginatorOrg:X-MS-Exchange-CrossTenant-AuthAs:X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-Network-Message-Id:X-MS-Exchange-CrossTenant-originalarrivaltime:X-MS-Exchange-CrossTenant-fromentityheader:X-MS-Exchange-CrossTenant-id:X-MS-Exchange-CrossTenant-mailboxtype:X-MS-Exchange-CrossTenant-userprincipalname:X-MS-Exchange-Transport-CrossTenantHeadersStamped:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubsc ribe-Post:List-Unsubscribe:X-Gm-Message-State:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1690251854; v=1; b=OdjgWBA1QNwhucrOQDjn7TfB7NUh08KQYJFAQGzGt0VIcKWXiiSYaJIdhNA/l96XDeqRY6CL uJgdOhEyMeX/X8jzJq2+NwV3kVdfu51pCE0oOisddGQZ02Y0GX+p04fYc5T0eLQoJznQUqoE4MO 3aVfC76PuVN7ivBJF5iXw/74= X-Received: by 127.0.0.2 with SMTP id FhrMYY7687511xkXGGcOeP9g; Mon, 24 Jul 2023 19:24:14 -0700 X-Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.43]) by mx.groups.io with SMTP id smtpd.web11.12133.1690251853001692628 for ; Mon, 24 Jul 2023 19:24:13 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g7oRhAQgAQvrGVTw6UvArZ11rMQoWyuaYfU+GWCVtqqpOZoGcOCeZhvCQ2bXlu7yc3pwAZczvX856EnWQ3XEleneV35PBWCqZws2n9EBHeb3GOGW8Jg9yeRoqDqm9i+IkA8ycefXy0TorIGQt0sAR0jQWTGkx/CJXQY7TklqaQiuT757DL3sAdRCawcRfx+TC9B+4B1YkpMqLv+yWkMoLX6Fqds38eIULPneeMmW4FC5eqhlwa6bVjYSzq4YecvksBZYhwNDcbMTD4nqEHMeZ99MJr62lhiidOhhqEmjqkpzcq8P0LBTB8YDCiMOj+yhHuZZi7iAVR0D7RGUhBzNbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bK0cCa8m17MW6AVwmlPaJV63O95WGb5mOVgA1xDfBcQ=; b=Kiok0rxlLtGmseEeKYN+wES8n4w6pletXjCRX0uqKcxlNPYP4XHhdWs1Ohad0SE5ibx/o+05p+kwZA/TQQQBsI1271eCHoHP+ReuJhNGUTylZQ+2NcjpaKzTenArD9zLMkxXyutoq3pljZxu3lOIAJp9LeVm1jCabfzO+Abo4kBy0d5LxiA7dGuX9fSmJimXU5UqYrTOPaZPqrJVl5deBPUYwPWu8LIYGGUWMUiZNysY2PyzAcBtHu4Ltdqhxz6ETMhP2Yv1YLM4mBYb+WM3Y4wX+0lqJcHqyC9Hfijon8u1CWWzsefb0Km+5uwt9ukbOLGhWPj/nKgrpFCmNk1VSw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ami.com; dmarc=pass action=none header.from=ami.com; dkim=pass header.d=ami.com; arc=none X-Received: from BLAPR10MB5185.namprd10.prod.outlook.com (2603:10b6:208:328::16) by CY8PR10MB7367.namprd10.prod.outlook.com (2603:10b6:930:7a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.33; Tue, 25 Jul 2023 02:24:10 +0000 X-Received: from BLAPR10MB5185.namprd10.prod.outlook.com ([fe80::54b4:fe44:b9d9:ab6d]) by BLAPR10MB5185.namprd10.prod.outlook.com ([fe80::54b4:fe44:b9d9:ab6d%4]) with mapi id 15.20.6609.032; Tue, 25 Jul 2023 02:24:09 +0000 From: "Igor Kulchytskyy via groups.io" To: Nickle Wang , "devel@edk2.groups.io" CC: Abner Chang , Nick Ramirez Subject: Re: [edk2-devel] [PATCH] RedfishPkg/RedfishDiscoverDxe: fix netmask check issue Thread-Topic: [EXTERNAL] [PATCH] RedfishPkg/RedfishDiscoverDxe: fix netmask check issue Thread-Index: AQHZvo0LFWePp2ipUU+hTgxxf5jUnq/JwQVQ Date: Tue, 25 Jul 2023 02:24:09 +0000 Message-ID: References: <20230725001438.1292-1-nicklew@nvidia.com> In-Reply-To: <20230725001438.1292-1-nicklew@nvidia.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BLAPR10MB5185:EE_|CY8PR10MB7367:EE_ x-ms-office365-filtering-correlation-id: 9a04d4e4-2e9e-427a-38eb-08db8cb63a3f x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: 8egRpgTdgQoVbEatceJCEhk1evR+k/4DvIU5KDAUrEqrp7LpuD+GbEDdBeBIGqjJ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Q?= =?us-ascii?Q?5TtBAzweD9kEiFjzIm3DUSzM4N/6zH9DgGatyd8f7R9d/H7jnGa1uSxSkM4Y?= =?us-ascii?Q?m4U7M/aFiJ9XVh+BBdyRQAu6/NiRxmvdMHgBfEUBZ1b265jWkkV5QOJj8H9S?= =?us-ascii?Q?RUr/RmubF6HsGHADvxcqDgSxOvBbVVzRCCEFMPXaOEBx5Nm80x6fork3865r?= =?us-ascii?Q?MBmNgF+CAfqIPAZI39Ll2X8+cDTYGc+Hmy9K7geP8KI8Rzg448aZVP1x6/XD?= =?us-ascii?Q?RxjAMMu25SBfuacWRyPTQIFcB2iGHESKtvRlW6yzKFGY8wKTBgMWgGcj2cJL?= =?us-ascii?Q?OmKj4vLnqS5kZIGY+YfxQAclABSnHXvVlz2K+mx8JqmL+RnPVCzogSJQAtol?= =?us-ascii?Q?Vni52EWtnGvbRDPS7RUx5ZY=3D?= MIME-Version: 1.0 X-OriginatorOrg: ami.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BLAPR10MB5185.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9a04d4e4-2e9e-427a-38eb-08db8cb63a3f X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Jul 2023 02:24:09.1925 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 27e97857-e15f-486c-b58e-86c2b3040f93 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: ujn81DJaDbhmMPZy1vhVfOtA+ekkHgP9vp/mr+WjvWPh1kbFGYGMsfyIN6nGNvP8 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR10MB7367 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,igork@ami.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: zj0P6vG2rkHfvdbp4dNW2BO5x7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=OdjgWBA1; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Reviewed-by: Igor Kulchytskyy -----Original Message----- From: Nickle Wang Sent: Monday, July 24, 2023 8:15 PM To: devel@edk2.groups.io Cc: Abner Chang ; Igor Kulchytskyy ; Ni= ck Ramirez Subject: [EXTERNAL] [PATCH] RedfishPkg/RedfishDiscoverDxe: fix netmask chec= k issue **CAUTION: The e-mail below is from an external source. Please exercise cau= tion before opening attachments, clicking links, or following guidance.** - 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 Cc: Abner Chang Cc: Igor Kulchytskyy Cc: Nick Ramirez --- .../RedfishDiscoverDxe/RedfishDiscoverDxe.inf | 2 ++ RedfishPkg/Include/Library/RedfishDebugLib.h | 17 ++++++++++++ .../RedfishDiscoverInternal.h | 1 + .../Library/RedfishDebugLib/RedfishDebugLib.c | 26 +++++++++++++++++++ .../RedfishDiscoverDxe/RedfishDiscoverDxe.c | 11 +++++--- 5 files changed, 53 insertions(+), 4 deletions(-) diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.inf b/Redfish= Pkg/RedfishDiscoverDxe/RedfishDiscoverDxe.inf index 345bacf44d20..950098bf6a0d 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
+# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserve= d. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -34,6 +35,7 @@ DebugLib MemoryAllocationLib PrintLib + RedfishDebugLib RestExLib UefiLib UefiBootServicesTableLib diff --git a/RedfishPkg/Include/Library/RedfishDebugLib.h b/RedfishPkg/Incl= ude/Library/RedfishDebugLib.h index da7e0d0bc9fc..5f75bad12a7f 100644 --- a/RedfishPkg/Include/Library/RedfishDebugLib.h +++ b/RedfishPkg/Include/Library/RedfishDebugLib.h @@ -121,4 +121,21 @@ DumpHttpStatusCode ( IN EFI_HTTP_STATUS_CODE HttpStatusCode ); +/** + + This function dump the IPv4 address in given error level. + + @param[in] ErrorLevel DEBUG macro error level + @param[in] Ipv4Address IPv4 address to dump + + @retval EFI_SUCCESS IPv4 address string is printed. + @retval Others Errors occur. + +**/ +EFI_STATUS +DumpIpv4Address ( + IN UINTN ErrorLevel, + IN EFI_IPv4_ADDRESS *Ipv4Address + ); + #endif diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h b/Redf= ishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h index d24c4081d9c0..01454acc1d9d 100644 --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include diff --git a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c b/Redfish= Pkg/Library/RedfishDebugLib/RedfishDebugLib.c index 0b2a9a5c4ec8..efa9a5ca1319 100644 --- a/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c +++ b/RedfishPkg/Library/RedfishDebugLib/RedfishDebugLib.c @@ -340,3 +340,29 @@ DumpRedfishResponse ( return EFI_SUCCESS; } + +/** + + This function dump the IPv4 address in given error level. + + @param[in] ErrorLevel DEBUG macro error level + @param[in] Ipv4Address IPv4 address to dump + + @retval EFI_SUCCESS IPv4 address string is printed. + @retval Others Errors occur. + +**/ +EFI_STATUS +DumpIpv4Address ( + IN UINTN ErrorLevel, + IN EFI_IPv4_ADDRESS *Ipv4Address + ) +{ + if (Ipv4Address =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + DEBUG ((ErrorLevel, "%d.%d.%d.%d\n", Ipv4Address->Addr[0], Ipv4Address->= Addr[1], Ipv4Address->Addr[2], Ipv4Address->Addr[3])); + + return EFI_SUCCESS; +} diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPk= g/RedfishDiscoverDxe/RedfishDiscoverDxe.c index 470b4c9e0060..17c88ad82db4 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 a= nd use system default address. // Instance->HostAddrFormat =3D REDFISH_HOST_INTERFACE_HOST_IP_ADDRES= S_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 *)Dat= a->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 *)Dat= a->RedfishServiceIpAddress); -- 2.17.1 -The information contained in this message may be confidential and propriet= ary 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 desig= nee. If the reader of this message is not the intended recipient, you are o= n notice that any distribution of this message, in any form, is strictly pr= ohibited. 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= . -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#107216): https://edk2.groups.io/g/devel/message/107216 Mute This Topic: https://groups.io/mt/100341380/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-