1
0
mirror of https://passt.top/passt synced 2024-12-22 21:55:22 +00:00

test: Simplify data handling for transfer tests

Many of our tests are based around performing transfers of sample data
across passt/pasta created links.  The data flow here can be a bit
hard to follow since, e.g. we create a file transfer it to the guest,
then transfer it back to the host across several different tests.
This also means that the test cases aren't independent of each other.

Because we don't have the original file available at both ends in some
cases, we compare them by generating md5sums at each end and comparing
them, which is a bit complicated.

Make a number of changes to simplify this:
  1. Pre-generate the sample data files as a test asset, rather than
     building them on the fly during the tests proper
  2. Include the sample data files in the mbuto guest image
  3. Because we have good copies of the original data available in all
     contexts, we can now simply use 'cmp' to check if the transfer
     has worked, avoiding md5sum complications.
  4. Similarly we can always use the original copy of the sample data
     on the send side of each transfer, meaning that the tests become
     more independent of each other.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
David Gibson 2022-09-26 20:43:40 +10:00 committed by Stefano Brivio
parent 0a15b467d4
commit feb8946ff5
10 changed files with 214 additions and 294 deletions

1
test/.gitignore vendored
View File

@ -5,6 +5,7 @@ QEMU_EFI.fd
*.qcow2 *.qcow2
*.raw *.raw
*.raw.xz *.raw.xz
*.bin
nsholder nsholder
guest-key guest-key
guest-key.pub guest-key.pub

View File

@ -54,10 +54,12 @@ UBUNTU_IMGS = $(UBUNTU_OLD_IMGS) $(UBUNTU_NEW_IMGS)
DOWNLOAD_ASSETS = mbuto \ DOWNLOAD_ASSETS = mbuto \
$(DEBIAN_IMGS) $(FEDORA_IMGS) $(OPENSUSE_IMGS) $(UBUNTU_IMGS) $(DEBIAN_IMGS) $(FEDORA_IMGS) $(OPENSUSE_IMGS) $(UBUNTU_IMGS)
TESTDATA_ASSETS = small.bin big.bin medium.bin
LOCAL_ASSETS = mbuto.img QEMU_EFI.fd \ LOCAL_ASSETS = mbuto.img QEMU_EFI.fd \
$(DEBIAN_IMGS:%=prepared-%) $(FEDORA_IMGS:%=prepared-%) \ $(DEBIAN_IMGS:%=prepared-%) $(FEDORA_IMGS:%=prepared-%) \
$(UBUNTU_NEW_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) ASSETS = $(DOWNLOAD_ASSETS) $(LOCAL_ASSETS)
@ -71,7 +73,7 @@ mbuto:
guest-key guest-key.pub: guest-key guest-key.pub:
ssh-keygen -f guest-key -N '' 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 $@ ./mbuto/mbuto -p ./$< -c lz4 -f $@
nsholder: nsholder.c nsholder: nsholder.c
@ -88,6 +90,15 @@ prepared-%.img: %.img ./prepare-distro-img.sh
qemu-img create -f qcow2 -F qcow2 -b $< $@ qemu-img create -f qcow2 -F qcow2 -b $< $@
./prepare-distro-img.sh $(IMGTYPE) $@ ./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 check: assets
./run ./run

View File

@ -12,8 +12,8 @@
PROGS="${PROGS:-ash,dash,bash ip mount ls insmod mkdir ln cat chmod lsmod 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 modprobe find grep mknod mv rm umount jq iperf3 dhclient hostname
sed tr chown sipcalc cut md5sum socat dd strace ping tail killall sleep sed tr chown sipcalc cut socat dd strace ping tail killall sleep sysctl
sysctl nproc tcp_rr tcp_crr udp_rr which tee seq bc sshd ssh-keygen}" 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}" 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" 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}"' FIXUP="${FIXUP}"'
cat > /sbin/dhclient-script << EOF cat > /sbin/dhclient-script << EOF
#!/bin/sh #!/bin/sh

View File

@ -11,77 +11,66 @@
# Copyright (c) 2021 Red Hat GmbH # Copyright (c) 2021 Red Hat GmbH
# Author: Stefano Brivio <sbrivio@redhat.com> # Author: Stefano Brivio <sbrivio@redhat.com>
gtools socat ip jq md5sum cut gtools socat ip jq cmp
htools dd socat ip jq md5sum cut 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 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 guestb socat -u TCP4-LISTEN:10001,reuseaddr OPEN:test_big.bin,create,trunc
sleep 1 sleep 1
host dd if=/dev/urandom bs=1M count=10 > __TEMP_BIG__ host socat -u OPEN:__BASEPATH__/big.bin TCP4:127.0.0.1:10001
host socat -u OPEN:__TEMP_BIG__ TCP4:127.0.0.1:10001
guestw guestw
hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 guest cmp /root/big.bin test_big.bin
gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1
check [ "__GUEST_MD5_BIG__" = "__HOST_MD5_BIG__" ]
test TCP/IPv4: guest to host: big transfer 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 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' 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 hostw
hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 check cmp __BASEPATH__/big.bin __TEMP_BIG__
check [ "__GUEST_MD5_BIG__" = "__HOST_MD5_BIG__" ]
test TCP/IPv4: host to guest: small transfer 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 guestb socat -u TCP4-LISTEN:10001,reuseaddr OPEN:test_small.bin,create,trunc
sleep 1 sleep 1
host dd if=/dev/urandom bs=2k count=1 > __TEMP_SMALL__ host socat -u OPEN:__BASEPATH__/small.bin TCP4:127.0.0.1:10001
host socat -u OPEN:__TEMP_SMALL__ TCP4:127.0.0.1:10001
guestw guestw
hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 guest cmp /root/small.bin test_small.bin
gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1
check [ "__GUEST_MD5_SMALL__" = "__HOST_MD5_SMALL__" ]
test TCP/IPv4: guest to host: small transfer 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 hostb socat -u TCP4-LISTEN:10003,bind=127.0.0.1,reuseaddr OPEN:__TEMP_SMALL__,create,trunc
sleep 1 sleep 1
guest socat -u OPEN:test_small.bin TCP4:__GW__:10003 guest socat -u OPEN:/root/small.bin TCP4:__GW__:10003
hostw hostw
hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 check cmp __BASEPATH__/small.bin __TEMP_SMALL__
check [ "__GUEST_MD5_SMALL__" = "__HOST_MD5_SMALL__" ]
test TCP/IPv6: host to guest: big transfer test TCP/IPv6: host to guest: big transfer
guestb socat -u TCP6-LISTEN:10001,reuseaddr OPEN:test_big.bin,create,trunc guestb socat -u TCP6-LISTEN:10001,reuseaddr OPEN:test_big.bin,create,trunc
sleep 1 sleep 1
host socat -u OPEN:__TEMP_BIG__ TCP6:[::1]:10001 host socat -u OPEN:__BASEPATH__/big.bin TCP6:[::1]:10001
guestw guestw
gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 guest cmp /root/big.bin test_big.bin
check [ "__GUEST_MD5_BIG__" = "__HOST_MD5_BIG__" ]
test TCP/IPv6: guest to host: big transfer test TCP/IPv6: guest to host: big transfer
hostb socat -u TCP6-LISTEN:10003,bind=[::1],reuseaddr OPEN:__TEMP_BIG__,create,trunc 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 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' 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 hostw
hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 check cmp __BASEPATH__/big.bin __TEMP_BIG__
check [ "__GUEST_MD5_BIG__" = "__HOST_MD5_BIG__" ]
test TCP/IPv6: host to guest: small transfer test TCP/IPv6: host to guest: small transfer
guestb socat -u TCP6-LISTEN:10001,reuseaddr OPEN:test_small.bin,create,trunc guestb socat -u TCP6-LISTEN:10001,reuseaddr OPEN:test_small.bin,create,trunc
sleep 1 sleep 1
host socat -u OPEN:__TEMP_SMALL__ TCP6:[::1]:10001 host socat -u OPEN:__BASEPATH__/small.bin TCP6:[::1]:10001
guestw guestw
gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 guest cmp /root/small.bin test_small.bin
check [ "__GUEST_MD5_SMALL__" = "__HOST_MD5_SMALL__" ]
test TCP/IPv6: guest to host: small transfer test TCP/IPv6: guest to host: small transfer
hostb socat -u TCP6-LISTEN:10003,bind=[::1],reuseaddr OPEN:__TEMP_SMALL__,create,trunc hostb socat -u TCP6-LISTEN:10003,bind=[::1],reuseaddr OPEN:__TEMP_SMALL__,create,trunc
sleep 1 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 hostw
hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 check cmp __BASEPATH__/small.bin __TEMP_SMALL__
check [ "__GUEST_MD5_SMALL__" = "__HOST_MD5_SMALL__" ]

View File

@ -11,41 +11,36 @@
# Copyright (c) 2021 Red Hat GmbH # Copyright (c) 2021 Red Hat GmbH
# Author: Stefano Brivio <sbrivio@redhat.com> # Author: Stefano Brivio <sbrivio@redhat.com>
gtools socat ip jq md5sum cut gtools socat ip jq cmp
htools dd socat jq md5sum cut htools socat jq
set TEMP __STATEDIR__/test.bin
test UDP/IPv4: host to guest test UDP/IPv4: host to guest
set TEMP __STATEDIR__/data
guestb socat -u UDP4-LISTEN:10001,null-eof OPEN:test.bin,create,trunc guestb socat -u UDP4-LISTEN:10001,null-eof OPEN:test.bin,create,trunc
sleep 1 sleep 1
host dd if=/dev/urandom bs=1k count=5 > __TEMP__ host socat -u OPEN:__BASEPATH__/medium.bin UDP4:127.0.0.1:10001,shut-null
host socat -u OPEN:__TEMP__ UDP4:127.0.0.1:10001,shut-null
guestw guestw
hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 guest cmp /root/medium.bin test.bin
gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1
check [ "__GUEST_MD5__" = "__HOST_MD5__" ]
test UDP/IPv4: guest to host test UDP/IPv4: guest to host
hostb socat -u UDP4-LISTEN:10003,bind=127.0.0.1,null-eof OPEN:__TEMP__,create,trunc 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' 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 hostw
hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 check cmp __BASEPATH__/medium.bin __TEMP__
check [ "__GUEST_MD5__" = "__HOST_MD5__" ]
test UDP/IPv6: host to guest test UDP/IPv6: host to guest
guestb socat -u UDP6-LISTEN:10001,null-eof OPEN:test.bin,create,trunc guestb socat -u UDP6-LISTEN:10001,null-eof OPEN:test.bin,create,trunc
sleep 1 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 guestw
gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 guest cmp /root/medium.bin test.bin
check [ "__GUEST_MD5__" = "__HOST_MD5__" ]
test UDP/IPv6: guest to host test UDP/IPv6: guest to host
hostb socat -u UDP6-LISTEN:10003,bind=[::1],null-eof OPEN:__TEMP__,create,trunc 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 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' 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 hostw
hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 check cmp __BASEPATH__/medium.bin __TEMP__
check [ "__GUEST_MD5__" = "__HOST_MD5__" ]

View File

@ -11,281 +11,246 @@
# Copyright (c) 2021 Red Hat GmbH # Copyright (c) 2021 Red Hat GmbH
# Author: Stefano Brivio <sbrivio@redhat.com> # Author: Stefano Brivio <sbrivio@redhat.com>
gtools socat ip jq md5sum cut gtools socat ip jq
htools dd socat ip jq md5sum cut htools socat ip jq
nstools socat ip jq md5sum cut 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 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 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 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 guestw
hout MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 guest cmp test_big.bin /root/big.bin
gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1
check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv4: host to ns: big transfer 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 nsb socat -u TCP4-LISTEN:10002 OPEN:__TEMP_NS_BIG__,create,trunc
sleep 1 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 nsw
nsout NS_MD5_BIG md5sum __TEMP_NS_BIG__ | cut -d' ' -f1 check cmp __TEMP_NS_BIG__ __BASEPATH__/big.bin
check [ "__NS_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv4: guest to host: big transfer test TCP/IPv4: guest to host: big transfer
hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc
gout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway' gout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
sleep 1 sleep 1
guest socat -u OPEN:test_big.bin TCP4:__GW__:10003 guest socat -u OPEN:/root/big.bin TCP4:__GW__:10003
hostw hostw
hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 check cmp __TEMP_BIG__ __BASEPATH__/big.bin
check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv4: guest to ns: big transfer 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 sleep 1
guest socat -u OPEN:test_big.bin TCP4:__GW__:10002 guest socat -u OPEN:/root/big.bin TCP4:__GW__:10002
nsw nsw
hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 check cmp __TEMP_NS_BIG__ __BASEPATH__/big.bin
check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv4: ns to host (spliced): big transfer test TCP/IPv4: ns to host (spliced): big transfer
hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc
sleep 1 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 hostw
hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 check cmp __TEMP_BIG__ __BASEPATH__/big.bin
check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv4: ns to host (via tap): big transfer test TCP/IPv4: ns to host (via tap): big transfer
hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc
sleep 1 sleep 1
ns socat -u OPEN:__TEMP_NS_BIG__ TCP4:__GW__:10003 ns socat -u OPEN:__BASEPATH__/big.bin TCP4:__GW__:10003
hostw hostw
hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 check cmp __TEMP_BIG__ __BASEPATH__/big.bin
check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv4: ns to guest (using loopback address): big transfer test TCP/IPv4: ns to guest (using loopback address): big transfer
guestb socat -u TCP4-LISTEN:10001 OPEN:test_big.bin,create,trunc guestb socat -u TCP4-LISTEN:10001 OPEN:test_big.bin,create,trunc
sleep 1 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 guestw
gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 guest cmp test_big.bin /root/big.bin
check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv4: ns to guest (using namespace address): big transfer test TCP/IPv4: ns to guest (using namespace address): big transfer
guestb socat -u TCP4-LISTEN:10001 OPEN:test_big.bin,create,trunc 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 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' nsout ADDR ip -j -4 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[0].local'
sleep 1 sleep 1
ns socat -u OPEN:__TEMP_NS_BIG__ TCP4:__ADDR__:10001 ns socat -u OPEN:__BASEPATH__/big.bin TCP4:__ADDR__:10001
guestw guestw
gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 guest cmp test_big.bin /root/big.bin
check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv4: host to guest: small transfer 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 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 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 guestw
hout MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 guest cmp test_small.bin /root/small.bin
gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1
check [ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ]
test TCP/IPv4: host to ns: small transfer 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 nsb socat -u TCP4-LISTEN:10002 OPEN:__TEMP_NS_SMALL__,create,trunc
sleep 1 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 nsw
nsout NS_MD5_SMALL md5sum __TEMP_NS_SMALL__ | cut -d' ' -f1 check cmp __TEMP_NS_SMALL__ __BASEPATH__/small.bin
check [ "__NS_MD5_SMALL__" = "__MD5_SMALL__" ]
test TCP/IPv4: guest to host: small transfer test TCP/IPv4: guest to host: small transfer
hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc
gout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway' gout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
sleep 1 sleep 1
guest socat -u OPEN:test_small.bin TCP4:__GW__:10003 guest socat -u OPEN:/root/small.bin TCP4:__GW__:10003
hostw hostw
hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 check cmp __TEMP_SMALL__ __BASEPATH__/small.bin
check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ]
test TCP/IPv4: guest to ns: small transfer 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 sleep 1
guest socat -u OPEN:test_small.bin TCP4:__GW__:10002 guest socat -u OPEN:/root/small.bin TCP4:__GW__:10002
nsw nsw
hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 check cmp __TEMP_NS_SMALL__ __BASEPATH__/small.bin
check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ]
test TCP/IPv4: ns to host (spliced): small transfer test TCP/IPv4: ns to host (spliced): small transfer
hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc
sleep 1 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 hostw
hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 check cmp __TEMP_SMALL__ __BASEPATH__/small.bin
check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ]
test TCP/IPv4: ns to host (via tap): small transfer test TCP/IPv4: ns to host (via tap): small transfer
hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc
sleep 1 sleep 1
ns socat -u OPEN:__TEMP_NS_SMALL__ TCP4:__GW__:10003 ns socat -u OPEN:__BASEPATH__/small.bin TCP4:__GW__:10003
hostw hostw
hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 check cmp __TEMP_SMALL__ __BASEPATH__/small.bin
check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ]
test TCP/IPv4: ns to guest (using loopback address): small transfer test TCP/IPv4: ns to guest (using loopback address): small transfer
guestb socat -u TCP4-LISTEN:10001 OPEN:test_small.bin,create,trunc guestb socat -u TCP4-LISTEN:10001 OPEN:test_small.bin,create,trunc
sleep 1 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 guestw
gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 guest cmp test_small.bin /root/small.bin
check [ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ]
test TCP/IPv4: ns to guest (using namespace address): small transfer test TCP/IPv4: ns to guest (using namespace address): small transfer
guestb socat -u TCP4-LISTEN:10001 OPEN:test_small.bin,create,trunc guestb socat -u TCP4-LISTEN:10001 OPEN:test_small.bin,create,trunc
sleep 1 sleep 1
ns socat -u OPEN:__TEMP_NS_SMALL__ TCP4:__ADDR__:10001 ns socat -u OPEN:__BASEPATH__/small.bin TCP4:__ADDR__:10001
guestw guestw
gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 guest cmp test_small.bin /root/small.bin
check [ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ]
test TCP/IPv6: host to guest: big transfer test TCP/IPv6: host to guest: big transfer
guestb socat -u TCP6-LISTEN:10001 OPEN:test_big.bin,create,trunc guestb socat -u TCP6-LISTEN:10001 OPEN:test_big.bin,create,trunc
sleep 1 sleep 1
host socat -u OPEN:__TEMP_BIG__ TCP6:[::1]:10001 host socat -u OPEN:__BASEPATH__/big.bin TCP6:[::1]:10001
guestw guestw
gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 guest cmp test_big.bin /root/big.bin
check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv6: host to ns: big transfer test TCP/IPv6: host to ns: big transfer
nsb socat -u TCP6-LISTEN:10002 OPEN:__TEMP_NS_BIG__,create,trunc nsb socat -u TCP6-LISTEN:10002 OPEN:__TEMP_NS_BIG__,create,trunc
sleep 1 sleep 1
host socat -u OPEN:__TEMP_BIG__ TCP6:[::1]:10002 host socat -u OPEN:__BASEPATH__/big.bin TCP6:[::1]:10002
nsw nsw
nsout NS_MD5_BIG md5sum __TEMP_NS_BIG__ | cut -d' ' -f1 check cmp __TEMP_NS_BIG__ __BASEPATH__/big.bin
check [ "__NS_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv6: guest to host: big transfer test TCP/IPv6: guest to host: big transfer
hostb socat -u TCP6-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc 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 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' gout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'
sleep 1 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 hostw
hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 check cmp __TEMP_BIG__ __BASEPATH__/big.bin
check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv6: guest to ns: big transfer 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 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 nsw
hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 check cmp __TEMP_NS_BIG__ __BASEPATH__/big.bin
check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv6: ns to host (spliced): big transfer test TCP/IPv6: ns to host (spliced): big transfer
hostb socat -u TCP6-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc hostb socat -u TCP6-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc
sleep 1 sleep 1
ns socat -u OPEN:__TEMP_NS_BIG__ TCP6:[::1]:10003 ns socat -u OPEN:__BASEPATH__/big.bin TCP6:[::1]:10003
hostw hostw
hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 check cmp __TEMP_BIG__ __BASEPATH__/big.bin
check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv6: ns to host (via tap): big transfer test TCP/IPv6: ns to host (via tap): big transfer
hostb socat -u TCP6-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc hostb socat -u TCP6-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc
nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'
sleep 1 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 hostw
hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 check cmp __TEMP_BIG__ __BASEPATH__/big.bin
check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv6: ns to guest (using loopback address): big transfer test TCP/IPv6: ns to guest (using loopback address): big transfer
guestb socat -u TCP6-LISTEN:10001 OPEN:test_big.bin,create,trunc guestb socat -u TCP6-LISTEN:10001 OPEN:test_big.bin,create,trunc
sleep 1 sleep 1
ns socat -u OPEN:__TEMP_NS_BIG__ TCP6:[::1]:10001 ns socat -u OPEN:__BASEPATH__/big.bin TCP6:[::1]:10001
guestw guestw
gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 guest cmp test_big.bin /root/big.bin
check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv6: ns to guest (using namespace address): big transfer test TCP/IPv6: ns to guest (using namespace address): big transfer
guestb socat -u TCP6-LISTEN:10001 OPEN:test_big.bin,create,trunc 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' nsout ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[0].local'
sleep 1 sleep 1
ns socat -u OPEN:__TEMP_NS_BIG__ TCP6:[__ADDR6__]:10001 ns socat -u OPEN:__BASEPATH__/big.bin TCP6:[__ADDR6__]:10001
guestw guestw
gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 guest cmp test_big.bin /root/big.bin
check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv6: host to guest: small transfer test TCP/IPv6: host to guest: small transfer
guestb socat -u TCP6-LISTEN:10001 OPEN:test_small.bin,create,trunc guestb socat -u TCP6-LISTEN:10001 OPEN:test_small.bin,create,trunc
sleep 1 sleep 1
host socat -u OPEN:__TEMP_SMALL__ TCP6:[::1]:10001 host socat -u OPEN:__BASEPATH__/small.bin TCP6:[::1]:10001
guestw guestw
gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 guest cmp test_small.bin /root/small.bin
check [ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ]
test TCP/IPv6: host to ns: small transfer test TCP/IPv6: host to ns: small transfer
nsb socat -u TCP6-LISTEN:10002 OPEN:__TEMP_NS_SMALL__,create,trunc nsb socat -u TCP6-LISTEN:10002 OPEN:__TEMP_NS_SMALL__,create,trunc
sleep 1 sleep 1
host socat -u OPEN:__TEMP_SMALL__ TCP6:[::1]:10002 host socat -u OPEN:__BASEPATH__/small.bin TCP6:[::1]:10002
nsw nsw
nsout NS_MD5_SMALL md5sum __TEMP_NS_SMALL__ | cut -d' ' -f1 check cmp __TEMP_NS_SMALL__ __BASEPATH__/small.bin
check [ "__NS_MD5_SMALL__" = "__MD5_SMALL__" ]
test TCP/IPv6: guest to host: small transfer test TCP/IPv6: guest to host: small transfer
hostb socat -u TCP6-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc 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 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' gout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'
sleep 1 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 hostw
hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 check cmp __TEMP_SMALL__ __BASEPATH__/small.bin
check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ]
test TCP/IPv6: guest to ns: small transfer 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 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 nsw
hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 check cmp __TEMP_NS_SMALL__ __BASEPATH__/small.bin
check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ]
test TCP/IPv6: ns to host (spliced): small transfer test TCP/IPv6: ns to host (spliced): small transfer
hostb socat -u TCP6-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc hostb socat -u TCP6-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc
sleep 1 sleep 1
ns socat -u OPEN:__TEMP_NS_SMALL__ TCP6:[::1]:10003 ns socat -u OPEN:__BASEPATH__/small.bin TCP6:[::1]:10003
hostw hostw
hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 check cmp __TEMP_SMALL__ __BASEPATH__/small.bin
check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ]
test TCP/IPv6: ns to host (via tap): small transfer test TCP/IPv6: ns to host (via tap): small transfer
hostb socat -u TCP6-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc hostb socat -u TCP6-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc
nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'
sleep 1 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 hostw
hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 check cmp __TEMP_SMALL__ __BASEPATH__/small.bin
check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ]
test TCP/IPv6: ns to guest (using loopback address): small transfer test TCP/IPv6: ns to guest (using loopback address): small transfer
guestb socat -u TCP6-LISTEN:10001 OPEN:test_small.bin,create,trunc guestb socat -u TCP6-LISTEN:10001 OPEN:test_small.bin,create,trunc
sleep 1 sleep 1
ns socat -u OPEN:__TEMP_NS_SMALL__ TCP6:[::1]:10001 ns socat -u OPEN:__BASEPATH__/small.bin TCP6:[::1]:10001
guestw guestw
gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 guest cmp test_small.bin /root/small.bin
check [ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ]
test TCP/IPv6: ns to guest (using namespace address): small transfer test TCP/IPv6: ns to guest (using namespace address): small transfer
guestb socat -u TCP6-LISTEN:10001 OPEN:test_small.bin,create,trunc guestb socat -u TCP6-LISTEN:10001 OPEN:test_small.bin,create,trunc
sleep 1 sleep 1
ns socat -u OPEN:__TEMP_NS_SMALL__ TCP6:[__ADDR6__]:10001 ns socat -u OPEN:__BASEPATH__/small.bin TCP6:[__ADDR6__]:10001
guestw guestw
gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 guest cmp test_small.bin /root/small.bin
check [ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ]

View File

@ -11,145 +11,128 @@
# Copyright (c) 2021 Red Hat GmbH # Copyright (c) 2021 Red Hat GmbH
# Author: Stefano Brivio <sbrivio@redhat.com> # Author: Stefano Brivio <sbrivio@redhat.com>
gtools socat ip jq md5sum cut gtools socat ip jq
nstools socat ip jq md5sum cut nstools socat ip jq
htools dd socat ip jq md5sum cut htools socat ip jq
set TEMP __STATEDIR__/test.bin
set TEMP_NS __STATEDIR__/test_ns.bin
test UDP/IPv4: host to guest test UDP/IPv4: host to guest
set TEMP __STATEDIR__/data
guestb socat -u UDP4-LISTEN:10001,null-eof OPEN:test.bin,create,trunc 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 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 guestw
hout MD5 md5sum __TEMP__ | cut -d' ' -f1 guest cmp test.bin /root/medium.bin
gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1
check [ "__GUEST_MD5__" = "__MD5__" ]
test UDP/IPv4: host to ns 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 nsb socat -u UDP4-LISTEN:10002,null-eof OPEN:__TEMP_NS__,create,trunc
sleep 1 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 nsw
nsout NS_MD5 md5sum __TEMP_NS__ | cut -d' ' -f1 check cmp __TEMP_NS__ __BASEPATH__/medium.bin
check [ "__NS_MD5__" = "__MD5__" ]
test UDP/IPv4: guest to host test UDP/IPv4: guest to host
hostb socat -u UDP4-LISTEN:10003,null-eof OPEN:__TEMP__,create,trunc 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' gout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
sleep 1 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 hostw
hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 check cmp __TEMP__ __BASEPATH__/medium.bin
check [ "__HOST_MD5__" = "__MD5__" ]
test UDP/IPv4: guest to ns test UDP/IPv4: guest to ns
nsb socat -u UDP4-LISTEN:10002,null-eof OPEN:__TEMP_NS__,create,trunc nsb socat -u UDP4-LISTEN:10002,null-eof OPEN:__TEMP_NS__,create,trunc
sleep 1 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 nsw
hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 check cmp __TEMP_NS__ __BASEPATH__/medium.bin
check [ "__HOST_MD5__" = "__MD5__" ]
test UDP/IPv4: ns to host (recvmmsg/sendmmsg) test UDP/IPv4: ns to host (recvmmsg/sendmmsg)
hostb socat -u UDP4-LISTEN:10003,null-eof OPEN:__TEMP__,create,trunc hostb socat -u UDP4-LISTEN:10003,null-eof OPEN:__TEMP__,create,trunc
sleep 1 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 hostw
hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 check cmp __TEMP__ __BASEPATH__/medium.bin
check [ "__HOST_MD5__" = "__MD5__" ]
test UDP/IPv4: ns to host (via tap) test UDP/IPv4: ns to host (via tap)
hostb socat -u UDP4-LISTEN:10003,null-eof OPEN:__TEMP__,create,trunc hostb socat -u UDP4-LISTEN:10003,null-eof OPEN:__TEMP__,create,trunc
sleep 1 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 hostw
hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 check cmp __TEMP__ __BASEPATH__/medium.bin
check [ "__HOST_MD5__" = "__MD5__" ]
test UDP/IPv4: ns to guest (using loopback address) test UDP/IPv4: ns to guest (using loopback address)
guestb socat -u UDP4-LISTEN:10001,null-eof OPEN:test.bin,create,trunc guestb socat -u UDP4-LISTEN:10001,null-eof OPEN:test.bin,create,trunc
sleep 1 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 guestw
gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 guest cmp test.bin /root/medium.bin
check [ "__GUEST_MD5__" = "__MD5__" ]
test UDP/IPv4: ns to guest (using namespace address) test UDP/IPv4: ns to guest (using namespace address)
guestb socat -u UDP4-LISTEN:10001,null-eof OPEN:test.bin,create,trunc 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 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' nsout ADDR ip -j -4 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[0].local'
sleep 1 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 guestw
gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 guest cmp test.bin /root/medium.bin
check [ "__GUEST_MD5__" = "__MD5__" ]
test UDP/IPv6: host to guest test UDP/IPv6: host to guest
guestb socat -u UDP6-LISTEN:10001,null-eof OPEN:test.bin,create,trunc guestb socat -u UDP6-LISTEN:10001,null-eof OPEN:test.bin,create,trunc
sleep 1 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 guestw
gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 guest cmp test.bin /root/medium.bin
check [ "__GUEST_MD5__" = "__MD5__" ]
test UDP/IPv6: host to ns test UDP/IPv6: host to ns
nsb socat -u UDP6-LISTEN:10002,null-eof OPEN:__TEMP_NS__,create,trunc nsb socat -u UDP6-LISTEN:10002,null-eof OPEN:__TEMP_NS__,create,trunc
sleep 1 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 nsw
nsout NS_MD5 md5sum __TEMP_NS__ | cut -d' ' -f1 check cmp __TEMP_NS__ __BASEPATH__/medium.bin
check [ "__NS_MD5__" = "__MD5__" ]
test UDP/IPv6: guest to host test UDP/IPv6: guest to host
hostb socat -u UDP6-LISTEN:10003,null-eof OPEN:__TEMP__,create,trunc 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 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' gout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'
sleep 1 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 hostw
hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 check cmp __TEMP__ __BASEPATH__/medium.bin
check [ "__HOST_MD5__" = "__MD5__" ]
test UDP/IPv6: guest to ns test UDP/IPv6: guest to ns
nsb socat -u UDP6-LISTEN:10002,null-eof OPEN:__TEMP_NS__,create,trunc nsb socat -u UDP6-LISTEN:10002,null-eof OPEN:__TEMP_NS__,create,trunc
sleep 1 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 nsw
hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 check cmp __TEMP_NS__ __BASEPATH__/medium.bin
check [ "__HOST_MD5__" = "__MD5__" ]
test UDP/IPv6: ns to host (recvmmsg/sendmmsg) test UDP/IPv6: ns to host (recvmmsg/sendmmsg)
hostb socat -u UDP6-LISTEN:10003,null-eof OPEN:__TEMP__,create,trunc hostb socat -u UDP6-LISTEN:10003,null-eof OPEN:__TEMP__,create,trunc
sleep 1 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 hostw
hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 check cmp __TEMP__ __BASEPATH__/medium.bin
check [ "__HOST_MD5__" = "__MD5__" ]
test UDP/IPv6: ns to host (via tap) test UDP/IPv6: ns to host (via tap)
hostb socat -u UDP6-LISTEN:10003,null-eof OPEN:__TEMP__,create,trunc 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' nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'
sleep 1 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 hostw
hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 check cmp __TEMP__ __BASEPATH__/medium.bin
check [ "__HOST_MD5__" = "__MD5__" ]
test UDP/IPv6: ns to guest (using loopback address) test UDP/IPv6: ns to guest (using loopback address)
guestb socat -u UDP6-LISTEN:10001,null-eof OPEN:test.bin,create,trunc guestb socat -u UDP6-LISTEN:10001,null-eof OPEN:test.bin,create,trunc
sleep 1 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 guestw
gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 guest cmp test.bin /root/medium.bin
check [ "__GUEST_MD5__" = "__MD5__" ]
test UDP/IPv6: ns to guest (using namespace address) test UDP/IPv6: ns to guest (using namespace address)
guestb socat -u UDP6-LISTEN:10001,null-eof OPEN:test.bin,create,trunc 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' nsout ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[0].local'
sleep 1 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 guestw
gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 guest cmp test.bin /root/medium.bin
check [ "__GUEST_MD5__" = "__MD5__" ]

View File

@ -11,103 +11,86 @@
# Copyright (c) 2021 Red Hat GmbH # Copyright (c) 2021 Red Hat GmbH
# Author: Stefano Brivio <sbrivio@redhat.com> # Author: Stefano Brivio <sbrivio@redhat.com>
htools dd socat ip jq md5sum cut htools socat ip jq
nstools socat ip jq md5sum cut 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 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 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:__BASEPATH__/big.bin TCP4:127.0.0.1:10002
host socat -u OPEN:__TEMP_BIG__ TCP4:127.0.0.1:10002
nsw nsw
hout MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 check cmp __BASEPATH__/big.bin __TEMP_NS_BIG__
nsout NS_MD5_BIG md5sum __TEMP_NS_BIG__ | cut -d' ' -f1
check [ "__NS_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv4: ns to host (spliced): big transfer 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 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 hostw
hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 check cmp __BASEPATH__/big.bin __TEMP_BIG__
check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv4: ns to host (via tap): big transfer test TCP/IPv4: ns to host (via tap): big transfer
hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc
nsout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway' 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 hostw
hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 check cmp __BASEPATH__/big.bin __TEMP_BIG__
check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv4: host to ns: small transfer 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 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:__BASEPATH__/small.bin TCP4:127.0.0.1:10002
host socat OPEN:__TEMP_SMALL__ TCP4:127.0.0.1:10002
nsw nsw
hout MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 check cmp __BASEPATH__/small.bin __TEMP_NS_SMALL__
nsout NS_MD5_SMALL md5sum __TEMP_NS_SMALL__ | cut -d' ' -f1
check [ "__NS_MD5_SMALL__" = "__MD5_SMALL__" ]
test TCP/IPv4: ns to host (spliced): small transfer 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 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 hostw
hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 check cmp __BASEPATH__/small.bin __TEMP_SMALL__
check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ]
test TCP/IPv4: ns to host (via tap): small transfer test TCP/IPv4: ns to host (via tap): small transfer
hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc
nsout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway' 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 hostw
hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 check cmp __BASEPATH__/small.bin __TEMP_SMALL__
check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ]
test TCP/IPv6: host to ns: big transfer test TCP/IPv6: host to ns: big transfer
nsb socat -u TCP6-LISTEN:10002,bind=[::1] OPEN:__TEMP_NS_BIG__,create,trunc 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 nsw
hout MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 check cmp __BASEPATH__/big.bin __TEMP_NS_BIG__
nsout NS_MD5_BIG md5sum __TEMP_NS_BIG__ | cut -d' ' -f1
check [ "__NS_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv6: ns to host (spliced): big transfer test TCP/IPv6: ns to host (spliced): big transfer
hostb socat -u TCP6-LISTEN:10003,bind=[::1] OPEN:__TEMP_BIG__,create,trunc 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 hostw
hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 check cmp __BASEPATH__/big.bin __TEMP_BIG__
check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv6: ns to host (via tap): big transfer test TCP/IPv6: ns to host (via tap): big transfer
hostb socat -u TCP6-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc 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 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' 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 hostw
hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 check cmp __BASEPATH__/big.bin __TEMP_BIG__
check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv6: host to ns: small transfer test TCP/IPv6: host to ns: small transfer
nsb socat -u TCP6-LISTEN:10002,bind=[::1] OPEN:__TEMP_NS_SMALL__,create,trunc 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 nsw
hout MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 check cmp __BASEPATH__/small.bin __TEMP_NS_SMALL__
nsout NS_MD5_SMALL md5sum __TEMP_NS_SMALL__ | cut -d' ' -f1
check [ "__NS_MD5_SMALL__" = "__MD5_SMALL__" ]
test TCP/IPv6: ns to host (spliced): small transfer test TCP/IPv6: ns to host (spliced): small transfer
hostb socat -u TCP6-LISTEN:10003,bind=[::1] OPEN:__TEMP_SMALL__,create,trunc 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 hostw
hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 check cmp __BASEPATH__/small.bin __TEMP_SMALL__
check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ]
test TCP/IPv6: ns to host (via tap): small transfer test TCP/IPv6: ns to host (via tap): small transfer
hostb socat -u TCP6-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc 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 hostw
hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 check cmp __BASEPATH__/small.bin __TEMP_SMALL__
check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ]

View File

@ -11,58 +11,49 @@
# Copyright (c) 2021 Red Hat GmbH # Copyright (c) 2021 Red Hat GmbH
# Author: Stefano Brivio <sbrivio@redhat.com> # Author: Stefano Brivio <sbrivio@redhat.com>
nstools socat ip jq md5sum cut nstools socat ip jq
htools dd socat ip jq md5sum cut htools dd socat ip jq
set TEMP __STATEDIR__/test.bin
set TEMP_NS __STATEDIR__/test_ns.bin
test UDP/IPv4: host to ns 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 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:__BASEPATH__/medium.bin UDP4:127.0.0.1:10002,shut-null
host socat OPEN:__TEMP__ UDP4:127.0.0.1:10002,shut-null
nsw nsw
hout MD5 md5sum __TEMP__ | cut -d' ' -f1 check cmp __BASEPATH__/medium.bin __TEMP_NS__
nsout NS_MD5 md5sum __TEMP_NS__ | cut -d' ' -f1
check [ "__NS_MD5__" = "__MD5__" ]
test UDP/IPv4: ns to host (recvmmsg/sendmmsg) 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 hostb socat -u UDP4-LISTEN:10003,bind=127.0.0.1,null-eof OPEN:__TEMP__,create,trunc
sleep 1 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 hostw
hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 check cmp __BASEPATH__/medium.bin __TEMP__
check [ "__HOST_MD5__" = "__MD5__" ]
test UDP/IPv4: ns to host (via tap) test UDP/IPv4: ns to host (via tap)
hostb socat -u UDP4-LISTEN:10003,null-eof OPEN:__TEMP__,create,trunc 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' 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 hostw
hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 check cmp __BASEPATH__/medium.bin __TEMP__
check [ "__HOST_MD5__" = "__MD5__" ]
test UDP/IPv6: host to ns test UDP/IPv6: host to ns
nsb socat -u UDP6-LISTEN:10002,bind=[::1],null-eof OPEN:__TEMP_NS__,create,trunc 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 nsw
hout MD5 md5sum __TEMP__ | cut -d' ' -f1 check cmp __BASEPATH__/medium.bin __TEMP_NS__
nsout NS_MD5 md5sum __TEMP_NS__ | cut -d' ' -f1
check [ "__NS_MD5__" = "__MD5__" ]
test UDP/IPv6: ns to host (recvmmsg/sendmmsg) test UDP/IPv6: ns to host (recvmmsg/sendmmsg)
hostb socat -u UDP6-LISTEN:10003,bind=[::1],null-eof OPEN:__TEMP__,create,trunc hostb socat -u UDP6-LISTEN:10003,bind=[::1],null-eof OPEN:__TEMP__,create,trunc
sleep 1 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 hostw
hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 check cmp __BASEPATH__/medium.bin __TEMP__
check [ "__HOST_MD5__" = "__MD5__" ]
test UDP/IPv6: ns to host (via tap) test UDP/IPv6: ns to host (via tap)
hostb socat -u UDP6-LISTEN:10003,null-eof OPEN:__TEMP__,create,trunc 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 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' 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 hostw
hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 check cmp __BASEPATH__/medium.bin __TEMP__
check [ "__HOST_MD5__" = "__MD5__" ]

View File

@ -13,7 +13,7 @@
g1tools ip jq dhclient socat cat g1tools ip jq dhclient socat cat
g2tools ip jq dhclient socat cat g2tools ip jq dhclient socat cat
htools ip jq md5sum cut htools ip jq
test Interface names test Interface names
g1out IFNAME1 ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' g1out IFNAME1 ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'