X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FIp4Dxe%2FIp4Icmp.c;h=052d6b77f79a08186f11c65f79df674049259760;hp=76208e071bb49cb41ff8086e40acc5ba39a557dc;hb=9d510e61fceee7b92955ef9a3c20343752d8ce3f;hpb=f6b7393ceb34c9b3a27434268bf2ce517047641f diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Icmp.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Icmp.c index 76208e071b..052d6b77f7 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Icmp.c +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Icmp.c @@ -1,13 +1,7 @@ /** @file -Copyright (c) 2005 - 2009, Intel Corporation.
-All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -72,7 +66,7 @@ mIp4SupportedIcmp[23] = { /** Process the ICMP redirect. Find the instance then update its route cache. - + All kinds of redirect is treated as host redirect as specified by RFC1122 3.3.1.2: "Since the subnet mask appropriate to the destination @@ -80,7 +74,7 @@ mIp4SupportedIcmp[23] = { message SHOULD be treated identically to a Host Redirect message;" - @param[in] IpSb The IP4 service binding instance that received + @param[in] IpSb The IP4 service binding instance that received the packet. @param[in] Head The IP head of the received ICMPpacket. @param[in] Packet The content of the ICMP redirect packet with IP @@ -105,6 +99,8 @@ Ip4ProcessIcmpRedirect ( IP4_ROUTE_CACHE_ENTRY *CacheEntry; IP4_INTERFACE *IpIf; IP4_ADDR Gateway; + IP4_ADDR Src; + IP4_ADDR Dst; // // Find the interface whose IP address is the source of the @@ -133,11 +129,9 @@ Ip4ProcessIcmpRedirect ( continue; } - CacheEntry = Ip4FindRouteCache ( - Ip4Instance->RouteTable, - NTOHL (Icmp->IpHead.Dst), - NTOHL (Icmp->IpHead.Src) - ); + Dst = NTOHL (Icmp->IpHead.Dst); + Src = NTOHL (Icmp->IpHead.Src); + CacheEntry = Ip4FindRouteCache (Ip4Instance->RouteTable, Dst, Src); // // Only update the route cache's gateway if the source of the @@ -158,15 +152,15 @@ Ip4ProcessIcmpRedirect ( update call Ip4ProcessIcmpRedirect to update the IP instance's route cache, otherwise, deliver the packet to upper layer. - @param[in] IpSb The IP service that received the packet. - @param[in] Head The IP head of the ICMP error packet - @param[in] Packet The content of the ICMP error with IP head + @param[in] IpSb The IP4 service that received the packet. + @param[in] Head The IP4 head of the ICMP error packet + @param[in] Packet The content of the ICMP error with IP4 head removed. @retval EFI_SUCCESS The ICMP error is processed successfully. @retval EFI_INVALID_PARAMETER The packet is invalid @retval Others Failed to process the packet. - + **/ EFI_STATUS Ip4ProcessIcmpError ( @@ -193,16 +187,16 @@ Ip4ProcessIcmpError ( } IP4_GET_CLIP_INFO (Packet)->Status = EFI_ICMP_ERROR; - return Ip4Demultiplex (IpSb, Head, Packet); + return Ip4Demultiplex (IpSb, Head, Packet, NULL, 0); } /** Replay an ICMP echo request. - @param[in] IpSb The IP service that receivd the packet - @param[in] Head The IP head of the ICMP error packet - @param[in] Packet The content of the ICMP error with IP head + @param[in] IpSb The IP4 service that receivd the packet + @param[in] Head The IP4 head of the ICMP error packet + @param[in] Packet The content of the ICMP error with IP4 head removed. @retval EFI_OUT_OF_RESOURCES Failed to allocate resource. @@ -240,6 +234,7 @@ Ip4IcmpReplyEcho ( // update is omitted. // Icmp = (IP4_ICMP_QUERY_HEAD *) NetbufGetByte (Data, 0, NULL); + ASSERT (Icmp != NULL); Icmp->Head.Type = ICMP_ECHO_REPLY; Icmp->Head.Checksum = 0; Icmp->Head.Checksum = (UINT16) (~NetblockChecksum ((UINT8 *) Icmp, Data->TotalSize)); @@ -266,6 +261,9 @@ Ip4IcmpReplyEcho ( Ip4SysPacketSent, NULL ); + if (EFI_ERROR (Status)) { + NetbufFree (Data); + } ON_EXIT: NetbufFree (Packet); @@ -277,9 +275,9 @@ ON_EXIT: Process the ICMP query message. If it is an ICMP echo request, answer it. Otherwise deliver it to upper layer. - @param[in] IpSb The IP service that receivd the packet - @param[in] Head The IP head of the ICMP query packet - @param[in] Packet The content of the ICMP query with IP head + @param[in] IpSb The IP4 service that receivd the packet + @param[in] Head The IP4 head of the ICMP query packet + @param[in] Packet The content of the ICMP query with IP4 head removed. @retval EFI_INVALID_PARAMETER The packet is invalid @@ -307,7 +305,7 @@ Ip4ProcessIcmpQuery ( return Ip4IcmpReplyEcho (IpSb, Head, Packet); } - return Ip4Demultiplex (IpSb, Head, Packet); + return Ip4Demultiplex (IpSb, Head, Packet, NULL, 0); } @@ -316,9 +314,9 @@ Ip4ProcessIcmpQuery ( then according to the message types, process it as query or error packet. - @param[in] IpSb The IP service that receivd the packet - @param[in] Head The IP head of the ICMP query packet - @param[in] Packet The content of the ICMP query with IP head + @param[in] IpSb The IP4 service that receivd the packet. + @param[in] Head The IP4 head of the ICMP query packet. + @param[in] Packet The content of the ICMP query with IP4 head removed. @retval EFI_INVALID_PARAMETER The packet is malformated.