~ [ 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 ] ~

Diff markup

Differences between /tools/testing/selftests/net/mptcp/pm_netlink.sh (Architecture i386) and /tools/testing/selftests/net/mptcp/pm_netlink.sh (Architecture sparc64)


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