~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/net/mptcp/pm_netlink.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0
  3 
  4 . "$(dirname "${0}")/mptcp_lib.sh"
  5 
  6 ret=0
  7 
  8 usage() {
  9         echo "Usage: $0 [ -i ] [ -h ]"
 10         echo -e "\t-i: use 'ip mptcp' instead of 'pm_nl_ctl'"
 11         echo -e "\t-h: help"
 12 }
 13 
 14 optstring=hi
 15 while getopts "$optstring" option;do
 16         case "$option" in
 17         "h")
 18                 usage "$0"
 19                 exit ${KSFT_PASS}
 20                 ;;
 21         "i")
 22                 mptcp_lib_set_ip_mptcp
 23                 ;;
 24         "?")
 25                 usage "$0"
 26                 exit ${KSFT_FAIL}
 27                 ;;
 28         esac
 29 done
 30 
 31 ns1=""
 32 err=$(mktemp)
 33 
 34 # This function is used in the cleanup trap
 35 #shellcheck disable=SC2317
 36 cleanup()
 37 {
 38         rm -f "${err}"
 39         mptcp_lib_ns_exit "${ns1}"
 40 }
 41 
 42 mptcp_lib_check_mptcp
 43 mptcp_lib_check_tools ip
 44 
 45 trap cleanup EXIT
 46 
 47 mptcp_lib_ns_init ns1
 48 
 49 format_limits() {
 50         local accept="${1}"
 51         local subflows="${2}"
 52 
 53         if mptcp_lib_is_ip_mptcp; then
 54                 # with a space at the end
 55                 printf "add_addr_accepted %d subflows %d \n" "${accept}" "${subflows}"
 56         else
 57                 printf "accept %d\nsubflows %d\n" "${accept}" "${subflows}"
 58         fi
 59 }
 60 
 61 get_limits() {
 62         if mptcp_lib_is_ip_mptcp; then
 63                 ip -n "${ns1}" mptcp limits
 64         else
 65                 ip netns exec "${ns1}" ./pm_nl_ctl limits
 66         fi
 67 }
 68 
 69 format_endpoints() {
 70         mptcp_lib_pm_nl_format_endpoints "${@}"
 71 }
 72 
 73 get_endpoint() {
 74         # shellcheck disable=SC2317 # invoked indirectly
 75         mptcp_lib_pm_nl_get_endpoint "${ns1}" "${@}"
 76 }
 77 
 78 change_address() {
 79         local addr=${1}
 80         local flags=${2}
 81 
 82         if mptcp_lib_is_ip_mptcp; then
 83                 ip -n "${ns1}" mptcp endpoint change "${addr}" "${flags}"
 84         else
 85                 ip netns exec "${ns1}" ./pm_nl_ctl set "${addr}" flags "${flags}"
 86         fi
 87 }
 88 
 89 set_limits()
 90 {
 91         mptcp_lib_pm_nl_set_limits "${ns1}" "${@}"
 92 }
 93 
 94 add_endpoint()
 95 {
 96         mptcp_lib_pm_nl_add_endpoint "${ns1}" "${@}"
 97 }
 98 
 99 del_endpoint()
