2 # SPDX-License-Identifier: GPL-2.0
4 # Testing For SCTP VRF.
5 # TOPO: CLIENT_NS1 (veth1) <---> (veth1) -> vrf_s1
7 # CLIENT_NS2 (veth1) <---> (veth2) -> vrf_s2
21 setup_ns CLIENT_NS1 CLIENT_NS2 SERVER_NS
23 ip net
exec $CLIENT_NS1 sysctl
-w net.ipv6.conf.default.accept_dad
=0 2>&1 >/dev
/null
24 ip net
exec $CLIENT_NS2 sysctl
-w net.ipv6.conf.default.accept_dad
=0 2>&1 >/dev
/null
25 ip net
exec $SERVER_NS sysctl
-w net.ipv6.conf.default.accept_dad
=0 2>&1 >/dev
/null
27 ip
-n $SERVER_NS link add veth1
type veth peer name veth1 netns
$CLIENT_NS1
28 ip
-n $SERVER_NS link add veth2
type veth peer name veth1 netns
$CLIENT_NS2
30 ip
-n $CLIENT_NS1 link
set veth1 up
31 ip
-n $CLIENT_NS1 addr add
$CLIENT_IP4/24 dev veth1
32 ip
-n $CLIENT_NS1 addr add
$CLIENT_IP6/24 dev veth1
34 ip
-n $CLIENT_NS2 link
set veth1 up
35 ip
-n $CLIENT_NS2 addr add
$CLIENT_IP4/24 dev veth1
36 ip
-n $CLIENT_NS2 addr add
$CLIENT_IP6/24 dev veth1
38 ip
-n $SERVER_NS link add dummy1
type dummy
39 ip
-n $SERVER_NS link
set dummy1 up
40 ip
-n $SERVER_NS link add vrf-1
type vrf table
10
41 ip
-n $SERVER_NS link add vrf-2
type vrf table
20
42 ip
-n $SERVER_NS link
set vrf-1 up
43 ip
-n $SERVER_NS link
set vrf-2 up
44 ip
-n $SERVER_NS link
set veth1 master vrf-1
45 ip
-n $SERVER_NS link
set veth2 master vrf-2
47 ip
-n $SERVER_NS addr add
$SERVER_IP4/24 dev dummy1
48 ip
-n $SERVER_NS addr add
$SERVER_IP4/24 dev veth1
49 ip
-n $SERVER_NS addr add
$SERVER_IP4/24 dev veth2
50 ip
-n $SERVER_NS addr add
$SERVER_IP6/24 dev dummy1
51 ip
-n $SERVER_NS addr add
$SERVER_IP6/24 dev veth1
52 ip
-n $SERVER_NS addr add
$SERVER_IP6/24 dev veth2
54 ip
-n $SERVER_NS link
set veth1 up
55 ip
-n $SERVER_NS link
set veth2 up
56 ip
-n $SERVER_NS route add table
10 $CLIENT_IP4 dev veth1 src
$SERVER_IP4
57 ip
-n $SERVER_NS route add table
20 $CLIENT_IP4 dev veth2 src
$SERVER_IP4
58 ip
-n $SERVER_NS route add
$CLIENT_IP4 dev veth1 src
$SERVER_IP4
59 ip
-n $SERVER_NS route add table
10 $CLIENT_IP6 dev veth1 src
$SERVER_IP6
60 ip
-n $SERVER_NS route add table
20 $CLIENT_IP6 dev veth2 src
$SERVER_IP6
61 ip
-n $SERVER_NS route add
$CLIENT_IP6 dev veth1 src
$SERVER_IP6
65 ip netns
exec $SERVER_NS pkill sctp_hello
2>&1 >/dev
/null
66 cleanup_ns
$CLIENT_NS1 $CLIENT_NS2 $SERVER_NS
73 until ip netns
exec $SERVER_NS ss
-lS src
$SERVER_IP:$SERVER_PORT | \
74 grep LISTEN |
grep "$IFACE" 2>&1 >/dev
/null
; do
75 [ $
((CNT
++)) = "20" ] && { RET
=3; return $RET; }
84 ip netns
exec $SERVER_NS pkill sctp_hello
2>&1 >/dev
/null
85 ip netns
exec $SERVER_NS .
/sctp_hello server
$AF $SERVER_IP \
86 $SERVER_PORT $IFACE 2>&1 >/dev
/null
&
88 wait_server
$IFACE ||
return $RET
89 timeout
3 ip netns
exec $CLIENT_NS .
/sctp_hello client
$AF \
90 $SERVER_IP $SERVER_PORT $CLIENT_IP $CLIENT_PORT 2>&1 >/dev
/null
99 ip netns
exec $SERVER_NS pkill sctp_hello
2>&1 >/dev
/null
100 ip netns
exec $SERVER_NS .
/sctp_hello server
$AF $SERVER_IP \
101 $SERVER_PORT $IFACE1 2>&1 >/dev
/null
&
103 wait_server
$IFACE1 ||
return $RET
104 ip netns
exec $SERVER_NS .
/sctp_hello server
$AF $SERVER_IP \
105 $SERVER_PORT $IFACE2 2>&1 >/dev
/null
&
107 wait_server
$IFACE2 ||
return $RET
108 timeout
3 ip netns
exec $CLIENT_NS1 .
/sctp_hello client
$AF \
109 $SERVER_IP $SERVER_PORT $CLIENT_IP $CLIENT_PORT 2>&1 >/dev
/null
&& \
110 timeout
3 ip netns
exec $CLIENT_NS2 .
/sctp_hello client
$AF \
111 $SERVER_IP $SERVER_PORT $CLIENT_IP $CLIENT_PORT 2>&1 >/dev
/null
117 ip netns
exec $SERVER_NS sysctl
-w net.sctp.l3mdev_accept
=1 2>&1 >/dev
/null
118 echo -n "TEST 01: nobind, connect from client 1, l3mdev_accept=1, Y "
119 do_test
$CLIENT_NS1 ||
{ echo "[FAIL]"; return $RET; }
122 echo -n "TEST 02: nobind, connect from client 2, l3mdev_accept=1, N "
123 do_test
$CLIENT_NS2 && { echo "[FAIL]"; return $RET; }
126 ip netns
exec $SERVER_NS sysctl
-w net.sctp.l3mdev_accept
=0 2>&1 >/dev
/null
127 echo -n "TEST 03: nobind, connect from client 1, l3mdev_accept=0, N "
128 do_test
$CLIENT_NS1 && { echo "[FAIL]"; return $RET; }
131 echo -n "TEST 04: nobind, connect from client 2, l3mdev_accept=0, N "
132 do_test
$CLIENT_NS2 && { echo "[FAIL]"; return $RET; }
135 echo -n "TEST 05: bind veth2 in server, connect from client 1, N "
136 do_test
$CLIENT_NS1 veth2
&& { echo "[FAIL]"; return $RET; }
139 echo -n "TEST 06: bind veth1 in server, connect from client 1, Y "
140 do_test
$CLIENT_NS1 veth1 ||
{ echo "[FAIL]"; return $RET; }
143 echo -n "TEST 07: bind vrf-1 in server, connect from client 1, Y "
144 do_test
$CLIENT_NS1 vrf-1 ||
{ echo "[FAIL]"; return $RET; }
147 echo -n "TEST 08: bind vrf-2 in server, connect from client 1, N "
148 do_test
$CLIENT_NS1 vrf-2
&& { echo "[FAIL]"; return $RET; }
151 echo -n "TEST 09: bind vrf-2 in server, connect from client 2, Y "
152 do_test
$CLIENT_NS2 vrf-2 ||
{ echo "[FAIL]"; return $RET; }
155 echo -n "TEST 10: bind vrf-1 in server, connect from client 2, N "
156 do_test
$CLIENT_NS2 vrf-1
&& { echo "[FAIL]"; return $RET; }
159 echo -n "TEST 11: bind vrf-1 & 2 in server, connect from client 1 & 2, Y "
160 do_testx vrf-1 vrf-2 ||
{ echo "[FAIL]"; return $RET; }
163 echo -n "TEST 12: bind vrf-2 & 1 in server, connect from client 1 & 2, N "
164 do_testx vrf-2 vrf-1 ||
{ echo "[FAIL]"; return $RET; }
169 setup
&& echo "Testing For SCTP VRF:" && \
170 CLIENT_IP
=$CLIENT_IP4 SERVER_IP
=$SERVER_IP4 AF
="-4" testup
&& echo "***v4 Tests Done***" &&
171 CLIENT_IP
=$CLIENT_IP6 SERVER_IP
=$SERVER_IP6 AF
="-6" testup
&& echo "***v6 Tests Done***"