1# $OpenBSD: Makefile,v 1.32 2019/03/30 06:37:10 yasuoka Exp $ 2 3ROUTE?= /sbin/route 4RDOMAIN?= 5 5 6.MAIN: all 7 8.ifmake !obj && !clean && !cleandir && !regress 9.if (${.TARGET} != all && ! make(all)) || (${.TARGET} == all) 10 11.SILENT: .BEGIN .END 12 13.BEGIN: 14.for itf in lo10001 lo10002 lo10003 lo10004 vlan99 vether99 15 -${SUDO} ifconfig ${itf} destroy 2>/dev/null || true 16.endfor 17 -${SUDO} ifconfig lo${RDOMAIN} rdomain ${RDOMAIN} -inet6 down 18 -${SUDO} ifconfig lo10001 up rdomain ${RDOMAIN} 192.0.2.1/32 19 -${SUDO} ifconfig lo10002 up rdomain ${RDOMAIN} 192.0.2.2/32 20 -${SUDO} ifconfig lo10003 up rdomain ${RDOMAIN} 192.0.2.3/32 21 -${SUDO} ifconfig lo10004 up rdomain ${RDOMAIN} 192.0.2.4/32 22 23.END: 24.for itf in lo10001 lo10002 lo10003 lo10004 vlan99 vether99 25 -${SUDO} ifconfig ${itf} destroy 2>/dev/null || true 26.endfor 27 28.endif 29.endif 30 31RCMD= ${SUDO} ${ROUTE} -T ${RDOMAIN} -n 32 33netmask: 34.for mod in -net -dst 35.for cmd in add delete 36 ${RCMD} -t ${cmd} ${mod} 192.0.3/24 192.0.2.1 37 ${RCMD} -t ${cmd} ${mod} 192.0.4.0 -netmask 255.255.255.0 192.0.2.1 38.endfor 39.endfor 40 41# check that more specific routes work properly (rn_dupedkey behaviour) 42n= 1 43RTTEST_TARGETS+:=rttest${n} 44rttest${n}: 45 ${RCMD} add 10/8 192.0.2.1 46 ${RCMD} add 10.0/16 192.0.2.4 47 ${RCMD} add 10.0/10 192.0.2.4 48 ${RCMD} add 10.8/16 192.0.2.3 49 ${RCMD} add 10.8.0/24 192.0.2.1 50 ${RCMD} add 10.8.1/24 192.0.2.2 51 ${RCMD} add 10.8.3/24 192.0.2.3 52 ${RCMD} add 10.8.4/24 192.0.2.4 53 ${RCMD} show -inet 2>&1 | \ 54 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 55 56# can we add multiple pathes 57n= 2 58RTTEST_TARGETS+:=rttest${n} 59rttest${n}: 60 ${RCMD} add -mpath 10.8.1/24 192.0.2.3 61 ${RCMD} add -mpath 10.8.1/24 192.0.2.4 62 ${RCMD} show -inet 2>&1 | \ 63 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 64 65# but we can not readd the same multipath route twice 66n= 3 67RTTEST_TARGETS+:=rttest${n} 68rttest${n}: 69 ${RCMD} add -mpath 10.8.1/24 192.0.2.3 70 ${RCMD} add -mpath 10.8.1/24 192.0.2.3 && exit 1 || exit 0 71 ${RCMD} show -inet 2>&1 | \ 72 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 73 74 75# do priorities work 76n= 4 77RTTEST_TARGETS+:=rttest${n} 78rttest${n}: 79 ${RCMD} add -priority 16 10.8.1/24 192.0.2.1 80 ${RCMD} add -priority 17 10.8.1/24 192.0.2.2 81 ${RCMD} add -priority 18 10.8.1/24 192.0.2.3 82 ${RCMD} show -inet 2>&1 | \ 83 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 84 85# priority and multipath 86n= 5 87RTTEST_TARGETS+:=rttest${n} 88rttest${n}: 89 ${RCMD} add -mpath -priority 16 10.8.1/24 192.0.2.2 90 ${RCMD} add -mpath -priority 17 10.8.1/24 192.0.2.2 91 ${RCMD} add -mpath -priority 18 10.8.1/24 192.0.2.2 92 ! ${RCMD} add -mpath -priority 17 10.8.1/24 192.0.2.2 93 ${RCMD} show -inet 2>&1 | \ 94 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 95 96# priority but failing multipath because of same gateway 97n= 6 98RTTEST_TARGETS+:=rttest${n} 99rttest${n}: 100 ${RCMD} add -priority 16 10.8.1/24 192.0.2.1 101 ${RCMD} add -priority 17 10.8.1/24 192.0.2.2 102 ${RCMD} add -priority 18 10.8.1/24 192.0.2.3 103 ! ${RCMD} add -priority 17 10.8.1/24 192.0.2.2 104 ${RCMD} show -inet 2>&1 | \ 105 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 106 107# deletion of priority route in the middle 108n= 7 109RTTEST_TARGETS+:=rttest${n} 110rttest${n}: 111 ${RCMD} add -priority 16 10.8.1/24 192.0.2.1 112 ${RCMD} add -priority 17 10.8.1/24 192.0.2.2 113 ${RCMD} add -priority 18 10.8.1/24 192.0.2.3 114 ${RCMD} delete -priority 17 10.8.1/24 115 ${RCMD} show -inet 2>&1 | \ 116 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 117 118# readd of same route fail even if interface is down 119n= 8 120RTTEST_TARGETS+:=rttest${n} 121rttest${n}: 122 ${RCMD} add -priority 16 10.8.1/24 192.0.2.1 123 ${RCMD} add -priority 17 10.8.1/24 192.0.2.2 124 ${RCMD} add -priority 18 10.8.1/24 192.0.2.3 125 ${SUDO} ifconfig lo10002 down 126 ! ${RCMD} add -priority 17 10.8.1/24 192.0.2.2 127 # Wait until SRP reference count are dropped 128 sleep .5 129 ${RCMD} show -inet 2>&1 | \ 130 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 131 132# deletion of priority route in the middle after reprio because of iface down 133n= 9 134RTTEST_TARGETS+:=rttest${n} 135rttest${n}: 136 ${RCMD} add -priority 16 10.8.1/24 192.0.2.1 137 ${RCMD} add -priority 17 10.8.1/24 192.0.2.2 138 ${RCMD} add -priority 18 10.8.1/24 192.0.2.3 139 ${SUDO} ifconfig lo10002 down 140 ${RCMD} delete -priority 17 10.8.1/24 141 ${RCMD} show -inet 2>&1 | \ 142 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 143 144# addition of priority route works even if interface is down 145n= 10 146RTTEST_TARGETS+:=rttest${n} 147rttest${n}: 148 ${SUDO} ifconfig lo10002 down 149 ${RCMD} add -priority 16 10.8.1/24 192.0.2.1 150 ${RCMD} add -priority 17 10.8.1/24 192.0.2.2 151 ${RCMD} add -priority 18 10.8.1/24 192.0.2.3 152 ${RCMD} show -inet 2>&1 | \ 153 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 154 155# same as 10 but different order 156n= 11 157RTTEST_TARGETS+:=rttest${n} 158rttest${n}: 159 ${SUDO} ifconfig lo10002 down 160 ${RCMD} add -priority 16 10.8.1/24 192.0.2.1 161 ${RCMD} add -priority 18 10.8.1/24 192.0.2.3 162 ${RCMD} add -priority 17 10.8.1/24 192.0.2.2 163 ${RCMD} show -inet 2>&1 | \ 164 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 165 166# change non-mpath route (even though the route was marked as mpath) 167n= 12 168RTTEST_TARGETS+:=rttest${n} 169rttest${n}: 170 ${RCMD} add -mpath 10.8.1/24 192.0.2.3 171 ${RCMD} change -mpath 10.8.1/24 192.0.2.4 172 ${RCMD} show -inet 2>&1 | \ 173 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 174 175# Cannot change the gateway of an mpath route 176n= 13 177RTTEST_TARGETS+:=rttest${n} 178rttest${n}: 179 ${RCMD} add -mpath 10.8.1/24 192.0.2.3 180 ${RCMD} add -mpath 10.8.1/24 192.0.2.4 181 ! ${RCMD} change -mpath 10.8.1/24 192.0.2.1 182 183# Changing MTU should not change the ifa 184n= 14 185RTTEST_TARGETS+:=rttest${n} 186rttest${n}: 187 ${SUDO} ifconfig lo10001 inet6 eui64 188 ${SUDO} ifconfig lo10002 inet6 fd88::1/64 189 ${SUDO} ifconfig lo10003 inet6 fd99::1/64 190 ${RCMD} add -inet6 fd88::666 fd99::1 191 ${RCMD} change fd88::666 -mtu 1500 192 ${RCMD} show -inet6 2>&1 | \ 193 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 194 195# Changing the ifa should not change the gw 196n= 15 197RTTEST_TARGETS+:=rttest${n} 198rttest${n}: 199 ${RCMD} add 10.0/16 192.0.2.4 200 ${RCMD} change 10.0/16 -ifa 192.0.2.2 201 ${RCMD} show -inet 2>&1 | \ 202 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 203 204# Changing ifp should not change the gw 205n= 16 206RTTEST_TARGETS+:=rttest${n} 207rttest${n}: 208 ${SUDO} ifconfig lo10001 inet6 eui64 209 ${SUDO} ifconfig lo10002 inet6 fd88::1/64 210 ${SUDO} ifconfig lo10003 inet6 fd99::1/64 211 ${RCMD} add -inet6 fd88::666 fd99::1 212 ${RCMD} change fd88::666 -ifp lo10002 213 ${RCMD} show -inet6 2>&1 | \ 214 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 215 216# Removing 2nd-last multipath route (head) 217n= 17 218RTTEST_TARGETS+:=rttest${n} 219rttest${n}: 220 ${RCMD} add -mpath 10.8.1/24 192.0.2.3 221 ${RCMD} add -mpath 10.8.1/24 192.0.2.4 222 ${RCMD} delete -mpath 10.8.1/24 192.0.2.3 223 ${RCMD} show -inet -gateway 2>&1 | \ 224 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 225 226# Removing 2nd-last multipath route (tail) 227n= 18 228RTTEST_TARGETS+:=rttest${n} 229rttest${n}: 230 ${RCMD} add -mpath 10.8.1/24 192.0.2.3 231 ${RCMD} add -mpath 10.8.1/24 192.0.2.4 232 ${RCMD} delete -mpath 10.8.1/24 192.0.2.4 233 ${RCMD} show -inet -gateway 2>&1 | \ 234 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 235 236# Removing 2nd-last multipath route (head of dupedkey chain) 237n= 19 238RTTEST_TARGETS+:=rttest${n} 239rttest${n}: 240 ${RCMD} add 10.8.1/24 192.0.2.1 241 ${RCMD} add -mpath 10.8.1/25 192.0.2.3 242 ${RCMD} add -mpath 10.8.1/25 192.0.2.4 243 ${RCMD} add 10.8.1/26 192.0.2.2 244 ${RCMD} delete -mpath 10.8.1/25 192.0.2.3 245 ${RCMD} show -inet -gateway 2>&1 | \ 246 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 247 248# RTM_GET for mpath routes does not need a gateway argument 249n= 20 250RTTEST_TARGETS+:=rttest${n} 251rttest${n}: 252 ${SUDO} ifconfig lo10001 inet6 fd88::1/64 253 ${SUDO} ifconfig lo10002 inet6 fd88::2/64 254 ${RCMD} add -inet6 2001:ee0:2001:c0::/64 fd88::1 255 ${RCMD} add -inet6 -mpath 2001:ee0:2001:c0::/64 fd88::2 256 ${RCMD} get -inet6 2001:ee0:2001:c0::/64 2>&1 | \ 257 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 258 259# Verify order of multiple priorities 260n= 21 261RTTEST_TARGETS+:=rttest${n} 262rttest${n}: 263 ${RCMD} add 10.8.1/24 -gateway 192.0.2.3 -priority 4 264 ${RCMD} add 10.8.1/24 -gateway 192.0.2.3 -priority 3 265 ${RCMD} add 10.8.1/24 -gateway 192.0.2.3 -priority 5 266 ${RCMD} show -inet 2>&1 | \ 267 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 268 269# Can change the MTU of an mpath route that exists 270n= 22 271RTTEST_TARGETS+:=rttest${n} 272rttest${n}: 273 ${RCMD} add -mpath 10.8.1/24 192.0.2.3 274 ${RCMD} add -mpath 10.8.1/24 192.0.2.4 275 ${RCMD} change -mpath -mtu 1000 10.8.1/24 192.0.2.4 276 ${RCMD} show -inet 2>&1 | \ 277 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 278 279# Can't change the MTU of an mpath route without gateway 280n= 23 281RTTEST_TARGETS+:=rttest${n} 282rttest${n}: 283 ${RCMD} add -mpath 10.8.1/24 192.0.2.3 284 ${RCMD} add -mpath 10.8.1/24 192.0.2.4 285 ! ${RCMD} change -mpath -mtu 1000 10.8.1/24 286 287# Can change and lock the MTU of an mpath route that exists 288# (route can't just lock so this is mostly the same as rttest22) 289n= 24 290RTTEST_TARGETS+:=rttest${n} 291rttest${n}: 292 ${RCMD} add -mpath 10.8.1/24 192.0.2.3 293 ${RCMD} add -mpath 10.8.1/24 192.0.2.4 294 ${RCMD} change -mpath -lock -mtu 1000 10.8.1/24 192.0.2.4 295 ${RCMD} show -inet 2>&1 | \ 296 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 297 298# Can't change the MTU of an mpath route that has a wrong gateway 299n= 25 300RTTEST_TARGETS+:=rttest${n} 301rttest${n}: 302 ${RCMD} add -mpath 10.8.1/24 192.0.2.3 303 ${RCMD} add -mpath 10.8.1/24 192.0.2.4 304 ! ${RCMD} change -mpath -mtu 1000 10.8.1/24 192.0.2.1 305 306# Can change the MTU of an non-mpath route without gateway 307n= 26 308RTTEST_TARGETS+:=rttest${n} 309rttest${n}: 310 ${RCMD} add -mpath 10.8.1/24 192.0.2.3 311 ${RCMD} change -mpath -mtu 1000 10.8.1/24 312 ${RCMD} show -inet 2>&1 | \ 313 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 314 315# Can change the MTU and gateway of an non-mpath route at the same time 316n= 27 317RTTEST_TARGETS+:=rttest${n} 318rttest${n}: 319 ${RCMD} add -mpath 10.8.1/24 192.0.2.3 320 ${RCMD} change -mpath -mtu 1000 10.8.1/24 192.0.2.4 321 ${RCMD} show -inet 2>&1 | \ 322 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 323 324# Can't delete RTF_LOCAL route 325n= 28 326RTTEST_TARGETS+:=rttest${n} 327rttest${n}: 328 ! ${RCMD} delete 192.0.2.1 192.0.2.1 329 330# Can't change/set expire on a RTF_LOCAL route 331n= 29 332RTTEST_TARGETS+:=rttest${n} 333rttest${n}: 334 ! ${RCMD} change -expire 30 192.0.2.1 192.0.2.2 335 336 337# Ensure that all MPATH routes on vlan99 are taken down 338n= 30 339RTTEST_TARGETS+:=rttest${n} 340rttest${n}: 341 ${SUDO} ifconfig vether99 rdomain ${RDOMAIN} lladdr fe:e1:ba:d4:c8:1d up 342 ${SUDO} ifconfig vlan99 rdomain ${RDOMAIN} parent vether99 vnetid 3 up 343 ${SUDO} ifconfig vether99 10.1.254.56/14 344 ${SUDO} ifconfig vlan99 inet alias 10.1.255.1/14 345 ${SUDO} ifconfig vlan99 inet alias 10.1.255.2/14 346 ${SUDO} ifconfig vlan99 inet alias 10.1.255.3/14 347 ${SUDO} ifconfig vlan99 down 348 # Wait until SRP reference count are dropped 349 sleep .5 350 ${RCMD} show -inet 2>&1 | \ 351 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 352 353# Check that routes are inserted respecting their priority order 354n= 31 355RTTEST_TARGETS+:=rttest${n} 356rttest${n}: 357 ${RCMD} add -mpath 192.0.3/24 -priority 13 192.0.2.3 358 ${RCMD} add -mpath 192.0.3/24 -priority 11 192.0.2.1 359 ${RCMD} add -mpath 192.0.3/24 -priority 14 192.0.2.4 360 ${RCMD} add -mpath 192.0.3/24 -priority 12 192.0.2.2 361 ${RCMD} show -inet 2>&1 | \ 362 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 363 364# Check that next-hop L2 cache are cloned using the correct MPATH route 365n= 32 366RTTEST_TARGETS+:=rttest${n} 367rttest${n}: 368 # Use vether(4) and vlan(4) because we need IFT_ETHER interfaces 369 # for the auto-magic RTF_CLONING routes. 370 ${SUDO} ifconfig vether99 rdomain ${RDOMAIN} lladdr fe:e1:ba:d4:c8:1d up 371 ${SUDO} ifconfig vether99 130.102.71.68/27 372 ${SUDO} ifconfig vlan99 rdomain ${RDOMAIN} parent vether99 vnetid 3 up 373 ${SUDO} ifconfig vlan99 130.102.71.70/27 374 # Inserting such route generate the insertion of a RTF_CLONED entry 375 # attached to the specified interface 376 ${RCMD} add -net 192.168.67.0/25 130.102.71.67 -priority 9 -ifp vether99 377 ${RCMD} add -net 192.168.67.128/25 130.102.71.67 -priority 3 -ifp vlan99 378 ${RCMD} show -inet 2>&1 | \ 379 sed -e "s,link\#[0-9 ]*U,link# U," | \ 380 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 381 382# Check that removing a RTF_CLONING route do not remove RTF_CACHED children 383# from another cloning route. 384n= 33 385RTTEST_TARGETS+:=rttest${n} 386rttest${n}: 387 # Use vether(4) because we need IFT_ETHER interfaces 388 # for the auto-magic RTF_CLONING routes. 389 ${SUDO} ifconfig vether99 rdomain ${RDOMAIN} lladdr fe:e1:ba:d4:c8:1d up 390 ${SUDO} ifconfig vether99 192.168.178.52/24 391 ${SUDO} ifconfig vether99 alias 192.168.178.53/24 392 ${RCMD} add default 192.168.178.1 393 # Remove the alias 394 ${SUDO} ifconfig vether99 192.168.178.53 delete 395 ${RCMD} show -inet 2>&1 | \ 396 sed -e "s,link\#[0-9 ]*U,link# U," | \ 397 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 398 399# Check that adding default route by "default" works properly 400n= 34 401RTTEST_TARGETS+:=rttest${n} 402rttest${n}: 403 ${SUDO} ifconfig vether99 rdomain ${RDOMAIN} lladdr fe:e1:ba:d4:c8:1d up 404 ${SUDO} ifconfig vether99 192.168.71.10 405 ${RCMD} add default 192.168.71.1 406 ${RCMD} show -inet 2>&1 | \ 407 sed -e "s,link\#[0-9 ]*U,link# U," | \ 408 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 409 410# Check that adding default route by "0.0.0.0/0" works properly 411n= 35 412RTTEST_TARGETS+:=rttest${n} 413rttest${n}: 414 ${SUDO} ifconfig vether99 rdomain ${RDOMAIN} lladdr fe:e1:ba:d4:c8:1d up 415 ${SUDO} ifconfig vether99 192.168.3.23 416 ${RCMD} add 0.0.0.0/0 192.168.3.1 417 ${RCMD} show -inet 2>&1 | \ 418 sed -e "s,link\#[0-9 ]*U,link# U," | \ 419 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 420 421# Check that adding "0.0.0.0" route doesn't mean default route 422n= 36 423RTTEST_TARGETS+:=rttest${n} 424rttest${n}: 425 ${SUDO} ifconfig vether99 rdomain ${RDOMAIN} lladdr fe:e1:ba:d4:c8:1d up 426 ${SUDO} ifconfig vether99 192.168.89.5 427 ${RCMD} add 0.0.0.0 192.168.89.1 428 ${RCMD} show -inet 2>&1 | \ 429 sed -e "s,link\#[0-9 ]*U,link# U," | \ 430 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 431 432# Check that adding routes with mask works properly 433n= 37 434RTTEST_TARGETS+:=rttest${n} 435rttest${n}: 436 ${RCMD} add 10.1.0.2/24 192.0.2.1 437 ${RCMD} add 10.2.1.8/16 192.0.2.2 438 ${RCMD} add 10.3.5.7/8 192.0.2.3 439 ${RCMD} add 172.25.8.3/24 192.0.2.1 440 ${RCMD} add 172.30.2.5/16 192.0.2.2 441 ${RCMD} add 172.21.4.7/8 192.0.2.3 442 ${RCMD} add 192.168.5.3/24 192.0.2.1 443 ${RCMD} add 192.168.9.8/16 192.0.2.2 444 ${RCMD} add 192.168.1.7/8 192.0.2.3 445 ${RCMD} show -inet 2>&1 | \ 446 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 447 448# Check that adding routes without mask works properly 449n= 38 450RTTEST_TARGETS+:=rttest${n} 451rttest${n}: 452 ${RCMD} add 10.0.0.5 192.0.2.1 453 ${RCMD} add 10.4.2 192.0.2.2 454 ${RCMD} add 10.5 192.0.2.3 455 ${RCMD} add 10 192.0.2.4 456 ${RCMD} add 172.16.1.8 192.0.2.1 457 ${RCMD} add 172.17.2 192.0.2.2 458 ${RCMD} add 172.28 192.0.2.3 459 ${RCMD} add 172 192.0.2.4 460 ${RCMD} add 192.168.7.9 192.0.2.1 461 ${RCMD} add 192.168.2 192.0.2.2 462 ${RCMD} add 192.168 192.0.2.3 463 ${RCMD} add 192 192.0.2.4 464 ${RCMD} show -inet 2>&1 | \ 465 diff -u ${.CURDIR}/${.TARGET}.ok /dev/stdin 466 467REGRESS_TARGETS=netmask ${RTTEST_TARGETS} 468REGRESS_ROOT_TARGETS=${REGRESS_TARGETS} 469.PHONY: ${REGRESS_TARGETS} 470 471.include <bsd.regress.mk> 472