# $NetBSD: t_dad.sh,v 1.14 2018/03/07 02:30:37 ozaki-r Exp $
#
# Copyright (c) 2015 The NetBSD Foundation, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
atf_check -s exit:0 rump.ifconfig shmif0 up
$DEBUG && rump.ifconfig shmif0
# The primary address doesn't start with tentative state
atf_check -s exit:0 -o match:"$localip1" \
-o not-match:"$localip1.+$tentative" \
rump.ifconfig shmif0
# The alias address starts with tentative state
# XXX we have no stable way to check this, so skip for now
#atf_check -s exit:0 -x "cat ./out |grep $localip2 |grep -q tentative"
# Check DAD probe packets (Neighbor Solicitation Message)
pkt=$(make_ns_pkt_str 2 $localip2)
pkt=$(echo $pkt | sed 's/\([\(\)]\)/\\\1/g')
atf_check -s exit:0 -o match:"$pkt" cat ./out
# No DAD for the primary address
pkt=$(make_ns_pkt_str 1 $localip1)
pkt=$(echo $pkt | sed 's/\([\(\)]\)/\\\1/g')
atf_check -s exit:0 -o not-match:"$pkt" cat ./out
# Waiting for DAD complete
atf_check -s exit:0 rump.ifconfig -w 10
extract_new_packets bus1 > ./out
$DEBUG && cat ./out
# IPv6 DAD doesn't announce (Neighbor Advertisement Message)
# The alias address left tentative
atf_check -s exit:0 -o match:"$localip2" \
-o not-match:"$localip2.+$tentative" \
rump.ifconfig shmif0
#
# Add a new address on the fly
#
atf_check -s exit:0 rump.ifconfig shmif0 inet6 $localip3
# The new address starts with tentative state
# XXX we have no stable way to check this, so skip for now
#atf_check -s exit:0 -x "rump.ifconfig shmif0 |grep $localip3 |grep -q tentative"