]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c
1. In IPv4 and IPv6 driver, before calling IPsec, a new NET_FRAGMENT structure is...
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4Dxe / Ip4Input.c
index cfa13e45cb812067f2accaf7da8f01fc957d94e3..9cd1ae5cfc58758cf493dde8147a2cf3c97a6fbe 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   IP4 input process.\r
   \r
-Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -583,11 +583,21 @@ Ip4IpSecProcessPacket (
   Ip4NtohHead (*Head);\r
   \r
   if (EFI_ERROR (Status)) {\r
+    FreePool (OriginalFragmentTable);\r
     goto ON_EXIT;\r
   }\r
 \r
   if (OriginalFragmentTable == FragmentTable && OriginalFragmentCount == FragmentCount) {\r
+    //\r
+    // For ByPass Packet\r
+    //\r
+    FreePool (FragmentTable);\r
     goto ON_EXIT;\r
+  } else {\r
+    //\r
+    // Free the FragmentTable which allocated before calling the IPsec.\r
+    //\r
+    FreePool (OriginalFragmentTable);\r
   }\r
 \r
   if (Direction == EfiIPsecOutBound && TxWrap != NULL) {\r
@@ -602,6 +612,11 @@ Ip4IpSecProcessPacket (
                                    TxWrap\r
                                    );\r
     if (TxWrap->Packet == NULL) {\r
+      //\r
+      // Recover the TxWrap->Packet, if meet a error, and the caller will free\r
+      // the TxWrap.\r
+      //\r
+      TxWrap->Packet = *Netbuf;\r
       Status = EFI_OUT_OF_RESOURCES;\r
       goto ON_EXIT;\r
     }\r
@@ -617,6 +632,8 @@ Ip4IpSecProcessPacket (
     IpSecWrap = AllocateZeroPool (sizeof (IP4_IPSEC_WRAP));\r
   \r
     if (IpSecWrap == NULL) {\r
+      Status = EFI_OUT_OF_RESOURCES;\r
+      gBS->SignalEvent (RecycleEvent);\r
       goto ON_EXIT;\r
     }\r
     \r
@@ -632,6 +649,9 @@ Ip4IpSecProcessPacket (
                                       );\r
   \r
     if (Packet == NULL) {\r
+      Packet = IpSecWrap->Packet;\r
+      gBS->SignalEvent (RecycleEvent);\r
+      FreePool (IpSecWrap);\r
       Status = EFI_OUT_OF_RESOURCES;\r
       goto ON_EXIT;\r
     }\r
@@ -848,11 +868,11 @@ Ip4AccpetFrame (
   // and no need consider any other ahead ext headers.\r
   //\r
   Status = Ip4IpSecProcessPacket (\r
-             IpSb, \r
-             &Head, \r
-             &Packet, \r
+             IpSb,\r
+             &Head,\r
+             &Packet,\r
              &Option,\r
-             &OptionLen, \r
+             &OptionLen,\r
              EfiIPsecInBound,\r
              NULL\r
              );\r
@@ -872,11 +892,11 @@ Ip4AccpetFrame (
   //\r
     Head = (IP4_HEAD *) NetbufGetByte (Packet, 0, NULL);\r
     Status = Ip4PreProcessPacket (\r
-               IpSb, \r
-               &Packet, \r
-               Head, \r
+               IpSb,\r
+               &Packet,\r
+               Head,\r
                Option,\r
-               OptionLen,  \r
+               OptionLen,\r
                Flag\r
                );\r
     if (EFI_ERROR (Status)) {\r