Module Name: src
Committed By: knakahara
Date: Fri Jun 5 03:24:59 UTC 2020
Modified Files:
src/tests/net/if_ipsec: t_ipsec_natt.sh
src/tests/net/ipsec: common.sh t_ipsec_natt.sh
Log Message:
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 [email protected], thanks.
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/net/if_ipsec/t_ipsec_natt.sh
cvs rdiff -u -r1.7 -r1.8 src/tests/net/ipsec/common.sh
cvs rdiff -u -r1.4 -r1.5 src/tests/net/ipsec/t_ipsec_natt.sh
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/net/if_ipsec/t_ipsec_natt.sh
diff -u src/tests/net/if_ipsec/t_ipsec_natt.sh:1.4 src/tests/net/if_ipsec/t_ipsec_natt.sh:1.5
--- src/tests/net/if_ipsec/t_ipsec_natt.sh:1.4 Mon Jun 1 04:38:37 2020
+++ src/tests/net/if_ipsec/t_ipsec_natt.sh Fri Jun 5 03:24:58 2020
@@ -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"
Index: src/tests/net/ipsec/common.sh
diff -u src/tests/net/ipsec/common.sh:1.7 src/tests/net/ipsec/common.sh:1.8
--- src/tests/net/ipsec/common.sh:1.7 Fri Oct 20 03:43:51 2017
+++ src/tests/net/ipsec/common.sh Fri Jun 5 03:24:58 2020
@@ -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
+}
Index: src/tests/net/ipsec/t_ipsec_natt.sh
diff -u src/tests/net/ipsec/t_ipsec_natt.sh:1.4 src/tests/net/ipsec/t_ipsec_natt.sh:1.5
--- src/tests/net/ipsec/t_ipsec_natt.sh:1.4 Mon Jun 1 04:38:37 2020
+++ src/tests/net/ipsec/t_ipsec_natt.sh Fri Jun 5 03:24:58 2020
@@ -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"