]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg/Ip6Dxe: Fix the IPv6 PXE boot option goes missing issue
authorJiaxin Wu <jiaxin.wu@intel.com>
Sun, 30 Jul 2017 13:52:02 +0000 (21:52 +0800)
committerJiaxin Wu <jiaxin.wu@intel.com>
Wed, 2 Aug 2017 07:31:37 +0000 (15:31 +0800)
This patch is to fix the potential issue recorded at Bugzilla 636:
https://bugzilla.tianocore.org/show_bug.cgi?id=636

The issue is caused by the IPv6 policy switching after PXEv6 boot. When IP
policy is changing, the IPv6 children used by PXE.UdpRead() will be destroyed.
Then, PXE Stop() function is called to uninstall the devicePath protocol,
which leads to the IPv6 PXE boot option goes missing.

Through the above analysis, the IP driver should take the responsibility for
the upper layer network stacks recovery by using ConnectController().

Cc: Hegde Nagaraj P <nagaraj-p.hegde@hpe.com>
Cc: Subramanian Sriram <sriram-s@hpe.com>
Cc: Ni Ruiyu <ruiyu.ni@intel.com>
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: Hegde Nagaraj P <nagaraj-p.hegde@hpe.com>
Reviewed-by: Subramanian Sriram <sriram-s@hpe.com>
Tested-by: Hegde Nagaraj P <nagaraj-p.hegde@hpe.com>
NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c

index 7c7acc72d5576665ab053069212eb52dd8e31301..f17071656dcca07f02e973eca9437683f5ee5e9c 100644 (file)
@@ -47,12 +47,17 @@ Ip6ConfigOnPolicyChanged (
   IN EFI_IP6_CONFIG_POLICY  NewPolicy\r
   )\r
 {\r
-  LIST_ENTRY      *Entry;\r
-  LIST_ENTRY      *Entry2;\r
-  LIST_ENTRY      *Next;\r
-  IP6_INTERFACE   *IpIf;\r
-  IP6_DAD_ENTRY   *DadEntry;\r
-  IP6_DELAY_JOIN_LIST       *DelayNode;\r
+  LIST_ENTRY          *Entry;\r
+  LIST_ENTRY          *Entry2;\r
+  LIST_ENTRY          *Next;\r
+  IP6_INTERFACE       *IpIf;\r
+  IP6_DAD_ENTRY       *DadEntry;\r
+  IP6_DELAY_JOIN_LIST *DelayNode;\r
+  IP6_ADDRESS_INFO    *AddrInfo;\r
+  IP6_PROTOCOL        *Instance;\r
+  BOOLEAN             Recovery;\r
+\r
+  Recovery = FALSE;\r
   \r
   //\r
   // Currently there are only two policies: Manual and Automatic. Regardless of\r
@@ -80,18 +85,48 @@ Ip6ConfigOnPolicyChanged (
       );\r
   }\r
 \r
-  //\r
-  // All IPv6 children that use global unicast address as it's source address\r
-  // should be destryoed now. The survivers are those use the link-local address\r
-  // or the unspecified address as the source address.\r
-  // TODO: Conduct a check here.\r
-  Ip6RemoveAddr (\r
-    IpSb,\r
-    &IpSb->DefaultInterface->AddressList,\r
-    &IpSb->DefaultInterface->AddressCount,\r
-    NULL,\r
-    0\r
-    );\r
+  if (!IsListEmpty (&IpSb->DefaultInterface->AddressList) && IpSb->DefaultInterface->AddressCount > 0) {\r
+    //  \r
+    // If any IPv6 children (Instance) in configured state and use global unicast address, it will be \r
+    // destroyed in Ip6RemoveAddr() function later. Then, the upper layer driver's Stop() function will be \r
+    // called, which may break the upper layer network stacks. So, the driver should take the responsibility \r
+    // for the recovery by using ConnectController() after Ip6RemoveAddr(). \r
+    // Here, just check whether need to recover the upper layer network stacks later.\r
+    //\r
+    NET_LIST_FOR_EACH (Entry, &IpSb->DefaultInterface->AddressList) { \r
+      AddrInfo = NET_LIST_USER_STRUCT_S (Entry, IP6_ADDRESS_INFO, Link, IP6_ADDR_INFO_SIGNATURE);\r
+      if (!IsListEmpty (&IpSb->Children)) {\r
+        NET_LIST_FOR_EACH (Entry2, &IpSb->Children) {\r
+          Instance = NET_LIST_USER_STRUCT_S (Entry2, IP6_PROTOCOL, Link, IP6_PROTOCOL_SIGNATURE);\r
+          if ((Instance->State == IP6_STATE_CONFIGED) && EFI_IP6_EQUAL (&Instance->ConfigData.StationAddress, &AddrInfo->Address)) {\r
+            Recovery = TRUE;\r
+            break;\r
+          }\r
+        }\r
+      }\r
+    }\r
+    \r
+    //\r
+    // All IPv6 children that use global unicast address as it's source address\r
+    // should be destroyed now. The survivers are those use the link-local address\r
+    // or the unspecified address as the source address.\r
+    // TODO: Conduct a check here.\r
+    Ip6RemoveAddr (\r
+      IpSb,\r
+      &IpSb->DefaultInterface->AddressList,\r
+      &IpSb->DefaultInterface->AddressCount,\r
+      NULL,\r
+      0\r
+      );\r
+    \r
+    if (IpSb->Controller != NULL && Recovery) {\r
+      //\r
+      // ConnectController() to recover the upper layer network stacks.\r
+      //\r
+      gBS->ConnectController (IpSb->Controller, NULL, NULL, TRUE);\r
+    }\r
+  }\r
+\r
 \r
   NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) {\r
     //\r
@@ -130,7 +165,6 @@ Ip6ConfigOnPolicyChanged (
     //\r
     IpSb->Ticks                   = (UINT32) IP6_GET_TICKS (IP6_ONE_SECOND_IN_MS);\r
   }\r
-\r
 }\r
 \r
 /**\r