1
0
mirror of https://passt.top/passt synced 2024-12-22 05:35:23 +00:00

Don't abbreviate ip(8) arguments in examples and tests

ip(8)'s ability to take abbreviated arguments (e.g. "li sh" instead of
"link show") is very handy when using it interactively, but it doesn't make
for very readable scripts and examples when shown that way.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
David Gibson 2022-06-10 12:32:42 +10:00 committed by Stefano Brivio
parent 6703da44c1
commit 2320ac3349
22 changed files with 114 additions and 114 deletions

View File

@ -259,7 +259,7 @@ we can now:
### verify that addresses are properly configured
crictl exec $c ip ad sh
crictl exec $c ip addr show
## Enable support for ICMP/ICMPv6 Echo Request

View File

@ -19,9 +19,9 @@ get_token() {
unset IFS
}
ipv6_dev() { get_token "dev" $(ip -o -6 ro show default | grep via); }
ipv6_devaddr() { get_token "inet6" $(ip -o -6 ad sh dev "${1}" scope global); }
ipv6_ll_addr() { get_token "inet6" $(ip -o -6 ad sh dev "${1}" scope link); }
ipv6_dev() { get_token "dev" $(ip -o -6 route show default | grep via); }
ipv6_devaddr() { get_token "inet6" $(ip -o -6 addr show dev "${1}" scope global); }
ipv6_ll_addr() { get_token "inet6" $(ip -o -6 addr show dev "${1}" scope link); }
ipv6_mask() { echo ${1#*/}; }
ipv6_mangle() {
IFS=':'
@ -93,7 +93,7 @@ if [ -n "${ipv6_addr}" ]; then
ip addr add "${ipv6_addr}" dev "veth_${ns}"
ip route add "${ipv6_passt}" dev "veth_${ns}"
passt_ll="$(ipv6_ll_addr "veth_${ns}")"
main_ll="$(get_token "link/ether" $(ip -o li sh "veth_${ns}"))"
main_ll="$(get_token "link/ether" $(ip -o link show "veth_${ns}"))"
ip neigh add "${passt_ll%%/*}" dev "veth_${ns}" lladdr "${main_ll}"
ip -n "${ns}" route add default via "${passt_ll%%/*}" dev "veth_${ns}"

View File

@ -108,13 +108,13 @@ sleep 10
nl
nl
guest ip li sh
guest ip link show
sleep 3
say Guest is up. Let's configure IPv4 first...
sleep 2
guest dhclient
sleep 2
guest ip ad sh
guest ip addr show
sleep 5
nl
@ -140,7 +140,7 @@ say Now the other way around... using
nl
say the address of the default gateway.
sleep 2
gout GW ip -j -4 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
gout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
sleep 5
hostb nc -l -p 31337
sleep 2
@ -168,8 +168,8 @@ host sysctl -w net.ipv4.tcp_rmem="4096 524288 134217728"
host sysctl -w net.ipv4.tcp_wmem="4096 524288 134217728"
host sysctl -w net.ipv4.tcp_timestamps=0
gout GW6 ip -j -6 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
gout IFNAME ip -j li sh | jq -rM '.[] | select(.link_type == "ether").ifname'
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'
nl
nl
info Throughput in Gbps, latency in µs

View File

@ -73,13 +73,13 @@ host q
nl
nl
ns ip li sh
ns ip link show
sleep 3
say Let's configure IPv4 first...
sleep 2
ns dhclient
sleep 2
ns ip ad sh
ns ip addr show
sleep 5
nl
@ -119,7 +119,7 @@ sleep 5
nl
say or the address of the default gateway.
sleep 2
nsout GW ip -j -4 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
nsout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
sleep 5
hostb nc -l -p 31337
sleep 2

View File

@ -73,13 +73,13 @@ nl
say We can observe some practical differences:
nl
ns1b ip ad sh
ns1b ip addr show
sleep 3
say - slirp4netns uses a predefined IPv4 address
hl NS1
sleep 2
ns2b ip ad sh
ns2b ip addr show
sleep 3
say ,
nl
@ -103,7 +103,7 @@ sleep 2
nl
say - same for routes:
ns1b ip ro sh
ns1b ip route show
sleep 3
say slirp4netns defines its own
nl
@ -112,8 +112,8 @@ hl NS1
sleep 2
say , pasta copies it from the host
ns2b ip ro sh
ns2b ip -6 ro sh
ns2b ip route show
ns2b ip -6 route show
sleep 5
nl
@ -310,11 +310,11 @@ nl
nl
say Everything is set now, let's start
sleep 2
hout IFNAME ip -j li sh | jq -rM '.[] | select(.link_type == "ether").ifname'
hout ADDR4 ip -j -4 ad sh|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.scope == "global").local'
hout ADDR6 ip -j -6 ad sh|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.scope == "global").local'
hout GW4 ip -j -4 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
hout GW6 ip -j -6 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
hout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'
hout ADDR4 ip -j -4 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.scope == "global").local'
hout ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.scope == "global").local'
hout GW4 ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
hout GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway'
nl
nl

