File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed
tools/testing/selftests/netfilter Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ checktool (){
41
41
42
42
checktool " iptables --version" " run test without iptables"
43
43
checktool " ip -Version" " run test without ip tool"
44
- checktool " which nc " " run test without nc (netcat) "
44
+ checktool " which socat " " run test without socat "
45
45
checktool " ip netns add ${r_a} " " create net namespace"
46
46
47
47
for n in ${r_b} ${r_w} ${c_a} ${c_b} ; do
@@ -60,11 +60,12 @@ trap cleanup EXIT
60
60
test_path () {
61
61
msg=" $1 "
62
62
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 &
64
64
65
65
sleep 1
66
66
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
68
69
done
69
70
70
71
wait
@@ -189,7 +190,7 @@ ip netns exec ${r_w} sysctl -q net.ipv4.conf.all.forwarding=1 > /dev/null
189
190
# ---------------------
190
191
# Now we send a 1400 bytes UDP packet from Client A to Client B:
191
192
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
193
194
test_path " without"
194
195
195
196
# 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
76
76
sleep 1
77
77
78
78
# 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 &
80
80
81
81
sleep 1
82
82
83
83
# ip daddr:dport will be rewritten to 192.168.1.1 5201
84
84
# NAT must reallocate source port 10000 because
85
85
# 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
87
87
ret=$?
88
88
89
89
kill $iperfs
90
90
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).
92
92
if [ $ret -eq 0 ]; then
93
- echo " PASS: nc can connect via NAT'd address"
93
+ echo " PASS: socat can connect via NAT'd address"
94
94
else
95
- echo " FAIL: nc cannot connect via NAT'd address"
95
+ echo " FAIL: socat cannot connect via NAT'd address"
96
96
exit 1
97
97
fi
98
98
You can’t perform that action at this time.
0 commit comments