X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=NetworkPkg%2FIp6Dxe%2FIp6Nd.c;h=a3f49bb2daadccf3d65a1ceb314299ccd68bbb2b;hb=e5735b98c2da8b4eeed36edfbec58a55ca3d236b;hp=f2a47a807312d1a6ba038fb9861d20ec6cbfdeab;hpb=a3bcde70e6dc69000f85cc5deee98101d2ae200a;p=mirror_edk2.git diff --git a/NetworkPkg/Ip6Dxe/Ip6Nd.c b/NetworkPkg/Ip6Dxe/Ip6Nd.c index f2a47a8073..a3f49bb2da 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Nd.c +++ b/NetworkPkg/Ip6Dxe/Ip6Nd.c @@ -1,7 +1,7 @@ /** @file Implementation of Neighbor Discovery support routines. - Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2016, 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 @@ -198,7 +198,7 @@ Ip6CreatePrefixListEntry ( LIST_ENTRY *Entry; IP6_PREFIX_LIST_ENTRY *TmpPrefixEntry; - if (Prefix == NULL || PreferredLifetime > ValidLifetime || PrefixLength >= IP6_PREFIX_NUM) { + if (Prefix == NULL || PreferredLifetime > ValidLifetime || PrefixLength > IP6_PREFIX_MAX) { return NULL; } @@ -261,7 +261,7 @@ Ip6CreatePrefixListEntry ( } /** - Destory a IP6 prefix list entry. + Destroy a IP6 prefix list entry. @param[in] IpSb The pointer to IP6_SERVICE instance. @param[in] PrefixEntry The to be destroyed prefix list entry. @@ -753,7 +753,6 @@ Ip6DestroyDefaultRouter ( Clean an IP6 default router list. @param[in] IpSb The pointer to the IP6_SERVICE instance. - @param[in] DefaultRouter The to be destroyed IP6_DEFAULT_ROUTER. **/ VOID @@ -822,7 +821,8 @@ Ip6OnDADFinished ( UINT16 OptBuf[4]; EFI_DHCP6_PACKET_OPTION *Oro; EFI_DHCP6_RETRANSMISSION InfoReqReXmit; - + EFI_IPv6_ADDRESS AllNodes; + IpSb = IpIf->Service; AddrInfo = DadEntry->AddressInfo; @@ -853,9 +853,9 @@ Ip6OnDADFinished ( // with DNS SERVERS. // Oro = (EFI_DHCP6_PACKET_OPTION *) OptBuf; - Oro->OpCode = HTONS (IP6_CONFIG_DHCP6_OPTION_ORO); + Oro->OpCode = HTONS (DHCP6_OPT_ORO); Oro->OpLen = HTONS (2); - *((UINT16 *) &Oro->Data[0]) = HTONS (IP6_CONFIG_DHCP6_OPTION_DNS_SERVERS); + *((UINT16 *) &Oro->Data[0]) = HTONS (DHCP6_OPT_DNS_SERVERS); InfoReqReXmit.Irt = 4; InfoReqReXmit.Mrc = 64; @@ -923,6 +923,11 @@ Ip6OnDADFinished ( RemoveEntryList (&DadEntry->Link); FreePool (DadEntry); // + // Leave link-scope all-nodes multicast address (FF02::1) + // + Ip6SetToAllNodeMulticast (FALSE, IP6_LINK_LOCAL_SCOPE, &AllNodes); + Ip6LeaveGroup (IpSb, &AllNodes); + // // Disable IP operation since link-local address is a duplicate address. // IpSb->LinkLocalDadFail = TRUE; @@ -977,6 +982,13 @@ Ip6InitDADProcess ( NET_CHECK_SIGNATURE (IpIf, IP6_INTERFACE_SIGNATURE); ASSERT (AddressInfo != NULL); + // + // Do nothing if we have already started DAD on the address. + // + if (Ip6FindDADEntry (IpIf->Service, &AddressInfo->Address, NULL) != NULL) { + return EFI_SUCCESS; + } + Status = EFI_SUCCESS; IpSb = IpIf->Service; DadXmits = &IpSb->Ip6ConfigInstance.DadXmits; @@ -1498,13 +1510,16 @@ Ip6ProcessNeighborSolicit ( goto Exit; } else { OptionLen = (UINT16) (Head->PayloadLength - IP6_ND_LENGTH); - Option = NetbufGetByte (Packet, IP6_ND_LENGTH, NULL); + if (OptionLen != 0) { + Option = NetbufGetByte (Packet, IP6_ND_LENGTH, NULL); + ASSERT (Option != NULL); - // - // All included options should have a length that is greater than zero. - // - if (!Ip6IsNDOptionValid (Option, OptionLen)) { - goto Exit; + // + // All included options should have a length that is greater than zero. + // + if (!Ip6IsNDOptionValid (Option, OptionLen)) { + goto Exit; + } } } @@ -1569,16 +1584,6 @@ Ip6ProcessNeighborSolicit ( if (IsDAD && !IsMaintained) { DupAddrDetect = Ip6FindDADEntry (IpSb, &Target, &IpIf); if (DupAddrDetect != NULL) { - if (DupAddrDetect->Transmit == 0) { - // - // The NS is from another node to performing DAD on the same address since - // we haven't send out any NS yet. Fail DAD for the tentative address. - // - Ip6OnDADFinished (FALSE, IpIf, DupAddrDetect); - Status = EFI_ICMP_ERROR; - goto Exit; - } - // // Check the MAC address of the incoming packet. // @@ -1734,13 +1739,16 @@ Ip6ProcessNeighborAdvertise ( goto Exit; } else { OptionLen = (UINT16) (Head->PayloadLength - IP6_ND_LENGTH); - Option = NetbufGetByte (Packet, IP6_ND_LENGTH, NULL); + if (OptionLen != 0) { + Option = NetbufGetByte (Packet, IP6_ND_LENGTH, NULL); + ASSERT (Option != NULL); - // - // All included options should have a length that is greater than zero. - // - if (!Ip6IsNDOptionValid (Option, OptionLen)) { - goto Exit; + // + // All included options should have a length that is greater than zero. + // + if (!Ip6IsNDOptionValid (Option, OptionLen)) { + goto Exit; + } } } @@ -1983,10 +1991,13 @@ Ip6ProcessRouterAdvertise ( // All included options have a length that is greater than zero. // OptionLen = (UINT16) (Head->PayloadLength - IP6_RA_LENGTH); - Option = NetbufGetByte (Packet, IP6_RA_LENGTH, NULL); + if (OptionLen != 0) { + Option = NetbufGetByte (Packet, IP6_RA_LENGTH, NULL); + ASSERT (Option != NULL); - if (!Ip6IsNDOptionValid (Option, OptionLen)) { - goto Exit; + if (!Ip6IsNDOptionValid (Option, OptionLen)) { + goto Exit; + } } // @@ -2429,10 +2440,13 @@ Ip6ProcessRedirect ( // All included options have a length that is greater than zero. // OptionLen = (UINT16) (Head->PayloadLength - IP6_REDITECT_LENGTH); - Option = NetbufGetByte (Packet, IP6_REDITECT_LENGTH, NULL); + if (OptionLen != 0) { + Option = NetbufGetByte (Packet, IP6_REDITECT_LENGTH, NULL); + ASSERT (Option != NULL); - if (!Ip6IsNDOptionValid (Option, OptionLen)) { - goto Exit; + if (!Ip6IsNDOptionValid (Option, OptionLen)) { + goto Exit; + } } Target = (EFI_IPv6_ADDRESS *) (Icmp + 1); @@ -2846,7 +2860,7 @@ Ip6NdFasterTimerTicking ( // Flag = FALSE; if ((DupAddrDetect->Receive == 0) || - (DupAddrDetect->Transmit == DupAddrDetect->Receive)) { + (DupAddrDetect->Transmit <= DupAddrDetect->Receive)) { Flag = TRUE; }