View File

@ -16,23 +16,23 @@ gtools ip jq dhclient sed tr
htools ip jq sed tr head
test Interface name
gout IFNAME ip -j li sh | jq -rM '.[] | select(.link_type == "ether").ifname'
hout HOST_IFNAME ip -j -4 ro sh|jq -rM '.[] | select(.dst == "default").dev'
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'
check [ -n "__IFNAME__" ]
test DHCP: address
guest /sbin/dhclient __IFNAME__
gout ADDR ip -j -4 ad sh|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[0].local'
hout HOST_ADDR ip -j -4 ad sh|jq -rM '.[] | select(.ifname == "__HOST_IFNAME__").addr_info[0].local'
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 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
hout HOST_GW ip -j -4 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
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'
check [ "__GW__" = "__HOST_GW__" ]
test DHCP: MTU
gout MTU ip -j li sh | jq -rM '.[] | select(.ifname == "__IFNAME__").mtu'
gout MTU ip -j link show | jq -rM '.[] | select(.ifname == "__IFNAME__").mtu'
check [ __MTU__ = 65520 ]
test DHCP: DNS
@ -49,13 +49,13 @@ check [ "__SEARCH__" = "__HOST_SEARCH__" ]
test DHCPv6: address
guest /sbin/dhclient -6 __IFNAME__
gout ADDR6 ip -j -6 ad sh|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.prefixlen == 128).local'
hout HOST_ADDR6 ip -j -6 ad sh|jq -rM '.[] | select(.ifname == "__HOST_IFNAME__").addr_info[] | select(.scope == "global").local'
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_IFNAME__").addr_info[] | select(.scope == "global").local'
check [ "__ADDR6__" = "__HOST_ADDR6__" ]
test DHCPv6: route
gout GW6 ip -j -6 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
hout HOST_GW6 ip -j -6 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
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'
check [ "__GW6__" = "__HOST_GW6__" ]
# Strip interface specifier: interface names might differ between host and guest

View File

@ -16,31 +16,31 @@ nstools ip jq /sbin/udhcpc /sbin/dhclient
htools ip jq
test Interface name
nsout IFNAME ip -j li sh | jq -rM '.[] | select(.link_type == "ether").ifname'
nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'
check [ -n "__IFNAME__" ]
test DHCP: address
ns /sbin/udhcpc -i __IFNAME__
nsout ADDR ip -j -4 ad sh|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[0].local'
hout HOST_ADDR ip -j -4 ad sh|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'
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 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
hout HOST_GW ip -j -4 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
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'
check [ __GW__ = __HOST_GW__ ]
test DHCP: MTU
nsout MTU ip -j li sh | jq -rM '.[] | select(.ifname == "__IFNAME__").mtu'
nsout MTU ip -j link show | jq -rM '.[] | select(.ifname == "__IFNAME__").mtu'
check [ __MTU__ = 65520 ]
test DHCPv6: address
ns /sbin/dhclient -6 __IFNAME__
nsout ADDR6 ip -j -6 ad sh|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.prefixlen == 128).local'
hout HOST_ADDR6 ip -j -6 ad sh|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.scope == "global").local'
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 == "__IFNAME__").addr_info[] | select(.scope == "global").local'
check [ __ADDR6__ = __HOST_ADDR6__ ]
test DHCPv6: route
nsout GW6 ip -j -6 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
hout HOST_GW6 ip -j -6 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
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'
check [ __GW6__ = __HOST_GW6__ ]

