Snap for 11871564 from b46b107f40a525386657729465fefac179fc5404 to sdk-release

Change-Id: Iac8daa5fd8f6d927f6fdb8d33e8c54ac9f451f6f
Signed-off-by: Coastguard Worker <android-build-coastguard-worker@google.com>
diff --git a/net/test/srcaddr_selection_test.py b/net/test/srcaddr_selection_test.py
index d200017..8c327c3 100755
--- a/net/test/srcaddr_selection_test.py
+++ b/net/test/srcaddr_selection_test.py
@@ -139,7 +139,19 @@
       if not self.AddressIsTentative(address):
         return
       time.sleep(0.1)
-    raise AssertionError("%s did not complete DAD after 2 seconds")
+    raise AssertionError(f"{address} did not complete DAD after 2 seconds")
+
+  def WaitForDadFailure(self, address):
+    # Address should be either deleted or set IFA_F_DADFAILED flag after DAD failure
+    for _ in range(20):
+      try:
+        ifa_msg = self.iproute.GetAddress(address)[0]
+      except OSError:
+        return
+      if ifa_msg.flags & iproute.IFA_F_DADFAILED:
+        return
+      time.sleep(0.1)
+    raise AssertionError(f"{address} did not complete DAD failure after 2 seconds")
 
 
 class MultiInterfaceSourceAddressSelectionTest(IPv6SourceAddressSelectionTest):
@@ -286,6 +298,7 @@
     self.SetUseOptimistic(self.test_ifname, 1)
     # Send a RA to start SLAAC and subsequent DAD.
     self.SendRA(self.test_netid, retranstimer=RETRANS_TIMER)
+    time.sleep(0.1) # Give the kernel time to notice our RA
     # Prove optimism and usability.
     self.assertAddressHasExpectedAttributes(
         self.test_ip, self.test_ifindex, iproute.IFA_F_OPTIMISTIC)
@@ -300,7 +313,7 @@
                    scapy.ICMPv6ND_NA(tgt=self.test_ip, R=0, S=0, O=1) /
                    scapy.ICMPv6NDOptDstLLAddr(lladdr=conflict_macaddr))
     self.ReceiveEtherPacketOn(self.test_netid, dad_defense)
-    self.WaitForDad(self.test_lladdr)
+    self.WaitForDadFailure(self.test_ip)
 
     # The address should have failed DAD, and therefore no longer be usable.
     self.assertAddressNotUsable(self.test_ip, self.test_netid)