Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 1 | #!/bin/bash |
2 | # SPDX-License-Identifier: GPL-2.0 | ||||
3 | |||||
4 | # This test is for checking IPv4 and IPv6 FIB behavior in response to | ||||
5 | # different events. | ||||
6 | |||||
7 | ret=0 | ||||
8 | |||||
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 9 | PAUSE_ON_FAIL=${PAUSE_ON_FAIL:=no} |
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 10 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 11 | log_test() |
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 12 | { |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 13 | local rc=$1 |
14 | local expected=$2 | ||||
15 | local msg="$3" | ||||
16 | |||||
17 | if [ ${rc} -eq ${expected} ]; then | ||||
18 | printf " %-60s [ OK ]\n" "${msg}" | ||||
19 | else | ||||
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 20 | ret=1 |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 21 | printf " %-60s [FAIL]\n" "${msg}" |
22 | if [ "${PAUSE_ON_FAIL}" = "yes" ]; then | ||||
23 | echo | ||||
24 | echo "hit enter to continue, 'q' to quit" | ||||
25 | read a | ||||
26 | [ "$a" = "q" ] && exit 1 | ||||
27 | fi | ||||
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 28 | fi |
29 | } | ||||
30 | |||||
David Ahern | ee395a5 | 2018-02-13 08:37:35 -0800 | [diff] [blame^] | 31 | setup() |
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 32 | { |
David Ahern | ee395a5 | 2018-02-13 08:37:35 -0800 | [diff] [blame^] | 33 | set -e |
34 | ip netns add testns | ||||
35 | ip -netns testns link set dev lo up | ||||
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 36 | |
David Ahern | ee395a5 | 2018-02-13 08:37:35 -0800 | [diff] [blame^] | 37 | ip -netns testns link add dummy0 type dummy |
38 | ip -netns testns link set dev dummy0 up | ||||
39 | ip -netns testns address add 198.51.100.1/24 dev dummy0 | ||||
40 | ip -netns testns -6 address add 2001:db8:1::1/64 dev dummy0 | ||||
41 | set +e | ||||
42 | |||||
43 | } | ||||
44 | |||||
45 | cleanup() | ||||
46 | { | ||||
47 | ip -netns testns link del dev dummy0 &> /dev/null | ||||
48 | ip netns del testns | ||||
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 49 | } |
50 | |||||
51 | fib_unreg_unicast_test() | ||||
52 | { | ||||
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 53 | echo |
54 | echo "Single path route test" | ||||
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 55 | |
David Ahern | ee395a5 | 2018-02-13 08:37:35 -0800 | [diff] [blame^] | 56 | setup |
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 57 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 58 | echo " Start point" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 59 | ip -netns testns route get fibmatch 198.51.100.2 &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 60 | log_test $? 0 "IPv4 fibmatch" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 61 | ip -netns testns -6 route get fibmatch 2001:db8:1::2 &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 62 | log_test $? 0 "IPv6 fibmatch" |
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 63 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 64 | set -e |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 65 | ip -netns testns link del dev dummy0 |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 66 | set +e |
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 67 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 68 | echo " Nexthop device deleted" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 69 | ip -netns testns route get fibmatch 198.51.100.2 &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 70 | log_test $? 2 "IPv4 fibmatch - no route" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 71 | ip -netns testns -6 route get fibmatch 2001:db8:1::2 &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 72 | log_test $? 2 "IPv6 fibmatch - no route" |
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 73 | |
David Ahern | ee395a5 | 2018-02-13 08:37:35 -0800 | [diff] [blame^] | 74 | cleanup |
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 75 | } |
76 | |||||
77 | fib_unreg_multipath_test() | ||||
78 | { | ||||
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 79 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 80 | echo |
81 | echo "Multipath route test" | ||||
82 | |||||
David Ahern | ee395a5 | 2018-02-13 08:37:35 -0800 | [diff] [blame^] | 83 | setup |
84 | |||||
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 85 | set -e |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 86 | ip -netns testns link add dummy1 type dummy |
87 | ip -netns testns link set dev dummy1 up | ||||
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 88 | ip -netns testns address add 192.0.2.1/24 dev dummy1 |
89 | ip -netns testns -6 address add 2001:db8:2::1/64 dev dummy1 | ||||
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 90 | |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 91 | ip -netns testns route add 203.0.113.0/24 \ |
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 92 | nexthop via 198.51.100.2 dev dummy0 \ |
93 | nexthop via 192.0.2.2 dev dummy1 | ||||
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 94 | ip -netns testns -6 route add 2001:db8:3::/64 \ |
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 95 | nexthop via 2001:db8:1::2 dev dummy0 \ |
96 | nexthop via 2001:db8:2::2 dev dummy1 | ||||
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 97 | set +e |
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 98 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 99 | echo " Start point" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 100 | ip -netns testns route get fibmatch 203.0.113.1 &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 101 | log_test $? 0 "IPv4 fibmatch" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 102 | ip -netns testns -6 route get fibmatch 2001:db8:3::1 &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 103 | log_test $? 0 "IPv6 fibmatch" |
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 104 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 105 | set -e |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 106 | ip -netns testns link del dev dummy0 |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 107 | set +e |
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 108 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 109 | echo " One nexthop device deleted" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 110 | ip -netns testns route get fibmatch 203.0.113.1 &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 111 | log_test $? 2 "IPv4 - multipath route removed on delete" |
112 | |||||
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 113 | ip -netns testns -6 route get fibmatch 2001:db8:3::1 &> /dev/null |
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 114 | # In IPv6 we do not flush the entire multipath route. |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 115 | log_test $? 0 "IPv6 - multipath down to single path" |
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 116 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 117 | set -e |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 118 | ip -netns testns link del dev dummy1 |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 119 | set +e |
120 | |||||
121 | echo " Second nexthop device deleted" | ||||
122 | ip -netns testns -6 route get fibmatch 2001:db8:3::1 &> /dev/null | ||||
123 | log_test $? 2 "IPv6 - no route" | ||||
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 124 | |
David Ahern | ee395a5 | 2018-02-13 08:37:35 -0800 | [diff] [blame^] | 125 | cleanup |
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 126 | } |
127 | |||||
128 | fib_unreg_test() | ||||
129 | { | ||||
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 130 | fib_unreg_unicast_test |
131 | fib_unreg_multipath_test | ||||
132 | } | ||||
133 | |||||
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 134 | fib_down_unicast_test() |
135 | { | ||||
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 136 | echo |
137 | echo "Single path, admin down" | ||||
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 138 | |
David Ahern | ee395a5 | 2018-02-13 08:37:35 -0800 | [diff] [blame^] | 139 | setup |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 140 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 141 | echo " Start point" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 142 | ip -netns testns route get fibmatch 198.51.100.2 &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 143 | log_test $? 0 "IPv4 fibmatch" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 144 | ip -netns testns -6 route get fibmatch 2001:db8:1::2 &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 145 | log_test $? 0 "IPv6 fibmatch" |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 146 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 147 | set -e |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 148 | ip -netns testns link set dev dummy0 down |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 149 | set +e |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 150 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 151 | echo " Route deleted on down" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 152 | ip -netns testns route get fibmatch 198.51.100.2 &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 153 | log_test $? 2 "IPv4 fibmatch" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 154 | ip -netns testns -6 route get fibmatch 2001:db8:1::2 &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 155 | log_test $? 2 "IPv6 fibmatch" |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 156 | |
David Ahern | ee395a5 | 2018-02-13 08:37:35 -0800 | [diff] [blame^] | 157 | cleanup |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 158 | } |
159 | |||||
160 | fib_down_multipath_test_do() | ||||
161 | { | ||||
162 | local down_dev=$1 | ||||
163 | local up_dev=$2 | ||||
164 | |||||
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 165 | ip -netns testns route get fibmatch 203.0.113.1 \ |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 166 | oif $down_dev &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 167 | log_test $? 2 "IPv4 fibmatch on down device" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 168 | ip -netns testns -6 route get fibmatch 2001:db8:3::1 \ |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 169 | oif $down_dev &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 170 | log_test $? 2 "IPv6 fibmatch on down device" |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 171 | |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 172 | ip -netns testns route get fibmatch 203.0.113.1 \ |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 173 | oif $up_dev &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 174 | log_test $? 0 "IPv4 fibmatch on up device" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 175 | ip -netns testns -6 route get fibmatch 2001:db8:3::1 \ |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 176 | oif $up_dev &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 177 | log_test $? 0 "IPv6 fibmatch on up device" |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 178 | |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 179 | ip -netns testns route get fibmatch 203.0.113.1 | \ |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 180 | grep $down_dev | grep -q "dead linkdown" |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 181 | log_test $? 0 "IPv4 flags on down device" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 182 | ip -netns testns -6 route get fibmatch 2001:db8:3::1 | \ |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 183 | grep $down_dev | grep -q "dead linkdown" |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 184 | log_test $? 0 "IPv6 flags on down device" |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 185 | |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 186 | ip -netns testns route get fibmatch 203.0.113.1 | \ |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 187 | grep $up_dev | grep -q "dead linkdown" |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 188 | log_test $? 1 "IPv4 flags on up device" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 189 | ip -netns testns -6 route get fibmatch 2001:db8:3::1 | \ |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 190 | grep $up_dev | grep -q "dead linkdown" |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 191 | log_test $? 1 "IPv6 flags on up device" |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 192 | } |
193 | |||||
194 | fib_down_multipath_test() | ||||
195 | { | ||||
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 196 | echo |
197 | echo "Admin down multipath" | ||||
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 198 | |
David Ahern | ee395a5 | 2018-02-13 08:37:35 -0800 | [diff] [blame^] | 199 | setup |
200 | |||||
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 201 | set -e |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 202 | ip -netns testns link add dummy1 type dummy |
203 | ip -netns testns link set dev dummy1 up | ||||
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 204 | |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 205 | ip -netns testns address add 192.0.2.1/24 dev dummy1 |
206 | ip -netns testns -6 address add 2001:db8:2::1/64 dev dummy1 | ||||
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 207 | |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 208 | ip -netns testns route add 203.0.113.0/24 \ |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 209 | nexthop via 198.51.100.2 dev dummy0 \ |
210 | nexthop via 192.0.2.2 dev dummy1 | ||||
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 211 | ip -netns testns -6 route add 2001:db8:3::/64 \ |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 212 | nexthop via 2001:db8:1::2 dev dummy0 \ |
213 | nexthop via 2001:db8:2::2 dev dummy1 | ||||
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 214 | set +e |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 215 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 216 | echo " Verify start point" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 217 | ip -netns testns route get fibmatch 203.0.113.1 &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 218 | log_test $? 0 "IPv4 fibmatch" |
219 | |||||
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 220 | ip -netns testns -6 route get fibmatch 2001:db8:3::1 &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 221 | log_test $? 0 "IPv6 fibmatch" |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 222 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 223 | set -e |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 224 | ip -netns testns link set dev dummy0 down |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 225 | set +e |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 226 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 227 | echo " One device down, one up" |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 228 | fib_down_multipath_test_do "dummy0" "dummy1" |
229 | |||||
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 230 | set -e |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 231 | ip -netns testns link set dev dummy0 up |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 232 | ip -netns testns link set dev dummy1 down |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 233 | set +e |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 234 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 235 | echo " Other device down and up" |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 236 | fib_down_multipath_test_do "dummy1" "dummy0" |
237 | |||||
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 238 | set -e |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 239 | ip -netns testns link set dev dummy0 down |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 240 | set +e |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 241 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 242 | echo " Both devices down" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 243 | ip -netns testns route get fibmatch 203.0.113.1 &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 244 | log_test $? 2 "IPv4 fibmatch" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 245 | ip -netns testns -6 route get fibmatch 2001:db8:3::1 &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 246 | log_test $? 2 "IPv6 fibmatch" |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 247 | |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 248 | ip -netns testns link del dev dummy1 |
David Ahern | ee395a5 | 2018-02-13 08:37:35 -0800 | [diff] [blame^] | 249 | cleanup |
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 250 | } |
251 | |||||
252 | fib_down_test() | ||||
253 | { | ||||
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 254 | fib_down_unicast_test |
255 | fib_down_multipath_test | ||||
256 | } | ||||
257 | |||||
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 258 | # Local routes should not be affected when carrier changes. |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 259 | fib_carrier_local_test() |
260 | { | ||||
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 261 | echo |
262 | echo "Local carrier tests - single path" | ||||
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 263 | |
David Ahern | ee395a5 | 2018-02-13 08:37:35 -0800 | [diff] [blame^] | 264 | setup |
265 | |||||
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 266 | set -e |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 267 | ip -netns testns link set dev dummy0 carrier on |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 268 | set +e |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 269 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 270 | echo " Start point" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 271 | ip -netns testns route get fibmatch 198.51.100.1 &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 272 | log_test $? 0 "IPv4 fibmatch" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 273 | ip -netns testns -6 route get fibmatch 2001:db8:1::1 &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 274 | log_test $? 0 "IPv6 fibmatch" |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 275 | |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 276 | ip -netns testns route get fibmatch 198.51.100.1 | \ |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 277 | grep -q "linkdown" |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 278 | log_test $? 1 "IPv4 - no linkdown flag" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 279 | ip -netns testns -6 route get fibmatch 2001:db8:1::1 | \ |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 280 | grep -q "linkdown" |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 281 | log_test $? 1 "IPv6 - no linkdown flag" |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 282 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 283 | set -e |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 284 | ip -netns testns link set dev dummy0 carrier off |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 285 | set +e |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 286 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 287 | echo " Carrier off on nexthop" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 288 | ip -netns testns route get fibmatch 198.51.100.1 &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 289 | log_test $? 0 "IPv4 fibmatch" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 290 | ip -netns testns -6 route get fibmatch 2001:db8:1::1 &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 291 | log_test $? 0 "IPv6 fibmatch" |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 292 | |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 293 | ip -netns testns route get fibmatch 198.51.100.1 | \ |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 294 | grep -q "linkdown" |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 295 | log_test $? 1 "IPv4 - linkdown flag set" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 296 | ip -netns testns -6 route get fibmatch 2001:db8:1::1 | \ |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 297 | grep -q "linkdown" |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 298 | log_test $? 1 "IPv6 - linkdown flag set" |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 299 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 300 | set -e |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 301 | ip -netns testns address add 192.0.2.1/24 dev dummy0 |
302 | ip -netns testns -6 address add 2001:db8:2::1/64 dev dummy0 | ||||
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 303 | set +e |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 304 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 305 | echo " Route to local address with carrier down" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 306 | ip -netns testns route get fibmatch 192.0.2.1 &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 307 | log_test $? 0 "IPv4 fibmatch" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 308 | ip -netns testns -6 route get fibmatch 2001:db8:2::1 &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 309 | log_test $? 0 "IPv6 fibmatch" |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 310 | |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 311 | ip -netns testns route get fibmatch 192.0.2.1 | \ |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 312 | grep -q "linkdown" |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 313 | log_test $? 1 "IPv4 linkdown flag set" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 314 | ip -netns testns -6 route get fibmatch 2001:db8:2::1 | \ |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 315 | grep -q "linkdown" |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 316 | log_test $? 1 "IPv6 linkdown flag set" |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 317 | |
David Ahern | ee395a5 | 2018-02-13 08:37:35 -0800 | [diff] [blame^] | 318 | cleanup |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 319 | } |
320 | |||||
321 | fib_carrier_unicast_test() | ||||
322 | { | ||||
323 | ret=0 | ||||
324 | |||||
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 325 | echo |
326 | echo "Single path route carrier test" | ||||
327 | |||||
David Ahern | ee395a5 | 2018-02-13 08:37:35 -0800 | [diff] [blame^] | 328 | setup |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 329 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 330 | set -e |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 331 | ip -netns testns link set dev dummy0 carrier on |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 332 | set +e |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 333 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 334 | echo " Start point" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 335 | ip -netns testns route get fibmatch 198.51.100.2 &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 336 | log_test $? 0 "IPv4 fibmatch" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 337 | ip -netns testns -6 route get fibmatch 2001:db8:1::2 &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 338 | log_test $? 0 "IPv6 fibmatch" |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 339 | |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 340 | ip -netns testns route get fibmatch 198.51.100.2 | \ |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 341 | grep -q "linkdown" |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 342 | log_test $? 1 "IPv4 no linkdown flag" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 343 | ip -netns testns -6 route get fibmatch 2001:db8:1::2 | \ |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 344 | grep -q "linkdown" |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 345 | log_test $? 1 "IPv6 no linkdown flag" |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 346 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 347 | set -e |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 348 | ip -netns testns link set dev dummy0 carrier off |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 349 | set +e |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 350 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 351 | echo " Carrier down" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 352 | ip -netns testns route get fibmatch 198.51.100.2 &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 353 | log_test $? 0 "IPv4 fibmatch" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 354 | ip -netns testns -6 route get fibmatch 2001:db8:1::2 &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 355 | log_test $? 0 "IPv6 fibmatch" |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 356 | |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 357 | ip -netns testns route get fibmatch 198.51.100.2 | \ |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 358 | grep -q "linkdown" |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 359 | log_test $? 0 "IPv4 linkdown flag set" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 360 | ip -netns testns -6 route get fibmatch 2001:db8:1::2 | \ |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 361 | grep -q "linkdown" |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 362 | log_test $? 0 "IPv6 linkdown flag set" |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 363 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 364 | set -e |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 365 | ip -netns testns address add 192.0.2.1/24 dev dummy0 |
366 | ip -netns testns -6 address add 2001:db8:2::1/64 dev dummy0 | ||||
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 367 | set +e |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 368 | |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 369 | echo " Second address added with carrier down" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 370 | ip -netns testns route get fibmatch 192.0.2.2 &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 371 | log_test $? 0 "IPv4 fibmatch" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 372 | ip -netns testns -6 route get fibmatch 2001:db8:2::2 &> /dev/null |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 373 | log_test $? 0 "IPv6 fibmatch" |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 374 | |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 375 | ip -netns testns route get fibmatch 192.0.2.2 | \ |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 376 | grep -q "linkdown" |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 377 | log_test $? 0 "IPv4 linkdown flag set" |
David Ahern | 07f4e62 | 2018-02-13 08:37:33 -0800 | [diff] [blame] | 378 | ip -netns testns -6 route get fibmatch 2001:db8:2::2 | \ |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 379 | grep -q "linkdown" |
David Ahern | 1056691 | 2018-02-13 08:37:34 -0800 | [diff] [blame] | 380 | log_test $? 0 "IPv6 linkdown flag set" |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 381 | |
David Ahern | ee395a5 | 2018-02-13 08:37:35 -0800 | [diff] [blame^] | 382 | cleanup |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 383 | } |
384 | |||||
385 | fib_carrier_test() | ||||
386 | { | ||||
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 387 | fib_carrier_local_test |
388 | fib_carrier_unicast_test | ||||
389 | } | ||||
390 | |||||
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 391 | fib_test() |
392 | { | ||||
393 | fib_unreg_test | ||||
Ido Schimmel | 5adb768 | 2018-01-07 12:45:17 +0200 | [diff] [blame] | 394 | fib_down_test |
Ido Schimmel | 82e45b6 | 2018-01-07 12:45:18 +0200 | [diff] [blame] | 395 | fib_carrier_test |
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 396 | } |
397 | |||||
398 | if [ "$(id -u)" -ne 0 ];then | ||||
399 | echo "SKIP: Need root privileges" | ||||
400 | exit 0 | ||||
401 | fi | ||||
402 | |||||
403 | if [ ! -x "$(command -v ip)" ]; then | ||||
404 | echo "SKIP: Could not run test without ip tool" | ||||
405 | exit 0 | ||||
406 | fi | ||||
407 | |||||
408 | ip route help 2>&1 | grep -q fibmatch | ||||
409 | if [ $? -ne 0 ]; then | ||||
410 | echo "SKIP: iproute2 too old, missing fibmatch" | ||||
411 | exit 0 | ||||
412 | fi | ||||
413 | |||||
David Ahern | ee395a5 | 2018-02-13 08:37:35 -0800 | [diff] [blame^] | 414 | # start clean |
415 | cleanup &> /dev/null | ||||
416 | |||||
Ido Schimmel | 607bd2e | 2018-01-07 12:45:16 +0200 | [diff] [blame] | 417 | fib_test |
418 | |||||
419 | exit $ret |