View File

@ -21,13 +21,13 @@ nstools ip jq sleep
gtools ping ip jq
test ICMP echo: guest to ns
nsout IFNAME_NS ip -j li sh | jq -rM '.[] | select(.link_type == "ether").ifname'
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 li sh | jq -rM '.[] | select(.link_type == "ether").ifname'
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__

View File

@ -141,7 +141,7 @@ setup_passt_in_ns() {
pane_status GUEST
pane_status NS
pane_run NS "ip -j li sh | jq -rM '.[] | select(.link_type == \"ether\").ifname'"
pane_run NS "ip -j link show | jq -rM '.[] | select(.link_type == \"ether\").ifname'"
pane_wait NS
__ifname="$(pane_parse NS)"
pane_run NS "/sbin/udhcpc -i ${__ifname}"
@ -228,7 +228,7 @@ setup_two_guests() {
pane_run GUEST_1 "nsenter -t ${__ns1_pid} -U -n --preserve-credentials"
pane_run GUEST_2 "nsenter -t ${__ns2_pid} -U -n --preserve-credentials"
pane_run PASST_1 "ip -j li sh | jq -rM '.[] | select(.link_type == \"ether\").ifname'"
pane_run PASST_1 "ip -j link show | jq -rM '.[] | select(.link_type == \"ether\").ifname'"
pane_wait PASST_1
__ifname="$(pane_parse PASST_1)"

View File

@ -16,19 +16,19 @@ gtools ip jq sipcalc grep
htools ip jq sipcalc grep cut
test Interface name
gout IFNAME ip -j li sh | jq -rM '.[] | select(.link_type == "ether").ifname'
gout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'
guest ip link set dev __IFNAME__ up && sleep 2
hout HOST_IFNAME ip -j -4 ro sh|jq -rM '.[] | select(.dst == "default").dev'
hout HOST_IFNAME ip -j -4 route show|jq -rM '.[] | select(.dst == "default").dev'
check [ -n "__IFNAME__" ]
test SLAAC: prefix
gout ADDR6 ip -j -6 ad sh|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.scope == "global" and .prefixlen == 64).local'
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 ad sh|jq -rM '.[] | select(.ifname == "__HOST_IFNAME__").addr_info[] | select(.scope == "global").local'
hout HOST_ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__HOST_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
gout GW6 ip -j -6 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
hout HOST_GW6 ip -j -6 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
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'
check [ __GW6__ = __HOST_GW6__ ]

View File

@ -16,20 +16,20 @@ nstools ip jq sipcalc grep cut
htools ip jq sipcalc grep cut
test Interface name
nsout IFNAME ip -j li sh | jq -rM '.[] | select(.link_type == "ether").ifname'
nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'
ns ip link set dev __IFNAME__ up
sleep 2
hout HOST_IFNAME ip -j -4 ro sh|jq -rM '.[] | select(.dst == "default").dev'
hout HOST_IFNAME ip -j -4 route show|jq -rM '.[] | select(.dst == "default").dev'
check [ -n "__IFNAME__" ]
test SLAAC: prefix
nsout ADDR6 ip -j -6 ad sh|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.scope == "global" and .prefixlen == 64).local'
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 ad sh|jq -rM '.[] | select(.ifname == "__HOST_IFNAME__").addr_info[] | select(.scope == "global").local'
hout HOST_ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__HOST_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 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
hout HOST_GW6 ip -j -6 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
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'
check [ __GW6__ = __HOST_GW6__ ]

View File

