From nobody Sat Nov 2 08:25:54 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1493257855248910.773436135938; Wed, 26 Apr 2017 18:50:55 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9811221951C80; Wed, 26 Apr 2017 18:50:52 -0700 (PDT) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A9C8A21954071 for ; Wed, 26 Apr 2017 18:50:51 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP; 26 Apr 2017 18:50:51 -0700 Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.239.196.120]) by fmsmga005.fm.intel.com with ESMTP; 26 Apr 2017 18:50:50 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,256,1488873600"; d="scan'208";a="94308263" From: Jiaxin Wu To: edk2-devel@lists.01.org Date: Thu, 27 Apr 2017 09:50:40 +0800 Message-Id: <1493257840-38320-1-git-send-email-jiaxin.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [edk2] [Patch] NetworkPkg: Fix PXEv6 boot failure when DhcpBinl offer received. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ye Ting , Fu Siyuan , Wu Jiaxin MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In case of the DHCP and PXE services on different servers,PXEv6 boot will failure when DhcpBinl offer received. The issue is caused by the following reasons: * PXE Client doesn't append VENDOR_CLASS request parameter, so the offer replied from DHCP service will not contain VENDOR_CLASS option (16). * Once the DhcpBinl offer is selected, the boot discover message should be sent out to request the bootfile by this offer. Current implementation always use servers multi-cast address instead of BootFileUrl address in dhcp6 offer. we should check it first, then decide whether use multi-cast address or not. * If DhcpBinl offer is selected, the boot discover message shouldn't find server ID Option from DhcpBinl offer. That's incorrect because DHCP service and PXE service on different servers. In such a case, we can ignore the Server ID Option. With the above fix in the patch, PXEv6 can boot successfully when DhcpBinl offer received. Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin Reviewed-by: Fu Siyuan Reviewed-by: Ye Ting =20 --- NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c | 43 +++++++++++++++++++-------------= ---- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c b/NetworkPkg/UefiPxeBcDxe= /PxeBcDhcp6.c index 4cd1770..f2239fd 100644 --- a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c +++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c @@ -91,15 +91,16 @@ PxeBcBuildDhcp6Options ( =20 // // Append client option request option // OptList[Index]->OpCode =3D HTONS (DHCP6_OPT_ORO); - OptList[Index]->OpLen =3D HTONS (6); + OptList[Index]->OpLen =3D HTONS (8); OptEnt.Oro =3D (PXEBC_DHCP6_OPTION_ORO *) OptList[Index]= ->Data; OptEnt.Oro->OpCode[0] =3D HTONS(DHCP6_OPT_BOOT_FILE_URL); OptEnt.Oro->OpCode[1] =3D HTONS(DHCP6_OPT_BOOT_FILE_PARAM); OptEnt.Oro->OpCode[2] =3D HTONS(DHCP6_OPT_DNS_SERVERS); + OptEnt.Oro->OpCode[3] =3D HTONS(DHCP6_OPT_VENDOR_CLASS); Index++; OptList[Index] =3D GET_NEXT_DHCP6_OPTION (OptList[Index - 1]= ); =20 // // Append client network device interface option @@ -905,16 +906,16 @@ PxeBcRequestBootService ( UINTN ReadSize; UINT16 OpFlags; UINT16 OpCode; UINT16 OpLen; EFI_STATUS Status; - EFI_DHCP6_PACKET *ProxyOffer; + EFI_DHCP6_PACKET *IndexOffer; UINT8 *Option; =20 PxeBc =3D &Private->PxeBc; Request =3D Private->Dhcp6Request; - ProxyOffer =3D &Private->OfferBuffer[Index].Dhcp6.Packet.Offer; + IndexOffer =3D &Private->OfferBuffer[Index].Dhcp6.Packet.Offer; SrcPort =3D PXEBC_BS_DISCOVER_PORT; DestPort =3D PXEBC_BS_DISCOVER_PORT; OpFlags =3D 0; =20 if (Request =3D=3D NULL) { @@ -927,36 +928,38 @@ PxeBcRequestBootService ( } =20 // // Build the request packet by the cached request packet before. // - Discover->TransactionId =3D ProxyOffer->Dhcp6.Header.TransactionId; + Discover->TransactionId =3D IndexOffer->Dhcp6.Header.TransactionId; Discover->MessageType =3D Request->Dhcp6.Header.MessageType; RequestOpt =3D Request->Dhcp6.Option; DiscoverOpt =3D Discover->DhcpOptions; DiscoverLen =3D sizeof (EFI_DHCP6_HEADER); RequestLen =3D DiscoverLen; =20 // // Find Server ID Option from ProxyOffer. // - Option =3D PxeBcDhcp6SeekOption ( - ProxyOffer->Dhcp6.Option, - ProxyOffer->Length - 4, - DHCP6_OPT_SERVER_ID - ); - if (Option =3D=3D NULL) { - return EFI_NOT_FOUND; - } + if (Private->OfferBuffer[Index].Dhcp6.OfferType =3D=3D PxeOfferTypeProxy= Binl) { =20 + Option =3D PxeBcDhcp6SeekOption ( + IndexOffer->Dhcp6.Option, + IndexOffer->Length - 4, + DHCP6_OPT_SERVER_ID + ); + if (Option =3D=3D NULL) { + return EFI_NOT_FOUND; + } =20 - // - // Add Server ID Option. - // - OpLen =3D NTOHS (((EFI_DHCP6_PACKET_OPTION *) Option)->OpLen); - CopyMem (DiscoverOpt, Option, OpLen + 4); - DiscoverOpt +=3D (OpLen + 4); - DiscoverLen +=3D (OpLen + 4); + // + // Add Server ID Option. + // + OpLen =3D NTOHS (((EFI_DHCP6_PACKET_OPTION *) Option)->OpLen); + CopyMem (DiscoverOpt, Option, OpLen + 4); + DiscoverOpt +=3D (OpLen + 4); + DiscoverLen +=3D (OpLen + 4); + } =20 while (RequestLen < Request->Length) { OpCode =3D NTOHS (((EFI_DHCP6_PACKET_OPTION *) RequestOpt)->OpCode); OpLen =3D NTOHS (((EFI_DHCP6_PACKET_OPTION *) RequestOpt)->OpLen); if (OpCode !=3D EFI_DHCP6_IA_TYPE_NA && @@ -1076,11 +1079,11 @@ PxeBcRetryDhcp6Binl ( Private->OfferBuffer[Index].Dhcp6.OfferType =3D=3D PxeOfferTypeP= roxyBinl); =20 Mode =3D Private->PxeBc.Mode; Private->IsDoDiscover =3D FALSE; Offer =3D &Private->OfferBuffer[Index].Dhcp6; - if (Offer->OfferType =3D=3D PxeOfferTypeDhcpBinl) { + if (Offer->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL] =3D=3D NULL) { // // There is no BootFileUrl option in dhcp6 offer, so use servers multi= -cast address instead. // CopyMem ( &Private->ServerIp.v6, --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel