From cca5e4221b3c345eb79a3542bfcd10d8160b303d Mon Sep 17 00:00:00 2001 From: Fu Siyuan Date: Wed, 29 Apr 2015 05:47:03 +0000 Subject: [PATCH] Remove duplicate DAD entry in IP6 driver to fix DAD fail issue. The IP6 driver may create duplicate IP6_DAD_ENTRY in DupAddrDetectList in some situation like: 1. Address policy switch but not clear the delay node list, OR 2. Set manual address repeatedly before the previous DAD is finished. The NS sent out by duplicate DAD entry will mix up with the loop back multicast packet, result in DAD fail. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Fu Siyuan Reviewed-by: Ye Ting Reviewed-by: Wu Jiaxin git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17263 6f19259b-4bc3-4df7-8a09-765794883524 --- NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c | 13 +++++++++++-- NetworkPkg/Ip6Dxe/Ip6Nd.c | 19 ++++++++----------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c index 9a1e3d076f..75d4f23fb0 100644 --- a/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c +++ b/NetworkPkg/Ip6Dxe/Ip6ConfigImpl.c @@ -52,7 +52,8 @@ Ip6ConfigOnPolicyChanged ( LIST_ENTRY *Next; IP6_INTERFACE *IpIf; IP6_DAD_ENTRY *DadEntry; - + IP6_DELAY_JOIN_LIST *DelayNode; + // // Currently there are only two policies: Manual and Automatic. Regardless of // what transition is going on, i.e., Manual -> Automatic and Automatic -> @@ -94,10 +95,18 @@ Ip6ConfigOnPolicyChanged ( NET_LIST_FOR_EACH (Entry, &IpSb->Interfaces) { // - // remove all pending DAD entries for the global addresses. + // remove all pending delay node and DAD entries for the global addresses. // IpIf = NET_LIST_USER_STRUCT_S (Entry, IP6_INTERFACE, Link, IP6_INTERFACE_SIGNATURE); + NET_LIST_FOR_EACH_SAFE (Entry2, Next, &IpIf->DelayJoinList) { + DelayNode = NET_LIST_USER_STRUCT (Entry2, IP6_DELAY_JOIN_LIST, Link); + if (!NetIp6IsLinkLocalAddr (&DelayNode->AddressInfo->Address)) { + RemoveEntryList (&DelayNode->Link); + FreePool (DelayNode); + } + } + NET_LIST_FOR_EACH_SAFE (Entry2, Next, &IpIf->DupAddrDetectList) { DadEntry = NET_LIST_USER_STRUCT_S (Entry2, IP6_DAD_ENTRY, Link, IP6_DAD_ENTRY_SIGNATURE); diff --git a/NetworkPkg/Ip6Dxe/Ip6Nd.c b/NetworkPkg/Ip6Dxe/Ip6Nd.c index 9f30f9b20e..2c8be42f09 100644 --- a/NetworkPkg/Ip6Dxe/Ip6Nd.c +++ b/NetworkPkg/Ip6Dxe/Ip6Nd.c @@ -982,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; @@ -1577,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. // @@ -2863,7 +2860,7 @@ Ip6NdFasterTimerTicking ( // Flag = FALSE; if ((DupAddrDetect->Receive == 0) || - (DupAddrDetect->Transmit == DupAddrDetect->Receive)) { + (DupAddrDetect->Transmit <= DupAddrDetect->Receive)) { Flag = TRUE; } -- 2.39.2