+ #
+ # Source from the unspecified address ::. This happens when the RS
+ # is sent before the host has a configured address/sub-net,
+ # i.e. auto-config. Since the sender has no IP address, the reply
+ # comes back mcast - so the capture needs to not filter this.
+ # If we happen to pick up the periodic RA at this point then so be it,
+ # it's not an error.
+ #
+ self.pg0.ip6_ra_config(send_unicast=1, suppress=1)
+ p = (Ether(dst=dmac, src=self.pg0.remote_mac) /
+ IPv6(dst="ff02::2", src="::") /
+ ICMPv6ND_RS())
+ pkts = [p]
+ self.send_and_expect_ra(self.pg0, pkts,
+ "RS sourced from unspecified",
+ dst_ip="ff02::1",
+ filter_out_fn=None)
+
+ #
+ # Configure The RA to announce the links prefix
+ #
+ self.pg0.ip6_ra_prefix(self.pg0.local_ip6n,
+ self.pg0.local_ip6_prefix_len)
+
+ #
+ # RAs should now contain the prefix information option
+ #
+ opt = ICMPv6NDOptPrefixInfo(prefixlen=self.pg0.local_ip6_prefix_len,
+ prefix=self.pg0.local_ip6,
+ L=1,
+ A=1)
+
+ self.pg0.ip6_ra_config(send_unicast=1)
+ ll = mk_ll_addr(self.pg0.remote_mac)
+ p = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) /
+ IPv6(dst=self.pg0.local_ip6, src=ll) /
+ ICMPv6ND_RS())
+ self.send_and_expect_ra(self.pg0, p,
+ "RA with prefix-info",
+ dst_ip=ll,
+ opt=opt)
+
+ #
+ # Change the prefix info to not off-link
+ # L-flag is clear
+ #
+ self.pg0.ip6_ra_prefix(self.pg0.local_ip6n,
+ self.pg0.local_ip6_prefix_len,
+ off_link=1)
+
+ opt = ICMPv6NDOptPrefixInfo(prefixlen=self.pg0.local_ip6_prefix_len,
+ prefix=self.pg0.local_ip6,
+ L=0,
+ A=1)
+
+ self.pg0.ip6_ra_config(send_unicast=1)
+ self.send_and_expect_ra(self.pg0, p,
+ "RA with Prefix info with L-flag=0",
+ dst_ip=ll,
+ opt=opt)
+
+ #
+ # Change the prefix info to not off-link, no-autoconfig
+ # L and A flag are clear in the advert
+ #
+ self.pg0.ip6_ra_prefix(self.pg0.local_ip6n,
+ self.pg0.local_ip6_prefix_len,
+ off_link=1,
+ no_autoconfig=1)
+
+ opt = ICMPv6NDOptPrefixInfo(prefixlen=self.pg0.local_ip6_prefix_len,
+ prefix=self.pg0.local_ip6,
+ L=0,
+ A=0)
+
+ self.pg0.ip6_ra_config(send_unicast=1)
+ self.send_and_expect_ra(self.pg0, p,
+ "RA with Prefix info with A & L-flag=0",
+ dst_ip=ll,
+ opt=opt)
+
+ #
+ # Change the flag settings back to the defaults
+ # L and A flag are set in the advert
+ #
+ self.pg0.ip6_ra_prefix(self.pg0.local_ip6n,
+ self.pg0.local_ip6_prefix_len)
+
+ opt = ICMPv6NDOptPrefixInfo(prefixlen=self.pg0.local_ip6_prefix_len,
+ prefix=self.pg0.local_ip6,
+ L=1,
+ A=1)
+
+ self.pg0.ip6_ra_config(send_unicast=1)
+ self.send_and_expect_ra(self.pg0, p,
+ "RA with Prefix info",
+ dst_ip=ll,
+ opt=opt)
+
+ #
+ # Change the prefix info to not off-link, no-autoconfig
+ # L and A flag are clear in the advert
+ #
+ self.pg0.ip6_ra_prefix(self.pg0.local_ip6n,
+ self.pg0.local_ip6_prefix_len,
+ off_link=1,
+ no_autoconfig=1)
+
+ opt = ICMPv6NDOptPrefixInfo(prefixlen=self.pg0.local_ip6_prefix_len,
+ prefix=self.pg0.local_ip6,
+ L=0,
+ A=0)
+
+ self.pg0.ip6_ra_config(send_unicast=1)
+ self.send_and_expect_ra(self.pg0, p,
+ "RA with Prefix info with A & L-flag=0",
+ dst_ip=ll,
+ opt=opt)
+
+ #
+ # Use the reset to defults option to revert to defaults
+ # L and A flag are clear in the advert
+ #
+ self.pg0.ip6_ra_prefix(self.pg0.local_ip6n,
+ self.pg0.local_ip6_prefix_len,
+ use_default=1)
+
+ opt = ICMPv6NDOptPrefixInfo(prefixlen=self.pg0.local_ip6_prefix_len,
+ prefix=self.pg0.local_ip6,
+ L=1,
+ A=1)
+
+ self.pg0.ip6_ra_config(send_unicast=1)
+ self.send_and_expect_ra(self.pg0, p,
+ "RA with Prefix reverted to defaults",
+ dst_ip=ll,
+ opt=opt)
+
+ #
+ # Advertise Another prefix. With no L-flag/A-flag
+ #
+ self.pg0.ip6_ra_prefix(self.pg1.local_ip6n,
+ self.pg1.local_ip6_prefix_len,
+ off_link=1,
+ no_autoconfig=1)
+
+ opt = [ICMPv6NDOptPrefixInfo(prefixlen=self.pg0.local_ip6_prefix_len,
+ prefix=self.pg0.local_ip6,
+ L=1,
+ A=1),
+ ICMPv6NDOptPrefixInfo(prefixlen=self.pg1.local_ip6_prefix_len,
+ prefix=self.pg1.local_ip6,
+ L=0,
+ A=0)]
+
+ self.pg0.ip6_ra_config(send_unicast=1)
+ ll = mk_ll_addr(self.pg0.remote_mac)
+ p = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) /
+ IPv6(dst=self.pg0.local_ip6, src=ll) /
+ ICMPv6ND_RS())
+ self.send_and_expect_ra(self.pg0, p,
+ "RA with multiple Prefix infos",
+ dst_ip=ll,
+ opt=opt)
+
+ #
+ # Remove the first refix-info - expect the second is still in the
+ # advert
+ #
+ self.pg0.ip6_ra_prefix(self.pg0.local_ip6n,
+ self.pg0.local_ip6_prefix_len,
+ is_no=1)
+
+ opt = ICMPv6NDOptPrefixInfo(prefixlen=self.pg1.local_ip6_prefix_len,
+ prefix=self.pg1.local_ip6,
+ L=0,
+ A=0)
+
+ self.pg0.ip6_ra_config(send_unicast=1)
+ self.send_and_expect_ra(self.pg0, p,
+ "RA with Prefix reverted to defaults",
+ dst_ip=ll,
+ opt=opt)
+
+ #
+ # Remove the second prefix-info - expect no prefix-info i nthe adverts
+ #
+ self.pg0.ip6_ra_prefix(self.pg1.local_ip6n,
+ self.pg1.local_ip6_prefix_len,
+ is_no=1)
+
+ self.pg0.ip6_ra_config(send_unicast=1)
+ self.send_and_expect_ra(self.pg0, p,
+ "RA with Prefix reverted to defaults",
+ dst_ip=ll)
+
+ #
+ # Reset the periodic advertisements back to default values
+ #
+ self.pg0.ip6_ra_config(no=1, suppress=1, send_unicast=0)
+
+
+class IPv6NDProxyTest(TestIPv6ND):
+ """ IPv6 ND ProxyTest Case """
+
+ def setUp(self):
+ super(IPv6NDProxyTest, self).setUp()
+
+ # create 3 pg interfaces
+ self.create_pg_interfaces(range(3))
+
+ # pg0 is the master interface, with the configured subnet
+ self.pg0.admin_up()
+ self.pg0.config_ip6()
+ self.pg0.resolve_ndp()
+
+ self.pg1.ip6_enable()
+ self.pg2.ip6_enable()
+
+ def tearDown(self):
+ super(IPv6NDProxyTest, self).tearDown()
+
+ def test_nd_proxy(self):
+ """ IPv6 Proxy ND """
+
+ #
+ # Generate some hosts in the subnet that we are proxying
+ #
+ self.pg0.generate_remote_hosts(8)
+
+ nsma = in6_getnsma(inet_pton(AF_INET6, self.pg0.local_ip6))
+ d = inet_ntop(AF_INET6, nsma)
+
+ #
+ # Send an NS for one of those remote hosts on one of the proxy links
+ # expect no response since it's from an address that is not
+ # on the link that has the prefix configured
+ #
+ ns_pg1 = (Ether(dst=in6_getnsmac(nsma), src=self.pg1.remote_mac) /
+ IPv6(dst=d, src=self.pg0._remote_hosts[2].ip6) /
+ ICMPv6ND_NS(tgt=self.pg0.local_ip6) /
+ ICMPv6NDOptSrcLLAddr(lladdr=self.pg0._remote_hosts[2].mac))
+
+ self.send_and_assert_no_replies(self.pg1, ns_pg1, "Off link NS")
+
+ #
+ # Add proxy support for the host
+ #
+ self.vapi.ip6_nd_proxy(
+ inet_pton(AF_INET6, self.pg0._remote_hosts[2].ip6),
+ self.pg1.sw_if_index)
+
+ #
+ # try that NS again. this time we expect an NA back
+ #
+ self.pg1.add_stream(ns_pg1)