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 2209D7803D0 for ; Fri, 3 Nov 2023 15:54:48 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=hKYod8ncYvBGdzFUUabkVqD48p5pU3qHeM6eR0HUry8=; c=relaxed/simple; d=groups.io; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Transfer-Encoding; s=20140610; t=1699026887; v=1; b=tQOI1RXtgeM5p0BAen+3R08r5xLe8UjTz2A/Xw2QVxMnT6llB3qYwD6E73zKnFm57ob5L8hb yQnTLE45iMtZIoFhN9uzYoQrCVaYZwW7yeWJONBVZTe3Nj68JK7F3ZuA9Nq2heOhnW4egJdc3uI IJeUBaIkrWNAjjRg2Q0yDRlM= X-Received: by 127.0.0.2 with SMTP id z5c3YY7687511xgwAkSf6Hpr; Fri, 03 Nov 2023 08:54:47 -0700 X-Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) by mx.groups.io with SMTP id smtpd.web11.56661.1699026887241792608 for ; Fri, 03 Nov 2023 08:54:47 -0700 X-Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-5a7dd65052aso26878187b3.0 for ; Fri, 03 Nov 2023 08:54:47 -0700 (PDT) X-Gm-Message-State: CUqL2ZpkWjIvjQKBYnLK2NJpx7686176AA= X-Google-Smtp-Source: AGHT+IHZKKAgQ34bMsw+pbsH2folM3PrlDYbYFzdaJn5MoKcwGWAsdIZJJ0dgmrijksTQ/TE48QVjAIpGXOFhnIke8w= X-Received: by 2002:a81:6006:0:b0:594:e2e6:25e8 with SMTP id u6-20020a816006000000b00594e2e625e8mr3089009ywb.48.1699026886261; Fri, 03 Nov 2023 08:54:46 -0700 (PDT) MIME-Version: 1.0 References: <20231101201704.1504-1-igork@ami.com> In-Reply-To: <20231101201704.1504-1-igork@ami.com> From: "Mike Maslenkin" Date: Fri, 3 Nov 2023 18:54:10 +0300 Message-ID: Subject: Re: [edk2-devel] [PATCH v2] RedfishPkg: RedfishDiscoverDxe: Fix issue if IPv4 installed after RestEx To: Igor Kulchytskyy Cc: "devel@edk2.groups.io" , Abner Chang , Nickle Wang 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,mike.maslenkin@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: text/plain; charset="UTF-8" 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=tQOI1RXt; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=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 On Wed, Nov 1, 2023 at 11:17=E2=80=AFPM Igor Kulchytskyy wr= ote: > > Supported function of the driver changed to wait for all newtwork > interface to be installed. > Filer out the network interfaces which are not supported by > Redfish Host Interface. > > Cc: Abner Chang > Cc: Nickle Wang > Cc: Mike Maslenkin > Signed-off-by: Igor Kulchytskyy > --- > RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c | 131 ++++++++++++++-= ----- > 1 file changed, 95 insertions(+), 36 deletions(-) > > diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/Redfish= Pkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c > index 23da3b968f..c67b8acf12 100644 > --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c > +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c > @@ -322,9 +322,15 @@ GetTargetNetworkInterfaceInternal ( > { > EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *ThisNetworkInterface= ; > > + if (IsListEmpty (&mEfiRedfishDiscoverNetworkInterface)) { > + return NULL; > + } > + > ThisNetworkInterface =3D (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTER= NAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface); > while (TRUE) { > - if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNe= tworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) =3D=3D 0) = { > + if (CompareMem ((VOID *)&ThisNetworkInterface->MacAddress, &TargetNe= tworkInterface->MacAddress, ThisNetworkInterface->HwAddressSize) =3D=3D 0 &= & > + ((TargetNetworkInterface->IsIpv6 && ThisNetworkInterface->Networ= kProtocolType =3D=3D ProtocolTypeTcp6) || > + (!TargetNetworkInterface->IsIpv6 && ThisNetworkInterface->Ne= tworkProtocolType =3D=3D ProtocolTypeTcp4))) { > return ThisNetworkInterface; > } > > @@ -354,6 +360,10 @@ GetTargetNetworkInterfaceInternalByController ( > { > EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *ThisNetworkInterface= ; > > + if (IsListEmpty (&mEfiRedfishDiscoverNetworkInterface)) { > + return NULL; > + } > + > ThisNetworkInterface =3D (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTER= NAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface); > while (TRUE) { > if (ThisNetworkInterface->OpenDriverControllerHandle =3D=3D Controll= erHandle) { > @@ -476,6 +486,39 @@ CheckIsIpVersion6 ( > return FALSE; > } > > +/** > + This function returns the IP type supported by the Host Interface > + > + @retval IP Type > + // Unknown=3D00h, > + // Ipv4=3D01h, > + // Ipv6=3D02h, > + > +**/ > +STATIC > +UINT8 > +GetHiIpProtocolType() > +{ > + EFI_STATUS Status; > + REDFISH_OVER_IP_PROTOCOL_DATA *Data; > + REDFISH_INTERFACE_DATA *DeviceDescriptor; > + > + Data =3D NULL; > + DeviceDescriptor =3D NULL; > + if (mSmbios =3D=3D NULL) { > + Status =3D gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID= **)&mSmbios); > + if (EFI_ERROR (Status)) { > + return REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN; > + } > + } > + Status =3D RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescri= ptor, &Data); // Search for SMBIOS type 42h > + if (!EFI_ERROR (Status) && (Data !=3D NULL) && > + (Data->HostIpAssignmentType =3D=3D RedfishHostIpAssignmentStatic))= { > + return Data->HostIpAddressFormat; > + } > + return REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN; > +} > + > /** > This function discover Redfish service through SMBIOS host interface. > > @@ -512,6 +555,15 @@ DiscoverRedfishHostInterface ( > > Status =3D RedfishGetHostInterfaceProtocolData (mSmbios, &DeviceDescri= ptor, &Data); // Search for SMBIOS type 42h > if (!EFI_ERROR (Status) && (Data !=3D NULL) && (DeviceDescriptor !=3D = NULL)) { > + > + if (Instance->NetworkInterface->NetworkProtocolType =3D=3D ProtocolT= ypeTcp4 && Data->HostIpAddressFormat !=3D REDFISH_HOST_INTERFACE_HOST_IP_AD= DRESS_FORMAT_IP4) { // IPv4 case > + DEBUG ((DEBUG_ERROR, "%a: Network Interface is IPv4, but Host Inte= rface requires Ipv6\n", __func__)); > + return EFI_UNSUPPORTED; > + } > + else if (Instance->NetworkInterface->NetworkProtocolType =3D=3D Prot= ocolTypeTcp6 && Data->HostIpAddressFormat !=3D REDFISH_HOST_INTERFACE_HOST_= IP_ADDRESS_FORMAT_IP6) { // IPv6 case > + DEBUG ((DEBUG_ERROR, "%a: Network Interface is IPv6, but Host Inte= rface requires IPv4\n", __func__)); > + return EFI_UNSUPPORTED; > + } > // > // Check if we can reach out Redfish service using this network inte= rface. > // Check with MAC address using Device Descriptor Data Device Type 0= 4 and Type 05. > @@ -1102,6 +1154,7 @@ RedfishServiceGetNetworkInterface ( > OUT EFI_REDFISH_DISCOVER_NETWORK_INTERFACE **NetworkIntfInstances > ) > { > + EFI_STATUS Status; > EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *ThisNetworkInterface= Intn; > EFI_REDFISH_DISCOVER_NETWORK_INTERFACE *ThisNetworkInterface= ; > EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL *RestExInstance; > @@ -1141,6 +1194,16 @@ RedfishServiceGetNetworkInterface ( > > ThisNetworkInterfaceIntn =3D (EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_I= NTERNAL *)GetFirstNode (&mEfiRedfishDiscoverNetworkInterface); > while (TRUE) { > + // If Get Subnet Info failed then skip this interface > + Status =3D NetworkInterfaceGetSubnetInfo (ThisNetworkInterfaceIntn, = ImageHandle); // Get subnet info > + if (EFI_ERROR(Status)) { > + if (IsNodeAtEnd (&mEfiRedfishDiscoverNetworkInterface, &ThisNetwor= kInterfaceIntn->Entry)) { > + break; > + } > + ThisNetworkInterfaceIntn =3D (EFI_REDFISH_DISCOVER_NETWORK_INTERFA= CE_INTERNAL *)GetNextNode (&mEfiRedfishDiscoverNetworkInterface, &ThisNetwo= rkInterfaceIntn->Entry); > + continue; > + } > + > ThisNetworkInterface->IsIpv6 =3D FALSE; > if (CheckIsIpVersion6 (ThisNetworkInterfaceIntn)) { > ThisNetworkInterface->IsIpv6 =3D TRUE; Now this loop looks like: while (TRUE) { Status =3D NetworkInterfaceGetSubnetInfo (ThisNetworkInterfaceIntn, ImageHandle); // Get subnet info if (EFI_ERROR (Status)) { if (Cond) { break; } continue; } ThisNetworkInterface->IsIpv6 =3D FALSE; if (CheckIsIpVersion6 (ThisNetworkInterfaceIntn)) { ThisNetworkInterface->IsIpv6 =3D TRUE; } CopyMem ((VOID *)&ThisNetworkInterface->MacAddress, &ThisNetworkInterfaceIntn->MacAddress, ThisNetworkInterfaceIntn->HwAddressSize); NetworkInterfaceGetSubnetInfo (ThisNetworkInterfaceIntn, ImageHandle); // Get subnet info. .... It seems the second call NetworkInterfaceGetSubnetInfo() is not required. Regards, Mike. -=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 (#110644): https://edk2.groups.io/g/devel/message/110644 Mute This Topic: https://groups.io/mt/102328322/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-