summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorharti <harti@FreeBSD.org>2004-01-29 15:58:06 +0000
committerharti <harti@FreeBSD.org>2004-01-29 15:58:06 +0000
commit7dac4543ee8f303b86dcc2501f1f55f0c0b96a55 (patch)
treeff1bbb9b1dacc00921d10210248efea303479ac6
parent02d5f9e710f222c4ecd682a1ccaf8d5a96642722 (diff)
downloadFreeBSD-src-7dac4543ee8f303b86dcc2501f1f55f0c0b96a55.zip
FreeBSD-src-7dac4543ee8f303b86dcc2501f1f55f0c0b96a55.tar.gz
Add a simple test script for the ng_atmpif node.
Submitted by: Vincent Jardin <vjardin@free.fr>
-rw-r--r--tools/regression/atm/harp/atm_udp.ng155
-rw-r--r--tools/regression/atm/harp/memory_leak.sh13
2 files changed, 168 insertions, 0 deletions
diff --git a/tools/regression/atm/harp/atm_udp.ng b/tools/regression/atm/harp/atm_udp.ng
new file mode 100644
index 0000000..329b696
--- /dev/null
+++ b/tools/regression/atm/harp/atm_udp.ng
@@ -0,0 +1,155 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+err() {
+ echo "$*" >&2
+}
+usage() {
+ err "Usage: `basename $0` atmindex loc_ip udp_port rem_ip udp_port [pref_iface]"
+ err " or: `basename $0` flush"
+ exit $1
+}
+
+args=`getopt ed $*`
+if [ $? != 0 ] ; then
+ usage 2
+fi
+set -- $args
+
+debug_enable=0
+
+for i
+do
+ case "$i"
+ in
+ -e)
+ debug_enable=1
+ shift;;
+ -d)
+ debug_enable=-1
+ shift;;
+ --)
+ shift ; break;;
+ esac
+done
+
+if [ $# -lt 1 ] ; then
+ err "Missing arguments"
+ usage 1
+fi
+
+#
+# Handle debug flags
+#
+case ${debug_enable} in
+
+1)
+ #
+ # Enable all the HARP debugging features
+ #
+ sysctl -w net.harp.atm.atm_debug=1
+ sysctl -w net.harp.atm.atm_dev_print=1
+ sysctl -w net.harp.atm.atm_print_data=1
+ sysctl -w net.harp.ip.ipatm_print=1
+ sysctl -w net.harp.spans.spanscls_print=1
+ sysctl -w net.harp.uni.uniarp_print=1
+ sysctl -w net.harp.uni.unisig_print_msg=2
+ ;;
+
+-1)
+ #
+ # Disable all the HARP debugging features
+ #
+ sysctl -w net.harp.atm.atm_debug=0
+ sysctl -w net.harp.atm.atm_dev_print=0
+ sysctl -w net.harp.atm.atm_print_data=0
+ sysctl -w net.harp.ip.ipatm_print=0
+ sysctl -w net.harp.spans.spanscls_print=0
+ sysctl -w net.harp.uni.uniarp_print=0
+ sysctl -w net.harp.uni.unisig_print_msg=0
+ ;;
+esac
+
+if [ "${1}" = "flush" ] ; then
+ #
+ # Remove all atmpif nodes
+ #
+ for i in `ngctl list | grep atmpif | awk '{print $6}'` ; do
+ ngctl shutdown [$i]:
+ done
+ exit 0
+fi
+
+ID=${1}
+
+if [ $# -lt 5 -o $# -gt 6 ] ; then
+ err "wrong number of arguments"
+ usage 1
+fi
+
+LOC_IP=${2}
+LOC_UDP_PORT=${3}
+REM_IP=${4}
+REM_UDP_PORT=${5}
+PREF_IFACE=${6}
+
+if [ "${LOC_IP}" = "" -o "${LOC_UDP_PORT}" = "" -o \
+ "${REM_IP}" = "" -o "${REM_UDP_PORT}" = "" ] ; then
+ err "bad argument"
+ usage 1
+fi
+
+#
+# Default interface prefix: atmX
+#
+if [ "${PREF_IFACE}" = "" ] ; then
+ PREF_IFACE="atm"
+fi
+
+# Create the ATM PIF (Physical Interface) vatmpifXX
+#
+ngctl -f - <<EOF
+ mkpeer atmpif dummy link
+ name .:dummy vatmpif${ID}
+EOF
+
+# Attach a UDP socket to the ``link'' hook of the atm interface node
+# using the ng_ksocket(8) node type.
+#
+echo ngctl mkpeer vatmpif${ID}: ksocket link inet/dgram/udp
+ngctl -d mkpeer vatmpif${ID}: ksocket link inet/dgram/udp
+
+# Enable HARP debugging of the API between the Netgraph node and the
+# HARP stack
+#
+ngctl msg vatmpif${ID}: setconfig { debug=1 pcr=353207 macaddr=00:09:c0:00:00:cd }
+
+# Bind the UDP socket to the local external IP address and port
+#
+echo ngctl msg vatmpif${ID}:link bind inet/${LOC_IP}:${LOC_UDP_PORT}
+ngctl -d msg vatmpif${ID}:link bind inet/${LOC_IP}:${LOC_UDP_PORT}
+
+# Connect the UDP socket to the peer's external IP address and port
+#
+echo ngctl msg vatmpif${ID}:link connect inet/${REM_IP}:${REM_UDP_PORT}
+ngctl -d msg vatmpif${ID}:link connect inet/${REM_IP}:${REM_UDP_PORT}
+
+# Display the atm interfaces:
+#
+atm show config
+
+# Get the ATM device
+#
+ATMPIF=`atm show config | grep ^hva | tail -1 | cut -f 1 -d " "`
+
+# Open a PVC
+#
+atm set netif ${ATMPIF} ${PREF_IFACE} 5
+atm attach ${ATMPIF} sigpvc
+ifconfig ${PREF_IFACE}0 1.${ID}.1.1/16
+atm add pvc ${ATMPIF} ${ID} 40 AAL5 null IP ${PREF_IFACE}0 1.${ID}.2.2
+atm show ipvcc
+atm show vcc
+atm show stats vcc
+atm show stats interface ${ATMPIF}
diff --git a/tools/regression/atm/harp/memory_leak.sh b/tools/regression/atm/harp/memory_leak.sh
new file mode 100644
index 0000000..ac6cebb
--- /dev/null
+++ b/tools/regression/atm/harp/memory_leak.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+# Perform memory leak test
+#
+
+while [ 1 ] ; do
+ ./atm_udp.ng 1 127.0.0.1 5001 127.0.0.1 5002
+ sleep 2
+ ./atm_udp.ng flush
+ vmstat -m
+done
OpenPOWER on IntegriCloud