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 AFA859417AA for ; Sun, 7 Jan 2024 13:27:46 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=gR4CzDjw3e+tI4Zq4Qfs6SEUjYtHvQaCzNIYIHFCdVY=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Received-SPF:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1704634065; v=1; b=JztGs99ReFh+Mwgm38civ6E5w0ttGYKPfSzqkn973GncsncksRG6XRx+0doDzLn3U2wCFVAo k6m6JD1I9QAvaLBl77A5qUstCjitqzccAEQifEIYU9bAuD9YQFLDKfYsEkvxM8Pckldu2RBkX0u LaI+jlAUHVmd/apA14jK718Y= X-Received: by 127.0.0.2 with SMTP id olLRYY7687511xgopTLm9q6B; Sun, 07 Jan 2024 05:27:45 -0800 X-Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.107.236.41]) by mx.groups.io with SMTP id smtpd.web10.14902.1704634064709640808 for ; Sun, 07 Jan 2024 05:27:44 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bzifQfP4GzEYBapLZ4ruvDUUF+K2f4sbP+5FiwAjrGVXk6lr8fHZjIWi6x3njIlaWsutQrhwTYVLVDDDkjknPdYa2clBHbo9z+U0fgfKl4gZB4OXjLNU2EhH5ICFXggZHufvzzBRAG0RJi8BslRTtXpji1A8x3Tmj9kmuDbeiFluB5LWhZctI6eDF9CCeNw60jwCtcwVLGFAWeID+6TxBaPyZ++VIpYtbkKAIZu8h9lgeI7k/0ToA4qOlpq7PNnowMKTrTOmt0mXYAX4k0JCHDKnFfu1EEgO7gag7Ipnt0DAt8UQbNHqvyS/KzV2DvRxS3rVwzIMe49JQeqeAk6abg== 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=uDgxcxEChhVommNQjQdcbe1UJJmr+fSotSM3h/F5QQ8=; b=Gm5tKye2lR6jHH+xybMIEDufdi6bS/7mIfi2uk9fMK8wX3VOfh6gdj+V6BtSd/CXBz98OlZ22ZlG9X2XrcUpY/WDMKBtnW0OexUYz685umsXm5LtJngzPXlr18VupQOfs3dJuX8s5jSKEZJX5+m9ikhFsp07AJAlXn+eF5QaRdW8Fq9/s62rQimMRRNU2WwrypgbISxQ47G0ztydhviIwYGRQ9APj/VnyfXLVqqxRJo/pc8AKFAk//mtRqQXxkCqdGF+8T+oLSNqeMj1SBn18Z1azEFwiFdMv0PpflOuX/t4ip2EjZaoqjzI88QYaV9vQZANNPlJNoMOgkUsuLDyqQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) X-Received: from BL1PR13CA0127.namprd13.prod.outlook.com (2603:10b6:208:2bb::12) by DS0PR12MB6440.namprd12.prod.outlook.com (2603:10b6:8:c8::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.20; Sun, 7 Jan 2024 13:27:42 +0000 X-Received: from BL6PEPF0001AB4B.namprd04.prod.outlook.com (2603:10b6:208:2bb:cafe::22) by BL1PR13CA0127.outlook.office365.com (2603:10b6:208:2bb::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.12 via Frontend Transport; Sun, 7 Jan 2024 13:27:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C X-Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB4B.mail.protection.outlook.com (10.167.242.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7181.13 via Frontend Transport; Sun, 7 Jan 2024 13:27:41 +0000 X-Received: from TPE-L1-ABNCHANG.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Sun, 7 Jan 2024 07:27:40 -0600 From: "Chang, Abner via groups.io" To: CC: Nickle Wang , Igor Kulchytskyy Subject: [edk2-devel] [PATCH V2 4/6] RedfishPkg/RedfishRestExDxe: Implement EDKII_HTTP_CALLBACK_PROTOCOL Date: Sun, 7 Jan 2024 21:26:59 +0800 Message-ID: <20240107132701.302-5-abner.chang@amd.com> In-Reply-To: <20240107132701.302-1-abner.chang@amd.com> References: <20240107132701.302-1-abner.chang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB4B:EE_|DS0PR12MB6440:EE_ X-MS-Office365-Filtering-Correlation-Id: 5e4263fc-3259-4309-7b98-08dc0f846cf8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: 0wkbGLc8Wnv/3xfjlwlj/HOSPmu+ABQprpxOSW4lHLxWHMPNc5sJzUqILIOt5Qdn2vFCaKp7up+zxg95P6aldwEiSHz5l6sw0MPvmzmjPSrXCtrUNqL9BnAHy/XImFgGXGUaj5BCAt2nZpGf+v5InP+iv41UozLNOKZ4bqqZ+1hkd5qsuSUkn1pK/6VmXVYbqEPGtkc2oy0IV8tRU208xuGWMOznwEe60JISzj21uvgbctxEdfEqyDT0FL9Dcf4J5ocVz0jZsIyYGrleLhLXKrcY7L0hr7kNX0OnPF46tKhL2hMfn6U5TpENSSt9rXL1bpULr33wRmOLMoJAEIUfFJ2V6W3qTVtjx6QNQgkMEz0c+t9bvbzCqu0WPQL1z//3voCi7HnVanHCCkpdPDAJSr9hDIjoininoF12sXJRy7pkBLWLVD2OiGgJidTvZCS/j2AgySPgcA9rzoaoy1Mwgo9W7avAuS+qYIS3UX/MuYnZKIvx/bSCb4LyNPxRgjnLnKI6/coHwYbE0CKjEZjh9hZjql4hoeH8IJyFDccOOA6yp4fG6GUdXMuZLXL1OmJinRCsOEMGbAbt7EHxg2UvsgYRvOPuoML5RPyrZt4TDm203mfMWhUvyztrtR6k5rUoRE05N1zSzRxzLrlrVK/FcSULHi/i769VvDJyLtJ7zKK46a6T6lB9Sk755HVPctsGCKvkBwcfDdgGsqBCWeLXyxPQ0A1hXwwgtCXOes4aE1oA+rlGJHQA7vBPIlHfsPskGg2GvkYQ3Dc3UgycpTBMxA== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2024 13:27:41.7622 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5e4263fc-3259-4309-7b98-08dc0f846cf8 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB4B.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6440 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,abner.chang@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: msV4cOTRRDkyi3eys4JALeggx7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=JztGs99R; 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 From: Abner Chang Implement EDKII_HTTP_CALLBACK_PROTOCOL that listens to HttpEventTlsConfigured event for reconfiguring TLS configuration data. Signed-off-by: Abner Chang Cc: Nickle Wang Cc: Igor Kulchytskyy --- .../RedfishRestExDxe/RedfishRestExDxe.inf | 3 + .../RedfishRestExDxe/RedfishRestExDriver.h | 32 ++++++--- .../RedfishRestExDxe/RedfishRestExDriver.c | 70 +++++++++++++++++++ 3 files changed, 95 insertions(+), 10 deletions(-) diff --git a/RedfishPkg/RedfishRestExDxe/RedfishRestExDxe.inf b/RedfishPkg/= RedfishRestExDxe/RedfishRestExDxe.inf index 64e6343bfbf..6da416ddb92 100644 --- a/RedfishPkg/RedfishRestExDxe/RedfishRestExDxe.inf +++ b/RedfishPkg/RedfishRestExDxe/RedfishRestExDxe.inf @@ -5,6 +5,7 @@ # (C) Copyright 2020 Hewlett Packard Enterprise Development LP
# Copyright (c) 2023, American Megatrends International LLC. # Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserve= d. +# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -57,6 +58,8 @@ gEfiHttpServiceBindingProtocolGuid ## TO_START gEfiHttpProtocolGuid ## TO_START gEfiDevicePathProtocolGuid ## TO_START + gEdkiiHttpCallbackProtocolGuid ## CONSUMES + gEfiTlsProtocolGuid ## CONSUMES =20 [Pcd] gEfiRedfishPkgTokenSpaceGuid.PcdRedfishRestExServiceAccessModeInBand ## = CONSUMES diff --git a/RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.h b/RedfishPkg= /RedfishRestExDxe/RedfishRestExDriver.h index 6b94e5814c4..929691cea35 100644 --- a/RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.h +++ b/RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.h @@ -4,6 +4,7 @@ Copyright (c) 2019, Intel Corporation. All rights reserved.
(C) Copyright 2020 Hewlett Packard Enterprise Development LP
Copyright (c) 2023, Ampere Computing LLC. All rights reserved.
+ Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -32,6 +33,8 @@ #include #include #include +#include +#include =20 /// /// Protocol instances @@ -67,6 +70,9 @@ typedef struct _RESTEX_INSTANCE RESTEX_INSTANCE; #define RESTEX_INSTANCE_FROM_THIS(a) \ CR (a, RESTEX_INSTANCE, RestEx, RESTEX_INSTANCE_SIGNATURE) =20 +#define RESTEX_INSTANCE_FROM_HTTP_CALLBACK(a) \ + CR (a, RESTEX_INSTANCE, HttpCallbakFunction, RESTEX_INSTANCE_SIGNATURE) + #define RESTEX_STATE_UNCONFIGED 0 #define RESTEX_STATE_CONFIGED 1 =20 @@ -94,25 +100,31 @@ struct _RESTEX_SERVICE { #define RESTEX_INSTANCE_FLAGS_TCP_ERROR_RETRY 0x00000002 =20 struct _RESTEX_INSTANCE { - UINT32 Signature; - LIST_ENTRY Link; + UINT32 Signature; + LIST_ENTRY Link; =20 - EFI_REST_EX_PROTOCOL RestEx; + EFI_REST_EX_PROTOCOL RestEx; =20 - INTN State; - BOOLEAN InDestroy; + INTN State; + BOOLEAN InDestroy; =20 - RESTEX_SERVICE *Service; - EFI_HANDLE ChildHandle; + RESTEX_SERVICE *Service; + EFI_HANDLE ChildHandle; =20 - EFI_REST_EX_CONFIG_DATA ConfigData; + EFI_REST_EX_CONFIG_DATA ConfigData; =20 // // HTTP_IO to access the HTTP service // - HTTP_IO HttpIo; + HTTP_IO HttpIo; + + // + // EDKII_HTTP_CALLBACK_PROTOCOL that listens to + // HttpEventInitSession event. + // + EDKII_HTTP_CALLBACK_PROTOCOL HttpCallbakFunction; =20 - UINT32 Flags; + UINT32 Flags; }; =20 typedef struct { diff --git a/RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.c b/RedfishPkg= /RedfishRestExDxe/RedfishRestExDriver.c index 7036aed4268..39221989c49 100644 --- a/RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.c +++ b/RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.c @@ -4,6 +4,7 @@ Copyright (c) 2019, Intel Corporation. All rights reserved.
(C) Copyright 2020 Hewlett Packard Enterprise Development LP
Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved= . + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -585,6 +586,53 @@ RedfishRestExDriverBindingStop ( return Status; } =20 +/** + Callback function that is invoked when HTTP event occurs. + + @param[in] This Pointer to the EDKII_HTTP_CALLBACK_PROTO= COL instance. + @param[in] Event The event that occurs in the current sta= te. + @param[in] EventStatus The Status of Event, EFI_SUCCESS or othe= r errors. +**/ +VOID +EFIAPI +RestExHttpCallback ( + IN EDKII_HTTP_CALLBACK_PROTOCOL *This, + IN EDKII_HTTP_CALLBACK_EVENT Event, + IN EFI_STATUS EventStatus + ) +{ + EFI_STATUS Status; + EFI_TLS_PROTOCOL *TlsProtocol; + RESTEX_INSTANCE *Instance; + EFI_TLS_VERIFY TlsVerifyMethod; + + if ((Event =3D=3D HttpEventTlsConfigured) && (EventStatus =3D=3D EFI_SUC= CESS)) { + // Reconfigure TLS configuration data. + Instance =3D RESTEX_INSTANCE_FROM_HTTP_CALLBACK (This); + Status =3D gBS->HandleProtocol ( + Instance->HttpIo.Handle, + &gEfiTlsProtocolGuid, + (VOID **)&TlsProtocol + ); + if (EFI_ERROR (Status)) { + return; + } + + TlsVerifyMethod =3D EFI_TLS_VERIFY_NONE; + Status =3D TlsProtocol->SetSessionData ( + TlsProtocol, + EfiTlsVerifyMethod, + &TlsVerifyMethod, + sizeof (EFI_TLS_VERIFY) + ); + if (!EFI_ERROR (Status)) { + DEBUG ((DEBUG_MANAGEABILITY, "%a: REST EX reconfigures TLS verify me= thod.\n", __func__)); + } + } + + return; +} + /** Creates a child handle and installs a protocol. =20 @@ -699,6 +747,19 @@ RedfishRestExServiceBindingCreateChild ( goto ON_ERROR; } =20 + // Initial HTTP callback funciton on this REST EX instance + Instance->HttpCallbakFunction.Callback =3D RestExHttpCallback; + Status =3D gBS->InstallProtocolInterface= ( + &Instance->HttpIo.Handle= , + &gEdkiiHttpCallbackProto= colGuid, + EFI_NATIVE_INTERFACE, + &Instance->HttpCallbakFu= nction + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Fail to install HttpCallbakFunction.\n", __f= unc__)); + goto ON_ERROR; + } + // // Add it to the parent's child list. // @@ -812,6 +873,15 @@ RedfishRestExServiceBindingDestroyChild ( RestEx ); =20 + // + // Uninstall the HTTP callback protocol. + // + Status =3D gBS->UninstallProtocolInterface ( + Instance->HttpIo.Handle, + &gEdkiiHttpCallbackProtocolGuid, + &Instance->HttpCallbakFunction + ); + OldTpl =3D gBS->RaiseTPL (TPL_CALLBACK); =20 if (EFI_ERROR (Status)) { --=20 2.37.1.windows.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 (#113330): https://edk2.groups.io/g/devel/message/113330 Mute This Topic: https://groups.io/mt/103577246/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-