Refactor a little and follow new format of "npfctl list".

Fix the below ATF failures.
    - net/if_ipsec/t_ipsec_natt:ipsecif_natt_transport_null
    - net/if_ipsec/t_ipsec_natt:ipsecif_natt_transport_rijndaelcbc
    - net/ipsec/t_ipsec_natt:ipsec_natt_transport_ipv4_null
    - net/ipsec/t_ipsec_natt:ipsec_natt_transport_ipv4_rijndaelcbc

ok'ed by ozaki-r@n.o, thanks.
This commit is contained in:
knakahara 2020-06-05 03:24:58 +00:00
parent 4197c34981
commit f26b5d9d11
3 changed files with 19 additions and 8 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: t_ipsec_natt.sh,v 1.4 2020/06/01 04:38:37 martin Exp $
# $NetBSD: t_ipsec_natt.sh,v 1.5 2020/06/05 03:24:58 knakahara Exp $
#
# Copyright (c) 2018 Internet Initiative Japan Inc.
# All rights reserved.
@ -33,7 +33,6 @@ BUS_LOCAL=./bus_ipsec_natt_local
BUS_NAT=./bus_ipsec_natt_nat
DEBUG=${DEBUG:-false}
HIJACKING_NPF="${HIJACKING},blanket=/dev/npf"
setup_servers()
{
@ -386,7 +385,7 @@ test_ipsecif_natt_transport()
export RUMP_SERVER=$SOCK_NAT
$DEBUG && $HIJACKING_NPF npfctl list
# 192.168.0.2:4500 10.0.0.2:4500 via shmif1:65248
port_a=$($HIJACKING_NPF npfctl list | grep $ip_local_a | awk -F 'shmif1:' '/4500/ {print $2;}')
port_a=$(get_natt_port $ip_local_a $ip_nat_remote)
$DEBUG && echo port_a=$port_a
if [ -z "$port_a" ]; then
atf_fail "Failed to get a translated port on NAPT"
@ -441,7 +440,7 @@ test_ipsecif_natt_transport()
export RUMP_SERVER=$SOCK_NAT
$DEBUG && $HIJACKING_NPF npfctl list
# 192.168.0.2:4500 10.0.0.2:4500 via shmif1:65248
port_b=$($HIJACKING_NPF npfctl list | grep $ip_local_b | awk -F 'shmif1:' '/4500/ {print $2;}')
port_b=$(get_natt_port $ip_local_b $ip_nat_remote)
$DEBUG && echo port_b=$port_b
if [ -z "$port_b" ]; then
atf_fail "Failed to get a translated port on NAPT"

View File

@ -1,4 +1,4 @@
# $NetBSD: common.sh,v 1.7 2017/10/20 03:43:51 ozaki-r Exp $
# $NetBSD: common.sh,v 1.8 2020/06/05 03:24:58 knakahara Exp $
#
# Copyright (c) 2017 Internet Initiative Japan Inc.
# All rights reserved.
@ -25,6 +25,8 @@
# POSSIBILITY OF SUCH DAMAGE.
#
HIJACKING_NPF="${HIJACKING},blanket=/dev/npf"
test_flush_entries()
{
local sock=$1
@ -83,3 +85,14 @@ generate_pktproto()
echo $proto | tr 'a-z' 'A-Z'
fi
}
get_natt_port()
{
local local_addr=$1
local remote_addr=$2
local port=""
# 10.0.1.2:4500 20.0.0.2:4500 shmif1 20.0.0.1:35574
port=$($HIJACKING_NPF npfctl list | grep $local_addr | awk -F "${remote_addr}:" '/4500/ {print $2;}')
echo $port
}

View File

@ -1,4 +1,4 @@
# $NetBSD: t_ipsec_natt.sh,v 1.4 2020/06/01 04:38:37 martin Exp $
# $NetBSD: t_ipsec_natt.sh,v 1.5 2020/06/05 03:24:58 knakahara Exp $
#
# Copyright (c) 2017 Internet Initiative Japan Inc.
# All rights reserved.
@ -34,7 +34,6 @@ BUS_REMOTE=./bus_ipsec_natt_remote
BUS_GLOBAL=./bus_ipsec_natt_global
DEBUG=${DEBUG:-false}
HIJACKING_NPF="${HIJACKING},blanket=/dev/npf"
setup_servers_ipv4()
{
@ -325,7 +324,7 @@ test_ipsec_natt_transport_ipv4()
export RUMP_SERVER=$SOCK_NAT
$DEBUG && $HIJACKING_NPF npfctl list
# 10.0.1.2:4500 20.0.0.2:4500 via shmif1:9696
port=$($HIJACKING_NPF npfctl list | awk -F 'shmif1:' '/4500/ {print $2;}')
port=$(get_natt_port $ip_local $ip_nat_remote)
$DEBUG && echo port=$port
if [ -z "$port" ]; then
atf_fail "Failed to get a translated port on NAPT"