@ -35,9 +35,9 @@ ns sysctl -w net.ipv4.tcp_rmem="4096 524288 134217728"
ns sysctl -w net.ipv4.tcp_wmem="4096 524288 134217728"
ns sysctl -w net.ipv4.tcp_timestamps=0
gout GW ip -j -4 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
gout GW6 ip -j -6 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
gout IFNAME ip -j li sh | jq -rM '.[] | select(.link_type == "ether").ifname'
gout GW ip -j -4 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'
hout FREQ_PROCFS (echo "scale=1"; sed -n 's/cpu MHz.*: \([0-9]*\)\..*$/(\1+10^2\/2)\/10^3/p' /proc/cpuinfo) | bc -l | head -n1
hout FREQ_CPUFREQ (echo "scale=1"; printf '( %i + 10^5 / 2 ) / 10^6\n' $(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq) ) | bc -l

View File

@ -28,9 +28,9 @@ guest /sbin/sysctl -w net.core.wmem_max=16777216
guest /sbin/sysctl -w net.core.rmem_default=16777216
guest /sbin/sysctl -w net.core.wmem_default=16777216
gout GW ip -j -4 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
gout GW6 ip -j -6 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
gout IFNAME ip -j li sh | jq -rM '.[] | select(.link_type == "ether").ifname'
gout GW ip -j -4 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'
hout FREQ_PROCFS (echo "scale=1"; sed -n 's/cpu MHz.*: \([0-9]*\)\..*$/(\1+10^2\/2)\/10^3/p' /proc/cpuinfo) | bc -l | head -n1
hout FREQ_CPUFREQ (echo "scale=1"; printf '( %i + 10^5 / 2 ) / 10^6\n' $(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq) ) | bc -l

View File

@ -170,9 +170,9 @@ te
test pasta: throughput and latency (connections via tap)
nsout GW ip -j -4 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
nsout GW6 ip -j -6 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
nsout IFNAME ip -j li sh | jq -rM '.[] | select(.link_type == "ether").ifname'
nsout GW ip -j -4 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'
set THREADS 1
set STREAMS 2
set OPTS -Z -P __STREAMS__ -i1 -t30 -O5 --pacing-timer 100000

View File

@ -129,9 +129,9 @@ te
test pasta: throughput and latency (traffic via tap)
nsout GW ip -j -4 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
nsout GW6 ip -j -6 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
nsout IFNAME ip -j li sh | jq -rM '.[] | select(.link_type == "ether").ifname'
nsout GW ip -j -4 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'
info Throughput in Gbps, latency in µs, one thread at __FREQ__ GHz, __STREAMS__ streams
report pasta tap_udp 1 __FREQ__

View File

@ -27,7 +27,7 @@ check [ "__GUEST_MD5_BIG__" = "__HOST_MD5_BIG__" ]
test TCP/IPv4: guest to host: big transfer
hostb nc -4 -l 10003 > __TEMP_BIG__
gout GW ip -j -4 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
gout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
guest cat test_big.bin | nc -N __GW__ 10003
hostw
hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1
@ -62,8 +62,8 @@ check [ "__GUEST_MD5_BIG__" = "__HOST_MD5_BIG__" ]
test TCP/IPv6: guest to host: big transfer
hostb nc -6 -l 10003 > __TEMP_BIG__
gout GW6 ip -j -6 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
gout IFNAME ip -j li sh | jq -rM '.[] | select(.link_type == "ether").ifname'
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 cat test_big.bin | nc -N __GW6__%__IFNAME__ 10003
hostw
hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1

View File

