mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-14 22:44:27 +08:00
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: Florian Westphal <fw@strlen.de>
This commit is contained in:
parent
39aebedeaa
commit
25b327d4f8
@ -91,7 +91,7 @@ src
|
||||
start 1
|
||||
count 5
|
||||
src_delta 2000
|
||||
tools sendip nc bash
|
||||
tools sendip socat nc bash
|
||||
proto udp
|
||||
|
||||
race_repeat 3
|
||||
@ -116,7 +116,7 @@ src
|
||||
start 10
|
||||
count 5
|
||||
src_delta 2000
|
||||
tools sendip nc bash
|
||||
tools sendip socat nc bash
|
||||
proto udp6
|
||||
|
||||
race_repeat 3
|
||||
@ -141,7 +141,7 @@ src
|
||||
start 1
|
||||
count 5
|
||||
src_delta 2000
|
||||
tools sendip nc bash
|
||||
tools sendip socat nc bash
|
||||
proto udp
|
||||
|
||||
race_repeat 0
|
||||
@ -163,7 +163,7 @@ src mac
|
||||
start 10
|
||||
count 5
|
||||
src_delta 2000
|
||||
tools sendip nc bash
|
||||
tools sendip socat nc bash
|
||||
proto udp6
|
||||
|
||||
race_repeat 0
|
||||
@ -185,7 +185,7 @@ src mac proto
|
||||
start 10
|
||||
count 5
|
||||
src_delta 2000
|
||||
tools sendip nc bash
|
||||
tools sendip socat nc bash
|
||||
proto udp6
|
||||
|
||||
race_repeat 0
|
||||
@ -207,7 +207,7 @@ src addr4
|
||||
start 1
|
||||
count 5
|
||||
src_delta 2000
|
||||
tools sendip nc bash
|
||||
tools sendip socat nc bash
|
||||
proto udp
|
||||
|
||||
race_repeat 3
|
||||
@ -227,7 +227,7 @@ src addr6 port
|
||||
start 10
|
||||
count 5
|
||||
src_delta 2000
|
||||
tools sendip nc
|
||||
tools sendip socat nc
|
||||
proto udp6
|
||||
|
||||
race_repeat 3
|
||||
@ -247,7 +247,7 @@ src mac proto addr4
|
||||
start 1
|
||||
count 5
|
||||
src_delta 2000
|
||||
tools sendip nc bash
|
||||
tools sendip socat nc bash
|
||||
proto udp
|
||||
|
||||
race_repeat 0
|
||||
@ -264,7 +264,7 @@ src mac
|
||||
start 1
|
||||
count 5
|
||||
src_delta 2000
|
||||
tools sendip nc bash
|
||||
tools sendip socat nc bash
|
||||
proto udp
|
||||
|
||||
race_repeat 0
|
||||
@ -286,7 +286,7 @@ src mac addr4
|
||||
start 1
|
||||
count 5
|
||||
src_delta 2000
|
||||
tools sendip nc bash
|
||||
tools sendip socat nc bash
|
||||
proto udp
|
||||
|
||||
race_repeat 0
|
||||
@ -337,7 +337,7 @@ src addr4
|
||||
start 1
|
||||
count 5
|
||||
src_delta 2000
|
||||
tools sendip nc
|
||||
tools sendip socat nc
|
||||
proto udp
|
||||
|
||||
race_repeat 3
|
||||
@ -363,7 +363,7 @@ src mac
|
||||
start 1
|
||||
count 1
|
||||
src_delta 2000
|
||||
tools sendip nc bash
|
||||
tools sendip socat nc bash
|
||||
proto udp
|
||||
|
||||
race_repeat 0
|
||||
@ -541,6 +541,24 @@ setup_send_udp() {
|
||||
dst_port=
|
||||
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
|
||||
if nc -u -w0 1.1.1.1 1 2>/dev/null; then
|
||||
# OpenBSD netcat
|
||||
@ -606,6 +624,29 @@ setup_send_udp6() {
|
||||
dst_port=
|
||||
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
|
||||
# GNU netcat might not work with IPv6, try next tool
|
||||
send_udp6() {
|
||||
|
Loading…
Reference in New Issue
Block a user