100 {
101         mptcp_lib_pm_nl_del_endpoint "${ns1}" "${@}"
102 }
103 
104 flush_endpoint()
105 {
106         mptcp_lib_pm_nl_flush_endpoint "${ns1}"
107 }
108 
109 show_endpoints()
110 {
111         mptcp_lib_pm_nl_show_endpoints "${ns1}"
112 }
113 
114 change_endpoint()
115 {
116         mptcp_lib_pm_nl_change_endpoint "${ns1}" "${@}"
117 }
118 
119 check()
120 {
121         local cmd="$1"
122         local expected="$2"
123         local msg="$3"
124         local rc=0
125 
126         mptcp_lib_print_title "$msg"
127         mptcp_lib_check_output "${err}" "${cmd}" "${expected}" || rc=${?}
128         if [ ${rc} -eq 2 ]; then
129                 mptcp_lib_result_fail "${msg} # error ${rc}"
130                 ret=${KSFT_FAIL}
131         elif [ ${rc} -eq 0 ]; then
132                 mptcp_lib_print_ok "[ OK ]"
133                 mptcp_lib_result_pass "${msg}"
134         elif [ ${rc} -eq 1 ]; then
135                 mptcp_lib_result_fail "${msg} # different output"
136                 ret=${KSFT_FAIL}
137         fi
138 }
139 
140 mptcp_lib_subtests_last_ts_reset
141 
142 check "show_endpoints" "" "defaults addr list"
143 
144 default_limits="$(get_limits)"
145 if mptcp_lib_expect_all_features; then
146         check "get_limits" "$(format_limits 0 2)" "defaults limits"
147 fi
148 
149 add_endpoint 10.0.1.1
150 add_endpoint 10.0.1.2 flags subflow dev lo
151 add_endpoint 10.0.1.3 flags signal,backup
152 check "get_endpoint 1" "$(format_endpoints "1,10.0.1.1")" "simple add/get addr"
153 
154 check "show_endpoints" \
155         "$(format_endpoints "1,10.0.1.1" \
156                             "2,10.0.1.2,subflow,lo" \
157                             "3,10.0.1.3,signal backup")" "dump addrs"
158 
159 del_endpoint 2
160 check "get_endpoint 2" "" "simple del addr"
161 check "show_endpoints" \
162         "$(format_endpoints "1,10.0.1.1" \
163                             "3,10.0.1.3,signal backup")" "dump addrs after del"
164 
165 add_endpoint 10.0.1.3 2>/dev/null
166 check "get_endpoint 4" "" "duplicate addr"
167 
168 add_endpoint 10.0.1.4 flags signal
169 check "get_endpoint 4" "$(format_endpoints "4,10.0.1.4,signal")" "id addr increment"
170 
171 for i in $(seq 5 9); do
172         add_endpoint "10.0.1.${i}" flags signal >/dev/null 2>&1
173 done
174 check "get_endpoint 9" "$(format_endpoints "9,10.0.1.9,signal")" "hard addr limit"
175 check "get_endpoint 10" "" "above hard addr limit"
176 
177 del_endpoint 9
178 for i in $(seq 10 255); do
179         add_endpoint 10.0.0.9 id "${i}"
180         del_endpoint "${i}"
181 done
182 check "show_endpoints" \
183         "$(format_endpoints "1,10.0.1.1" \
184                             "3,10.0.1.3,signal backup" \
185                             "4,10.0.1.4,signal" \
186                             "5,10.0.1.5,signal" \
187                             "6,10.0.1.6,signal" \
188                             "7,10.0.1.7,signal" \
189                             "8,10.0.1.8,signal")" "id limit"
190 
191 flush_endpoint
192 check "show_endpoints" "" "flush addrs"
193 
194 set_limits 9 1 2>/dev/null
195 check "get_limits" "${default_limits}" "rcv addrs above hard limit"
196 
197 set_limits 1 9 2>/dev/null
198 check "get_limits" "${default_limits}" "subflows above hard limit"
199 
200 set_limits 8 8
201 check "get_limits" "$(format_limits 8 8)" "set limits"
202 
203 flush_endpoint
204 add_endpoint 10.0.1.1
205 add_endpoint 10.0.1.2
206 add_endpoint 10.0.1.3 id 100
207 add_endpoint 10.0.1.4
208 add_endpoint 10.0.1.5 id 254
209 add_endpoint 10.0.1.6
210 add_endpoint 10.0.1.7
211 add_endpoint 10.0.1.8
212 check "show_endpoints" \
213         "$(format_endpoints "1,10.0.1.1" \
214                             "2,10.0.1.2" \
215                             "3,10.0.1.7" \
216                             "4,10.0.1.8" \
217                             "100,10.0.1.3" \
218                             "101,10.0.1.4" \
219                             "254,10.0.1.5" \
220                             "255,10.0.1.6")" "set ids"
221 
222 flush_endpoint
223 add_endpoint 10.0.0.1
224 add_endpoint 10.0.0.2 id 254
225 add_endpoint 10.0.0.3
226 add_endpoint 10.0.0.4
227 add_endpoint 10.0.0.5 id 253
228 add_endpoint 10.0.0.6
229 add_endpoint 10.0.0.7
230 add_endpoint 10.0.0.8
231 check "show_endpoints" \
232         "$(format_endpoints "1,10.0.0.1" \
233                             "2,10.0.0.4" \
234                             "3,10.0.0.6" \
235                             "4,10.0.0.7" \
236                             "5,10.0.0.8" \
237                             "253,10.0.0.5" \
238                             "254,10.0.0.2" \
239                             "255,10.0.0.3")" "wrap-around ids"
240 
241 flush_endpoint
242 add_endpoint 10.0.1.1 flags subflow
243 change_address 10.0.1.1 backup
244 check "show_endpoints" "$(format_endpoints "1,10.0.1.1,subflow backup")" \
245         "set flags (backup)"
246 change_address 10.0.1.1 nobackup
247 check "show_endpoints" "$(format_endpoints "1,10.0.1.1,subflow")" \
248         "          (nobackup)"
249 
250 # fullmesh support has been added later
251 change_endpoint 1 fullmesh 2>/dev/null
252 if show_endpoints | grep -q "fullmesh" ||
253    mptcp_lib_expect_all_features; then
254         check "show_endpoints" "$(format_endpoints "1,10.0.1.1,subflow fullmesh")" \
255                 "          (fullmesh)"
256         change_endpoint 1 nofullmesh
257         check "show_endpoints" "$(format_endpoints "1,10.0.1.1,subflow")" \
258                 "          (nofullmesh)"
259         change_endpoint 1 backup,fullmesh
260         check "show_endpoints" "$(format_endpoints "1,10.0.1.1,subflow backup fullmesh")" \
261                 "          (backup,fullmesh)"
262 else
263         for st in fullmesh nofullmesh backup,fullmesh; do
264                 st="          (${st})"
265                 mptcp_lib_print_title "${st}"
266                 mptcp_lib_pr_skip
267                 mptcp_lib_result_skip "${st}"
268         done
269 fi
270 
271 mptcp_lib_result_print_all_tap
272 exit $ret

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php