@ -36,7 +36,7 @@ check [ "__NS_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv4: guest to host: big transfer
hostb nc -4 -l 10003 > __TEMP_BIG__
gout GW ip -j -4 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
gout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
guest cat test_big.bin | nc -N __GW__ 10003
hostw
hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1
@ -73,8 +73,8 @@ check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv4: ns to guest (using namespace address): big transfer
guestb nc -4 -l 10001 > test_big.bin
nsout IFNAME ip -j li sh | jq -rM '.[] | select(.link_type == "ether").ifname'
nsout ADDR ip -j -4 ad sh|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[0].local'
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 cat __TEMP_NS_BIG__ | nc -N __ADDR__ 10001
guestw
gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1
@ -100,7 +100,7 @@ check [ "__NS_MD5_SMALL__" = "__MD5_SMALL__" ]
test TCP/IPv4: guest to host: small transfer
hostb nc -4 -l 10003 > __TEMP_SMALL__
gout GW ip -j -4 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
gout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
guest cat test_small.bin | nc -N __GW__ 10003
hostw
hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1
@ -158,8 +158,8 @@ check [ "__NS_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv6: guest to host: big transfer
hostb nc -6 -l 10003 > __TEMP_BIG__
gout GW6 ip -j -6 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
gout IFNAME ip -j li sh | jq -rM '.[] | select(.link_type == "ether").ifname'
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 cat test_big.bin | nc -N __GW6__%__IFNAME__ 10003
hostw
hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1
@ -181,7 +181,7 @@ check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv6: ns to host (via tap): big transfer
hostb nc -6 -l 10003 > __TEMP_BIG__
nsout IFNAME ip -j li sh | jq -rM '.[] | select(.link_type == "ether").ifname'
nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'
ns cat __TEMP_NS_BIG__ | nc -N __GW6__%__IFNAME__ 10003
hostw
hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1
@ -196,7 +196,7 @@ check [ "__GUEST_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv6: ns to guest (using namespace address): big transfer
guestb nc -6 -l 10001 > test_big.bin
nsout ADDR6 ip -j -6 ad sh|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'
ns cat __TEMP_NS_BIG__ | nc -N __ADDR6__ 10001
guestw
gout GUEST_MD5_BIG md5sum test_big.bin | cut -d' ' -f1
@ -218,8 +218,8 @@ check [ "__NS_MD5_SMALL__" = "__MD5_SMALL__" ]
test TCP/IPv6: guest to host: small transfer
hostb nc -6 -l 10003 > __TEMP_SMALL__
gout GW6 ip -j -6 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
gout IFNAME ip -j li sh | jq -rM '.[] | select(.link_type == "ether").ifname'
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 cat test_small.bin | nc -N __GW6__%__IFNAME__ 10003
hostw
hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1
@ -241,7 +241,7 @@ check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ]
test TCP/IPv6: ns to host (via tap): small transfer
hostb nc -6 -l 10003 > __TEMP_SMALL__
nsout IFNAME ip -j li sh | jq -rM '.[] | select(.link_type == "ether").ifname'
nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'
ns cat __TEMP_NS_SMALL__ | nc -N __GW6__%__IFNAME__ 10003
hostw
hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1

View File

@ -35,7 +35,7 @@ check [ "__HOST_MD5_BIG__" = "__MD5_BIG__" ]
test TCP/IPv4: ns to host (via tap): big transfer
hostb nc -4 -l 10003 > __TEMP_BIG__
nsout GW ip -j -4 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
nsout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
ns cat __TEMP_NS_BIG__ | nc -N __GW__ 10003
hostw
hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1
@ -61,7 +61,7 @@ check [ "__HOST_MD5_SMALL__" = "__MD5_SMALL__" ]
test TCP/IPv4: ns to host (via tap): small transfer
hostb nc -4 -l 10003 > __TEMP_SMALL__
nsout GW ip -j -4 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
nsout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
ns cat __TEMP_NS_SMALL__ | nc -N __GW__ 10003
hostw
hout HOST_MD5_SMALL md5sum __TEMP_SMALL__ | cut -d' ' -f1
@ -85,8 +85,8 @@ nsw
test TCP/IPv6: ns to host (via tap): big transfer
hostb nc -6 -l 10003 > __TEMP_BIG__
nsout GW6 ip -j -6 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
nsout IFNAME ip -j li sh | jq -rM '.[] | select(.link_type == "ether").ifname'
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 cat __TEMP_NS_BIG__ | nc -N __GW6__%__IFNAME__ 10003
hostw
hout HOST_MD5_BIG md5sum __TEMP_BIG__ | cut -d' ' -f1

View File

@ -16,18 +16,18 @@ g2tools ip jq dhclient nc cat
htools ip jq cat md5sum cut
test Interface names
g1out IFNAME1 ip -j li sh | jq -rM '.[] | select(.link_type == "ether").ifname'
g2out IFNAME2 ip -j li sh | jq -rM '.[] | select(.link_type == "ether").ifname'
hout HOST_IFNAME ip -j -4 ro sh|jq -rM '.[] | select(.dst == "default").dev'
g1out IFNAME1 ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'
g2out IFNAME2 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'
check [ -n "__IFNAME1__" ]
check [ -n "__IFNAME2__" ]
test DHCP: addresses
guest1 /sbin/dhclient __IFNAME1__
guest2 /sbin/dhclient __IFNAME1__
g1out ADDR1 ip -j -4 ad sh|jq -rM '.[] | select(.ifname == "__IFNAME1__").addr_info[0].local'
g2out ADDR2 ip -j -4 ad sh|jq -rM '.[] | select(.ifname == "__IFNAME2__").addr_info[0].local'
hout HOST_ADDR ip -j -4 ad sh|jq -rM '.[] | select(.ifname == "__HOST_IFNAME__").addr_info[0].local'
g1out ADDR1 ip -j -4 addr show|jq -rM '.[] | select(.ifname == "__IFNAME1__").addr_info[0].local'
g2out ADDR2 ip -j -4 addr show|jq -rM '.[] | select(.ifname == "__IFNAME2__").addr_info[0].local'
hout HOST_ADDR ip -j -4 addr show|jq -rM '.[] | select(.ifname == "__HOST_IFNAME__").addr_info[0].local'
check [ "__ADDR1__" = "__HOST_ADDR__" ]
check [ "__ADDR2__" = "__HOST_ADDR__" ]
@ -36,14 +36,14 @@ test DHCPv6: addresses
sleep 2
guest1 /sbin/dhclient -6 __IFNAME1__
guest2 /sbin/dhclient -6 __IFNAME1__
g1out ADDR1_6 ip -j -6 ad sh|jq -rM '.[] | select(.ifname == "__IFNAME1__").addr_info[] | select(.prefixlen == 128).local'
g2out ADDR2_6 ip -j -6 ad sh|jq -rM '.[] | select(.ifname == "__IFNAME2__").addr_info[] | select(.prefixlen == 128).local'
hout HOST_ADDR6 ip -j -6 ad sh|jq -rM '.[] | select(.ifname == "__HOST_IFNAME__").addr_info[] | select(.scope == "global").local'
g1out ADDR1_6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__IFNAME1__").addr_info[] | select(.prefixlen == 128).local'
g2out ADDR2_6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__IFNAME2__").addr_info[] | select(.prefixlen == 128).local'
hout HOST_ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__HOST_IFNAME__").addr_info[] | select(.scope == "global").local'
check [ "__ADDR1_6__" = "__HOST_ADDR6__" ]
check [ "__ADDR2_6__" = "__HOST_ADDR6__" ]
test TCP/IPv4: guest 1 > guest 2
g1out GW1 ip -j -4 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
g1out GW1 ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
guest2b nc -4 -l 10004 > msg
guest1 echo "Hello_from_guest_1" | nc -N __GW1__ 10004
guest2w
@ -52,7 +52,7 @@ g2out MSG2 cat msg
check [ "__MSG2__" = "Hello_from_guest_1" ]
test TCP/IPv6: guest 2 > guest 1
g2out GW2_6 ip -j -6 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
g2out GW2_6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway'
guest1b nc -6 -l 10001 > msg
guest2 echo "Hello_from_guest_2" | nc -N __GW2_6__%__IFNAME2__ 10001
guest1w

View File

@ -29,7 +29,7 @@ check [ "__GUEST_MD5__" = "__HOST_MD5__" ]
test UDP/IPv4: guest to host
host :> __TEMP__
hostb (nc -u -q1 -4 -l 10003 & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
gout GW ip -j -4 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
gout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
guest cat test.bin | nc -u -q1 -N __GW__ 10003
hostw
hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1
@ -46,8 +46,8 @@ check [ "__GUEST_MD5__" = "__HOST_MD5__" ]
test UDP/IPv6: guest to host
host :> __TEMP__
hostb (nc -u -q1 -6 -l 10003 & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
gout GW6 ip -j -6 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
gout IFNAME ip -j li sh | jq -rM '.[] | select(.link_type == "ether").ifname'
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 cat test.bin | nc -u -q1 -N __GW6__%__IFNAME__ 10003
hostw
hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1

View File

@ -39,7 +39,7 @@ check [ "__NS_MD5__" = "__MD5__" ]
test UDP/IPv4: guest to host
host :> __TEMP__
hostb (nc -u -q1 -4 -l 10003 & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
gout GW ip -j -4 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
gout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
guest cat test.bin | nc -u -q1 -N __GW__ 10003
hostw
hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1
@ -79,8 +79,8 @@ check [ "__GUEST_MD5__" = "__MD5__" ]
test UDP/IPv4: ns to guest (using namespace address)
guestb (nc -u -q1 -4 -l 10001 & echo $! > nc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat nc.pid))
nsout IFNAME ip -j li sh | jq -rM '.[] | select(.link_type == "ether").ifname'
nsout ADDR ip -j -4 ad sh|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[0].local'
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 cat __TEMP_NS__ | nc -u -q1 -N __ADDR__ 10001
guestw
gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1
@ -104,8 +104,8 @@ check [ "__NS_MD5__" = "__MD5__" ]
test UDP/IPv6: guest to host
host :> __TEMP__
hostb (nc -u -q1 -6 -l 10003 & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
gout GW6 ip -j -6 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
gout IFNAME ip -j li sh | jq -rM '.[] | select(.link_type == "ether").ifname'
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 cat test.bin | nc -u -q1 -N __GW6__%__IFNAME__ 10003
hostw
hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1
@ -130,7 +130,7 @@ check [ "__HOST_MD5__" = "__MD5__" ]
test UDP/IPv6: ns to host (via tap)
host :> __TEMP__
hostb (nc -u -q1 -6 -l 10003 & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
nsout IFNAME ip -j li sh | jq -rM '.[] | select(.link_type == "ether").ifname'
nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'
ns cat __TEMP_NS__ | nc -u -q1 -N __GW6__%__IFNAME__ 10003
hostw
hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1
@ -145,7 +145,7 @@ check [ "__GUEST_MD5__" = "__MD5__" ]
test UDP/IPv6: ns to guest (using namespace address)
guestb (nc -u -q1 -6 -l 10001 & echo $! > nc.pid) | tee test.bin | (grep -qm1 "END_OF_TEST" && kill $(cat nc.pid))
nsout ADDR6 ip -j -6 ad sh|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'
ns cat __TEMP_NS__ | nc -u -q1 -N __ADDR6__ 10001
guestw
gout GUEST_MD5 md5sum test.bin | cut -d' ' -f1

View File

@ -40,7 +40,7 @@ check [ "__HOST_MD5__" = "__MD5__" ]
test UDP/IPv4: ns to host (via tap)
host :> __TEMP__
hostb (nc -u -q1 -4 -l 10003 & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
nsout GW ip -j -4 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
nsout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway'
ns cat __TEMP_NS__ | nc -u -q1 -N __GW__ 10003
hostw
hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1
@ -68,8 +68,8 @@ nsw
test UDP/IPv6: ns to host (via tap)
host :> __TEMP__
hostb (nc -u -q1 -6 -l 10003 & echo $! > __NC_PID__) | tee __TEMP__ | (grep -qm1 "END_OF_TEST" && kill $(cat __NC_PID__))
nsout GW6 ip -j -6 ro sh|jq -rM '.[] | select(.dst == "default").gateway'
nsout IFNAME ip -j li sh | jq -rM '.[] | select(.link_type == "ether").ifname'
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 cat __TEMP_NS__ | nc -u -q1 -N __GW6__%__IFNAME__ 10003
hostw
hout HOST_MD5 md5sum __TEMP__ | cut -d' ' -f1