From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 82FD221A134A3 for ; Tue, 2 May 2017 19:51:28 -0700 (PDT) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP; 02 May 2017 19:51:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,282,1491289200"; d="scan'208";a="83081431" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga004.jf.intel.com with ESMTP; 02 May 2017 19:51:27 -0700 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 2 May 2017 19:51:25 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by fmsmsx109.amr.corp.intel.com (10.18.116.9) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 2 May 2017 19:51:25 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.117]) by shsmsx102.ccr.corp.intel.com ([169.254.2.246]) with mapi id 14.03.0319.002; Wed, 3 May 2017 10:51:21 +0800 From: "Ye, Ting" To: "Wu, Jiaxin" , "edk2-devel@lists.01.org" CC: "Fu, Siyuan" Thread-Topic: [Patch] NetworkPkg: Fix PXEv6 boot failure when DhcpBinl offer received. Thread-Index: AQHSvvi1P9KxnIpKoEGOiOXK8ei4faHh8kcQ Date: Wed, 3 May 2017 02:51:20 +0000 Message-ID: References: <1493257840-38320-1-git-send-email-jiaxin.wu@intel.com> In-Reply-To: <1493257840-38320-1-git-send-email-jiaxin.wu@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [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: , X-List-Received-Date: Wed, 03 May 2017 02:51:28 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ye Ting =20 -----Original Message----- From: Wu, Jiaxin=20 Sent: Thursday, April 27, 2017 9:51 AM To: edk2-devel@lists.01.org Cc: Ye, Ting ; Fu, Siyuan ; Wu, Jia= xin Subject: [Patch] NetworkPkg: Fix PXEv6 boot failure when DhcpBinl offer rec= eived. In case of the DHCP and PXE services on different servers,PXEv6 boot will f= ailure when DhcpBinl offer received. The issue is caused by the following reasons: * PXE Client doesn't append VENDOR_CLASS request parameter, so the offer re= plied 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 alwa= ys use servers multi-cast address instead of BootFileUrl address in dhcp6 offer. we should check it first, then decide whether use multi-cast a= ddress or not. * If DhcpBinl offer is selected, the boot discover message shouldn't find s= erver 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 Ser= ver 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 --- 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 @@ P= xeBcRequestBootService ( 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 @@ PxeBcR= etryDhcp6Binl ( 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, -- 1.9.5.msysgit.1