diff --git a/test/.gitignore b/test/.gitignore index e00b544..fbee491 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -5,6 +5,7 @@ QEMU_EFI.fd *.qcow2 *.raw *.raw.xz +*.bin nsholder guest-key guest-key.pub diff --git a/test/Makefile b/test/Makefile index cc1a818..08f0c2d 100644 --- a/test/Makefile +++ b/test/Makefile @@ -54,10 +54,12 @@ UBUNTU_IMGS = $(UBUNTU_OLD_IMGS) $(UBUNTU_NEW_IMGS) DOWNLOAD_ASSETS = mbuto \ $(DEBIAN_IMGS) $(FEDORA_IMGS) $(OPENSUSE_IMGS) $(UBUNTU_IMGS) +TESTDATA_ASSETS = small.bin big.bin medium.bin LOCAL_ASSETS = mbuto.img QEMU_EFI.fd \ $(DEBIAN_IMGS:%=prepared-%) $(FEDORA_IMGS:%=prepared-%) \ $(UBUNTU_NEW_IMGS:%=prepared-%) \ - nsholder guest-key guest-key.pub + nsholder guest-key guest-key.pub \ + $(TESTDATA_ASSETS) ASSETS = $(DOWNLOAD_ASSETS) $(LOCAL_ASSETS) @@ -71,7 +73,7 @@ mbuto: guest-key guest-key.pub: ssh-keygen -f guest-key -N '' -mbuto.img: passt.mbuto mbuto guest-key.pub +mbuto.img: passt.mbuto mbuto guest-key.pub $(TESTDATA_ASSETS) ./mbuto/mbuto -p ./$< -c lz4 -f $@ nsholder: nsholder.c @@ -88,6 +90,15 @@ prepared-%.img: %.img ./prepare-distro-img.sh qemu-img create -f qcow2 -F qcow2 -b $< $@ ./prepare-distro-img.sh $(IMGTYPE) $@ +small.bin: + dd if=/dev/urandom bs=2k count=1 of=$@ + +medium.bin: + dd if=/dev/urandom bs=1k count=5 of=$@ + +big.bin: + dd if=/dev/urandom bs=1M count=10 of=$@ + check: assets ./run diff --git a/test/passt.mbuto b/test/passt.mbuto index 51c9ada..d9cb078 100755 --- a/test/passt.mbuto +++ b/test/passt.mbuto @@ -12,8 +12,8 @@ PROGS="${PROGS:-ash,dash,bash ip mount ls insmod mkdir ln cat chmod lsmod modprobe find grep mknod mv rm umount jq iperf3 dhclient hostname - sed tr chown sipcalc cut md5sum socat dd strace ping tail killall sleep - sysctl nproc tcp_rr tcp_crr udp_rr which tee seq bc sshd ssh-keygen}" + sed tr chown sipcalc cut socat dd strace ping tail killall sleep sysctl + nproc tcp_rr tcp_crr udp_rr which tee seq bc sshd ssh-keygen cmp}" KMODS="${KMODS:- virtio_net virtio_pci vmw_vsock_virtio_transport}" @@ -23,6 +23,8 @@ LINKS="${LINKS:- DIRS="${DIRS} /tmp /sbin /usr/share /var/log /var/lib /etc/ssh /run/sshd /root/.ssh" +COPIES="${COPIES} small.bin,/root/small.bin medium.bin,/root/medium.bin big.bin,/root/big.bin" + FIXUP="${FIXUP}"' cat > /sbin/dhclient-script << EOF #!/bin/sh diff --git a/test/passt/tcp b/test/passt/tcp index 7af9c54..67668aa 100644 --- a/test/passt/tcp +++ b/test/passt/tcp @@ -11,77 +11,66 @@ # Copyright (c) 2021 Red Hat GmbH # Author: Stefano Brivio -gtools socat ip jq md5sum cut -htools dd socat ip jq md5sum cut +gtools socat ip jq cmp +htools socat ip jq + +set TEMP_BIG __STATEDIR__/test_big.bin +set TEMP_SMALL __STATEDIR__/test_small.bin test TCP/IPv4: host to guest: big transfer -set TEMP_BIG __STATEDIR__/big guestb socat -u TCP4-LISTEN:10001,reuseaddr OPEN:test_big.bin,create,trunc sleep 1 -host dd if=/dev/urandom bs=1M count=10 > __TEMP_BIG__ -host socat -u OPEN:__TEMP_BIG__ TCP4:127.0.0.1:10001 +host socat -u OPEN:__BASEPATH__/big.bin TCP4:127.0.0.1:10001 guestw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_BIG__" = "__HOST_MD5_BIG__" ] +guest cmp /root/big.bin test_big.bin test TCP/IPv4: guest to host: big transfer hostb socat -u TCP4-LISTEN:10003,bind=127.0.0.1,reuseaddr OPEN:__TEMP_BIG__,create,trunc gout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway' -guest socat -u OPEN:test_big.bin TCP4:__GW__:10003 +guest socat -u OPEN:/root/big.bin TCP4:__GW__:10003 hostw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__GUEST_MD5_BIG__" = "__HOST_MD5_BIG__" ] +check cmp __BASEPATH__/big.bin __TEMP_BIG__ test TCP/IPv4: host to guest: small transfer -set TEMP_SMALL __STATEDIR__/small guestb socat -u TCP4-LISTEN:10001,reuseaddr OPEN:test_small.bin,create,trunc sleep 1 -host dd if=/dev/urandom bs=2k count=1 > __TEMP_SMALL__ -host socat -u OPEN:__TEMP_SMALL__ TCP4:127.0.0.1:10001 +host socat -u OPEN:__BASEPATH__/small.bin TCP4:127.0.0.1:10001 guestw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_SMALL__" = "__HOST_MD5_SMALL__" ] +guest cmp /root/small.bin test_small.bin test TCP/IPv4: guest to host: small transfer hostb socat -u TCP4-LISTEN:10003,bind=127.0.0.1,reuseaddr OPEN:__TEMP_SMALL__,create,trunc sleep 1 -guest socat -u OPEN:test_small.bin TCP4:__GW__:10003 +guest socat -u OPEN:/root/small.bin TCP4:__GW__:10003 hostw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__GUEST_MD5_SMALL__" = "__HOST_MD5_SMALL__" ] +check cmp __BASEPATH__/small.bin __TEMP_SMALL__ test TCP/IPv6: host to guest: big transfer guestb socat -u TCP6-LISTEN:10001,reuseaddr OPEN:test_big.bin,create,trunc sleep 1 -host socat -u OPEN:__TEMP_BIG__ TCP6:[::1]:10001 +host socat -u OPEN:__BASEPATH__/big.bin TCP6:[::1]:10001 guestw -gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_BIG__" = "__HOST_MD5_BIG__" ] +guest cmp /root/big.bin test_big.bin test TCP/IPv6: guest to host: big transfer hostb socat -u TCP6-LISTEN:10003,bind=[::1],reuseaddr OPEN:__TEMP_BIG__,create,trunc gout GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway' gout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' -guest socat -u OPEN:test_big.bin TCP6:[__GW6__%__IFNAME__]:10003 +guest socat -u OPEN:/root/big.bin TCP6:[__GW6__%__IFNAME__]:10003 hostw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__GUEST_MD5_BIG__" = "__HOST_MD5_BIG__" ] +check cmp __BASEPATH__/big.bin __TEMP_BIG__ test TCP/IPv6: host to guest: small transfer guestb socat -u TCP6-LISTEN:10001,reuseaddr OPEN:test_small.bin,create,trunc sleep 1 -host socat -u OPEN:__TEMP_SMALL__ TCP6:[::1]:10001 +host socat -u OPEN:__BASEPATH__/small.bin TCP6:[::1]:10001 guestw -gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_SMALL__" = "__HOST_MD5_SMALL__" ] +guest cmp /root/small.bin test_small.bin test TCP/IPv6: guest to host: small transfer hostb socat -u TCP6-LISTEN:10003,bind=[::1],reuseaddr OPEN:__TEMP_SMALL__,create,trunc sleep 1 -guest socat -u OPEN:test_small.bin TCP6:[__GW6__%__IFNAME__]:10003 +guest socat -u OPEN:/root/small.bin TCP6:[__GW6__%__IFNAME__]:10003 hostw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__GUEST_MD5_SMALL__" = "__HOST_MD5_SMALL__" ] +check cmp __BASEPATH__/small.bin __TEMP_SMALL__ diff --git a/test/passt/udp b/test/passt/udp index 7d444b8..b9533e0 100644 --- a/test/passt/udp +++ b/test/passt/udp @@ -11,41 +11,36 @@ # Copyright (c) 2021 Red Hat GmbH # Author: Stefano Brivio -gtools socat ip jq md5sum cut -htools dd socat jq md5sum cut +gtools socat ip jq cmp +htools socat jq + +set TEMP __STATEDIR__/test.bin test UDP/IPv4: host to guest -set TEMP __STATEDIR__/data guestb socat -u UDP4-LISTEN:10001,null-eof OPEN:test.bin,create,trunc sleep 1 -host dd if=/dev/urandom bs=1k count=5 > __TEMP__ -host socat -u OPEN:__TEMP__ UDP4:127.0.0.1:10001,shut-null +host socat -u OPEN:__BASEPATH__/medium.bin UDP4:127.0.0.1:10001,shut-null guestw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 -check [ "__GUEST_MD5__" = "__HOST_MD5__" ] +guest cmp /root/medium.bin test.bin test UDP/IPv4: guest to host hostb socat -u UDP4-LISTEN:10003,bind=127.0.0.1,null-eof OPEN:__TEMP__,create,trunc gout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway' -guest socat -u OPEN:test.bin UDP4:__GW__:10003,shut-null +guest socat -u OPEN:/root/medium.bin UDP4:__GW__:10003,shut-null hostw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__GUEST_MD5__" = "__HOST_MD5__" ] +check cmp __BASEPATH__/medium.bin __TEMP__ test UDP/IPv6: host to guest guestb socat -u UDP6-LISTEN:10001,null-eof OPEN:test.bin,create,trunc sleep 1 -host socat -u OPEN:__TEMP__ UDP6:[::1]:10001,shut-null +host socat -u OPEN:__BASEPATH__/medium.bin UDP6:[::1]:10001,shut-null guestw -gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 -check [ "__GUEST_MD5__" = "__HOST_MD5__" ] +guest cmp /root/medium.bin test.bin test UDP/IPv6: guest to host hostb socat -u UDP6-LISTEN:10003,bind=[::1],null-eof OPEN:__TEMP__,create,trunc gout GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway' gout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' -guest socat -u OPEN:test.bin UDP6:[__GW6__%__IFNAME__]:10003,shut-null +guest socat -u OPEN:/root/medium.bin UDP6:[__GW6__%__IFNAME__]:10003,shut-null hostw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__GUEST_MD5__" = "__HOST_MD5__" ] +check cmp __BASEPATH__/medium.bin __TEMP__ diff --git a/test/passt_in_ns/tcp b/test/passt_in_ns/tcp index 71fe1c1..842b345 100644 --- a/test/passt_in_ns/tcp +++ b/test/passt_in_ns/tcp @@ -11,281 +11,246 @@ # Copyright (c) 2021 Red Hat GmbH # Author: Stefano Brivio -gtools socat ip jq md5sum cut -htools dd socat ip jq md5sum cut -nstools socat ip jq md5sum cut +gtools socat ip jq +htools socat ip jq +nstools socat ip jq + +set TEMP_BIG __STATEDIR__/test_big.bin +set TEMP_SMALL __STATEDIR__/test_small.bin +set TEMP_NS_BIG __STATEDIR__/test_ns_big.bin +set TEMP_NS_SMALL __STATEDIR__/test_ns_small.bin test TCP/IPv4: host to guest: big transfer -set TEMP_BIG __STATEDIR__/big.img guestb socat -u TCP4-LISTEN:10001 OPEN:test_big.bin,create,trunc -host dd if=/dev/urandom bs=1M count=10 of=__TEMP_BIG__ sleep 1 -host socat -u OPEN:__TEMP_BIG__ TCP4:127.0.0.1:10001 +host socat -u OPEN:__BASEPATH__/big.bin TCP4:127.0.0.1:10001 guestw -hout MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ] +guest cmp test_big.bin /root/big.bin test TCP/IPv4: host to ns: big transfer -set TEMP_NS_BIG __STATEDIR__/big_ns.img nsb socat -u TCP4-LISTEN:10002 OPEN:__TEMP_NS_BIG__,create,trunc sleep 1 -host socat -u OPEN:__TEMP_BIG__ TCP4:127.0.0.1:10002 +host socat -u OPEN:__BASEPATH__/big.bin TCP4:127.0.0.1:10002 nsw -nsout NS_MD5_BIG md5sum __TEMP_NS_BIG__ | cut -d' ' -f1 -check [ "__NS_MD5_BIG__" = "__MD5_BIG__" ] +check cmp __TEMP_NS_BIG__ __BASEPATH__/big.bin test TCP/IPv4: guest to host: big transfer hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc gout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway' sleep 1 -guest socat -u OPEN:test_big.bin TCP4:__GW__:10003 +guest socat -u OPEN:/root/big.bin TCP4:__GW__:10003 hostw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] +check cmp __TEMP_BIG__ __BASEPATH__/big.bin test TCP/IPv4: guest to ns: big transfer -nsb socat -u TCP4-LISTEN:10002 OPEN:__TEMP_BIG__,create,trunc +nsb socat -u TCP4-LISTEN:10002 OPEN:__TEMP_NS_BIG__,create,trunc sleep 1 -guest socat -u OPEN:test_big.bin TCP4:__GW__:10002 +guest socat -u OPEN:/root/big.bin TCP4:__GW__:10002 nsw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] +check cmp __TEMP_NS_BIG__ __BASEPATH__/big.bin test TCP/IPv4: ns to host (spliced): big transfer hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc sleep 1 -ns socat -u OPEN:__TEMP_NS_BIG__ TCP4:127.0.0.1:10003 +ns socat -u OPEN:__BASEPATH__/big.bin TCP4:127.0.0.1:10003 hostw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] +check cmp __TEMP_BIG__ __BASEPATH__/big.bin test TCP/IPv4: ns to host (via tap): big transfer hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc sleep 1 -ns socat -u OPEN:__TEMP_NS_BIG__ TCP4:__GW__:10003 +ns socat -u OPEN:__BASEPATH__/big.bin TCP4:__GW__:10003 hostw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] +check cmp __TEMP_BIG__ __BASEPATH__/big.bin test TCP/IPv4: ns to guest (using loopback address): big transfer guestb socat -u TCP4-LISTEN:10001 OPEN:test_big.bin,create,trunc sleep 1 -ns socat -u OPEN:__TEMP_NS_BIG__ TCP4:127.0.0.1:10001 +ns socat -u OPEN:__BASEPATH__/big.bin TCP4:127.0.0.1:10001 guestw -gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ] +guest cmp test_big.bin /root/big.bin test TCP/IPv4: ns to guest (using namespace address): big transfer guestb socat -u TCP4-LISTEN:10001 OPEN:test_big.bin,create,trunc nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' nsout ADDR ip -j -4 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[0].local' sleep 1 -ns socat -u OPEN:__TEMP_NS_BIG__ TCP4:__ADDR__:10001 +ns socat -u OPEN:__BASEPATH__/big.bin TCP4:__ADDR__:10001 guestw -gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ] +guest cmp test_big.bin /root/big.bin test TCP/IPv4: host to guest: small transfer -set TEMP_SMALL __STATEDIR__/small.img guestb socat -u TCP4-LISTEN:10001 OPEN:test_small.bin,create,trunc -host dd if=/dev/urandom bs=2k count=100 of=__TEMP_SMALL__ sleep 1 -host socat -u OPEN:__TEMP_SMALL__ TCP4:127.0.0.1:10001 +host socat -u OPEN:__BASEPATH__/small.bin TCP4:127.0.0.1:10001 guestw -hout MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ] +guest cmp test_small.bin /root/small.bin test TCP/IPv4: host to ns: small transfer -set TEMP_NS_SMALL __STATEDIR__/small_ns.img nsb socat -u TCP4-LISTEN:10002 OPEN:__TEMP_NS_SMALL__,create,trunc sleep 1 -host socat -u OPEN:__TEMP_SMALL__ TCP4:127.0.0.1:10002 +host socat -u OPEN:__BASEPATH__/small.bin TCP4:127.0.0.1:10002 nsw -nsout NS_MD5_SMALL md5sum __TEMP_NS_SMALL__ | cut -d' ' -f1 -check [ "__NS_MD5_SMALL__" = "__MD5_SMALL__" ] +check cmp __TEMP_NS_SMALL__ __BASEPATH__/small.bin test TCP/IPv4: guest to host: small transfer hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc gout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway' sleep 1 -guest socat -u OPEN:test_small.bin TCP4:__GW__:10003 +guest socat -u OPEN:/root/small.bin TCP4:__GW__:10003 hostw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] +check cmp __TEMP_SMALL__ __BASEPATH__/small.bin test TCP/IPv4: guest to ns: small transfer -nsb socat -u TCP4-LISTEN:10002 OPEN:__TEMP_SMALL__,create,trunc +nsb socat -u TCP4-LISTEN:10002 OPEN:__TEMP_NS_SMALL__,create,trunc sleep 1 -guest socat -u OPEN:test_small.bin TCP4:__GW__:10002 +guest socat -u OPEN:/root/small.bin TCP4:__GW__:10002 nsw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] +check cmp __TEMP_NS_SMALL__ __BASEPATH__/small.bin test TCP/IPv4: ns to host (spliced): small transfer hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc sleep 1 -ns socat -u OPEN:__TEMP_NS_SMALL__ TCP4:127.0.0.1:10003 +ns socat -u OPEN:__BASEPATH__/small.bin TCP4:127.0.0.1:10003 hostw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] +check cmp __TEMP_SMALL__ __BASEPATH__/small.bin test TCP/IPv4: ns to host (via tap): small transfer hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc sleep 1 -ns socat -u OPEN:__TEMP_NS_SMALL__ TCP4:__GW__:10003 +ns socat -u OPEN:__BASEPATH__/small.bin TCP4:__GW__:10003 hostw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] +check cmp __TEMP_SMALL__ __BASEPATH__/small.bin test TCP/IPv4: ns to guest (using loopback address): small transfer guestb socat -u TCP4-LISTEN:10001 OPEN:test_small.bin,create,trunc sleep 1 -ns socat -u OPEN:__TEMP_NS_SMALL__ TCP4:127.0.0.1:10001 +ns socat -u OPEN:__BASEPATH__/small.bin TCP4:127.0.0.1:10001 guestw -gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ] +guest cmp test_small.bin /root/small.bin test TCP/IPv4: ns to guest (using namespace address): small transfer guestb socat -u TCP4-LISTEN:10001 OPEN:test_small.bin,create,trunc sleep 1 -ns socat -u OPEN:__TEMP_NS_SMALL__ TCP4:__ADDR__:10001 +ns socat -u OPEN:__BASEPATH__/small.bin TCP4:__ADDR__:10001 guestw -gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ] +guest cmp test_small.bin /root/small.bin test TCP/IPv6: host to guest: big transfer guestb socat -u TCP6-LISTEN:10001 OPEN:test_big.bin,create,trunc sleep 1 -host socat -u OPEN:__TEMP_BIG__ TCP6:[::1]:10001 +host socat -u OPEN:__BASEPATH__/big.bin TCP6:[::1]:10001 guestw -gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ] +guest cmp test_big.bin /root/big.bin test TCP/IPv6: host to ns: big transfer nsb socat -u TCP6-LISTEN:10002 OPEN:__TEMP_NS_BIG__,create,trunc sleep 1 -host socat -u OPEN:__TEMP_BIG__ TCP6:[::1]:10002 +host socat -u OPEN:__BASEPATH__/big.bin TCP6:[::1]:10002 nsw -nsout NS_MD5_BIG md5sum __TEMP_NS_BIG__ | cut -d' ' -f1 -check [ "__NS_MD5_BIG__" = "__MD5_BIG__" ] +check cmp __TEMP_NS_BIG__ __BASEPATH__/big.bin test TCP/IPv6: guest to host: big transfer hostb socat -u TCP6-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc gout GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway' gout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' sleep 1 -guest socat -u OPEN:test_big.bin TCP6:[__GW6__%__IFNAME__]:10003 +guest socat -u OPEN:/root/big.bin TCP6:[__GW6__%__IFNAME__]:10003 hostw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] +check cmp __TEMP_BIG__ __BASEPATH__/big.bin test TCP/IPv6: guest to ns: big transfer -nsb socat -u TCP6-LISTEN:10002 OPEN:__TEMP_BIG__,create,trunc +nsb socat -u TCP6-LISTEN:10002 OPEN:__TEMP_NS_BIG__,create,trunc sleep 1 -guest socat -u OPEN:test_big.bin TCP6:[__GW6__%__IFNAME__]:10002 +guest socat -u OPEN:/root/big.bin TCP6:[__GW6__%__IFNAME__]:10002 nsw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] +check cmp __TEMP_NS_BIG__ __BASEPATH__/big.bin test TCP/IPv6: ns to host (spliced): big transfer hostb socat -u TCP6-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc sleep 1 -ns socat -u OPEN:__TEMP_NS_BIG__ TCP6:[::1]:10003 +ns socat -u OPEN:__BASEPATH__/big.bin TCP6:[::1]:10003 hostw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] +check cmp __TEMP_BIG__ __BASEPATH__/big.bin test TCP/IPv6: ns to host (via tap): big transfer hostb socat -u TCP6-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' sleep 1 -ns socat -u OPEN:__TEMP_NS_BIG__ TCP6:[__GW6__%__IFNAME__]:10003 +ns socat -u OPEN:__BASEPATH__/big.bin TCP6:[__GW6__%__IFNAME__]:10003 hostw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] +check cmp __TEMP_BIG__ __BASEPATH__/big.bin test TCP/IPv6: ns to guest (using loopback address): big transfer guestb socat -u TCP6-LISTEN:10001 OPEN:test_big.bin,create,trunc sleep 1 -ns socat -u OPEN:__TEMP_NS_BIG__ TCP6:[::1]:10001 +ns socat -u OPEN:__BASEPATH__/big.bin TCP6:[::1]:10001 guestw -gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ] +guest cmp test_big.bin /root/big.bin test TCP/IPv6: ns to guest (using namespace address): big transfer guestb socat -u TCP6-LISTEN:10001 OPEN:test_big.bin,create,trunc nsout ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[0].local' sleep 1 -ns socat -u OPEN:__TEMP_NS_BIG__ TCP6:[__ADDR6__]:10001 +ns socat -u OPEN:__BASEPATH__/big.bin TCP6:[__ADDR6__]:10001 guestw -gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ] +guest cmp test_big.bin /root/big.bin test TCP/IPv6: host to guest: small transfer guestb socat -u TCP6-LISTEN:10001 OPEN:test_small.bin,create,trunc sleep 1 -host socat -u OPEN:__TEMP_SMALL__ TCP6:[::1]:10001 +host socat -u OPEN:__BASEPATH__/small.bin TCP6:[::1]:10001 guestw -gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ] +guest cmp test_small.bin /root/small.bin test TCP/IPv6: host to ns: small transfer nsb socat -u TCP6-LISTEN:10002 OPEN:__TEMP_NS_SMALL__,create,trunc sleep 1 -host socat -u OPEN:__TEMP_SMALL__ TCP6:[::1]:10002 +host socat -u OPEN:__BASEPATH__/small.bin TCP6:[::1]:10002 nsw -nsout NS_MD5_SMALL md5sum __TEMP_NS_SMALL__ | cut -d' ' -f1 -check [ "__NS_MD5_SMALL__" = "__MD5_SMALL__" ] +check cmp __TEMP_NS_SMALL__ __BASEPATH__/small.bin test TCP/IPv6: guest to host: small transfer hostb socat -u TCP6-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc gout GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway' gout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' sleep 1 -guest socat -u OPEN:test_small.bin TCP6:[__GW6__%__IFNAME__]:10003 +guest socat -u OPEN:/root/small.bin TCP6:[__GW6__%__IFNAME__]:10003 hostw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] +check cmp __TEMP_SMALL__ __BASEPATH__/small.bin test TCP/IPv6: guest to ns: small transfer -nsb socat -u TCP6-LISTEN:10002 OPEN:__TEMP_SMALL__ +nsb socat -u TCP6-LISTEN:10002 OPEN:__TEMP_NS_SMALL__ sleep 1 -guest socat -u OPEN:test_small.bin TCP6:[__GW6__%__IFNAME__]:10002 +guest socat -u OPEN:/root/small.bin TCP6:[__GW6__%__IFNAME__]:10002 nsw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] +check cmp __TEMP_NS_SMALL__ __BASEPATH__/small.bin test TCP/IPv6: ns to host (spliced): small transfer hostb socat -u TCP6-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc sleep 1 -ns socat -u OPEN:__TEMP_NS_SMALL__ TCP6:[::1]:10003 +ns socat -u OPEN:__BASEPATH__/small.bin TCP6:[::1]:10003 hostw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] +check cmp __TEMP_SMALL__ __BASEPATH__/small.bin test TCP/IPv6: ns to host (via tap): small transfer hostb socat -u TCP6-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' sleep 1 -ns socat -u OPEN:__TEMP_NS_SMALL__ TCP6:[__GW6__%__IFNAME__]:10003 +ns socat -u OPEN:__BASEPATH__/small.bin TCP6:[__GW6__%__IFNAME__]:10003 hostw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] +check cmp __TEMP_SMALL__ __BASEPATH__/small.bin test TCP/IPv6: ns to guest (using loopback address): small transfer guestb socat -u TCP6-LISTEN:10001 OPEN:test_small.bin,create,trunc sleep 1 -ns socat -u OPEN:__TEMP_NS_SMALL__ TCP6:[::1]:10001 +ns socat -u OPEN:__BASEPATH__/small.bin TCP6:[::1]:10001 guestw -gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ] +guest cmp test_small.bin /root/small.bin test TCP/IPv6: ns to guest (using namespace address): small transfer guestb socat -u TCP6-LISTEN:10001 OPEN:test_small.bin,create,trunc sleep 1 -ns socat -u OPEN:__TEMP_NS_SMALL__ TCP6:[__ADDR6__]:10001 +ns socat -u OPEN:__BASEPATH__/small.bin TCP6:[__ADDR6__]:10001 guestw -gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ] +guest cmp test_small.bin /root/small.bin diff --git a/test/passt_in_ns/udp b/test/passt_in_ns/udp index b7e9cf3..d9cd85a 100644 --- a/test/passt_in_ns/udp +++ b/test/passt_in_ns/udp @@ -11,145 +11,128 @@ # Copyright (c) 2021 Red Hat GmbH # Author: Stefano Brivio -gtools socat ip jq md5sum cut -nstools socat ip jq md5sum cut -htools dd socat ip jq md5sum cut +gtools socat ip jq +nstools socat ip jq +htools socat ip jq + +set TEMP __STATEDIR__/test.bin +set TEMP_NS __STATEDIR__/test_ns.bin test UDP/IPv4: host to guest -set TEMP __STATEDIR__/data guestb socat -u UDP4-LISTEN:10001,null-eof OPEN:test.bin,create,trunc -host dd if=/dev/urandom bs=1k count=5 > __TEMP__ sleep 1 -host socat -u OPEN:__TEMP__ UDP4:127.0.0.1:10001,shut-null +host socat -u OPEN:__BASEPATH__/medium.bin UDP4:127.0.0.1:10001,shut-null guestw -hout MD5 md5sum __TEMP__ | cut -d' ' -f1 -gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 -check [ "__GUEST_MD5__" = "__MD5__" ] +guest cmp test.bin /root/medium.bin test UDP/IPv4: host to ns -set TEMP_NS __STATEDIR__/data_ns nsb socat -u UDP4-LISTEN:10002,null-eof OPEN:__TEMP_NS__,create,trunc sleep 1 -host socat -u OPEN:__TEMP__ UDP4:127.0.0.1:10002,shut-null +host socat -u OPEN:__BASEPATH__/medium.bin UDP4:127.0.0.1:10002,shut-null nsw -nsout NS_MD5 md5sum __TEMP_NS__ | cut -d' ' -f1 -check [ "__NS_MD5__" = "__MD5__" ] +check cmp __TEMP_NS__ __BASEPATH__/medium.bin test UDP/IPv4: guest to host hostb socat -u UDP4-LISTEN:10003,null-eof OPEN:__TEMP__,create,trunc gout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway' sleep 1 -guest socat -u OPEN:test.bin UDP4:__GW__:10003,shut-null +guest socat -u OPEN:/root/medium.bin UDP4:__GW__:10003,shut-null hostw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__HOST_MD5__" = "__MD5__" ] +check cmp __TEMP__ __BASEPATH__/medium.bin test UDP/IPv4: guest to ns nsb socat -u UDP4-LISTEN:10002,null-eof OPEN:__TEMP_NS__,create,trunc sleep 1 -guest socat -u OPEN:test.bin UDP4:__GW__:10002,shut-null +guest socat -u OPEN:/root/medium.bin UDP4:__GW__:10002,shut-null nsw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__HOST_MD5__" = "__MD5__" ] +check cmp __TEMP_NS__ __BASEPATH__/medium.bin test UDP/IPv4: ns to host (recvmmsg/sendmmsg) hostb socat -u UDP4-LISTEN:10003,null-eof OPEN:__TEMP__,create,trunc sleep 1 -ns socat -u OPEN:__TEMP_NS__ UDP4:127.0.0.1:10003,shut-null +ns socat -u OPEN:__BASEPATH__/medium.bin UDP4:127.0.0.1:10003,shut-null hostw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__HOST_MD5__" = "__MD5__" ] +check cmp __TEMP__ __BASEPATH__/medium.bin test UDP/IPv4: ns to host (via tap) hostb socat -u UDP4-LISTEN:10003,null-eof OPEN:__TEMP__,create,trunc sleep 1 -ns socat -u OPEN:__TEMP_NS__ UDP4:__GW__:10003,shut-null +ns socat -u OPEN:__BASEPATH__/medium.bin UDP4:__GW__:10003,shut-null hostw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__HOST_MD5__" = "__MD5__" ] +check cmp __TEMP__ __BASEPATH__/medium.bin test UDP/IPv4: ns to guest (using loopback address) guestb socat -u UDP4-LISTEN:10001,null-eof OPEN:test.bin,create,trunc sleep 1 -ns socat -u OPEN:__TEMP_NS__ UDP4:127.0.0.1:10001,shut-null +ns socat -u OPEN:__BASEPATH__/medium.bin UDP4:127.0.0.1:10001,shut-null guestw -gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 -check [ "__GUEST_MD5__" = "__MD5__" ] +guest cmp test.bin /root/medium.bin test UDP/IPv4: ns to guest (using namespace address) guestb socat -u UDP4-LISTEN:10001,null-eof OPEN:test.bin,create,trunc nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' nsout ADDR ip -j -4 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[0].local' sleep 1 -ns socat -u OPEN:__TEMP_NS__ UDP4:__ADDR__:10001,shut-null +ns socat -u OPEN:__BASEPATH__/medium.bin UDP4:__ADDR__:10001,shut-null guestw -gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 -check [ "__GUEST_MD5__" = "__MD5__" ] +guest cmp test.bin /root/medium.bin test UDP/IPv6: host to guest guestb socat -u UDP6-LISTEN:10001,null-eof OPEN:test.bin,create,trunc sleep 1 -host socat -u OPEN:__TEMP__ UDP6:[::1]:10001,shut-null +host socat -u OPEN:__BASEPATH__/medium.bin UDP6:[::1]:10001,shut-null guestw -gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 -check [ "__GUEST_MD5__" = "__MD5__" ] +guest cmp test.bin /root/medium.bin test UDP/IPv6: host to ns nsb socat -u UDP6-LISTEN:10002,null-eof OPEN:__TEMP_NS__,create,trunc sleep 1 -host socat -u OPEN:__TEMP__ UDP6:[::1]:10002,shut-null +host socat -u OPEN:__BASEPATH__/medium.bin UDP6:[::1]:10002,shut-null nsw -nsout NS_MD5 md5sum __TEMP_NS__ | cut -d' ' -f1 -check [ "__NS_MD5__" = "__MD5__" ] +check cmp __TEMP_NS__ __BASEPATH__/medium.bin test UDP/IPv6: guest to host hostb socat -u UDP6-LISTEN:10003,null-eof OPEN:__TEMP__,create,trunc gout GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway' gout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' sleep 1 -guest socat -u OPEN:test.bin UDP6:[__GW6__%__IFNAME__]:10003,shut-null +guest socat -u OPEN:/root/medium.bin UDP6:[__GW6__%__IFNAME__]:10003,shut-null hostw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__HOST_MD5__" = "__MD5__" ] +check cmp __TEMP__ __BASEPATH__/medium.bin test UDP/IPv6: guest to ns nsb socat -u UDP6-LISTEN:10002,null-eof OPEN:__TEMP_NS__,create,trunc sleep 1 -guest socat -u OPEN:test.bin UDP6:[__GW6__%__IFNAME__]:10002,shut-null +guest socat -u OPEN:/root/medium.bin UDP6:[__GW6__%__IFNAME__]:10002,shut-null nsw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__HOST_MD5__" = "__MD5__" ] +check cmp __TEMP_NS__ __BASEPATH__/medium.bin test UDP/IPv6: ns to host (recvmmsg/sendmmsg) hostb socat -u UDP6-LISTEN:10003,null-eof OPEN:__TEMP__,create,trunc sleep 1 -ns socat -u OPEN:__TEMP_NS__ UDP6:[::1]:10003,shut-null +ns socat -u OPEN:__BASEPATH__/medium.bin UDP6:[::1]:10003,shut-null hostw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__HOST_MD5__" = "__MD5__" ] +check cmp __TEMP__ __BASEPATH__/medium.bin test UDP/IPv6: ns to host (via tap) hostb socat -u UDP6-LISTEN:10003,null-eof OPEN:__TEMP__,create,trunc nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' sleep 1 -ns socat -u OPEN:__TEMP_NS__ UDP6:[__GW6__%__IFNAME__]:10003,shut-null +ns socat -u OPEN:__BASEPATH__/medium.bin UDP6:[__GW6__%__IFNAME__]:10003,shut-null hostw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__HOST_MD5__" = "__MD5__" ] +check cmp __TEMP__ __BASEPATH__/medium.bin test UDP/IPv6: ns to guest (using loopback address) guestb socat -u UDP6-LISTEN:10001,null-eof OPEN:test.bin,create,trunc sleep 1 -ns socat -u OPEN:__TEMP_NS__ UDP6:[::1]:10001,shut-null +ns socat -u OPEN:__BASEPATH__/medium.bin UDP6:[::1]:10001,shut-null guestw -gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 -check [ "__GUEST_MD5__" = "__MD5__" ] +guest cmp test.bin /root/medium.bin test UDP/IPv6: ns to guest (using namespace address) guestb socat -u UDP6-LISTEN:10001,null-eof OPEN:test.bin,create,trunc nsout ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[0].local' sleep 1 -ns socat -u OPEN:__TEMP_NS__ UDP6:[__ADDR6__]:10001,shut-null +ns socat -u OPEN:__BASEPATH__/medium.bin UDP6:[__ADDR6__]:10001,shut-null guestw -gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 -check [ "__GUEST_MD5__" = "__MD5__" ] +guest cmp test.bin /root/medium.bin diff --git a/test/pasta/tcp b/test/pasta/tcp index d37e21c..eeda20b 100644 --- a/test/pasta/tcp +++ b/test/pasta/tcp @@ -11,103 +11,86 @@ # Copyright (c) 2021 Red Hat GmbH # Author: Stefano Brivio -htools dd socat ip jq md5sum cut -nstools socat ip jq md5sum cut +htools socat ip jq +nstools socat ip jq + +set TEMP_BIG __STATEDIR__/test_big.bin +set TEMP_NS_BIG __STATEDIR__/test_ns_big.bin +set TEMP_SMALL __STATEDIR__/test_small.bin +set TEMP_NS_SMALL __STATEDIR__/test_ns_small.bin test TCP/IPv4: host to ns: big transfer -set TEMP_BIG __STATEDIR__/big -set TEMP_NS_BIG __STATEDIR__/big_ns nsb socat -u TCP4-LISTEN:10002,bind=127.0.0.1 OPEN:__TEMP_NS_BIG__,create,trunc -host dd if=/dev/urandom bs=1M count=10 of=__TEMP_BIG__ -host socat -u OPEN:__TEMP_BIG__ TCP4:127.0.0.1:10002 +host socat -u OPEN:__BASEPATH__/big.bin TCP4:127.0.0.1:10002 nsw -hout MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -nsout NS_MD5_BIG md5sum __TEMP_NS_BIG__ | cut -d' ' -f1 -check [ "__NS_MD5_BIG__" = "__MD5_BIG__" ] +check cmp __BASEPATH__/big.bin __TEMP_NS_BIG__ test TCP/IPv4: ns to host (spliced): big transfer hostb socat -u TCP4-LISTEN:10003,bind=127.0.0.1 OPEN:__TEMP_BIG__,create,trunc -ns socat -u OPEN:__TEMP_NS_BIG__ TCP4:127.0.0.1:10003 +ns socat -u OPEN:__BASEPATH__/big.bin TCP4:127.0.0.1:10003 hostw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] +check cmp __BASEPATH__/big.bin __TEMP_BIG__ test TCP/IPv4: ns to host (via tap): big transfer hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc nsout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway' -ns socat -u OPEN:__TEMP_NS_BIG__ TCP4:__GW__:10003 +ns socat -u OPEN:__BASEPATH__/big.bin TCP4:__GW__:10003 hostw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] +check cmp __BASEPATH__/big.bin __TEMP_BIG__ test TCP/IPv4: host to ns: small transfer -set TEMP_SMALL __STATEDIR__/small -set TEMP_NS_SMALL __STATEDIR__/small_ns nsb socat -u TCP4-LISTEN:10002,bind=127.0.0.1 OPEN:__TEMP_NS_SMALL__,create,trunc -host dd if=/dev/urandom bs=2k count=1 of=__TEMP_SMALL__ -host socat OPEN:__TEMP_SMALL__ TCP4:127.0.0.1:10002 +host socat OPEN:__BASEPATH__/small.bin TCP4:127.0.0.1:10002 nsw -hout MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -nsout NS_MD5_SMALL md5sum __TEMP_NS_SMALL__ | cut -d' ' -f1 -check [ "__NS_MD5_SMALL__" = "__MD5_SMALL__" ] +check cmp __BASEPATH__/small.bin __TEMP_NS_SMALL__ test TCP/IPv4: ns to host (spliced): small transfer hostb socat -u TCP4-LISTEN:10003,bind=127.0.0.1 OPEN:__TEMP_SMALL__,create,trunc -ns socat OPEN:__TEMP_NS_SMALL__ TCP4:127.0.0.1:10003 +ns socat OPEN:__BASEPATH__/small.bin TCP4:127.0.0.1:10003 hostw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] +check cmp __BASEPATH__/small.bin __TEMP_SMALL__ test TCP/IPv4: ns to host (via tap): small transfer hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc nsout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway' -ns socat -u OPEN:__TEMP_NS_SMALL__ TCP4:__GW__:10003 +ns socat -u OPEN:__BASEPATH__/small.bin TCP4:__GW__:10003 hostw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] +check cmp __BASEPATH__/small.bin __TEMP_SMALL__ test TCP/IPv6: host to ns: big transfer nsb socat -u TCP6-LISTEN:10002,bind=[::1] OPEN:__TEMP_NS_BIG__,create,trunc -host socat -u OPEN:__TEMP_BIG__ TCP6:[::1]:10002 +host socat -u OPEN:__BASEPATH__/big.bin TCP6:[::1]:10002 nsw -hout MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -nsout NS_MD5_BIG md5sum __TEMP_NS_BIG__ | cut -d' ' -f1 -check [ "__NS_MD5_BIG__" = "__MD5_BIG__" ] +check cmp __BASEPATH__/big.bin __TEMP_NS_BIG__ test TCP/IPv6: ns to host (spliced): big transfer hostb socat -u TCP6-LISTEN:10003,bind=[::1] OPEN:__TEMP_BIG__,create,trunc -ns socat -u OPEN:__TEMP_NS_BIG__ TCP6:[::1]:10003 +ns socat -u OPEN:__BASEPATH__/big.bin TCP6:[::1]:10003 hostw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] +check cmp __BASEPATH__/big.bin __TEMP_BIG__ test TCP/IPv6: ns to host (via tap): big transfer hostb socat -u TCP6-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc nsout GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway' nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' -ns socat -u OPEN:__TEMP_NS_BIG__ TCP6:[__GW6__%__IFNAME__]:10003 +ns socat -u OPEN:__BASEPATH__/big.bin TCP6:[__GW6__%__IFNAME__]:10003 hostw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] +check cmp __BASEPATH__/big.bin __TEMP_BIG__ test TCP/IPv6: host to ns: small transfer nsb socat -u TCP6-LISTEN:10002,bind=[::1] OPEN:__TEMP_NS_SMALL__,create,trunc -host socat -u OPEN:__TEMP_SMALL__ TCP6:[::1]:10002 +host socat -u OPEN:__BASEPATH__/small.bin TCP6:[::1]:10002 nsw -hout MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -nsout NS_MD5_SMALL md5sum __TEMP_NS_SMALL__ | cut -d' ' -f1 -check [ "__NS_MD5_SMALL__" = "__MD5_SMALL__" ] +check cmp __BASEPATH__/small.bin __TEMP_NS_SMALL__ test TCP/IPv6: ns to host (spliced): small transfer hostb socat -u TCP6-LISTEN:10003,bind=[::1] OPEN:__TEMP_SMALL__,create,trunc -ns socat -u OPEN:__TEMP_NS_SMALL__ TCP6:[::1]:10003 +ns socat -u OPEN:__BASEPATH__/small.bin TCP6:[::1]:10003 hostw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] +check cmp __BASEPATH__/small.bin __TEMP_SMALL__ test TCP/IPv6: ns to host (via tap): small transfer hostb socat -u TCP6-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc -ns socat -u OPEN:__TEMP_NS_SMALL__ TCP6:[__GW6__%__IFNAME__]:10003 +ns socat -u OPEN:__BASEPATH__/small.bin TCP6:[__GW6__%__IFNAME__]:10003 hostw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] +check cmp __BASEPATH__/small.bin __TEMP_SMALL__ diff --git a/test/pasta/udp b/test/pasta/udp index fc6bf0a..c8ff418 100644 --- a/test/pasta/udp +++ b/test/pasta/udp @@ -11,58 +11,49 @@ # Copyright (c) 2021 Red Hat GmbH # Author: Stefano Brivio -nstools socat ip jq md5sum cut -htools dd socat ip jq md5sum cut +nstools socat ip jq +htools dd socat ip jq + +set TEMP __STATEDIR__/test.bin +set TEMP_NS __STATEDIR__/test_ns.bin test UDP/IPv4: host to ns -set TEMP __STATEDIR__/data -set TEMP_NS __STATEDIR__/data_ns nsb socat -u UDP4-LISTEN:10002,bind=127.0.0.1,null-eof OPEN:__TEMP_NS__,create,trunc -host dd if=/dev/urandom bs=1k count=5 > __TEMP__ - -host socat OPEN:__TEMP__ UDP4:127.0.0.1:10002,shut-null +host socat OPEN:__BASEPATH__/medium.bin UDP4:127.0.0.1:10002,shut-null nsw -hout MD5 md5sum __TEMP__ | cut -d' ' -f1 -nsout NS_MD5 md5sum __TEMP_NS__ | cut -d' ' -f1 -check [ "__NS_MD5__" = "__MD5__" ] +check cmp __BASEPATH__/medium.bin __TEMP_NS__ test UDP/IPv4: ns to host (recvmmsg/sendmmsg) hostb socat -u UDP4-LISTEN:10003,bind=127.0.0.1,null-eof OPEN:__TEMP__,create,trunc sleep 1 -ns socat OPEN:__TEMP_NS__ UDP4:127.0.0.1:10003,shut-null +ns socat OPEN:__BASEPATH__/medium.bin UDP4:127.0.0.1:10003,shut-null hostw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__HOST_MD5__" = "__MD5__" ] +check cmp __BASEPATH__/medium.bin __TEMP__ test UDP/IPv4: ns to host (via tap) hostb socat -u UDP4-LISTEN:10003,null-eof OPEN:__TEMP__,create,trunc nsout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway' -ns socat -u OPEN:__TEMP_NS__ UDP4:__GW__:10003,shut-null +ns socat -u OPEN:__BASEPATH__/medium.bin UDP4:__GW__:10003,shut-null hostw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__HOST_MD5__" = "__MD5__" ] +check cmp __BASEPATH__/medium.bin __TEMP__ test UDP/IPv6: host to ns nsb socat -u UDP6-LISTEN:10002,bind=[::1],null-eof OPEN:__TEMP_NS__,create,trunc -host socat -u OPEN:__TEMP__ UDP6:[::1]:10002,shut-null +host socat -u OPEN:__BASEPATH__/medium.bin UDP6:[::1]:10002,shut-null nsw -hout MD5 md5sum __TEMP__ | cut -d' ' -f1 -nsout NS_MD5 md5sum __TEMP_NS__ | cut -d' ' -f1 -check [ "__NS_MD5__" = "__MD5__" ] +check cmp __BASEPATH__/medium.bin __TEMP_NS__ test UDP/IPv6: ns to host (recvmmsg/sendmmsg) hostb socat -u UDP6-LISTEN:10003,bind=[::1],null-eof OPEN:__TEMP__,create,trunc sleep 1 -ns socat -u OPEN:__TEMP_NS__ UDP6:[::1]:10003,shut-null +ns socat -u OPEN:__BASEPATH__/medium.bin UDP6:[::1]:10003,shut-null hostw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__HOST_MD5__" = "__MD5__" ] +check cmp __BASEPATH__/medium.bin __TEMP__ test UDP/IPv6: ns to host (via tap) hostb socat -u UDP6-LISTEN:10003,null-eof OPEN:__TEMP__,create,trunc nsout GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway' nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' -ns socat -u OPEN:__TEMP_NS__ UDP6:[__GW6__%__IFNAME__]:10003,shut-null +ns socat -u OPEN:__BASEPATH__/medium.bin UDP6:[__GW6__%__IFNAME__]:10003,shut-null hostw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__HOST_MD5__" = "__MD5__" ] +check cmp __BASEPATH__/medium.bin __TEMP__ diff --git a/test/two_guests/basic b/test/two_guests/basic index e226178..dba4b9e 100644 --- a/test/two_guests/basic +++ b/test/two_guests/basic @@ -13,7 +13,7 @@ g1tools ip jq dhclient socat cat g2tools ip jq dhclient socat cat -htools ip jq md5sum cut +htools ip jq test Interface names g1out IFNAME1 ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'