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 DD7FCAC101B for ; Fri, 5 Jan 2024 08:37:58 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=fZsrnD9bTY6srxC3Q3m06gQvHcHC+OZTCjyPcxtWBJ8=; 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=1704443877; v=1; b=quBRuN3TTTOoxHKpUVGtJwRdK0JvaV8SHYvKAo/hJlwyVNkXum6XnHkKg4ACU+P6vYkpsvtA vwGLeg4AAPVTdZCi+bOR1RthghFqbYglz8IXsa2FwjqcwehRBMLZqVf9O0dMBDHCtOlc17PTdpQ ef4ZbUtOWxcpY2IpI8FUIEd8= X-Received: by 127.0.0.2 with SMTP id XXQsYY7687511xgflCPbTt0w; Fri, 05 Jan 2024 00:37:57 -0800 X-Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.107.93.87]) by mx.groups.io with SMTP id smtpd.web11.19615.1704443875783012141 for ; Fri, 05 Jan 2024 00:37:56 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R6goNDt8RYnWeVFWPsf0HnzsiV3GTKEfCesKlv1f5IudVhJmsodXryC3/IWBl3ZWV89olSwZ+7DAwY5UO8FgYYslBbk2zmZbOvqiLi2t40dqH+a+wKiIJDJTJnU/BXlPrfengHlQb0c59r+AsNRufU2eZu7y30feF0FSZIZyabutMVezTdXS7sK5X1NIq7XWfFMYFZGGT2cRVYq5sDQ7vA6XpPogwFiGyMBOlY+ihRiM/F/ndKK7DLh5Py9GCD89gDyNEN7zAw15FKM9qnRcnEAMQlHXt1IIgWoHK8oS0BGypxdbkf5qfahhL5uJNIfAgnH6xkGQm/NvVfqP0CNbnw== 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=uF1CtEBPB+rAMt+UaoYWHyzRwkvxGPYvDdPCi06ODUQ=; b=VNjBgV1TS+PWhCpdQ99OFo2pMdpLCZiGiDO3bwclTrCqjDKk5tM2XkgbBIlQY/BSSsmHVymJSzxYgLCzG6P4Z40c9GonovJb/aMYihDZ6wweE3qQKSRd6yXMoz5qTYDYJUqMBKh6NrIy2XnKfSk2Qj6MyykpZeWiegEnJuLpN/X/NG1v7SIXJKYnb7jWAxHvG8W4v7Z7ZfYeT/hbwF+0twnb/wIjaYo5RjiOTrs+6+puZzenVow0J/LTUPR8gGHuJMTUD0IhMokzriIQPgql5JxW93qeE9FPcS7SpfKIyht+KfEfA5tkjMiyPfEX10YwPLelYaxog+o6rQlZq1zl8A== 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 SJ0PR13CA0224.namprd13.prod.outlook.com (2603:10b6:a03:2c1::19) by SA1PR12MB7102.namprd12.prod.outlook.com (2603:10b6:806:29f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.13; Fri, 5 Jan 2024 08:37:53 +0000 X-Received: from SJ1PEPF00001CE6.namprd03.prod.outlook.com (2603:10b6:a03:2c1:cafe::f5) by SJ0PR13CA0224.outlook.office365.com (2603:10b6:a03:2c1::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7181.9 via Frontend Transport; Fri, 5 Jan 2024 08:37:53 +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 SJ1PEPF00001CE6.mail.protection.outlook.com (10.167.242.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7159.9 via Frontend Transport; Fri, 5 Jan 2024 08:37:53 +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; Fri, 5 Jan 2024 02:37:51 -0600 From: "Chang, Abner via groups.io" To: CC: Nickle Wang , Igor Kulchytskyy Subject: [edk2-devel] [PATCH 4/5] RedfishPkg/RedfishRestExDxe: Implement EDKII_HTTP_CALLBACK_PROTOCOL Date: Fri, 5 Jan 2024 16:37:15 +0800 Message-ID: <20240105083716.340-5-abner.chang@amd.com> In-Reply-To: <20240105083716.340-1-abner.chang@amd.com> References: <20240105083716.340-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: SJ1PEPF00001CE6:EE_|SA1PR12MB7102:EE_ X-MS-Office365-Filtering-Correlation-Id: 932f2dc5-dde6-4a6b-4bde-08dc0dc99c08 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: qZUSJM35agYHLHUwVeUNF4kx5D0PHPgyFAZ8y3etnpVg2J4YfiAOgF9kHPHgWr9JBuHWD7hFV1j4yCZrFGr5m/E/5tDEp8eJ3F8EjZscVLq9/LBjCPpcfPfo1OXIDkLDUjvFeOLUSHNPF7ottvxk4/R0Iu4RL8HiQHFEfLGGZyAkoWXfw3kGpmwPNb2gZPnM9kLBF4+a+/oIcf7MrrQJbyU3hx2gRiJHUIPky4+e1ZCuL9lfQ333/zLqSZWPjVskDbXDbsTTuz842jx/KmEwkwrHRuTCOngY5SqZkMv+UnieqCKMp0xGm53AsKkW9IW23rQjz0p5ng0iI3qip/+YyWArFLv5yxzYRUsHLikZ9pF+YE3kXKPKl5V4YMznQZ2JtJT5mgNPIkDEk1PfYnV/7qa6+aHBn+iED1fAProOAG2P7AAcviSII4ETaUjKT+0DJH2uuFaY391wbOZBEw9GOhHDOKyACb1lmrtSrAHG7/XAIybMzbQP54IlSHR6U64/zWmAPVYud7N5dVphBOBG/kNcaZ1Nq6EAS76DkV8outJb4BYwC3fvcbRsipNZ5OU7khFJRVv3yc3hQBOpdDlrUDcU4d5LXAm8BOWHUWy88RanxCGnbYRDqUYK0WEsXzY6/YT6SqsZqyGjh2idgruwNGno65jIl9A8CTbV0PcP3OlPjVtpxPvENUJ2vTBb3z4h3AR01z6JazqwBLwXGZMVayOQtkfKZzY0JprzIlQKL3t/q0Fx4DmojmSP5yqq4qnWTXYeYaZ/ebDjVxhl8rp2IQ== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2024 08:37:53.5894 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 932f2dc5-dde6-4a6b-4bde-08dc0dc99c08 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: SJ1PEPF00001CE6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7102 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: 53uJ38wHJhGHmgcEUqPedZu1x7686176AA= 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=quBRuN3T; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); 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 | 2 + .../RedfishRestExDxe/RedfishRestExDriver.h | 31 ++++++--- .../RedfishRestExDxe/RedfishRestExDriver.c | 69 +++++++++++++++++++ 3 files changed, 92 insertions(+), 10 deletions(-) diff --git a/RedfishPkg/RedfishRestExDxe/RedfishRestExDxe.inf b/RedfishPkg/= RedfishRestExDxe/RedfishRestExDxe.inf index 64e6343bfbf..706d5a5f15e 100644 --- a/RedfishPkg/RedfishRestExDxe/RedfishRestExDxe.inf +++ b/RedfishPkg/RedfishRestExDxe/RedfishRestExDxe.inf @@ -57,6 +57,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..8d2b9ecb80b 100644 --- a/RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.h +++ b/RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.h @@ -32,6 +32,8 @@ #include #include #include +#include +#include =20 /// /// Protocol instances @@ -67,6 +69,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 +99,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..9a20c90d49a 100644 --- a/RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.c +++ b/RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.c @@ -585,6 +585,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 +746,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 +872,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 (#113228): https://edk2.groups.io/g/devel/message/113228 Mute This Topic: https://groups.io/mt/103539581/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-