From 594c2f93716380feb29aeb774ba77704684aa125 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Tue, 13 Sep 2022 14:35:16 +1000 Subject: test: Group tests by mode then protocol, rather than the reverse For example, passt/dhcp rather than dhcp/passt. This is more consistent with the two_guests and other test groups, and makes some other cleanups simpler. Signed-off-by: David Gibson --- test/dhcp/passt | 70 ------------ test/dhcp/pasta | 46 -------- test/icmp/passt_in_ns | 32 ------ test/ndp/passt | 33 ------ test/ndp/pasta | 33 ------ test/passt/dhcp | 70 ++++++++++++ test/passt/ndp | 33 ++++++ test/passt/shutdown | 20 ++++ test/passt/tcp | 87 +++++++++++++++ test/passt/udp | 52 +++++++++ test/passt_in_ns/icmp | 32 ++++++ test/passt_in_ns/shutdown | 20 ++++ test/passt_in_ns/tcp | 270 ++++++++++++++++++++++++++++++++++++++++++++++ test/passt_in_ns/udp | 142 ++++++++++++++++++++++++ test/pasta/dhcp | 46 ++++++++ test/pasta/ndp | 33 ++++++ test/pasta/tcp | 116 ++++++++++++++++++++ test/pasta/udp | 69 ++++++++++++ test/run | 38 +++---- test/shutdown/passt | 20 ---- test/shutdown/passt_in_ns | 20 ---- test/tcp/passt | 87 --------------- test/tcp/passt_in_ns | 270 ---------------------------------------------- test/tcp/pasta | 116 -------------------- test/udp/passt | 52 --------- test/udp/passt_in_ns | 142 ------------------------ test/udp/pasta | 69 ------------ 27 files changed, 1009 insertions(+), 1009 deletions(-) delete mode 100644 test/dhcp/passt delete mode 100644 test/dhcp/pasta delete mode 100644 test/icmp/passt_in_ns delete mode 100644 test/ndp/passt delete mode 100644 test/ndp/pasta create mode 100644 test/passt/dhcp create mode 100644 test/passt/ndp create mode 100644 test/passt/shutdown create mode 100644 test/passt/tcp create mode 100644 test/passt/udp create mode 100644 test/passt_in_ns/icmp create mode 100644 test/passt_in_ns/shutdown create mode 100644 test/passt_in_ns/tcp create mode 100644 test/passt_in_ns/udp create mode 100644 test/pasta/dhcp create mode 100644 test/pasta/ndp create mode 100644 test/pasta/tcp create mode 100644 test/pasta/udp delete mode 100644 test/shutdown/passt delete mode 100644 test/shutdown/passt_in_ns delete mode 100644 test/tcp/passt delete mode 100644 test/tcp/passt_in_ns delete mode 100644 test/tcp/pasta delete mode 100644 test/udp/passt delete mode 100644 test/udp/passt_in_ns delete mode 100644 test/udp/pasta (limited to 'test') diff --git a/test/dhcp/passt b/test/dhcp/passt deleted file mode 100644 index 37bf6b5..0000000 --- a/test/dhcp/passt +++ /dev/null @@ -1,70 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later -# -# PASST - Plug A Simple Socket Transport -# for qemu/UNIX domain socket mode -# -# PASTA - Pack A Subtle Tap Abstraction -# for network namespace/tap device mode -# -# test/dhcp/passt - Check DHCP and DHCPv6 functionality in passt mode -# -# Copyright (c) 2021 Red Hat GmbH -# Author: Stefano Brivio - -gtools ip jq dhclient sed tr -htools ip jq sed tr head - -test Interface name -gout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' -hout HOST_IFNAME ip -j -4 route show|jq -rM '[.[] | select(.dst == "default").dev] | .[0]' -hout HOST_IFNAME6 ip -j -6 route show|jq -rM '[.[] | select(.dst == "default").dev] | .[0]' -check [ -n "__IFNAME__" ] - -test DHCP: address -guest /sbin/dhclient -4 __IFNAME__ -gout ADDR ip -j -4 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[0].local' -hout HOST_ADDR ip -j -4 addr show|jq -rM '.[] | select(.ifname == "__HOST_IFNAME__").addr_info[0].local' -check [ "__ADDR__" = "__HOST_ADDR__" ] - -test DHCP: route -gout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway' -hout HOST_GW ip -j -4 route show|jq -rM '[.[] | select(.dst == "default").gateway] | .[0]' -check [ "__GW__" = "__HOST_GW__" ] - -test DHCP: MTU -gout MTU ip -j link show | jq -rM '.[] | select(.ifname == "__IFNAME__").mtu' -check [ __MTU__ = 65520 ] - -test DHCP: DNS -gout DNS sed -n 's/^nameserver \([0-9]*\.\)\(.*\)/\1\2/p' /etc/resolv.conf | tr '\n' ',' | sed 's/,$//;s/$/\n/' -hout HOST_DNS sed -n 's/^nameserver \([0-9]*\.\)\(.*\)/\1\2/p' /etc/resolv.conf | head -n3 | tr '\n' ',' | sed 's/,$//;s/$/\n/' -check [ "__DNS__" = "__HOST_DNS__" ] || [ "__DNS__" = "__HOST_GW__" -a "__HOST_DNS__" = "127.0.0.1" ] - -# FQDNs should be terminated by dots, but the guest DHCP client might omit them: -# strip them first -test DHCP: search list -gout SEARCH sed 's/\. / /g' /etc/resolv.conf | sed 's/\.$//g' | sed -n 's/^search \(.*\)/\1/p' | tr ' \n' ',' | sed 's/,$//;s/$/\n/' -hout HOST_SEARCH sed 's/\. / /g' /etc/resolv.conf | sed 's/\.$//g' | sed -n 's/^search \(.*\)/\1/p' | tr ' \n' ',' | sed 's/,$//;s/$/\n/' -check [ "__SEARCH__" = "__HOST_SEARCH__" ] - -test DHCPv6: address -guest /sbin/dhclient -6 __IFNAME__ -gout ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.prefixlen == 128).local' -hout HOST_ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__HOST_IFNAME6__").addr_info[] | select(.scope == "global").local' -check [ "__ADDR6__" = "__HOST_ADDR6__" ] - -test DHCPv6: route -gout GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway' -hout HOST_GW6 ip -j -6 route show|jq -rM '[.[] | select(.dst == "default").gateway] | .[0]' -check [ "__GW6__" = "__HOST_GW6__" ] - -# Strip interface specifier: interface names might differ between host and guest -test DHCPv6: DNS -gout DNS6 sed -n 's/^nameserver \([^:]*:\)\([^%]*\).*/\1\2/p' /etc/resolv.conf | tr '\n' ',' | sed 's/,$//;s/$/\n/' -hout HOST_DNS6 sed -n 's/^nameserver \([^:]*:\)\([^%]*\).*/\1\2/p' /etc/resolv.conf | tr '\n' ',' | sed 's/,$//;s/$/\n/' -check [ "__DNS6__" = "__HOST_DNS6__" ] || [ "__DNS6__" = "__HOST_GW6__" -a "__HOST_DNS6__" = "::1" ] - -test DHCPv6: search list -gout SEARCH6 sed 's/\. / /g' /etc/resolv.conf | sed 's/\.$//g' | sed -n 's/^search \(.*\)/\1/p' | tr ' \n' ',' | sed 's/,$//;s/$/\n/' -hout HOST_SEARCH6 sed 's/\. / /g' /etc/resolv.conf | sed 's/\.$//g' | sed -n 's/^search \(.*\)/\1/p' | tr ' \n' ',' | sed 's/,$//;s/$/\n/' -check [ "__SEARCH6__" = "__HOST_SEARCH6__" ] diff --git a/test/dhcp/pasta b/test/dhcp/pasta deleted file mode 100644 index d1e9611..0000000 --- a/test/dhcp/pasta +++ /dev/null @@ -1,46 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later -# -# PASST - Plug A Simple Socket Transport -# for qemu/UNIX domain socket mode -# -# PASTA - Pack A Subtle Tap Abstraction -# for network namespace/tap device mode -# -# test/dhcp/pasta - Check DHCP and DHCPv6 functionality in pasta mode -# -# Copyright (c) 2021 Red Hat GmbH -# Author: Stefano Brivio - -nstools ip jq /sbin/dhclient -htools ip jq - -test Interface name -nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' -check [ -n "__IFNAME__" ] - -test DHCP: address -ns /sbin/dhclient -4 --no-pid __IFNAME__ -nsout ADDR ip -j -4 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[0].local' -hout HOST_ADDR ip -j -4 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[0].local' -check [ __ADDR__ = __HOST_ADDR__ ] - -test DHCP: route -nsout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway' -hout HOST_GW ip -j -4 route show|jq -rM '[.[] | select(.dst == "default").gateway] | .[0]' -check [ __GW__ = __HOST_GW__ ] - -test DHCP: MTU -nsout MTU ip -j link show | jq -rM '.[] | select(.ifname == "__IFNAME__").mtu' -check [ __MTU__ = 65520 ] - -test DHCPv6: address -ns /sbin/dhclient -6 --no-pid __IFNAME__ -hout HOST_IFNAME6 ip -j -6 route show|jq -rM '[.[] | select(.dst == "default").dev] | .[0]' -nsout ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.prefixlen == 128).local' -hout HOST_ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__HOST_IFNAME6__").addr_info[] | select(.scope == "global").local' -check [ __ADDR6__ = __HOST_ADDR6__ ] - -test DHCPv6: route -nsout GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway' -hout HOST_GW6 ip -j -6 route show|jq -rM '[.[] | select(.dst == "default").gateway] | .[0]' -check [ __GW6__ = __HOST_GW6__ ] diff --git a/test/icmp/passt_in_ns b/test/icmp/passt_in_ns deleted file mode 100644 index e4ac4ff..0000000 --- a/test/icmp/passt_in_ns +++ /dev/null @@ -1,32 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later -# -# PASST - Plug A Simple Socket Transport -# for qemu/UNIX domain socket mode -# -# PASTA - Pack A Subtle Tap Abstraction -# for network namespace/tap device mode -# -# test/icmp/passt_in_ns - Check ICMP/ICMPv6 functionality for passt in ns -# -# Copyright (c) 2021 Red Hat GmbH -# Author: Stefano Brivio -# -# These tests can work reliably only within an isolated namespace: the host -# might have a net.ipv4.ping_group_range sysctl value not allowing pasta's gid -# to create "ping" sockets. Inside the namespace, there's a single group, which -# is allowed by default to create them. - -nstools ip jq sleep -gtools ping ip jq - -test ICMP echo: guest to ns -nsout IFNAME_NS ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' -ns ip addr add 192.0.2.1/32 dev __IFNAME_NS__ -guest ping -c1 -w1 192.0.2.1 -ns ip addr del 192.0.2.1/32 dev __IFNAME_NS__ - -test ICMPv6 echo: guest to ns -ns ip addr add 2001:db8::1 dev __IFNAME_NS__ && sleep 2 # DAD -gout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' -guest ping -c1 -w1 2001:db8::1 -ns ip addr del 2001:db8::1 dev __IFNAME_NS__ diff --git a/test/ndp/passt b/test/ndp/passt deleted file mode 100644 index c73fd4d..0000000 --- a/test/ndp/passt +++ /dev/null @@ -1,33 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later -# -# PASST - Plug A Simple Socket Transport -# for qemu/UNIX domain socket mode -# -# PASTA - Pack A Subtle Tap Abstraction -# for network namespace/tap device mode -# -# test/ndp/passt - Check NDP functionality in passt mode -# -# Copyright (c) 2021 Red Hat GmbH -# Author: Stefano Brivio - -gtools ip jq sipcalc grep -htools ip jq sipcalc grep cut - -test Interface name -gout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' -guest ip link set dev __IFNAME__ up && sleep 2 -hout HOST_IFNAME6 ip -j -6 route show|jq -rM '[.[] | select(.dst == "default").dev] | .[0]' -check [ -n "__IFNAME__" ] - -test SLAAC: prefix -gout ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.scope == "global" and .prefixlen == 64).local' -gout PREFIX6 sipcalc __ADDR6__/64 | grep prefix | cut -d' ' -f4 -hout HOST_ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__HOST_IFNAME6__").addr_info[] | select(.scope == "global").local' -hout HOST_PREFIX6 sipcalc __HOST_ADDR6__/64 | grep prefix | cut -d' ' -f4 -check [ "__PREFIX6__" = "__HOST_PREFIX6__" ] - -test SLAAC: route -gout GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway' -hout HOST_GW6 ip -j -6 route show|jq -rM '[.[] | select(.dst == "default").gateway] | .[0]' -check [ __GW6__ = __HOST_GW6__ ] diff --git a/test/ndp/pasta b/test/ndp/pasta deleted file mode 100644 index d776055..0000000 --- a/test/ndp/pasta +++ /dev/null @@ -1,33 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later -# -# PASST - Plug A Simple Socket Transport -# for qemu/UNIX domain socket mode -# -# PASTA - Pack A Subtle Tap Abstraction -# for network namespace/tap device mode -# -# test/ndp/pasta - Check DHCP and DHCPv6 functionality in pasta mode -# -# Copyright (c) 2021 Red Hat GmbH -# Author: Stefano Brivio - -nstools ip jq sipcalc grep cut -htools ip jq sipcalc grep cut - -test Interface name -nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' -check [ -n "__IFNAME__" ] -ns ip link set dev __IFNAME__ up -sleep 2 - -test SLAAC: prefix -nsout ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.scope == "global" and .prefixlen == 64).local' -nsout PREFIX6 sipcalc __ADDR6__/64 | grep prefix | cut -d' ' -f4 -hout HOST_ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.scope == "global").local' -hout HOST_PREFIX6 sipcalc __HOST_ADDR6__/64 | grep prefix | cut -d' ' -f4 -check [ "__PREFIX6__" = "__HOST_PREFIX6__" ] - -test SLAAC: route -nsout GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway' -hout HOST_GW6 ip -j -6 route show|jq -rM '[.[] | select(.dst == "default").gateway] | .[0]' -check [ __GW6__ = __HOST_GW6__ ] diff --git a/test/passt/dhcp b/test/passt/dhcp new file mode 100644 index 0000000..eef5183 --- /dev/null +++ b/test/passt/dhcp @@ -0,0 +1,70 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# PASST - Plug A Simple Socket Transport +# for qemu/UNIX domain socket mode +# +# PASTA - Pack A Subtle Tap Abstraction +# for network namespace/tap device mode +# +# test/passt/dhcp - Check DHCP and DHCPv6 functionality in passt mode +# +# Copyright (c) 2021 Red Hat GmbH +# Author: Stefano Brivio + +gtools ip jq dhclient sed tr +htools ip jq sed tr head + +test Interface name +gout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' +hout HOST_IFNAME ip -j -4 route show|jq -rM '[.[] | select(.dst == "default").dev] | .[0]' +hout HOST_IFNAME6 ip -j -6 route show|jq -rM '[.[] | select(.dst == "default").dev] | .[0]' +check [ -n "__IFNAME__" ] + +test DHCP: address +guest /sbin/dhclient -4 __IFNAME__ +gout ADDR ip -j -4 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[0].local' +hout HOST_ADDR ip -j -4 addr show|jq -rM '.[] | select(.ifname == "__HOST_IFNAME__").addr_info[0].local' +check [ "__ADDR__" = "__HOST_ADDR__" ] + +test DHCP: route +gout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway' +hout HOST_GW ip -j -4 route show|jq -rM '[.[] | select(.dst == "default").gateway] | .[0]' +check [ "__GW__" = "__HOST_GW__" ] + +test DHCP: MTU +gout MTU ip -j link show | jq -rM '.[] | select(.ifname == "__IFNAME__").mtu' +check [ __MTU__ = 65520 ] + +test DHCP: DNS +gout DNS sed -n 's/^nameserver \([0-9]*\.\)\(.*\)/\1\2/p' /etc/resolv.conf | tr '\n' ',' | sed 's/,$//;s/$/\n/' +hout HOST_DNS sed -n 's/^nameserver \([0-9]*\.\)\(.*\)/\1\2/p' /etc/resolv.conf | head -n3 | tr '\n' ',' | sed 's/,$//;s/$/\n/' +check [ "__DNS__" = "__HOST_DNS__" ] || [ "__DNS__" = "__HOST_GW__" -a "__HOST_DNS__" = "127.0.0.1" ] + +# FQDNs should be terminated by dots, but the guest DHCP client might omit them: +# strip them first +test DHCP: search list +gout SEARCH sed 's/\. / /g' /etc/resolv.conf | sed 's/\.$//g' | sed -n 's/^search \(.*\)/\1/p' | tr ' \n' ',' | sed 's/,$//;s/$/\n/' +hout HOST_SEARCH sed 's/\. / /g' /etc/resolv.conf | sed 's/\.$//g' | sed -n 's/^search \(.*\)/\1/p' | tr ' \n' ',' | sed 's/,$//;s/$/\n/' +check [ "__SEARCH__" = "__HOST_SEARCH__" ] + +test DHCPv6: address +guest /sbin/dhclient -6 __IFNAME__ +gout ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.prefixlen == 128).local' +hout HOST_ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__HOST_IFNAME6__").addr_info[] | select(.scope == "global").local' +check [ "__ADDR6__" = "__HOST_ADDR6__" ] + +test DHCPv6: route +gout GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway' +hout HOST_GW6 ip -j -6 route show|jq -rM '[.[] | select(.dst == "default").gateway] | .[0]' +check [ "__GW6__" = "__HOST_GW6__" ] + +# Strip interface specifier: interface names might differ between host and guest +test DHCPv6: DNS +gout DNS6 sed -n 's/^nameserver \([^:]*:\)\([^%]*\).*/\1\2/p' /etc/resolv.conf | tr '\n' ',' | sed 's/,$//;s/$/\n/' +hout HOST_DNS6 sed -n 's/^nameserver \([^:]*:\)\([^%]*\).*/\1\2/p' /etc/resolv.conf | tr '\n' ',' | sed 's/,$//;s/$/\n/' +check [ "__DNS6__" = "__HOST_DNS6__" ] || [ "__DNS6__" = "__HOST_GW6__" -a "__HOST_DNS6__" = "::1" ] + +test DHCPv6: search list +gout SEARCH6 sed 's/\. / /g' /etc/resolv.conf | sed 's/\.$//g' | sed -n 's/^search \(.*\)/\1/p' | tr ' \n' ',' | sed 's/,$//;s/$/\n/' +hout HOST_SEARCH6 sed 's/\. / /g' /etc/resolv.conf | sed 's/\.$//g' | sed -n 's/^search \(.*\)/\1/p' | tr ' \n' ',' | sed 's/,$//;s/$/\n/' +check [ "__SEARCH6__" = "__HOST_SEARCH6__" ] diff --git a/test/passt/ndp b/test/passt/ndp new file mode 100644 index 0000000..280b3ae --- /dev/null +++ b/test/passt/ndp @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# PASST - Plug A Simple Socket Transport +# for qemu/UNIX domain socket mode +# +# PASTA - Pack A Subtle Tap Abstraction +# for network namespace/tap device mode +# +# test/passt/ndp - Check NDP functionality in passt mode +# +# Copyright (c) 2021 Red Hat GmbH +# Author: Stefano Brivio + +gtools ip jq sipcalc grep +htools ip jq sipcalc grep cut + +test Interface name +gout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' +guest ip link set dev __IFNAME__ up && sleep 2 +hout HOST_IFNAME6 ip -j -6 route show|jq -rM '[.[] | select(.dst == "default").dev] | .[0]' +check [ -n "__IFNAME__" ] + +test SLAAC: prefix +gout ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.scope == "global" and .prefixlen == 64).local' +gout PREFIX6 sipcalc __ADDR6__/64 | grep prefix | cut -d' ' -f4 +hout HOST_ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__HOST_IFNAME6__").addr_info[] | select(.scope == "global").local' +hout HOST_PREFIX6 sipcalc __HOST_ADDR6__/64 | grep prefix | cut -d' ' -f4 +check [ "__PREFIX6__" = "__HOST_PREFIX6__" ] + +test SLAAC: route +gout GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway' +hout HOST_GW6 ip -j -6 route show|jq -rM '[.[] | select(.dst == "default").gateway] | .[0]' +check [ __GW6__ = __HOST_GW6__ ] diff --git a/test/passt/shutdown b/test/passt/shutdown new file mode 100644 index 0000000..ce90ea9 --- /dev/null +++ b/test/passt/shutdown @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# PASST - Plug A Simple Socket Transport +# for qemu/UNIX domain socket mode +# +# PASTA - Pack A Subtle Tap Abstraction +# for network namespace/tap device mode +# +# test/passt/shutdown - Shut down passt (or pasta) and check exit code (will +# detect valgrind errors amongst others) +# +# Copyright (c) 2022 Red Hat GmbH +# Author: Stefano Brivio + +test shutdown: exit code + +hout PASST_PID cat passt.pid +host kill __PASST_PID__ +sleep 1 +passtw diff --git a/test/passt/tcp b/test/passt/tcp new file mode 100644 index 0000000..d5c8164 --- /dev/null +++ b/test/passt/tcp @@ -0,0 +1,87 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# PASST - Plug A Simple Socket Transport +# for qemu/UNIX domain socket mode +# +# PASTA - Pack A Subtle Tap Abstraction +# for network namespace/tap device mode +# +# test/passt/tcp - Check TCP functionality in passt mode +# +# Copyright (c) 2021 Red Hat GmbH +# Author: Stefano Brivio + +gtools socat ip jq md5sum cut +htools dd socat ip jq md5sum cut + +test TCP/IPv4: host to guest: big transfer +temp TEMP_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 +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__" ] + +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 +hostw +hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 +check [ "__GUEST_MD5_BIG__" = "__HOST_MD5_BIG__" ] + +test TCP/IPv4: host to guest: small transfer +temp TEMP_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 +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__" ] + +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 +hostw +hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 +check [ "__GUEST_MD5_SMALL__" = "__HOST_MD5_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 +guestw +gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 +check [ "__GUEST_MD5_BIG__" = "__HOST_MD5_BIG__" ] + +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 +hostw +hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 +check [ "__GUEST_MD5_BIG__" = "__HOST_MD5_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 +guestw +gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 +check [ "__GUEST_MD5_SMALL__" = "__HOST_MD5_SMALL__" ] + +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 +hostw +hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 +check [ "__GUEST_MD5_SMALL__" = "__HOST_MD5_SMALL__" ] diff --git a/test/passt/udp b/test/passt/udp new file mode 100644 index 0000000..56d01b3 --- /dev/null +++ b/test/passt/udp @@ -0,0 +1,52 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# PASST - Plug A Simple Socket Transport +# for qemu/UNIX domain socket mode +# +# PASTA - Pack A Subtle Tap Abstraction +# for network namespace/tap device mode +# +# test/passt/udp - Check UDP functionality in passt mode +# +# Copyright (c) 2021 Red Hat GmbH +# Author: Stefano Brivio + +gtools socat tee grep cat ip jq md5sum cut +htools printf dd socat tee grep cat ip jq md5sum cut + +test UDP/IPv4: host to guest +temp TEMP +temp SC_PID +guestb (socat -u UDP4-LISTEN:10001 STDOUT & echo $! > __SC_PID__) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) +sleep 1 +host dd if=/dev/urandom bs=1k count=5 > __TEMP__ && printf "\nEND_OF_TEST\n" >> __TEMP__ +host socat -u OPEN:__TEMP__ UDP4:127.0.0.1:10001 +guestw +hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 +gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 +check [ "__GUEST_MD5__" = "__HOST_MD5__" ] + +test UDP/IPv4: guest to host +hostb (socat -u UDP4-LISTEN:10003,bind=127.0.0.1 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) +gout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway' +guest socat -u OPEN:test.bin UDP4:__GW__:10003 +hostw +hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 +check [ "__GUEST_MD5__" = "__HOST_MD5__" ] + +test UDP/IPv6: host to guest +guestb (socat -u UDP6-LISTEN:10001 STDOUT & echo $! > sc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat sc.pid)) +sleep 1 +host socat -u OPEN:__TEMP__ UDP6:[::1]:10001 +guestw +gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 +check [ "__GUEST_MD5__" = "__HOST_MD5__" ] + +test UDP/IPv6: guest to host +hostb (socat -u UDP6-LISTEN:10003,bind=[::1] STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) +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 +hostw +hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 +check [ "__GUEST_MD5__" = "__HOST_MD5__" ] diff --git a/test/passt_in_ns/icmp b/test/passt_in_ns/icmp new file mode 100644 index 0000000..f326d4b --- /dev/null +++ b/test/passt_in_ns/icmp @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# PASST - Plug A Simple Socket Transport +# for qemu/UNIX domain socket mode +# +# PASTA - Pack A Subtle Tap Abstraction +# for network namespace/tap device mode +# +# test/passt_in_ns/icmp - Check ICMP/ICMPv6 functionality for passt in ns +# +# Copyright (c) 2021 Red Hat GmbH +# Author: Stefano Brivio +# +# These tests can work reliably only within an isolated namespace: the host +# might have a net.ipv4.ping_group_range sysctl value not allowing pasta's gid +# to create "ping" sockets. Inside the namespace, there's a single group, which +# is allowed by default to create them. + +nstools ip jq sleep +gtools ping ip jq + +test ICMP echo: guest to ns +nsout IFNAME_NS ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' +ns ip addr add 192.0.2.1/32 dev __IFNAME_NS__ +guest ping -c1 -w1 192.0.2.1 +ns ip addr del 192.0.2.1/32 dev __IFNAME_NS__ + +test ICMPv6 echo: guest to ns +ns ip addr add 2001:db8::1 dev __IFNAME_NS__ && sleep 2 # DAD +gout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' +guest ping -c1 -w1 2001:db8::1 +ns ip addr del 2001:db8::1 dev __IFNAME_NS__ diff --git a/test/passt_in_ns/shutdown b/test/passt_in_ns/shutdown new file mode 100644 index 0000000..abe9d6c --- /dev/null +++ b/test/passt_in_ns/shutdown @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# PASST - Plug A Simple Socket Transport +# for qemu/UNIX domain socket mode +# +# PASTA - Pack A Subtle Tap Abstraction +# for network namespace/tap device mode +# +# test/passt_in_ns/shutdown - Shut down passt and check exit code (will detect +# valgrind errors amongst others) +# +# Copyright (c) 2022 Red Hat GmbH +# Author: Stefano Brivio + +test shutdown: exit code + +nsout PASST_PID cat passt.pid +ns kill __PASST_PID__ +sleep 1 +passtw diff --git a/test/passt_in_ns/tcp b/test/passt_in_ns/tcp new file mode 100644 index 0000000..5ec95e8 --- /dev/null +++ b/test/passt_in_ns/tcp @@ -0,0 +1,270 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# PASST - Plug A Simple Socket Transport +# for qemu/UNIX domain socket mode +# +# PASTA - Pack A Subtle Tap Abstraction +# for network namespace/tap device mode +# +# test/passt_in_ns/tcp - Check TCP functionality for passt in ns with pasta +# +# 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 + +test TCP/IPv4: host to guest: big transfer +temp TEMP_BIG +guestb socat -u TCP4-LISTEN:10001 OPEN:test_big.bin,create,trunc +sleep 1 +host dd if=/dev/urandom bs=1M count=10 of=__TEMP_BIG__ +host socat -u OPEN:__TEMP_BIG__ 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__" ] + +test TCP/IPv4: host to ns: big transfer +temp TEMP_NS_BIG +nsb socat -u TCP4-LISTEN:10002 OPEN:__TEMP_NS_BIG__,create,trunc +host socat -u OPEN:__TEMP_BIG__ TCP4:127.0.0.1:10002 +nsw +nsout NS_MD5_BIG md5sum __TEMP_NS_BIG__ | cut -d' ' -f1 +check [ "__NS_MD5_BIG__" = "__MD5_BIG__" ] + +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' +guest socat -u OPEN:test_big.bin TCP4:__GW__:10003 +hostw +hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 +check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] + +test TCP/IPv4: guest to ns: big transfer +nsb socat -u TCP4-LISTEN:10002 OPEN:__TEMP_BIG__,create,trunc +guest socat -u OPEN:test_big.bin TCP4:__GW__:10002 +nsw +hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 +check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] + +test TCP/IPv4: ns to host (spliced): big transfer +sleep 1 +hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc +ns socat -u OPEN:__TEMP_NS_BIG__ TCP4:127.0.0.1:10003 +hostw +hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 +check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] + +test TCP/IPv4: ns to host (via tap): big transfer +hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc +ns socat -u OPEN:__TEMP_NS_BIG__ TCP4:__GW__:10003 +hostw +hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 +check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] + +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 +guestw +gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 +check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ] + +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' +ns socat -u OPEN:__TEMP_NS_BIG__ TCP4:__ADDR__:10001 +guestw +gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 +check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ] + +test TCP/IPv4: host to guest: small transfer +temp TEMP_SMALL +guestb socat -u TCP4-LISTEN:10001 OPEN:test_small.bin,create,trunc +sleep 1 +host dd if=/dev/urandom bs=2k count=100 of=__TEMP_SMALL__ +host socat -u OPEN:__TEMP_SMALL__ 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__" ] + +test TCP/IPv4: host to ns: small transfer +temp TEMP_NS_SMALL +nsb socat -u TCP4-LISTEN:10002 OPEN:__TEMP_NS_SMALL__,create,trunc +host socat -u OPEN:__TEMP_SMALL__ TCP4:127.0.0.1:10002 +nsw +nsout NS_MD5_SMALL md5sum __TEMP_NS_SMALL__ | cut -d' ' -f1 +check [ "__NS_MD5_SMALL__" = "__MD5_SMALL__" ] + +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' +guest socat -u OPEN:test_small.bin TCP4:__GW__:10003 +hostw +hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 +check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] + +test TCP/IPv4: guest to ns: small transfer +nsb socat -u TCP4-LISTEN:10002 OPEN:__TEMP_SMALL__,create,trunc +guest socat -u OPEN:test_small.bin TCP4:__GW__:10002 +nsw +hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 +check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] + +test TCP/IPv4: ns to host (spliced): small transfer +sleep 1 +hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc +ns socat -u OPEN:__TEMP_NS_SMALL__ TCP4:127.0.0.1:10003 +hostw +hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 +check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] + +test TCP/IPv4: ns to host (via tap): small transfer +hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc +ns socat -u OPEN:__TEMP_NS_SMALL__ TCP4:__GW__:10003 +hostw +hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 +check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] + +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 +guestw +gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 +check [ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ] + +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 +guestw +gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 +check [ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ] + +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 +guestw +gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 +check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ] + +test TCP/IPv6: host to ns: big transfer +nsb socat -u TCP6-LISTEN:10002 OPEN:__TEMP_NS_BIG__,create,trunc +host socat -u OPEN:__TEMP_BIG__ TCP6:[::1]:10002 +nsw +nsout NS_MD5_BIG md5sum __TEMP_NS_BIG__ | cut -d' ' -f1 +check [ "__NS_MD5_BIG__" = "__MD5_BIG__" ] + +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' +guest socat -u OPEN:test_big.bin TCP6:[__GW6__%__IFNAME__]:10003 +hostw +hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 +check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] + +test TCP/IPv6: guest to ns: big transfer +nsb socat -u TCP6-LISTEN:10002 OPEN:__TEMP_BIG__,create,trunc +guest socat -u OPEN:test_big.bin TCP6:[__GW6__%__IFNAME__]:10002 +nsw +hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 +check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] + +test TCP/IPv6: ns to host (spliced): big transfer +hostb socat -u TCP6-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc +ns socat -u OPEN:__TEMP_NS_BIG__ TCP6:[::1]:10003 +hostw +hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 +check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] + +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' +ns socat -u OPEN:__TEMP_NS_BIG__ TCP6:[__GW6__%__IFNAME__]:10003 +hostw +hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 +check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] + +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 +guestw +gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 +check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ] + +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' +ns socat -u OPEN:__TEMP_NS_BIG__ TCP6:[__ADDR6__]:10001 +guestw +gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 +check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ] + +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 +guestw +gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 +check [ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ] + +test TCP/IPv6: host to ns: small transfer +nsb socat -u TCP6-LISTEN:10002 OPEN:__TEMP_NS_SMALL__,create,trunc +host socat -u OPEN:__TEMP_SMALL__ TCP6:[::1]:10002 +nsw +nsout NS_MD5_SMALL md5sum __TEMP_NS_SMALL__ | cut -d' ' -f1 +check [ "__NS_MD5_SMALL__" = "__MD5_SMALL__" ] + +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' +guest socat -u OPEN:test_small.bin TCP6:[__GW6__%__IFNAME__]:10003 +hostw +hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 +check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] + +test TCP/IPv6: guest to ns: small transfer +nsb socat -u TCP6-LISTEN:10002 OPEN:__TEMP_SMALL__ +guest socat -u OPEN:test_small.bin TCP6:[__GW6__%__IFNAME__]:10002 +nsw +hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 +check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] + +test TCP/IPv6: ns to host (spliced): small transfer +hostb socat -u TCP6-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc +ns socat -u OPEN:__TEMP_NS_SMALL__ TCP6:[::1]:10003 +hostw +hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 +check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] + +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' +ns socat -u OPEN:__TEMP_NS_SMALL__ TCP6:[__GW6__%__IFNAME__]:10003 +hostw +hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 +check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] + +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 +guestw +gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 +check [ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ] + +test TCP/IPv6: ns to guest (using namespace address): small transfer +guestb socat -u TCP6-LISTEN:10001 OPEN:test_small.bin,create,trunc +ns socat -u OPEN:__TEMP_NS_SMALL__ TCP6:[__ADDR6__]:10001 +guestw +gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 +check [ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ] diff --git a/test/passt_in_ns/udp b/test/passt_in_ns/udp new file mode 100644 index 0000000..c22a68f --- /dev/null +++ b/test/passt_in_ns/udp @@ -0,0 +1,142 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# PASST - Plug A Simple Socket Transport +# for qemu/UNIX domain socket mode +# +# PASTA - Pack A Subtle Tap Abstraction +# for network namespace/tap device mode +# +# test/passt_in_ns/udp - Check UDP functionality for passt in ns and pasta +# +# Copyright (c) 2021 Red Hat GmbH +# Author: Stefano Brivio + +gtools socat tee grep cat ip jq md5sum cut +nstools socat tee grep cat ip jq md5sum cut +htools printf dd socat tee grep cat ip jq md5sum cut + +test UDP/IPv4: host to guest +temp TEMP +temp SC_PID +guestb (socat -u UDP4-LISTEN:10001 STDOUT & echo $! > sc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat sc.pid)) +sleep 1 +host dd if=/dev/urandom bs=1k count=5 > __TEMP__ && printf "\nEND_OF_TEST\n" >> __TEMP__ +host socat -u OPEN:__TEMP__ UDP4:127.0.0.1:10001 +guestw +hout MD5 md5sum __TEMP__ | cut -d' ' -f1 +gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 +check [ "__GUEST_MD5__" = "__MD5__" ] + +test UDP/IPv4: host to ns +temp TEMP_NS +nsb (socat -u UDP4-LISTEN:10002 STDOUT & echo $! > __SC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) +host socat -u OPEN:__TEMP__ UDP4:127.0.0.1:10002 +nsw +nsout NS_MD5 md5sum __TEMP_NS__ | cut -d' ' -f1 +check [ "__NS_MD5__" = "__MD5__" ] + +test UDP/IPv4: guest to host +hostb (socat -u UDP4-LISTEN:10003 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) +gout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway' +guest socat -u OPEN:test.bin UDP4:__GW__:10003 +hostw +hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 +check [ "__HOST_MD5__" = "__MD5__" ] + +test UDP/IPv4: guest to ns +nsb (socat -u UDP4-LISTEN:10002 STDOUT & echo $! > __SC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) +guest socat -u OPEN:test.bin UDP4:__GW__:10002 +nsw +hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 +check [ "__HOST_MD5__" = "__MD5__" ] + +test UDP/IPv4: ns to host (recvmmsg/sendmmsg) +sleep 1 +hostb (socat -u UDP4-LISTEN:10003 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) +ns socat -u OPEN:__TEMP_NS__ UDP4:127.0.0.1:10003 +hostw +hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 +check [ "__HOST_MD5__" = "__MD5__" ] + +test UDP/IPv4: ns to host (via tap) +hostb (socat -u UDP4-LISTEN:10003 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) +ns socat -u OPEN:__TEMP_NS__ UDP4:__GW__:10003 +hostw +hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 +check [ "__HOST_MD5__" = "__MD5__" ] + +test UDP/IPv4: ns to guest (using loopback address) +guestb (socat -u UDP4-LISTEN:10001 STDOUT & echo $! > sc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat sc.pid)) +ns socat -u OPEN:__TEMP_NS__ UDP4:127.0.0.1:10001 +guestw +gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 +check [ "__GUEST_MD5__" = "__MD5__" ] + +test UDP/IPv4: ns to guest (using namespace address) +guestb (socat -u UDP4-LISTEN:10001 STDOUT & echo $! > sc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat sc.pid)) +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' +ns socat -u OPEN:__TEMP_NS__ UDP4:__ADDR__:10001 +guestw +gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 +check [ "__GUEST_MD5__" = "__MD5__" ] + +test UDP/IPv6: host to guest +guestb (socat -u UDP6-LISTEN:10001 STDOUT & echo $! > sc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat sc.pid)) +host socat -u OPEN:__TEMP__ UDP6:[::1]:10001 +guestw +gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 +check [ "__GUEST_MD5__" = "__MD5__" ] + +test UDP/IPv6: host to ns +nsb (socat -u UDP6-LISTEN:10002 STDOUT & echo $! > __SC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) +host socat -u OPEN:__TEMP__ UDP6:[::1]:10002 +nsw +nsout NS_MD5 md5sum __TEMP_NS__ | cut -d' ' -f1 +check [ "__NS_MD5__" = "__MD5__" ] + +test UDP/IPv6: guest to host +hostb (socat -u UDP6-LISTEN:10003 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) +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 +hostw +hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 +check [ "__HOST_MD5__" = "__MD5__" ] + +test UDP/IPv6: guest to ns +nsb (socat -u UDP6-LISTEN:10002 STDOUT & echo $! > __SC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) +guest socat -u OPEN:test.bin UDP6:[__GW6__%__IFNAME__]:10002 +nsw +hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 +check [ "__HOST_MD5__" = "__MD5__" ] + +test UDP/IPv6: ns to host (recvmmsg/sendmmsg) +hostb (socat -u UDP6-LISTEN:10003 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) +ns socat -u OPEN:__TEMP_NS__ UDP6:[::1]:10003 +hostw +hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 +check [ "__HOST_MD5__" = "__MD5__" ] + +test UDP/IPv6: ns to host (via tap) +hostb (socat -u UDP6-LISTEN:10003 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) +nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' +ns socat -u OPEN:__TEMP_NS__ UDP6:[__GW6__%__IFNAME__]:10003 +hostw +hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 +check [ "__HOST_MD5__" = "__MD5__" ] + +test UDP/IPv6: ns to guest (using loopback address) +guestb (socat -u UDP6-LISTEN:10001 STDOUT & echo $! > sc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat sc.pid)) +ns socat -u OPEN:__TEMP_NS__ UDP6:[::1]:10001 +guestw +gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 +check [ "__GUEST_MD5__" = "__MD5__" ] + +test UDP/IPv6: ns to guest (using namespace address) +guestb (socat -u UDP6-LISTEN:10001 STDOUT & echo $! > sc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat sc.pid)) +nsout ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[0].local' +ns socat -u OPEN:__TEMP_NS__ UDP6:[__ADDR6__]:10001 +guestw +gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 +check [ "__GUEST_MD5__" = "__MD5__" ] diff --git a/test/pasta/dhcp b/test/pasta/dhcp new file mode 100644 index 0000000..80eabf5 --- /dev/null +++ b/test/pasta/dhcp @@ -0,0 +1,46 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# PASST - Plug A Simple Socket Transport +# for qemu/UNIX domain socket mode +# +# PASTA - Pack A Subtle Tap Abstraction +# for network namespace/tap device mode +# +# test/pasta/dhcp - Check DHCP and DHCPv6 functionality in pasta mode +# +# Copyright (c) 2021 Red Hat GmbH +# Author: Stefano Brivio + +nstools ip jq /sbin/dhclient +htools ip jq + +test Interface name +nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' +check [ -n "__IFNAME__" ] + +test DHCP: address +ns /sbin/dhclient -4 --no-pid __IFNAME__ +nsout ADDR ip -j -4 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[0].local' +hout HOST_ADDR ip -j -4 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[0].local' +check [ __ADDR__ = __HOST_ADDR__ ] + +test DHCP: route +nsout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway' +hout HOST_GW ip -j -4 route show|jq -rM '[.[] | select(.dst == "default").gateway] | .[0]' +check [ __GW__ = __HOST_GW__ ] + +test DHCP: MTU +nsout MTU ip -j link show | jq -rM '.[] | select(.ifname == "__IFNAME__").mtu' +check [ __MTU__ = 65520 ] + +test DHCPv6: address +ns /sbin/dhclient -6 --no-pid __IFNAME__ +hout HOST_IFNAME6 ip -j -6 route show|jq -rM '[.[] | select(.dst == "default").dev] | .[0]' +nsout ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.prefixlen == 128).local' +hout HOST_ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__HOST_IFNAME6__").addr_info[] | select(.scope == "global").local' +check [ __ADDR6__ = __HOST_ADDR6__ ] + +test DHCPv6: route +nsout GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway' +hout HOST_GW6 ip -j -6 route show|jq -rM '[.[] | select(.dst == "default").gateway] | .[0]' +check [ __GW6__ = __HOST_GW6__ ] diff --git a/test/pasta/ndp b/test/pasta/ndp new file mode 100644 index 0000000..d2b2c0b --- /dev/null +++ b/test/pasta/ndp @@ -0,0 +1,33 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# PASST - Plug A Simple Socket Transport +# for qemu/UNIX domain socket mode +# +# PASTA - Pack A Subtle Tap Abstraction +# for network namespace/tap device mode +# +# test/pasta/ndp - Check DHCP and DHCPv6 functionality in pasta mode +# +# Copyright (c) 2021 Red Hat GmbH +# Author: Stefano Brivio + +nstools ip jq sipcalc grep cut +htools ip jq sipcalc grep cut + +test Interface name +nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' +check [ -n "__IFNAME__" ] +ns ip link set dev __IFNAME__ up +sleep 2 + +test SLAAC: prefix +nsout ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.scope == "global" and .prefixlen == 64).local' +nsout PREFIX6 sipcalc __ADDR6__/64 | grep prefix | cut -d' ' -f4 +hout HOST_ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.scope == "global").local' +hout HOST_PREFIX6 sipcalc __HOST_ADDR6__/64 | grep prefix | cut -d' ' -f4 +check [ "__PREFIX6__" = "__HOST_PREFIX6__" ] + +test SLAAC: route +nsout GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway' +hout HOST_GW6 ip -j -6 route show|jq -rM '[.[] | select(.dst == "default").gateway] | .[0]' +check [ __GW6__ = __HOST_GW6__ ] diff --git a/test/pasta/tcp b/test/pasta/tcp new file mode 100644 index 0000000..7c7de06 --- /dev/null +++ b/test/pasta/tcp @@ -0,0 +1,116 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# PASST - Plug A Simple Socket Transport +# for qemu/UNIX domain socket mode +# +# PASTA - Pack A Subtle Tap Abstraction +# for network namespace/tap device mode +# +# test/pasta/tcp - Check TCP functionality for pasta +# +# Copyright (c) 2021 Red Hat GmbH +# Author: Stefano Brivio + +htools dd socat ip jq md5sum cut +nstools socat ip jq md5sum cut + +test TCP/IPv4: host to ns: big transfer +temp TEMP_BIG +temp TEMP_NS_BIG +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 +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__" ] + +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 +hostw +hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 +check [ "__HOST_MD5_BIG__" = "__MD5_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 +hostw +hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 +check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] + +test TCP/IPv4: host to ns: small transfer +temp TEMP_SMALL +temp TEMP_NS_SMALL +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 +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__" ] + +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 +hostw +hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 +check [ "__HOST_MD5_SMALL__" = "__MD5_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 +hostw +hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 +check [ "__HOST_MD5_SMALL__" = "__MD5_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 +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__" ] + +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 +hostw +hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 +check [ "__HOST_MD5_BIG__" = "__MD5_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 +hostw +hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 +check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] + +test TCP/IPv6: host to ns: small transfer +temp TEMP_SMALL +temp TEMP_NS_SMALL +nsb socat -u TCP6-LISTEN:10002,bind=[::1] OPEN:__TEMP_NS_SMALL__,create,trunc +host dd if=/dev/urandom bs=2k count=1 of=__TEMP_SMALL__ +host socat -u OPEN:__TEMP_SMALL__ 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__" ] + +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 +hostw +hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 +check [ "__HOST_MD5_SMALL__" = "__MD5_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 +hostw +hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 +check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] diff --git a/test/pasta/udp b/test/pasta/udp new file mode 100644 index 0000000..0e58152 --- /dev/null +++ b/test/pasta/udp @@ -0,0 +1,69 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# PASST - Plug A Simple Socket Transport +# for qemu/UNIX domain socket mode +# +# PASTA - Pack A Subtle Tap Abstraction +# for network namespace/tap device mode +# +# test/pasta/udp - Check UDP functionality for pasta +# +# Copyright (c) 2021 Red Hat GmbH +# Author: Stefano Brivio + +nstools socat tee grep cat ip jq md5sum cut +htools printf dd socat tee grep cat ip jq md5sum cut + +test UDP/IPv4: host to ns +temp TEMP +temp TEMP_NS +temp NC_PID +nsb (socat -u UDP4-LISTEN:10002,bind=127.0.0.1 STDOUT & echo $! > __NC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__)) +host dd if=/dev/urandom bs=1k count=5 > __TEMP__ && printf "\nEND_OF_TEST\n" >> __TEMP__ + +host socat OPEN:__TEMP__ UDP4:127.0.0.1:10002 +nsw +hout MD5 md5sum __TEMP__ | cut -d' ' -f1 +nsout NS_MD5 md5sum __TEMP_NS__ | cut -d' ' -f1 +check [ "__NS_MD5__" = "__MD5__" ] + +test UDP/IPv4: ns to host (recvmmsg/sendmmsg) +hostb (socat -u UDP4-LISTEN:10003,bind=127.0.0.1 STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__)) +sleep 1 +ns socat OPEN:__TEMP_NS__ UDP4:127.0.0.1:10003 +hostw +hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 +check [ "__HOST_MD5__" = "__MD5__" ] + +test UDP/IPv4: ns to host (via tap) +hostb (socat -u UDP4-LISTEN:10003 STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__)) +nsout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway' +ns socat -u OPEN:__TEMP_NS__ UDP4:__GW__:10003 +hostw +hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 +check [ "__HOST_MD5__" = "__MD5__" ] + +test UDP/IPv6: host to ns +nsb (socat -u UDP6-LISTEN:10002,bind=[::1] STDOUT & echo $! > __NC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__)) +host socat -u OPEN:__TEMP__ UDP6:[::1]:10002 +nsw +hout MD5 md5sum __TEMP__ | cut -d' ' -f1 +nsout NS_MD5 md5sum __TEMP_NS__ | cut -d' ' -f1 +check [ "__NS_MD5__" = "__MD5__" ] + +test UDP/IPv6: ns to host (recvmmsg/sendmmsg) +hostb (socat -u UDP6-LISTEN:10003,bind=[::1] STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__)) +sleep 1 +ns socat -u OPEN:__TEMP_NS__ UDP6:[::1]:10003 +hostw +hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 +check [ "__HOST_MD5__" = "__MD5__" ] + +test UDP/IPv6: ns to host (via tap) +hostb (socat -u UDP6-LISTEN:10003 STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__)) +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 +hostw +hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 +check [ "__HOST_MD5__" = "__MD5__" ] diff --git a/test/run b/test/run index 0ec1334..d8b60bf 100755 --- a/test/run +++ b/test/run @@ -74,40 +74,40 @@ run() { teardown distro setup pasta - test ndp/pasta - test dhcp/pasta - test tcp/pasta - test udp/pasta - test shutdown/passt + test pasta/ndp + test pasta/dhcp + test pasta/tcp + test pasta/udp + test passt/shutdown teardown pasta setup passt - test ndp/passt - test dhcp/passt - test tcp/passt - test udp/passt - test shutdown/passt + test passt/ndp + test passt/dhcp + test passt/tcp + test passt/udp + test passt/shutdown teardown passt VALGRIND=1 setup passt_in_ns - test ndp/passt - test dhcp/passt - test icmp/passt_in_ns - test tcp/passt_in_ns - test udp/passt_in_ns - test shutdown/passt_in_ns + test passt/ndp + test passt/dhcp + test passt_in_ns/icmp + test passt_in_ns/tcp + test passt_in_ns/udp + test passt_in_ns/shutdown teardown passt_in_ns VALGRIND=0 setup passt_in_ns - test ndp/passt - test dhcp/passt + test passt/ndp + test passt/dhcp test perf/passt_tcp test perf/passt_udp test perf/pasta_tcp test perf/pasta_udp - test shutdown/passt_in_ns + test passt_in_ns/shutdown teardown passt_in_ns setup two_guests diff --git a/test/shutdown/passt b/test/shutdown/passt deleted file mode 100644 index ac8ff08..0000000 --- a/test/shutdown/passt +++ /dev/null @@ -1,20 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later -# -# PASST - Plug A Simple Socket Transport -# for qemu/UNIX domain socket mode -# -# PASTA - Pack A Subtle Tap Abstraction -# for network namespace/tap device mode -# -# test/shutdown/passt - Shut down passt (or pasta) and check exit code (will -# detect valgrind errors amongst others) -# -# Copyright (c) 2022 Red Hat GmbH -# Author: Stefano Brivio - -test shutdown: exit code - -hout PASST_PID cat passt.pid -host kill __PASST_PID__ -sleep 1 -passtw diff --git a/test/shutdown/passt_in_ns b/test/shutdown/passt_in_ns deleted file mode 100644 index 3808adb..0000000 --- a/test/shutdown/passt_in_ns +++ /dev/null @@ -1,20 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later -# -# PASST - Plug A Simple Socket Transport -# for qemu/UNIX domain socket mode -# -# PASTA - Pack A Subtle Tap Abstraction -# for network namespace/tap device mode -# -# test/shutdown/passt_in_ns - Shut down passt and check exit code (will detect -# valgrind errors amongst others) -# -# Copyright (c) 2022 Red Hat GmbH -# Author: Stefano Brivio - -test shutdown: exit code - -nsout PASST_PID cat passt.pid -ns kill __PASST_PID__ -sleep 1 -passtw diff --git a/test/tcp/passt b/test/tcp/passt deleted file mode 100644 index 265f270..0000000 --- a/test/tcp/passt +++ /dev/null @@ -1,87 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later -# -# PASST - Plug A Simple Socket Transport -# for qemu/UNIX domain socket mode -# -# PASTA - Pack A Subtle Tap Abstraction -# for network namespace/tap device mode -# -# test/tcp/passt - Check TCP functionality in passt mode -# -# Copyright (c) 2021 Red Hat GmbH -# Author: Stefano Brivio - -gtools socat ip jq md5sum cut -htools dd socat ip jq md5sum cut - -test TCP/IPv4: host to guest: big transfer -temp TEMP_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 -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__" ] - -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 -hostw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__GUEST_MD5_BIG__" = "__HOST_MD5_BIG__" ] - -test TCP/IPv4: host to guest: small transfer -temp TEMP_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 -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__" ] - -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 -hostw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__GUEST_MD5_SMALL__" = "__HOST_MD5_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 -guestw -gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_BIG__" = "__HOST_MD5_BIG__" ] - -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 -hostw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__GUEST_MD5_BIG__" = "__HOST_MD5_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 -guestw -gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_SMALL__" = "__HOST_MD5_SMALL__" ] - -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 -hostw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__GUEST_MD5_SMALL__" = "__HOST_MD5_SMALL__" ] diff --git a/test/tcp/passt_in_ns b/test/tcp/passt_in_ns deleted file mode 100644 index a248f00..0000000 --- a/test/tcp/passt_in_ns +++ /dev/null @@ -1,270 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later -# -# PASST - Plug A Simple Socket Transport -# for qemu/UNIX domain socket mode -# -# PASTA - Pack A Subtle Tap Abstraction -# for network namespace/tap device mode -# -# test/tcp/passt_in_ns - Check TCP functionality for passt in ns with pasta -# -# 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 - -test TCP/IPv4: host to guest: big transfer -temp TEMP_BIG -guestb socat -u TCP4-LISTEN:10001 OPEN:test_big.bin,create,trunc -sleep 1 -host dd if=/dev/urandom bs=1M count=10 of=__TEMP_BIG__ -host socat -u OPEN:__TEMP_BIG__ 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__" ] - -test TCP/IPv4: host to ns: big transfer -temp TEMP_NS_BIG -nsb socat -u TCP4-LISTEN:10002 OPEN:__TEMP_NS_BIG__,create,trunc -host socat -u OPEN:__TEMP_BIG__ TCP4:127.0.0.1:10002 -nsw -nsout NS_MD5_BIG md5sum __TEMP_NS_BIG__ | cut -d' ' -f1 -check [ "__NS_MD5_BIG__" = "__MD5_BIG__" ] - -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' -guest socat -u OPEN:test_big.bin TCP4:__GW__:10003 -hostw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] - -test TCP/IPv4: guest to ns: big transfer -nsb socat -u TCP4-LISTEN:10002 OPEN:__TEMP_BIG__,create,trunc -guest socat -u OPEN:test_big.bin TCP4:__GW__:10002 -nsw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] - -test TCP/IPv4: ns to host (spliced): big transfer -sleep 1 -hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc -ns socat -u OPEN:__TEMP_NS_BIG__ TCP4:127.0.0.1:10003 -hostw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] - -test TCP/IPv4: ns to host (via tap): big transfer -hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc -ns socat -u OPEN:__TEMP_NS_BIG__ TCP4:__GW__:10003 -hostw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] - -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 -guestw -gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ] - -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' -ns socat -u OPEN:__TEMP_NS_BIG__ TCP4:__ADDR__:10001 -guestw -gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ] - -test TCP/IPv4: host to guest: small transfer -temp TEMP_SMALL -guestb socat -u TCP4-LISTEN:10001 OPEN:test_small.bin,create,trunc -sleep 1 -host dd if=/dev/urandom bs=2k count=100 of=__TEMP_SMALL__ -host socat -u OPEN:__TEMP_SMALL__ 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__" ] - -test TCP/IPv4: host to ns: small transfer -temp TEMP_NS_SMALL -nsb socat -u TCP4-LISTEN:10002 OPEN:__TEMP_NS_SMALL__,create,trunc -host socat -u OPEN:__TEMP_SMALL__ TCP4:127.0.0.1:10002 -nsw -nsout NS_MD5_SMALL md5sum __TEMP_NS_SMALL__ | cut -d' ' -f1 -check [ "__NS_MD5_SMALL__" = "__MD5_SMALL__" ] - -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' -guest socat -u OPEN:test_small.bin TCP4:__GW__:10003 -hostw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] - -test TCP/IPv4: guest to ns: small transfer -nsb socat -u TCP4-LISTEN:10002 OPEN:__TEMP_SMALL__,create,trunc -guest socat -u OPEN:test_small.bin TCP4:__GW__:10002 -nsw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] - -test TCP/IPv4: ns to host (spliced): small transfer -sleep 1 -hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc -ns socat -u OPEN:__TEMP_NS_SMALL__ TCP4:127.0.0.1:10003 -hostw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] - -test TCP/IPv4: ns to host (via tap): small transfer -hostb socat -u TCP4-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc -ns socat -u OPEN:__TEMP_NS_SMALL__ TCP4:__GW__:10003 -hostw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] - -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 -guestw -gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ] - -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 -guestw -gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ] - -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 -guestw -gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ] - -test TCP/IPv6: host to ns: big transfer -nsb socat -u TCP6-LISTEN:10002 OPEN:__TEMP_NS_BIG__,create,trunc -host socat -u OPEN:__TEMP_BIG__ TCP6:[::1]:10002 -nsw -nsout NS_MD5_BIG md5sum __TEMP_NS_BIG__ | cut -d' ' -f1 -check [ "__NS_MD5_BIG__" = "__MD5_BIG__" ] - -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' -guest socat -u OPEN:test_big.bin TCP6:[__GW6__%__IFNAME__]:10003 -hostw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] - -test TCP/IPv6: guest to ns: big transfer -nsb socat -u TCP6-LISTEN:10002 OPEN:__TEMP_BIG__,create,trunc -guest socat -u OPEN:test_big.bin TCP6:[__GW6__%__IFNAME__]:10002 -nsw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] - -test TCP/IPv6: ns to host (spliced): big transfer -hostb socat -u TCP6-LISTEN:10003 OPEN:__TEMP_BIG__,create,trunc -ns socat -u OPEN:__TEMP_NS_BIG__ TCP6:[::1]:10003 -hostw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] - -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' -ns socat -u OPEN:__TEMP_NS_BIG__ TCP6:[__GW6__%__IFNAME__]:10003 -hostw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] - -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 -guestw -gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ] - -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' -ns socat -u OPEN:__TEMP_NS_BIG__ TCP6:[__ADDR6__]:10001 -guestw -gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ] - -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 -guestw -gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ] - -test TCP/IPv6: host to ns: small transfer -nsb socat -u TCP6-LISTEN:10002 OPEN:__TEMP_NS_SMALL__,create,trunc -host socat -u OPEN:__TEMP_SMALL__ TCP6:[::1]:10002 -nsw -nsout NS_MD5_SMALL md5sum __TEMP_NS_SMALL__ | cut -d' ' -f1 -check [ "__NS_MD5_SMALL__" = "__MD5_SMALL__" ] - -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' -guest socat -u OPEN:test_small.bin TCP6:[__GW6__%__IFNAME__]:10003 -hostw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] - -test TCP/IPv6: guest to ns: small transfer -nsb socat -u TCP6-LISTEN:10002 OPEN:__TEMP_SMALL__ -guest socat -u OPEN:test_small.bin TCP6:[__GW6__%__IFNAME__]:10002 -nsw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] - -test TCP/IPv6: ns to host (spliced): small transfer -hostb socat -u TCP6-LISTEN:10003 OPEN:__TEMP_SMALL__,create,trunc -ns socat -u OPEN:__TEMP_NS_SMALL__ TCP6:[::1]:10003 -hostw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] - -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' -ns socat -u OPEN:__TEMP_NS_SMALL__ TCP6:[__GW6__%__IFNAME__]:10003 -hostw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] - -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 -guestw -gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ] - -test TCP/IPv6: ns to guest (using namespace address): small transfer -guestb socat -u TCP6-LISTEN:10001 OPEN:test_small.bin,create,trunc -ns socat -u OPEN:__TEMP_NS_SMALL__ TCP6:[__ADDR6__]:10001 -guestw -gout GUEST_MD5_SMALL md5sum test_small.bin | cut -d' ' -f1 -check [ "__GUEST_MD5_SMALL__" = "__MD5_SMALL__" ] diff --git a/test/tcp/pasta b/test/tcp/pasta deleted file mode 100644 index a13a2ff..0000000 --- a/test/tcp/pasta +++ /dev/null @@ -1,116 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later -# -# PASST - Plug A Simple Socket Transport -# for qemu/UNIX domain socket mode -# -# PASTA - Pack A Subtle Tap Abstraction -# for network namespace/tap device mode -# -# test/tcp/pasta - Check TCP functionality for pasta -# -# Copyright (c) 2021 Red Hat GmbH -# Author: Stefano Brivio - -htools dd socat ip jq md5sum cut -nstools socat ip jq md5sum cut - -test TCP/IPv4: host to ns: big transfer -temp TEMP_BIG -temp TEMP_NS_BIG -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 -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__" ] - -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 -hostw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__HOST_MD5_BIG__" = "__MD5_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 -hostw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] - -test TCP/IPv4: host to ns: small transfer -temp TEMP_SMALL -temp TEMP_NS_SMALL -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 -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__" ] - -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 -hostw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__HOST_MD5_SMALL__" = "__MD5_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 -hostw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__HOST_MD5_SMALL__" = "__MD5_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 -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__" ] - -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 -hostw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__HOST_MD5_BIG__" = "__MD5_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 -hostw -hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1 -check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ] - -test TCP/IPv6: host to ns: small transfer -temp TEMP_SMALL -temp TEMP_NS_SMALL -nsb socat -u TCP6-LISTEN:10002,bind=[::1] OPEN:__TEMP_NS_SMALL__,create,trunc -host dd if=/dev/urandom bs=2k count=1 of=__TEMP_SMALL__ -host socat -u OPEN:__TEMP_SMALL__ 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__" ] - -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 -hostw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__HOST_MD5_SMALL__" = "__MD5_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 -hostw -hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1 -check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ] diff --git a/test/udp/passt b/test/udp/passt deleted file mode 100644 index a14e6d2..0000000 --- a/test/udp/passt +++ /dev/null @@ -1,52 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later -# -# PASST - Plug A Simple Socket Transport -# for qemu/UNIX domain socket mode -# -# PASTA - Pack A Subtle Tap Abstraction -# for network namespace/tap device mode -# -# test/udp/passt - Check UDP functionality in passt mode -# -# Copyright (c) 2021 Red Hat GmbH -# Author: Stefano Brivio - -gtools socat tee grep cat ip jq md5sum cut -htools printf dd socat tee grep cat ip jq md5sum cut - -test UDP/IPv4: host to guest -temp TEMP -temp SC_PID -guestb (socat -u UDP4-LISTEN:10001 STDOUT & echo $! > __SC_PID__) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) -sleep 1 -host dd if=/dev/urandom bs=1k count=5 > __TEMP__ && printf "\nEND_OF_TEST\n" >> __TEMP__ -host socat -u OPEN:__TEMP__ UDP4:127.0.0.1:10001 -guestw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 -check [ "__GUEST_MD5__" = "__HOST_MD5__" ] - -test UDP/IPv4: guest to host -hostb (socat -u UDP4-LISTEN:10003,bind=127.0.0.1 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) -gout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway' -guest socat -u OPEN:test.bin UDP4:__GW__:10003 -hostw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__GUEST_MD5__" = "__HOST_MD5__" ] - -test UDP/IPv6: host to guest -guestb (socat -u UDP6-LISTEN:10001 STDOUT & echo $! > sc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat sc.pid)) -sleep 1 -host socat -u OPEN:__TEMP__ UDP6:[::1]:10001 -guestw -gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 -check [ "__GUEST_MD5__" = "__HOST_MD5__" ] - -test UDP/IPv6: guest to host -hostb (socat -u UDP6-LISTEN:10003,bind=[::1] STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) -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 -hostw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__GUEST_MD5__" = "__HOST_MD5__" ] diff --git a/test/udp/passt_in_ns b/test/udp/passt_in_ns deleted file mode 100644 index d5f08fe..0000000 --- a/test/udp/passt_in_ns +++ /dev/null @@ -1,142 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later -# -# PASST - Plug A Simple Socket Transport -# for qemu/UNIX domain socket mode -# -# PASTA - Pack A Subtle Tap Abstraction -# for network namespace/tap device mode -# -# test/udp/passt_in_ns - Check UDP functionality for passt in ns and pasta -# -# Copyright (c) 2021 Red Hat GmbH -# Author: Stefano Brivio - -gtools socat tee grep cat ip jq md5sum cut -nstools socat tee grep cat ip jq md5sum cut -htools printf dd socat tee grep cat ip jq md5sum cut - -test UDP/IPv4: host to guest -temp TEMP -temp SC_PID -guestb (socat -u UDP4-LISTEN:10001 STDOUT & echo $! > sc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat sc.pid)) -sleep 1 -host dd if=/dev/urandom bs=1k count=5 > __TEMP__ && printf "\nEND_OF_TEST\n" >> __TEMP__ -host socat -u OPEN:__TEMP__ UDP4:127.0.0.1:10001 -guestw -hout MD5 md5sum __TEMP__ | cut -d' ' -f1 -gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 -check [ "__GUEST_MD5__" = "__MD5__" ] - -test UDP/IPv4: host to ns -temp TEMP_NS -nsb (socat -u UDP4-LISTEN:10002 STDOUT & echo $! > __SC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) -host socat -u OPEN:__TEMP__ UDP4:127.0.0.1:10002 -nsw -nsout NS_MD5 md5sum __TEMP_NS__ | cut -d' ' -f1 -check [ "__NS_MD5__" = "__MD5__" ] - -test UDP/IPv4: guest to host -hostb (socat -u UDP4-LISTEN:10003 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) -gout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway' -guest socat -u OPEN:test.bin UDP4:__GW__:10003 -hostw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__HOST_MD5__" = "__MD5__" ] - -test UDP/IPv4: guest to ns -nsb (socat -u UDP4-LISTEN:10002 STDOUT & echo $! > __SC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) -guest socat -u OPEN:test.bin UDP4:__GW__:10002 -nsw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__HOST_MD5__" = "__MD5__" ] - -test UDP/IPv4: ns to host (recvmmsg/sendmmsg) -sleep 1 -hostb (socat -u UDP4-LISTEN:10003 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) -ns socat -u OPEN:__TEMP_NS__ UDP4:127.0.0.1:10003 -hostw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__HOST_MD5__" = "__MD5__" ] - -test UDP/IPv4: ns to host (via tap) -hostb (socat -u UDP4-LISTEN:10003 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) -ns socat -u OPEN:__TEMP_NS__ UDP4:__GW__:10003 -hostw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__HOST_MD5__" = "__MD5__" ] - -test UDP/IPv4: ns to guest (using loopback address) -guestb (socat -u UDP4-LISTEN:10001 STDOUT & echo $! > sc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat sc.pid)) -ns socat -u OPEN:__TEMP_NS__ UDP4:127.0.0.1:10001 -guestw -gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 -check [ "__GUEST_MD5__" = "__MD5__" ] - -test UDP/IPv4: ns to guest (using namespace address) -guestb (socat -u UDP4-LISTEN:10001 STDOUT & echo $! > sc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat sc.pid)) -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' -ns socat -u OPEN:__TEMP_NS__ UDP4:__ADDR__:10001 -guestw -gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 -check [ "__GUEST_MD5__" = "__MD5__" ] - -test UDP/IPv6: host to guest -guestb (socat -u UDP6-LISTEN:10001 STDOUT & echo $! > sc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat sc.pid)) -host socat -u OPEN:__TEMP__ UDP6:[::1]:10001 -guestw -gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 -check [ "__GUEST_MD5__" = "__MD5__" ] - -test UDP/IPv6: host to ns -nsb (socat -u UDP6-LISTEN:10002 STDOUT & echo $! > __SC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) -host socat -u OPEN:__TEMP__ UDP6:[::1]:10002 -nsw -nsout NS_MD5 md5sum __TEMP_NS__ | cut -d' ' -f1 -check [ "__NS_MD5__" = "__MD5__" ] - -test UDP/IPv6: guest to host -hostb (socat -u UDP6-LISTEN:10003 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) -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 -hostw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__HOST_MD5__" = "__MD5__" ] - -test UDP/IPv6: guest to ns -nsb (socat -u UDP6-LISTEN:10002 STDOUT & echo $! > __SC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) -guest socat -u OPEN:test.bin UDP6:[__GW6__%__IFNAME__]:10002 -nsw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__HOST_MD5__" = "__MD5__" ] - -test UDP/IPv6: ns to host (recvmmsg/sendmmsg) -hostb (socat -u UDP6-LISTEN:10003 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) -ns socat -u OPEN:__TEMP_NS__ UDP6:[::1]:10003 -hostw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__HOST_MD5__" = "__MD5__" ] - -test UDP/IPv6: ns to host (via tap) -hostb (socat -u UDP6-LISTEN:10003 STDOUT & echo $! > __SC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __SC_PID__)) -nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname' -ns socat -u OPEN:__TEMP_NS__ UDP6:[__GW6__%__IFNAME__]:10003 -hostw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__HOST_MD5__" = "__MD5__" ] - -test UDP/IPv6: ns to guest (using loopback address) -guestb (socat -u UDP6-LISTEN:10001 STDOUT & echo $! > sc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat sc.pid)) -ns socat -u OPEN:__TEMP_NS__ UDP6:[::1]:10001 -guestw -gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 -check [ "__GUEST_MD5__" = "__MD5__" ] - -test UDP/IPv6: ns to guest (using namespace address) -guestb (socat -u UDP6-LISTEN:10001 STDOUT & echo $! > sc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat sc.pid)) -nsout ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[0].local' -ns socat -u OPEN:__TEMP_NS__ UDP6:[__ADDR6__]:10001 -guestw -gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1 -check [ "__GUEST_MD5__" = "__MD5__" ] diff --git a/test/udp/pasta b/test/udp/pasta deleted file mode 100644 index 0767e0b..0000000 --- a/test/udp/pasta +++ /dev/null @@ -1,69 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later -# -# PASST - Plug A Simple Socket Transport -# for qemu/UNIX domain socket mode -# -# PASTA - Pack A Subtle Tap Abstraction -# for network namespace/tap device mode -# -# test/udp/pasta - Check UDP functionality for pasta -# -# Copyright (c) 2021 Red Hat GmbH -# Author: Stefano Brivio - -nstools socat tee grep cat ip jq md5sum cut -htools printf dd socat tee grep cat ip jq md5sum cut - -test UDP/IPv4: host to ns -temp TEMP -temp TEMP_NS -temp NC_PID -nsb (socat -u UDP4-LISTEN:10002,bind=127.0.0.1 STDOUT & echo $! > __NC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__)) -host dd if=/dev/urandom bs=1k count=5 > __TEMP__ && printf "\nEND_OF_TEST\n" >> __TEMP__ - -host socat OPEN:__TEMP__ UDP4:127.0.0.1:10002 -nsw -hout MD5 md5sum __TEMP__ | cut -d' ' -f1 -nsout NS_MD5 md5sum __TEMP_NS__ | cut -d' ' -f1 -check [ "__NS_MD5__" = "__MD5__" ] - -test UDP/IPv4: ns to host (recvmmsg/sendmmsg) -hostb (socat -u UDP4-LISTEN:10003,bind=127.0.0.1 STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__)) -sleep 1 -ns socat OPEN:__TEMP_NS__ UDP4:127.0.0.1:10003 -hostw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__HOST_MD5__" = "__MD5__" ] - -test UDP/IPv4: ns to host (via tap) -hostb (socat -u UDP4-LISTEN:10003 STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__)) -nsout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway' -ns socat -u OPEN:__TEMP_NS__ UDP4:__GW__:10003 -hostw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__HOST_MD5__" = "__MD5__" ] - -test UDP/IPv6: host to ns -nsb (socat -u UDP6-LISTEN:10002,bind=[::1] STDOUT & echo $! > __NC_PID__) | tee __TEMP_NS__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__)) -host socat -u OPEN:__TEMP__ UDP6:[::1]:10002 -nsw -hout MD5 md5sum __TEMP__ | cut -d' ' -f1 -nsout NS_MD5 md5sum __TEMP_NS__ | cut -d' ' -f1 -check [ "__NS_MD5__" = "__MD5__" ] - -test UDP/IPv6: ns to host (recvmmsg/sendmmsg) -hostb (socat -u UDP6-LISTEN:10003,bind=[::1] STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__)) -sleep 1 -ns socat -u OPEN:__TEMP_NS__ UDP6:[::1]:10003 -hostw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__HOST_MD5__" = "__MD5__" ] - -test UDP/IPv6: ns to host (via tap) -hostb (socat -u UDP6-LISTEN:10003 STDOUT & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__)) -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 -hostw -hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1 -check [ "__HOST_MD5__" = "__MD5__" ] -- cgit v1.2.3