From nobody Mon May 13 17:24:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+107194+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1690244094637409.9234253996008; Mon, 24 Jul 2023 17:14:54 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=E8w5P1iPVAri3WWuUgnGKq54K6dDfZFs4Kd+M32TFZ0=; c=relaxed/simple; d=groups.io; h=X-Received:X-Received:ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:X-Received:X-Received:X-MS-Exchange-Authentication-Results:Received-SPF:X-Received:X-Received:X-Received:X-Received:From:To:CC:Subject:Date:Message-ID:MIME-Version:X-NV-OnPremToCloud:X-EOPAttributedMessage: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-OriginatorOrg:X-MS-Exchange-CrossTenant-OriginalArrivalTime:X-MS-Exchange-CrossTenant-Network-Message-Id:X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp:X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs:X-MS-Exchange-CrossTenant-FromEntityHeader:X-MS-Exchange-Transport-CrossTenantHeadersStamped:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:X-Gm-Message-State:Content-Transfer-Encoding:Content-Type; s=20140610; t=1690244094; v=1; b=xONHwFX4C156oaQ6kgAWdsGPdKyWyoozDhubKdLE83YIak3ZRYdRcl8xZRUCHlZWPItx/DzS dIkWQkXpK9rW6u1ErWYixkiUVkVLbzNufNRzjLWQvXKDuaxYFrT0cFIhaGeXCUAQGhmu5E9T9U+ 5fOpO5gtd47nmw28F0SJpitg= X-Received: by 127.0.0.2 with SMTP id LDuMYY1788612xtJMzr3AHFv; Mon, 24 Jul 2023 17:14:54 -0700 X-Received: from NAM04-BN8-obe.outbound.protection.outlook.com (NAM04-BN8-obe.outbound.protection.outlook.com [40.107.100.82]) by mx.groups.io with SMTP id smtpd.web10.9871.1690244093225984930 for ; Mon, 24 Jul 2023 17:14:53 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KM1JxegHv4EDhbhCkfQQAvNojL/9E2wDE/kkEEu7qtrKl1W4CBrXTYUpr04WU8bkBqxq0uFxcoQHBW3u4juLoYrVoPU39oiI8FBy8J/baf0xq+Qize09yHc8cV5cZA+VIlxkmnZ7mQfl9uEpbbsVlPkupM9FtIp8aG2oMoeqLAKg3+cPIjjxOTZGV8FzXA0JgGOGN7kNCkztLVBigNOpT1nW1Zpy7K/C9ZgKi9IM1XnjnTTRSH51qqodFU4xv4GNrBUk/fPkLmyPXyUP6veZOLtPRN+r2N76XuR4HYieEF5m0BxBWKFfOH2ZOidtNENfqYSJD0fWab4N+a2R+yfyuw== 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=B+AehFCW39TYRE13IrLfioOh4iXnzL2JWwgNCgUhjZE=; b=Z0iRjWEJjKJO30ghL/B0y3AOQgWHm0qyEkWwes5OmO5olAhYd86sig36BrFmQk5EOUVNSmGVBXC3bAggVtSHWtLaCdQf1A/V4FnTyN2954UvmcCqA0ll9owKQhNEvBj7TKTtE1N4Azon6i89OkLjIcDlVKcLRU/endAftapS+TXRZHhxIkkyCqrvLiGfbRBO4Rel1wcUvZE0PWYtIQk077TREdepmSN44a/f9p29JWiKe5nFD7DdQEiiIeWS7dctmuR6PF0++9uu1D7Bt84t2+NEaJRRCwMaq1TyjwmccpCQF/WoJhsLMT5uuOCB7MsF7JJ/58SKGIJrBW0S3NLnqw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none X-Received: from DM6PR14CA0067.namprd14.prod.outlook.com (2603:10b6:5:18f::44) by MW4PR12MB6900.namprd12.prod.outlook.com (2603:10b6:303:20e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Tue, 25 Jul 2023 00:14:50 +0000 X-Received: from DM6NAM11FT059.eop-nam11.prod.protection.outlook.com (2603:10b6:5:18f:cafe::47) by DM6PR14CA0067.outlook.office365.com (2603:10b6:5:18f::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.33 via Frontend Transport; Tue, 25 Jul 2023 00:14:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+107194+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C X-Received: from mail.nvidia.com (216.228.117.160) by DM6NAM11FT059.mail.protection.outlook.com (10.13.172.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.25 via Frontend Transport; Tue, 25 Jul 2023 00:14:50 +0000 X-Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Mon, 24 Jul 2023 17:14:40 -0700 X-Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Mon, 24 Jul 2023 17:14:39 -0700 X-Received: from NV-CL38DL3.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Mon, 24 Jul 2023 17:14:38 -0700 From: "Nickle Wang via groups.io" To: CC: Abner Chang , Igor Kulchytskyy , "Nick Ramirez" Subject: [edk2-devel] [PATCH] RedfishPkg/RedfishDiscoverDxe: fix netmask check issue Date: Tue, 25 Jul 2023 08:14:38 +0800 Message-ID: <20230725001438.1292-1-nicklew@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT059:EE_|MW4PR12MB6900:EE_ X-MS-Office365-Filtering-Correlation-Id: 8ba7c0bd-dcad-4b20-08a7-08db8ca42980 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: HbPn94MboIX7ZjysnYTe6dUubCtO9QiSWKrD0OHDfJaerb1ngB5idBZXCgd9cJmBVVh68NtnYeNuZEWQft1pTiJJXHCxcZyIORbrjaQNLD6lCcDv0QRoGSP/8rlTUK2TLy4dwQ7qlGs8w4zvljdNu9n9zc70aDaHN+c3PS94ESNvxKUCecpiu2oilvjq3lBzh4YgBvgdQFKmJ5SvwPTCqzl+rGa5rmjMU4qgC0WIJQ4qSXTTETf9QozFMKBES42u8+kYB+VRdYziZwjrUXL/DKXObHjWtLXKn5A6H39N4Yzc7eFfVfYMk79IHAyup2jjZq/+FRhc6Rie4EZQ4yC8ig81RV0du9EHCJdGeJSr5s2tOBRHMlKEvxK/NyFp3S2uL/x76xpQqUk4y0Kp6uMQMQshU8pmwCWZfV4jreyEQ/GllIHKul/rFT53LIC8jR8xsKOeoIiybCVeFB8Jy+nZ6njiMoHcIt7y5E9bHyCglsfHRlBdsZivmHo4bgxpdfH0KUyNJbEcNYD5KIx1/OSPSVI8uMX53R0OutcQLDhHTaIlNcMY07HPoeCmWNpIiI/sN+m4kspYxGS94MYXqTYjUAZKpJc2YK4gZqQXVzcBOUN49XfIdJZBiFru/i2n4FDSaZvjV8b+Y3lfmweVnQ8bTOtgFD2kFkA3rGCUL2Iva5mHciqIx+cdZAaOJq08jPwqzIaK1llDAq1M0bw66D/dtioj/7Jnd/AnJW1kobJmorU= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2023 00:14:50.0432 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8ba7c0bd-dcad-4b20-08a7-08db8ca42980 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT059.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6900 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,nicklew@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: fBTY7xl9zf24BXzby7QBDr1px1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1690244096768100003 Content-Type: text/plain; charset="utf-8" - 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 Reviewed-by: Abner Chang Reviewed-by: Igor Kulchytskyy --- .../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 ); =20 +/** + + 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 ( =20 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); =20 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; } =20 - 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); =20 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); --=20 2.17.1 -=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 (#107194): https://edk2.groups.io/g/devel/message/107194 Mute This Topic: https://groups.io/mt/100341380/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-