Skip to content

Commit 78324c6

Browse files
LorenzoBianconitohojo
authored andcommitted
Use socat as default utility for tcp/udp client/server connections
Right now we are using a mix of socat and nc in the selftests, so we depend on both tools. Since socat is more capable, and there are multiple incompatible versions of nc, let's move everything over to socat and get rid of the nc dependency. Signed-off-by: Lorenzo Bianconi <[email protected]>
1 parent 66dc003 commit 78324c6

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

lib/testing/test_runner.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ALL_TESTS=""
2525
VERBOSE_TESTS=${V:-0}
2626
NUM_NS=2
2727

28-
NEEDED_TOOLS="capinfos ethtool ip ping sed tc tcpdump timeout nc tshark nft socat"
28+
NEEDED_TOOLS="capinfos ethtool ip ping sed tc tcpdump timeout tshark nft socat"
2929

3030
if [ -f "$TEST_CONFIG" ]; then
3131
source "$TEST_CONFIG"

xdp-filter/tests/test-xdp-filter.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ check_port()
8787
local port=$2
8888
local expect=$3
8989
echo "$type port $port $expect"
90-
[[ "$type" == "tcp" ]] && command="nc -w 1 -z $OUTSIDE_IP6 $port"
91-
[[ "$type" == "udp" ]] && command="echo test | nc -w 1 -u $OUTSIDE_IP6 $port"
90+
[[ "$type" == "tcp" ]] && command="echo test | socat - TCP6:[$OUTSIDE_IP6]:$port,connect-timeout=1"
91+
[[ "$type" == "udp" ]] && command="echo test | socat - UDP6:[$OUTSIDE_IP6]:$port"
9292

9393
check_packet "$type dst port $port" "$command" $expect
9494
}

xdp-forward/tests/test-xdp-forward.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ EOF
115115
check_run $XDP_FORWARD load -f flowtable ${NS_NAMES[@]}
116116

117117
PID=$(start_background_ns_devnull "socat -4 TCP-LISTEN:10000,reuseaddr,fork -")
118-
check_run ip netns exec ${NS_NAMES[0]} socat ${INPUT_FILE} TCP4:${OUTSIDE_IP4}:12345
118+
check_run ip netns exec ${NS_NAMES[0]} socat ${INPUT_FILE} TCP4:${OUTSIDE_IP4}:12345,connect-timeout=1
119119
stop_background $PID
120120

121121
PID=$(start_background_ns_devnull "socat -6 TCP-LISTEN:10000,reuseaddr,fork -")
122-
check_run ip netns exec ${NS_NAMES[0]} socat ${INPUT_FILE} TCP6:[${OUTSIDE_IP6}]:12345
122+
check_run ip netns exec ${NS_NAMES[0]} socat ${INPUT_FILE} TCP6:[${OUTSIDE_IP6}]:12345,connect-timeout=1
123123
stop_background $PID
124124
}
125125

xdp-trafficgen/tests/test-xdp-trafficgen.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ test_tcp()
2828
skip_if_missing_kernel_support
2929
export XDP_SAMPLE_IMMEDIATE_EXIT=1
3030

31-
PID=$(start_background_ns_devnull "nc -6 -l 10000")
31+
PID=$(start_background_ns_devnull "socat -6 TCP-LISTEN:10000,reuseaddr,fork -")
3232
$XDP_TRAFFICGEN tcp -i $NS $INSIDE_IP6 -n 1
3333
res=$?
3434
stop_background $PID

0 commit comments

Comments
 (0)