# $NetBSD: t_dad.sh,v 1.16 2024/08/20 08:21:48 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.
#
# The primary address doesn't start with tentative state
atf_check -s exit:0 -o not-match:'10\.0\.0\.1.+TENTATIVE' cat ./out
# The alias address starts with tentative state
atf_check -s exit:0 -o match:'10\.0\.0\.2.+TENTATIVE' cat ./out
# Check DAD probe packets
pkt=$(make_pkt_str 10.0.0.2 0.0.0.0)
atf_check -s exit:0 -o match:"$pkt" cat ./out
# No DAD for the primary address
pkt=$(make_pkt_str 10.0.0.1 0.0.0.0)
atf_check -s exit:0 -o not-match:"$pkt" cat ./out
# Waiting for DAD complete
atf_check -s exit:0 rump.ifconfig -w 10
# Give a chance to send a DAD announce packet
atf_check -s exit:0 sleep 2
extract_new_packets bus1 > ./out
$DEBUG && cat ./out
# Check the DAD announce packet
pkt=$(make_pkt_str 10.0.0.2 10.0.0.2)
atf_check -s exit:0 -o match:"$pkt" cat ./out
# The alias address left tentative
atf_check -s exit:0 -o not-match:'10\.0\.0\.2.+TENTATIVE' \
rump.ifconfig shmif0
#
# Add a new address on the fly
#
atf_check -s exit:0 rump.ifconfig shmif0 inet 10.0.0.3/24 alias
# The new address starts with tentative state
atf_check -s exit:0 -o match:'10\.0\.0\.3.+TENTATIVE' \
rump.ifconfig shmif0
# Waiting for DAD complete
atf_check -s exit:0 rump.ifconfig -w 10
# Give a chance to send a DAD announce packet
atf_check -s exit:0 sleep 2
extract_new_packets bus1 > ./out
$DEBUG && cat ./out
# Check the DAD announce packet
pkt=$(make_pkt_str 10.0.0.3 10.0.0.3)
atf_check -s exit:0 -o match:"$pkt" cat ./out
# The new address left tentative
atf_check -s exit:0 -o not-match:'10\.0\.0\.3.+TENTATIVE' \
rump.ifconfig shmif0
rump_server_destroy_ifaces
}
dad_duplicated_body()
{
local localip1=10.0.1.1
local localip2=10.0.1.11
local peerip=10.0.1.2