Skip to content

Commit

Permalink
Use socat as default utility for tcp/udp client/server connections
Browse files Browse the repository at this point in the history
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 <lorenzo@kernel.org>
  • Loading branch information
LorenzoBianconi authored and tohojo committed Oct 17, 2024
1 parent 66dc003 commit 78324c6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/testing/test_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ALL_TESTS=""
VERBOSE_TESTS=${V:-0}
NUM_NS=2

NEEDED_TOOLS="capinfos ethtool ip ping sed tc tcpdump timeout nc tshark nft socat"
NEEDED_TOOLS="capinfos ethtool ip ping sed tc tcpdump timeout tshark nft socat"

if [ -f "$TEST_CONFIG" ]; then
source "$TEST_CONFIG"
Expand Down
4 changes: 2 additions & 2 deletions xdp-filter/tests/test-xdp-filter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ check_port()
local port=$2
local expect=$3
echo "$type port $port $expect"
[[ "$type" == "tcp" ]] && command="nc -w 1 -z $OUTSIDE_IP6 $port"
[[ "$type" == "udp" ]] && command="echo test | nc -w 1 -u $OUTSIDE_IP6 $port"
[[ "$type" == "tcp" ]] && command="echo test | socat - TCP6:[$OUTSIDE_IP6]:$port,connect-timeout=1"
[[ "$type" == "udp" ]] && command="echo test | socat - UDP6:[$OUTSIDE_IP6]:$port"

check_packet "$type dst port $port" "$command" $expect
}
Expand Down
4 changes: 2 additions & 2 deletions xdp-forward/tests/test-xdp-forward.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ EOF
check_run $XDP_FORWARD load -f flowtable ${NS_NAMES[@]}

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

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

Expand Down
2 changes: 1 addition & 1 deletion xdp-trafficgen/tests/test-xdp-trafficgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test_tcp()
skip_if_missing_kernel_support
export XDP_SAMPLE_IMMEDIATE_EXIT=1

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

0 comments on commit 78324c6

Please sign in to comment.