提交 25b327d4 编写于 作者: F Florian Westphal

selftests: nft_concat_range: add socat support

There are different flavors of 'nc' around, this script fails on
my test vm because 'nc' is 'nmap-ncat' which isn't 100% compatible.

Add socat support and use it if available.
Signed-off-by: NFlorian Westphal <fw@strlen.de>
上级 39aebede
...@@ -91,7 +91,7 @@ src ...@@ -91,7 +91,7 @@ src
start 1 start 1
count 5 count 5
src_delta 2000 src_delta 2000
tools sendip nc bash tools sendip socat nc bash
proto udp proto udp
race_repeat 3 race_repeat 3
...@@ -116,7 +116,7 @@ src ...@@ -116,7 +116,7 @@ src
start 10 start 10
count 5 count 5
src_delta 2000 src_delta 2000
tools sendip nc bash tools sendip socat nc bash
proto udp6 proto udp6
race_repeat 3 race_repeat 3
...@@ -141,7 +141,7 @@ src ...@@ -141,7 +141,7 @@ src
start 1 start 1
count 5 count 5
src_delta 2000 src_delta 2000
tools sendip nc bash tools sendip socat nc bash
proto udp proto udp
race_repeat 0 race_repeat 0
...@@ -163,7 +163,7 @@ src mac ...@@ -163,7 +163,7 @@ src mac
start 10 start 10
count 5 count 5
src_delta 2000 src_delta 2000
tools sendip nc bash tools sendip socat nc bash
proto udp6 proto udp6
race_repeat 0 race_repeat 0
...@@ -185,7 +185,7 @@ src mac proto ...@@ -185,7 +185,7 @@ src mac proto
start 10 start 10
count 5 count 5
src_delta 2000 src_delta 2000
tools sendip nc bash tools sendip socat nc bash
proto udp6 proto udp6
race_repeat 0 race_repeat 0
...@@ -207,7 +207,7 @@ src addr4 ...@@ -207,7 +207,7 @@ src addr4
start 1 start 1
count 5 count 5
src_delta 2000 src_delta 2000
tools sendip nc bash tools sendip socat nc bash
proto udp proto udp
race_repeat 3 race_repeat 3
...@@ -227,7 +227,7 @@ src addr6 port ...@@ -227,7 +227,7 @@ src addr6 port
start 10 start 10
count 5 count 5
src_delta 2000 src_delta 2000
tools sendip nc tools sendip socat nc
proto udp6 proto udp6
race_repeat 3 race_repeat 3
...@@ -247,7 +247,7 @@ src mac proto addr4 ...@@ -247,7 +247,7 @@ src mac proto addr4
start 1 start 1
count 5 count 5
src_delta 2000 src_delta 2000
tools sendip nc bash tools sendip socat nc bash
proto udp proto udp
race_repeat 0 race_repeat 0
...@@ -264,7 +264,7 @@ src mac ...@@ -264,7 +264,7 @@ src mac
start 1 start 1
count 5 count 5
src_delta 2000 src_delta 2000
tools sendip nc bash tools sendip socat nc bash
proto udp proto udp
race_repeat 0 race_repeat 0
...@@ -286,7 +286,7 @@ src mac addr4 ...@@ -286,7 +286,7 @@ src mac addr4
start 1 start 1
count 5 count 5
src_delta 2000 src_delta 2000
tools sendip nc bash tools sendip socat nc bash
proto udp proto udp
race_repeat 0 race_repeat 0
...@@ -337,7 +337,7 @@ src addr4 ...@@ -337,7 +337,7 @@ src addr4
start 1 start 1
count 5 count 5
src_delta 2000 src_delta 2000
tools sendip nc tools sendip socat nc
proto udp proto udp
race_repeat 3 race_repeat 3
...@@ -363,7 +363,7 @@ src mac ...@@ -363,7 +363,7 @@ src mac
start 1 start 1
count 1 count 1
src_delta 2000 src_delta 2000
tools sendip nc bash tools sendip socat nc bash
proto udp proto udp
race_repeat 0 race_repeat 0
...@@ -541,6 +541,24 @@ setup_send_udp() { ...@@ -541,6 +541,24 @@ setup_send_udp() {
dst_port= dst_port=
src_addr4= src_addr4=
} }
elif command -v socat -v >/dev/null; then
send_udp() {
if [ -n "${src_addr4}" ]; then
B ip addr add "${src_addr4}" dev veth_b
__socatbind=",bind=${src_addr4}"
if [ -n "${src_port}" ];then
__socatbind="${__socatbind}:${src_port}"
fi
fi
ip addr add "${dst_addr4}" dev veth_a 2>/dev/null
[ -z "${dst_port}" ] && dst_port=12345
echo "test4" | B socat -t 0.01 STDIN UDP4-DATAGRAM:${dst_addr4}:${dst_port}"${__socatbind}"
src_addr4=
src_port=
}
elif command -v nc >/dev/null; then elif command -v nc >/dev/null; then
if nc -u -w0 1.1.1.1 1 2>/dev/null; then if nc -u -w0 1.1.1.1 1 2>/dev/null; then
# OpenBSD netcat # OpenBSD netcat
...@@ -606,6 +624,29 @@ setup_send_udp6() { ...@@ -606,6 +624,29 @@ setup_send_udp6() {
dst_port= dst_port=
src_addr6= src_addr6=
} }
elif command -v socat -v >/dev/null; then
send_udp6() {
ip -6 addr add "${dst_addr6}" dev veth_a nodad \
2>/dev/null
__socatbind6=
if [ -n "${src_addr6}" ]; then
if [ -n "${src_addr6} != "${src_addr6_added} ]; then
B ip addr add "${src_addr6}" dev veth_b nodad
src_addr6_added=${src_addr6}
fi
__socatbind6=",bind=[${src_addr6}]"
if [ -n "${src_port}" ] ;then
__socatbind6="${__socatbind6}:${src_port}"
fi
fi
echo "test6" | B socat -t 0.01 STDIN UDP6-DATAGRAM:[${dst_addr6}]:${dst_port}"${__socatbind6}"
}
elif command -v nc >/dev/null && nc -u -w0 1.1.1.1 1 2>/dev/null; then elif command -v nc >/dev/null && nc -u -w0 1.1.1.1 1 2>/dev/null; then
# GNU netcat might not work with IPv6, try next tool # GNU netcat might not work with IPv6, try next tool
send_udp6() { send_udp6() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册