diff options
author | Zheng Pan <zhengpan@google.com> | 2024-05-14 16:39:54 -0700 |
---|---|---|
committer | Zheng Pan <zhengpan@google.com> | 2024-05-15 14:43:52 -0700 |
commit | b46b107f40a525386657729465fefac179fc5404 (patch) | |
tree | e77937b9f45a7cd0b190320adc2ac168b481b98f | |
parent | 2d537bcfdfe24ad2f791a6524dc6c2a949116fc1 (diff) | |
download | tests-master.tar.gz |
net-test: Fix testDadFailure()HEADmastermain-kernel-build-2024main
WaitForDad() on link local addr doesn't necessarily mean DAD failure.
Add WaitForDadFailure() to check either address is deleted or
IFA_F_DADFAILED flag is set after DAD failure.
Also after SendRA(), sleep(0.1) to give kernel time to initialize DAD.
Bug: 327366827
Test: atest
Change-Id: I9e71d2eee149216449ab1eca8fbdb0b2433bfac5
-rwxr-xr-x | net/test/srcaddr_selection_test.py | 17 |
1 files changed, 15 insertions, 2 deletions
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 @@ class IPv6SourceAddressSelectionTest(multinetwork_base.MultiNetworkBaseTest): 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 @@ class DadFailureTest(MultiInterfaceSourceAddressSelectionTest): 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 @@ class DadFailureTest(MultiInterfaceSourceAddressSelectionTest): 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) |