Page MenuHomeFreeBSD

D60520.diff
No OneTemporary

D60520.diff

diff --git a/tests/sys/netinet6/ndp.sh b/tests/sys/netinet6/ndp.sh
--- a/tests/sys/netinet6/ndp.sh
+++ b/tests/sys/netinet6/ndp.sh
@@ -860,6 +860,189 @@
}
+# SLAAC interface identifier selection in in6_ifadd(): a link-local
+# address with the advertised prefix length lends its identifier to the
+# autoconfigured address, otherwise the identifier is derived from the MAC
+# address, which covers PPP links with a /128 link-local address as well as
+# interfaces without a link-local address. The MAC address below gives the
+# EUI-64 based identifier 11:22ff:fe33:4455. Stable addresses (RFC 7217)
+# are switched off on the host, they bypass both paths. DAD is off on both
+# ends: while an address is tentative, the router sources its advertisements
+# from its global address, which hosts drop, and the host cannot send its
+# solicitation, both of which leave the cases to rtsol's retries.
+ndp_slaac_prefix="2001:db8:ffff:2000"
+ndp_slaac_mac="02:11:22:33:44:55"
+ndp_slaac_mac_ifid="11:22ff:fe33:4455"
+ndp_slaac_ll_ifid="dead:beef:1:2"
+
+# Prepare ${ifname} in jail ${jname} as a SLAAC host with the test MAC
+# address and without an automatic link-local address. The caller adds
+# the addresses its case needs and brings the interface up.
+ndp_slaac_host()
+{
+ local jname=$1 ifname=$2
+
+ atf_check jexec ${jname} ifconfig ${ifname} ether ${ndp_slaac_mac}
+ atf_check jexec ${jname} ifconfig ${ifname} inet6 -auto_linklocal \
+ -ifdisabled accept_rtadv -stableaddr no_dad
+}
+
+# Advertise ${ndp_slaac_prefix}::/64 from ${ifname} in jail ${jname}; rtadvd
+# advertises the prefixes configured on its interface.
+ndp_slaac_router()
+{
+ local jname=$1 ifname=$2
+
+ atf_check -o ignore jexec ${jname} sysctl net.inet6.ip6.forwarding=1
+ atf_check jexec ${jname} ifconfig ${ifname} inet6 -ifdisabled no_dad
+ atf_check jexec ${jname} ifconfig ${ifname} inet6 \
+ ${ndp_slaac_prefix}::1/64 up
+ atf_check jexec ${jname} rtadvd -c /dev/null -p $(pwd)/rtadvd.pid \
+ -C $(pwd)/rtadvd.sock ${ifname}
+ # Solicitations are lost until rtadvd has joined the all-routers group,
+ # which it does after daemonizing and writing its pidfile; the kernel
+ # never joins it on its own.
+ for i in $(jot 50); do
+ jexec ${jname} ifmcstat -f inet6 -i ${ifname} | \
+ grep -q "group ff02::2%${ifname} " && return
+ sleep 0.1
+ done
+ atf_fail "rtadvd did not start listening on ${ifname}"
+}
+
+# Solicit an advertisement on ${ifname} in jail ${jname} and wait for an
+# address from the test prefix to be autoconfigured on it. rtsol returns
+# once an advertisement arrived. The loop covers rtadvd's first unsolicited
+# advertisement, 16 seconds after it started, in case the solicitation went
+# out before rtadvd was ready to answer it.
+ndp_slaac_solicit()
+{
+ local jname=$1 ifname=$2 i
+
+ jexec ${jname} rtsol ${ifname} || true
+ for i in $(jot 200); do
+ if jexec ${jname} ifconfig ${ifname} inet6 | \
+ grep -q "inet6 ${ndp_slaac_prefix}:.*autoconf"; then
+ return
+ fi
+ sleep 0.1
+ done
+ atf_fail "No address from ${ndp_slaac_prefix}::/64 was autoconfigured on ${ifname}"
+}
+
+ndp_slaac_cleanup()
+{
+ if [ -f rtadvd.pid ]; then
+ # rtadvd takes a long time to shut down, its interface is
+ # about to be destroyed anyway.
+ pkill -kill -F rtadvd.pid
+ rm -f rtadvd.pid
+ fi
+ vnet_cleanup
+}
+
+atf_test_case "ndp_slaac_ifid_lladdr" "cleanup"
+ndp_slaac_ifid_lladdr_head() {
+ atf_set descr 'SLAAC takes the interface ID from a /64 link-local address'
+ atf_set require.user root
+ atf_set require.progs rtadvd rtsol ifmcstat
+}
+
+ndp_slaac_ifid_lladdr_body() {
+ local epair
+
+ vnet_init
+
+ epair=$(vnet_mkepair)
+ vnet_mkjail v6t-slaac-rtr ${epair}a
+ vnet_mkjail v6t-slaac-host ${epair}b
+
+ ndp_slaac_host v6t-slaac-host ${epair}b
+ atf_check jexec v6t-slaac-host ifconfig ${epair}b inet6 \
+ fe80::${ndp_slaac_ll_ifid}/64
+ atf_check jexec v6t-slaac-host ifconfig ${epair}b up
+ ndp_slaac_router v6t-slaac-rtr ${epair}a
+ ndp_slaac_solicit v6t-slaac-host ${epair}b
+
+ atf_check \
+ -o match:"inet6 ${ndp_slaac_prefix}:${ndp_slaac_ll_ifid} prefixlen 64.*autoconf" \
+ -o not-match:"inet6 ${ndp_slaac_prefix}:${ndp_slaac_mac_ifid} " \
+ jexec v6t-slaac-host ifconfig ${epair}b inet6
+}
+
+ndp_slaac_ifid_lladdr_cleanup() {
+ ndp_slaac_cleanup
+}
+
+atf_test_case "ndp_slaac_ifid_no_lladdr" "cleanup"
+ndp_slaac_ifid_no_lladdr_head() {
+ atf_set descr 'SLAAC derives the interface ID from the MAC address without a link-local address'
+ atf_set require.user root
+ atf_set require.progs rtadvd rtsol ifmcstat
+}
+
+ndp_slaac_ifid_no_lladdr_body() {
+ local epair
+
+ vnet_init
+
+ epair=$(vnet_mkepair)
+ vnet_mkjail v6t-slaac-rtr ${epair}a
+ vnet_mkjail v6t-slaac-host ${epair}b
+
+ # An interface joins the all-nodes group, and so receives
+ # advertisements, only once it has an IPv6 address: give it a
+ # static one from another prefix in place of the link-local one.
+ ndp_slaac_host v6t-slaac-host ${epair}b
+ atf_check jexec v6t-slaac-host ifconfig ${epair}b inet6 \
+ 2001:db8:ffff:1::2/64
+ atf_check jexec v6t-slaac-host ifconfig ${epair}b up
+ ndp_slaac_router v6t-slaac-rtr ${epair}a
+ ndp_slaac_solicit v6t-slaac-host ${epair}b
+
+ atf_check \
+ -o match:"inet6 ${ndp_slaac_prefix}:${ndp_slaac_mac_ifid} prefixlen 64.*autoconf" \
+ -o not-match:"inet6 fe80:" \
+ jexec v6t-slaac-host ifconfig ${epair}b inet6
+}
+
+ndp_slaac_ifid_no_lladdr_cleanup() {
+ ndp_slaac_cleanup
+}
+
+atf_test_case "ndp_slaac_ifid_lladdr_plen128" "cleanup"
+ndp_slaac_ifid_lladdr_plen128_head() {
+ atf_set descr 'SLAAC derives the interface ID from the MAC address when the link-local address is a /128'
+ atf_set require.user root
+ atf_set require.progs rtadvd rtsol ifmcstat
+}
+
+ndp_slaac_ifid_lladdr_plen128_body() {
+ local epair
+
+ vnet_init
+
+ epair=$(vnet_mkepair)
+ vnet_mkjail v6t-slaac-rtr ${epair}a
+ vnet_mkjail v6t-slaac-host ${epair}b
+
+ ndp_slaac_host v6t-slaac-host ${epair}b
+ atf_check jexec v6t-slaac-host ifconfig ${epair}b inet6 \
+ fe80::${ndp_slaac_ll_ifid}/128
+ atf_check jexec v6t-slaac-host ifconfig ${epair}b up
+ ndp_slaac_router v6t-slaac-rtr ${epair}a
+ ndp_slaac_solicit v6t-slaac-host ${epair}b
+
+ atf_check \
+ -o match:"inet6 ${ndp_slaac_prefix}:${ndp_slaac_mac_ifid} prefixlen 64.*autoconf" \
+ -o not-match:"inet6 ${ndp_slaac_prefix}:${ndp_slaac_ll_ifid} " \
+ jexec v6t-slaac-host ifconfig ${epair}b inet6
+}
+
+ndp_slaac_ifid_lladdr_plen128_cleanup() {
+ ndp_slaac_cleanup
+}
+
atf_init_test_cases()
{
atf_add_test_case "ndp_add_gu_success"
@@ -875,4 +1058,7 @@
atf_add_test_case "ndp_input_validation_src_linklocal"
atf_add_test_case "ndp_multirouter_pref"
atf_add_test_case "ndp_routeinfo_option"
+ atf_add_test_case "ndp_slaac_ifid_lladdr"
+ atf_add_test_case "ndp_slaac_ifid_no_lladdr"
+ atf_add_test_case "ndp_slaac_ifid_lladdr_plen128"
}

File Metadata

Mime Type
text/plain
Expires
Sun, Oct 11, 5:30 PM (6 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40544829
Default Alt Text
D60520.diff (6 KB)

Event Timeline