File tree Expand file tree Collapse file tree
tools/testing/selftests/netfilter Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ checktool (){
4141
4242checktool " iptables --version" " run test without iptables"
4343checktool " ip -Version" " run test without ip tool"
44- checktool " which nc " " run test without nc (netcat) "
44+ checktool " which socat " " run test without socat "
4545checktool " ip netns add ${r_a} " " create net namespace"
4646
4747for n in ${r_b} ${r_w} ${c_a} ${c_b} ; do
@@ -60,11 +60,12 @@ trap cleanup EXIT
6060test_path () {
6161 msg=" $1 "
6262
63- ip netns exec ${c_b} nc -n -w 3 -q 3 -u -l -p 5000 > ${rx} < /dev/null &
63+ ip netns exec ${c_b} socat -t 3 - udp4-listen: 5000,reuseaddr > ${rx} < /dev/null &
6464
6565 sleep 1
6666 for i in 1 2 3; do
67- head -c1400 /dev/zero | tr " \000" " a" | ip netns exec ${c_a} nc -n -w 1 -u 192.168.20.2 5000
67+ head -c1400 /dev/zero | tr " \000" " a" | \
68+ ip netns exec ${c_a} socat -t 1 -u STDIN UDP:192.168.20.2:5000
6869 done
6970
7071 wait
@@ -189,7 +190,7 @@ ip netns exec ${r_w} sysctl -q net.ipv4.conf.all.forwarding=1 > /dev/null
189190# ---------------------
190191# Now we send a 1400 bytes UDP packet from Client A to Client B:
191192
192- # clienta:~# head -c1400 /dev/zero | tr "\000" "a" | nc -u 192.168.20.2 5000
193+ # clienta:~# head -c1400 /dev/zero | tr "\000" "a" | socat -u STDIN UDP: 192.168.20.2: 5000
193194test_path " without"
194195
195196# The IPv4 stack on Client A already knows the PMTU to Client B, so the
Original file line number Diff line number Diff line change @@ -76,23 +76,23 @@ ip netns exec $ns2 ip route add 10.96.0.1 via 192.168.1.1
7676sleep 1
7777
7878# add a persistent connection from the other namespace
79- ip netns exec $ns2 nc -q 10 -w 10 192.168.1.1 5201 > /dev/null &
79+ ip netns exec $ns2 socat -t 10 - TCP: 192.168.1.1: 5201 > /dev/null &
8080
8181sleep 1
8282
8383# ip daddr:dport will be rewritten to 192.168.1.1 5201
8484# NAT must reallocate source port 10000 because
8585# 192.168.1.2:10000 -> 192.168.1.1:5201 is already in use
86- echo test | ip netns exec $ns2 nc -w 3 -q 3 10.96.0.1 443 > /dev/null
86+ echo test | ip netns exec $ns2 socat -t 3 -u STDIN TCP: 10.96.0.1: 443 > /dev/null
8787ret=$?
8888
8989kill $iperfs
9090
91- # Check nc can connect to 10.96.0.1:443 (aka 192.168.1.1:5201).
91+ # Check socat can connect to 10.96.0.1:443 (aka 192.168.1.1:5201).
9292if [ $ret -eq 0 ]; then
93- echo " PASS: nc can connect via NAT'd address"
93+ echo " PASS: socat can connect via NAT'd address"
9494else
95- echo " FAIL: nc cannot connect via NAT'd address"
95+ echo " FAIL: socat cannot connect via NAT'd address"
9696 exit 1
9797fi
9898
You can’t perform that action at this time.
0 commit comments