]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg/UefiPxeBcDxe: Configure the ARP Instance/RouteTable with new address
authorJiaxin Wu <jiaxin.wu@intel.com>
Tue, 13 Mar 2018 08:53:18 +0000 (16:53 +0800)
committerJiaxin Wu <jiaxin.wu@intel.com>
Thu, 22 Mar 2018 00:25:20 +0000 (08:25 +0800)
After completed a DHCP D.O.R.A process and got the new address, the ARP Instance
and RouteTable should be configured so as to avoid the later Pxe.Arp failure.

Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
NetworkPkg/UefiPxeBcDxe/PxeBcImpl.c
NetworkPkg/UefiPxeBcDxe/PxeBcSupport.c

index d3146c3a7e5feb958d6be1e778c600e7d94ced47..b828d24288990ea1cc1f1062f39969452dca4688 100644 (file)
@@ -2003,7 +2003,6 @@ EfiPxeBcSetStationIP (
   EFI_STATUS              Status;\r
   PXEBC_PRIVATE_DATA      *Private;\r
   EFI_PXE_BASE_CODE_MODE  *Mode;\r
-  EFI_ARP_CONFIG_DATA     ArpConfigData;\r
 \r
   if (This == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -2043,27 +2042,6 @@ EfiPxeBcSetStationIP (
     if (EFI_ERROR (Status)) {\r
       goto ON_EXIT;\r
     }\r
-  } else if (!Mode->UsingIpv6 && NewStationIp != NULL) {\r
-    //\r
-    // Configure the corresponding ARP with the IPv4 address.\r
-    //\r
-    ZeroMem (&ArpConfigData, sizeof (EFI_ARP_CONFIG_DATA));\r
-\r
-    ArpConfigData.SwAddressType   = 0x0800;\r
-    ArpConfigData.SwAddressLength = (UINT8) sizeof (EFI_IPv4_ADDRESS);\r
-    ArpConfigData.StationAddress  = &NewStationIp->v4;\r
-\r
-    Private->Arp->Configure (Private->Arp, NULL);\r
-    Private->Arp->Configure (Private->Arp, &ArpConfigData);\r
-\r
-    if (NewSubnetMask != NULL) {\r
-      Mode->RouteTableEntries                = 1;\r
-      Mode->RouteTable[0].IpAddr.Addr[0]     = NewStationIp->Addr[0] & NewSubnetMask->Addr[0];\r
-      Mode->RouteTable[0].SubnetMask.Addr[0] = NewSubnetMask->Addr[0];\r
-      Mode->RouteTable[0].GwAddr.Addr[0]     = 0;\r
-    }\r
-\r
-    Private->IsAddressOk = TRUE;\r
   }\r
 \r
   if (NewStationIp != NULL) {\r
@@ -2077,6 +2055,10 @@ EfiPxeBcSetStationIP (
   }\r
 \r
   Status = PxeBcFlushStationIp (Private, NewStationIp, NewSubnetMask);\r
+  if (!EFI_ERROR (Status)) {\r
+    Private->IsAddressOk = TRUE;\r
+  }\r
+  \r
 ON_EXIT:\r
   return Status;\r
 }\r
index 47bb7c5dbbbcf12816c01ef9b1f4e9ea012b2fe7..4b6f8c9c7feff899abe478e69962476b0d2f8790 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Support functions implementation for UefiPxeBc Driver.\r
 \r
-  Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -36,17 +36,19 @@ PxeBcFlushStationIp (
 {\r
   EFI_PXE_BASE_CODE_MODE   *Mode;\r
   EFI_STATUS               Status;\r
+  EFI_ARP_CONFIG_DATA      ArpConfigData;\r
 \r
   Mode   = Private->PxeBc.Mode;\r
   Status = EFI_SUCCESS;\r
+  ZeroMem (&ArpConfigData, sizeof (EFI_ARP_CONFIG_DATA));\r
 \r
-  if (Mode->UsingIpv6) {\r
-\r
-    if (StationIp != NULL) {\r
-      CopyMem (&Private->Udp6CfgData.StationAddress, StationIp, sizeof (EFI_IPv6_ADDRESS));\r
-      CopyMem (&Private->Ip6CfgData.StationAddress, StationIp, sizeof (EFI_IPv6_ADDRESS));\r
-    }\r
-\r
+  if (Mode->UsingIpv6 && StationIp != NULL) {\r
+    //\r
+    // Overwrite Udp6CfgData/Ip6CfgData StationAddress.\r
+    //\r
+    CopyMem (&Private->Udp6CfgData.StationAddress, StationIp, sizeof (EFI_IPv6_ADDRESS));\r
+    CopyMem (&Private->Ip6CfgData.StationAddress, StationIp, sizeof (EFI_IPv6_ADDRESS));\r
+    \r
     //\r
     // Reconfigure the Ip6 instance to capture background ICMP6 packets with new station Ip address.\r
     //\r
@@ -61,27 +63,55 @@ PxeBcFlushStationIp (
     Status = Private->Ip6->Receive (Private->Ip6, &Private->Icmp6Token);\r
   } else {\r
     if (StationIp != NULL) {\r
+      //\r
+      // Reconfigure the ARP instance with station Ip address.\r
+      //\r
+      ArpConfigData.SwAddressType   = 0x0800;\r
+      ArpConfigData.SwAddressLength = (UINT8) sizeof (EFI_IPv4_ADDRESS);\r
+      ArpConfigData.StationAddress = StationIp;\r
+\r
+      Private->Arp->Configure (Private->Arp, NULL);\r
+      Private->Arp->Configure (Private->Arp, &ArpConfigData);\r
+\r
+      //\r
+      // Overwrite Udp4CfgData/Ip4CfgData StationAddress.\r
+      //\r
       CopyMem (&Private->Udp4CfgData.StationAddress, StationIp, sizeof (EFI_IPv4_ADDRESS));\r
       CopyMem (&Private->Ip4CfgData.StationAddress, StationIp, sizeof (EFI_IPv4_ADDRESS));\r
     }\r
     \r
     if (SubnetMask != NULL) {\r
+      //\r
+      // Overwrite Udp4CfgData/Ip4CfgData SubnetMask.\r
+      //\r
       CopyMem (&Private->Udp4CfgData.SubnetMask, SubnetMask, sizeof (EFI_IPv4_ADDRESS));\r
       CopyMem (&Private->Ip4CfgData.SubnetMask, SubnetMask, sizeof (EFI_IPv4_ADDRESS));\r
     }\r
 \r
-    //\r
-    // Reconfigure the Ip4 instance to capture background ICMP packets with new station Ip address.\r
-    //\r
-    Private->Ip4->Cancel (Private->Ip4, &Private->IcmpToken);\r
-    Private->Ip4->Configure (Private->Ip4, NULL);\r
-\r
-    Status = Private->Ip4->Configure (Private->Ip4, &Private->Ip4CfgData);\r
-    if (EFI_ERROR (Status)) {\r
-      goto ON_EXIT;\r
+    if (StationIp != NULL && SubnetMask != NULL) {\r
+      //\r
+      // Updated the route table.\r
+      //\r
+      Mode->RouteTableEntries                = 1;\r
+      Mode->RouteTable[0].IpAddr.Addr[0]     = StationIp->Addr[0] & SubnetMask->Addr[0];\r
+      Mode->RouteTable[0].SubnetMask.Addr[0] = SubnetMask->Addr[0];\r
+      Mode->RouteTable[0].GwAddr.Addr[0]     = 0;\r
     }\r
+    \r
+    if (StationIp != NULL || SubnetMask != NULL) {\r
+      //\r
+      // Reconfigure the Ip4 instance to capture background ICMP packets with new station Ip address.\r
+      //\r
+      Private->Ip4->Cancel (Private->Ip4, &Private->IcmpToken);\r
+      Private->Ip4->Configure (Private->Ip4, NULL);\r
 \r
-    Status = Private->Ip4->Receive (Private->Ip4, &Private->IcmpToken);\r
+      Status = Private->Ip4->Configure (Private->Ip4, &Private->Ip4CfgData);\r
+      if (EFI_ERROR (Status)) {\r
+        goto ON_EXIT;\r
+      }\r
+\r
+      Status = Private->Ip4->Receive (Private->Ip4, &Private->IcmpToken);\r
+    }\r
   }\r
 \r
 ON_EXIT:\r