summaryrefslogtreecommitdiffstats
path: root/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
diff options
context:
space:
mode:
authorJiaxin Wu <jiaxin.wu@intel.com>2017-04-25 09:21:34 +0800
committerJiaxin Wu <jiaxin.wu@intel.com>2017-05-03 11:28:44 +0800
commitbe37315a08047945dcac91176cd99ee3397e151b (patch)
treeb8604070dea8f0202168b639d90f74e878b7cf22 /NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
parentcc432448426cb63b3948703da873d22debc69e79 (diff)
downloadedk2-be37315a08047945dcac91176cd99ee3397e151b.tar.gz
edk2-be37315a08047945dcac91176cd99ee3397e151b.tar.bz2
edk2-be37315a08047945dcac91176cd99ee3397e151b.zip
NetworkPkg: Fix PXEv6 boot failure when DhcpBinl offer received.
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 <ting.ye@intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com> Reviewed-by: Fu Siyuan <siyuan.fu@intel.com> Reviewed-by: Ye Ting <ting.ye@intel.com>
Diffstat (limited to 'NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c')
-rw-r--r--NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
index 4cd1770750..f2239fd8c0 100644
--- a/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
+++ b/NetworkPkg/UefiPxeBcDxe/PxeBcDhcp6.c
@@ -93,11 +93,12 @@ PxeBcBuildDhcp6Options (
// Append client option request option
//
OptList[Index]->OpCode = HTONS (DHCP6_OPT_ORO);
- OptList[Index]->OpLen = HTONS (6);
+ OptList[Index]->OpLen = HTONS (8);
OptEnt.Oro = (PXEBC_DHCP6_OPTION_ORO *) OptList[Index]->Data;
OptEnt.Oro->OpCode[0] = HTONS(DHCP6_OPT_BOOT_FILE_URL);
OptEnt.Oro->OpCode[1] = HTONS(DHCP6_OPT_BOOT_FILE_PARAM);
OptEnt.Oro->OpCode[2] = HTONS(DHCP6_OPT_DNS_SERVERS);
+ OptEnt.Oro->OpCode[3] = HTONS(DHCP6_OPT_VENDOR_CLASS);
Index++;
OptList[Index] = GET_NEXT_DHCP6_OPTION (OptList[Index - 1]);
@@ -907,12 +908,12 @@ PxeBcRequestBootService (
UINT16 OpCode;
UINT16 OpLen;
EFI_STATUS Status;
- EFI_DHCP6_PACKET *ProxyOffer;
+ EFI_DHCP6_PACKET *IndexOffer;
UINT8 *Option;
PxeBc = &Private->PxeBc;
Request = Private->Dhcp6Request;
- ProxyOffer = &Private->OfferBuffer[Index].Dhcp6.Packet.Offer;
+ IndexOffer = &Private->OfferBuffer[Index].Dhcp6.Packet.Offer;
SrcPort = PXEBC_BS_DISCOVER_PORT;
DestPort = PXEBC_BS_DISCOVER_PORT;
OpFlags = 0;
@@ -929,7 +930,7 @@ PxeBcRequestBootService (
//
// Build the request packet by the cached request packet before.
//
- Discover->TransactionId = ProxyOffer->Dhcp6.Header.TransactionId;
+ Discover->TransactionId = IndexOffer->Dhcp6.Header.TransactionId;
Discover->MessageType = Request->Dhcp6.Header.MessageType;
RequestOpt = Request->Dhcp6.Option;
DiscoverOpt = Discover->DhcpOptions;
@@ -939,22 +940,24 @@ PxeBcRequestBootService (
//
// Find Server ID Option from ProxyOffer.
//
- Option = PxeBcDhcp6SeekOption (
- ProxyOffer->Dhcp6.Option,
- ProxyOffer->Length - 4,
- DHCP6_OPT_SERVER_ID
- );
- if (Option == NULL) {
- return EFI_NOT_FOUND;
- }
+ if (Private->OfferBuffer[Index].Dhcp6.OfferType == PxeOfferTypeProxyBinl) {
+ Option = PxeBcDhcp6SeekOption (
+ IndexOffer->Dhcp6.Option,
+ IndexOffer->Length - 4,
+ DHCP6_OPT_SERVER_ID
+ );
+ if (Option == NULL) {
+ return EFI_NOT_FOUND;
+ }
- //
- // Add Server ID Option.
- //
- OpLen = NTOHS (((EFI_DHCP6_PACKET_OPTION *) Option)->OpLen);
- CopyMem (DiscoverOpt, Option, OpLen + 4);
- DiscoverOpt += (OpLen + 4);
- DiscoverLen += (OpLen + 4);
+ //
+ // Add Server ID Option.
+ //
+ OpLen = NTOHS (((EFI_DHCP6_PACKET_OPTION *) Option)->OpLen);
+ CopyMem (DiscoverOpt, Option, OpLen + 4);
+ DiscoverOpt += (OpLen + 4);
+ DiscoverLen += (OpLen + 4);
+ }
while (RequestLen < Request->Length) {
OpCode = NTOHS (((EFI_DHCP6_PACKET_OPTION *) RequestOpt)->OpCode);
@@ -1078,7 +1081,7 @@ PxeBcRetryDhcp6Binl (
Mode = Private->PxeBc.Mode;
Private->IsDoDiscover = FALSE;
Offer = &Private->OfferBuffer[Index].Dhcp6;
- if (Offer->OfferType == PxeOfferTypeDhcpBinl) {
+ if (Offer->OptList[PXEBC_DHCP6_IDX_BOOT_FILE_URL] == NULL) {
//
// There is no BootFileUrl option in dhcp6 offer, so use servers multi-cast address instead.
//