コード例 #1
0
    def testRfc6724Behaviour(self):
        # [3]  Get an IPv6 address back, in optimistic DAD start-up.
        self.SetDAD(self.test_ifname, 1)  # Enable DAD
        self.SetOptimisticDAD(self.test_ifname, 1)
        # Send a RA to start SLAAC and subsequent DAD.
        self.SendRA(self.test_netid, 0)
        # Get flags and prove optimism.
        self.assertAddressHasExpectedAttributes(self.test_ip,
                                                self.test_ifindex,
                                                iproute.IFA_F_OPTIMISTIC)

        # Optimistic addresses are usable but are not selected.
        if net_test.LinuxVersion() >= (3, 18, 0):
            # The version checked in to android kernels <= 3.10 requires the
            # use_optimistic sysctl to be turned on.
            self.assertAddressUsable(self.test_ip, self.test_netid)
        self.assertAddressNotSelected(self.test_ip, self.test_netid)

        # Busy wait for DAD to complete (should be less than 1 second).
        self.WaitForDad(self.test_ip)

        # The test_ip should have completed DAD by now, and should be the
        # chosen source address.
        self.assertAddressUsable(self.test_ip, self.test_netid)
        self.assertAddressSelected(self.test_ip, self.test_netid)
コード例 #2
0
    def testSendToOnlinkDestination(self):
        # [3]  Get an IPv6 address back, in optimistic DAD start-up.
        self.SetDAD(self.test_ifname, 1)  # Enable DAD
        self.SetOptimisticDAD(self.test_ifname, 1)
        self.SetUseOptimistic(self.test_ifname, 1)
        # Send a RA to start SLAAC and subsequent DAD.
        self.SendRA(self.test_netid, 0)
        # Prove optimism and usability.
        self.assertAddressHasExpectedAttributes(self.test_ip,
                                                self.test_ifindex,
                                                iproute.IFA_F_OPTIMISTIC)
        self.assertAddressUsable(self.test_ip, self.test_netid)
        self.assertAddressSelected(self.test_ip, self.test_netid)

        # [4]  Send to an on-link destination and observe a Neighbor Solicitation
        # packet with a source address that is NOT the optimistic address.
        # In this setup, the only usable address is the link-local address.
        onlink_dest = self.GetRandomDestination(
            self.IPv6Prefix(self.test_netid))
        self.SendWithSourceAddress(self.test_ip, self.test_netid, onlink_dest)

        if net_test.LinuxVersion() >= (3, 18, 0):
            # Older versions will actually choose the optimistic address to
            # originate Neighbor Solications (RFC violation).
            expected_ns = packets.NS(self.test_lladdr, onlink_dest,
                                     self.MyMacAddress(self.test_netid))[1]
            self.ExpectPacketOn(self.test_netid, "link-local NS", expected_ns)
コード例 #3
0
class NoNsFromOptimisticTest(MultiInterfaceSourceAddressSelectionTest):
    @unittest.skipUnless(HAVE_USE_OPTIMISTIC, "use_optimistic not supported")
    @unittest.skipUnless(net_test.LinuxVersion() >= (3, 18, 0),
                         "correct optimistic bind() not supported")
    def testSendToOnlinkDestination(self):
        # [3]  Get an IPv6 address back, in optimistic DAD start-up.
        self.SetDAD(self.test_ifname, 1)  # Enable DAD
        self.SetOptimisticDAD(self.test_ifname, 1)
        self.SetUseOptimistic(self.test_ifname, 1)
        # Send a RA to start SLAAC and subsequent DAD.
        self.SendRA(self.test_netid, 0)
        # Prove optimism and usability.
        self.assertAddressHasExpectedAttributes(self.test_ip,
                                                self.test_ifindex,
                                                iproute.IFA_F_OPTIMISTIC)
        self.assertAddressUsable(self.test_ip, self.test_netid)
        self.assertAddressSelected(self.test_ip, self.test_netid)

        # [4]  Send to an on-link destination and observe a Neighbor Solicitation
        # packet with a source address that is NOT the optimistic address.
        # In this setup, the only usable address is the link-local address.
        onlink_dest = self.GetRandomDestination(
            self.IPv6Prefix(self.test_netid))
        self.SendWithSourceAddress(self.test_ip, self.test_netid, onlink_dest)

        expected_ns = multinetwork_test.Packets.NS(
            net_test.GetLinkAddress(self.test_ifname, True), onlink_dest,
            self.MyMacAddress(self.test_netid))[1]
        self.ExpectPacketOn(self.test_netid, "link-local NS", expected_ns)