1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3# 4# This test is for checking VXLAN MDB functionality. The topology consists of 5# two sets of namespaces: One for the testing of IPv4 underlay and another for 6# IPv6. In both cases, both IPv4 and IPv6 overlay traffic are tested. 7# 8# Data path functionality is tested by sending traffic from one of the upper 9# namespaces and checking using ingress tc filters that the expected traffic 10# was received by one of the lower namespaces. 11# 12# +------------------------------------+ +------------------------------------+ 13# | ns1_v4 | | ns1_v6 | 14# | | | | 15# | br0.10 br0.4000 br0.20 | | br0.10 br0.4000 br0.20 | 16# | + + + | | + + + | 17# | | | | | | | | | | 18# | | | | | | | | | | 19# | +---------+---------+ | | +---------+---------+ | 20# | | | | | | 21# | | | | | | 22# | + | | + | 23# | br0 | | br0 | 24# | + | | + | 25# | | | | | | 26# | | | | | | 27# | + | | + | 28# | vx0 | | vx0 | 29# | | | | 30# | | | | 31# | veth0 | | veth0 | 32# | + | | + | 33# +-----------------|------------------+ +-----------------|------------------+ 34# | | 35# +-----------------|------------------+ +-----------------|------------------+ 36# | + | | + | 37# | veth0 | | veth0 | 38# | | | | 39# | | | | 40# | vx0 | | vx0 | 41# | + | | + | 42# | | | | | | 43# | | | | | | 44# | + | | + | 45# | br0 | | br0 | 46# | + | | + | 47# | | | | | | 48# | | | | | | 49# | +---------+---------+ | | +---------+---------+ | 50# | | | | | | | | | | 51# | | | | | | | | | | 52# | + + + | | + + + | 53# | br0.10 br0.4000 br0.10 | | br0.10 br0.4000 br0.20 | 54# | | | | 55# | ns2_v4 | | ns2_v6 | 56# +------------------------------------+ +------------------------------------+ 57 58source lib.sh 59ret=0 60 61CONTROL_PATH_TESTS=" 62 basic_star_g_ipv4_ipv4 63 basic_star_g_ipv6_ipv4 64 basic_star_g_ipv4_ipv6 65 basic_star_g_ipv6_ipv6 66 basic_sg_ipv4_ipv4 67 basic_sg_ipv6_ipv4 68 basic_sg_ipv4_ipv6 69 basic_sg_ipv6_ipv6 70 star_g_ipv4_ipv4 71 star_g_ipv6_ipv4 72 star_g_ipv4_ipv6 73 star_g_ipv6_ipv6 74 sg_ipv4_ipv4 75 sg_ipv6_ipv4 76 sg_ipv4_ipv6 77 sg_ipv6_ipv6 78 dump_ipv4_ipv4 79 dump_ipv6_ipv4 80 dump_ipv4_ipv6 81 dump_ipv6_ipv6 82 flush 83" 84 85DATA_PATH_TESTS=" 86 encap_params_ipv4_ipv4 87 encap_params_ipv6_ipv4 88 encap_params_ipv4_ipv6 89 encap_params_ipv6_ipv6 90 starg_exclude_ir_ipv4_ipv4 91 starg_exclude_ir_ipv6_ipv4 92 starg_exclude_ir_ipv4_ipv6 93 starg_exclude_ir_ipv6_ipv6 94 starg_include_ir_ipv4_ipv4 95 starg_include_ir_ipv6_ipv4 96 starg_include_ir_ipv4_ipv6 97 starg_include_ir_ipv6_ipv6 98 starg_exclude_p2mp_ipv4_ipv4 99 starg_exclude_p2mp_ipv6_ipv4 100 starg_exclude_p2mp_ipv4_ipv6 101 starg_exclude_p2mp_ipv6_ipv6 102 starg_include_p2mp_ipv4_ipv4 103 starg_include_p2mp_ipv6_ipv4 104 starg_include_p2mp_ipv4_ipv6 105 starg_include_p2mp_ipv6_ipv6 106 egress_vni_translation_ipv4_ipv4 107 egress_vni_translation_ipv6_ipv4 108 egress_vni_translation_ipv4_ipv6 109 egress_vni_translation_ipv6_ipv6 110 all_zeros_mdb_ipv4 111 all_zeros_mdb_ipv6 112 mdb_fdb_ipv4_ipv4 113 mdb_fdb_ipv6_ipv4 114 mdb_fdb_ipv4_ipv6 115 mdb_fdb_ipv6_ipv6 116 mdb_torture_ipv4_ipv4 117 mdb_torture_ipv6_ipv4 118 mdb_torture_ipv4_ipv6 119 mdb_torture_ipv6_ipv6 120" 121 122# All tests in this script. Can be overridden with -t option. 123TESTS=" 124 $CONTROL_PATH_TESTS 125 $DATA_PATH_TESTS 126" 127VERBOSE=0 128PAUSE_ON_FAIL=no 129PAUSE=no 130 131################################################################################ 132# Utilities 133 134log_test() 135{ 136 local rc=$1 137 local expected=$2 138 local msg="$3" 139 140 if [ ${rc} -eq ${expected} ]; then 141 printf "TEST: %-60s [ OK ]\n" "${msg}" 142 nsuccess=$((nsuccess+1)) 143 else 144 ret=1 145 nfail=$((nfail+1)) 146 printf "TEST: %-60s [FAIL]\n" "${msg}" 147 if [ "$VERBOSE" = "1" ]; then 148 echo " rc=$rc, expected $expected" 149 fi 150 151 if [ "${PAUSE_ON_FAIL}" = "yes" ]; then 152 echo 153 echo "hit enter to continue, 'q' to quit" 154 read a 155 [ "$a" = "q" ] && exit 1 156 fi 157 fi 158 159 if [ "${PAUSE}" = "yes" ]; then 160 echo 161 echo "hit enter to continue, 'q' to quit" 162 read a 163 [ "$a" = "q" ] && exit 1 164 fi 165 166 [ "$VERBOSE" = "1" ] && echo 167} 168 169run_cmd() 170{ 171 local cmd="$1" 172 local out 173 local stderr="2>/dev/null" 174 175 if [ "$VERBOSE" = "1" ]; then 176 printf "COMMAND: $cmd\n" 177 stderr= 178 fi 179 180 out=$(eval $cmd $stderr) 181 rc=$? 182 if [ "$VERBOSE" = "1" -a -n "$out" ]; then 183 echo " $out" 184 fi 185 186 return $rc 187} 188 189tc_check_packets() 190{ 191 local ns=$1; shift 192 local id=$1; shift 193 local handle=$1; shift 194 local count=$1; shift 195 local pkts 196 197 sleep 0.1 198 pkts=$(tc -n $ns -j -s filter show $id \ 199 | jq ".[] | select(.options.handle == $handle) | \ 200 .options.actions[0].stats.packets") 201 [[ $pkts == $count ]] 202} 203 204################################################################################ 205# Setup 206 207setup_common_ns() 208{ 209 local ns=$1; shift 210 local local_addr=$1; shift 211 212 ip netns exec $ns sysctl -qw net.ipv4.ip_forward=1 213 ip netns exec $ns sysctl -qw net.ipv4.fib_multipath_use_neigh=1 214 ip netns exec $ns sysctl -qw net.ipv4.conf.default.ignore_routes_with_linkdown=1 215 ip netns exec $ns sysctl -qw net.ipv6.conf.all.keep_addr_on_down=1 216 ip netns exec $ns sysctl -qw net.ipv6.conf.all.forwarding=1 217 ip netns exec $ns sysctl -qw net.ipv6.conf.default.forwarding=1 218 ip netns exec $ns sysctl -qw net.ipv6.conf.default.ignore_routes_with_linkdown=1 219 ip netns exec $ns sysctl -qw net.ipv6.conf.all.accept_dad=0 220 ip netns exec $ns sysctl -qw net.ipv6.conf.default.accept_dad=0 221 222 ip -n $ns link set dev lo up 223 ip -n $ns address add $local_addr dev lo 224 225 ip -n $ns link set dev veth0 up 226 227 ip -n $ns link add name br0 up type bridge vlan_filtering 1 \ 228 vlan_default_pvid 0 mcast_snooping 0 229 230 ip -n $ns link add link br0 name br0.10 up type vlan id 10 231 bridge -n $ns vlan add vid 10 dev br0 self 232 233 ip -n $ns link add link br0 name br0.20 up type vlan id 20 234 bridge -n $ns vlan add vid 20 dev br0 self 235 236 ip -n $ns link add link br0 name br0.4000 up type vlan id 4000 237 bridge -n $ns vlan add vid 4000 dev br0 self 238 239 ip -n $ns link add name vx0 up master br0 type vxlan \ 240 local $local_addr dstport 4789 external vnifilter 241 bridge -n $ns link set dev vx0 vlan_tunnel on 242 243 bridge -n $ns vlan add vid 10 dev vx0 244 bridge -n $ns vlan add vid 10 dev vx0 tunnel_info id 10010 245 bridge -n $ns vni add vni 10010 dev vx0 246 247 bridge -n $ns vlan add vid 20 dev vx0 248 bridge -n $ns vlan add vid 20 dev vx0 tunnel_info id 10020 249 bridge -n $ns vni add vni 10020 dev vx0 250 251 bridge -n $ns vlan add vid 4000 dev vx0 pvid 252 bridge -n $ns vlan add vid 4000 dev vx0 tunnel_info id 14000 253 bridge -n $ns vni add vni 14000 dev vx0 254} 255 256setup_common() 257{ 258 local ns1=$1; shift 259 local ns2=$1; shift 260 local local_addr1=$1; shift 261 local local_addr2=$1; shift 262 263 ip link add name veth0 type veth peer name veth1 264 ip link set dev veth0 netns $ns1 name veth0 265 ip link set dev veth1 netns $ns2 name veth0 266 267 setup_common_ns $ns1 $local_addr1 268 setup_common_ns $ns2 $local_addr2 269} 270 271setup_v4() 272{ 273 setup_ns ns1_v4 ns2_v4 274 setup_common $ns1_v4 $ns2_v4 192.0.2.1 192.0.2.2 275 276 ip -n $ns1_v4 address add 192.0.2.17/28 dev veth0 277 ip -n $ns2_v4 address add 192.0.2.18/28 dev veth0 278 279 ip -n $ns1_v4 route add default via 192.0.2.18 280 ip -n $ns2_v4 route add default via 192.0.2.17 281} 282 283cleanup_v4() 284{ 285 cleanup_ns $ns2_v4 $ns1_v4 286} 287 288setup_v6() 289{ 290 setup_ns ns1_v6 ns2_v6 291 setup_common $ns1_v6 $ns2_v6 2001:db8:1::1 2001:db8:1::2 292 293 ip -n $ns1_v6 address add 2001:db8:2::1/64 dev veth0 nodad 294 ip -n $ns2_v6 address add 2001:db8:2::2/64 dev veth0 nodad 295 296 ip -n $ns1_v6 route add default via 2001:db8:2::2 297 ip -n $ns2_v6 route add default via 2001:db8:2::1 298} 299 300cleanup_v6() 301{ 302 cleanup_ns $ns2_v6 $ns1_v6 303} 304 305setup() 306{ 307 set -e 308 309 setup_v4 310 setup_v6 311 312 sleep 5 313 314 set +e 315} 316 317cleanup() 318{ 319 cleanup_v6 &> /dev/null 320 cleanup_v4 &> /dev/null 321} 322 323################################################################################ 324# Tests - Control path 325 326basic_common() 327{ 328 local ns1=$1; shift 329 local grp_key=$1; shift 330 local vtep_ip=$1; shift 331 332 # Test basic control path operations common to all MDB entry types. 333 334 # Basic add, replace and delete behavior. 335 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key permanent dst $vtep_ip src_vni 10010" 336 log_test $? 0 "MDB entry addition" 337 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 $grp_key src_vni 10010" 338 log_test $? 0 "MDB entry presence after addition" 339 340 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 $grp_key permanent dst $vtep_ip src_vni 10010" 341 log_test $? 0 "MDB entry replacement" 342 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 $grp_key src_vni 10010" 343 log_test $? 0 "MDB entry presence after replacement" 344 345 run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 $grp_key dst $vtep_ip src_vni 10010" 346 log_test $? 0 "MDB entry deletion" 347 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 $grp_key src_vni 10010" 348 log_test $? 254 "MDB entry presence after deletion" 349 350 run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 $grp_key dst $vtep_ip src_vni 10010" 351 log_test $? 255 "Non-existent MDB entry deletion" 352 353 # Default protocol and replacement. 354 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key permanent dst $vtep_ip src_vni 10010" 355 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 $grp_key src_vni 10010 | grep \"proto static\"" 356 log_test $? 0 "MDB entry default protocol" 357 358 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 $grp_key permanent proto 123 dst $vtep_ip src_vni 10010" 359 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 $grp_key src_vni 10010 | grep \"proto 123\"" 360 log_test $? 0 "MDB entry protocol replacement" 361 362 run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 $grp_key dst $vtep_ip src_vni 10010" 363 364 # Default destination port and replacement. 365 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key permanent dst $vtep_ip src_vni 10010" 366 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 $grp_key src_vni 10010 | grep \" dst_port \"" 367 log_test $? 1 "MDB entry default destination port" 368 369 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 $grp_key permanent dst $vtep_ip dst_port 1234 src_vni 10010" 370 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 $grp_key src_vni 10010 | grep \"dst_port 1234\"" 371 log_test $? 0 "MDB entry destination port replacement" 372 373 run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 $grp_key dst $vtep_ip src_vni 10010" 374 375 # Default destination VNI and replacement. 376 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key permanent dst $vtep_ip src_vni 10010" 377 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 $grp_key src_vni 10010 | grep \" vni \"" 378 log_test $? 1 "MDB entry default destination VNI" 379 380 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 $grp_key permanent dst $vtep_ip vni 1234 src_vni 10010" 381 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 $grp_key src_vni 10010 | grep \"vni 1234\"" 382 log_test $? 0 "MDB entry destination VNI replacement" 383 384 run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 $grp_key dst $vtep_ip src_vni 10010" 385 386 # Default outgoing interface and replacement. 387 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key permanent dst $vtep_ip src_vni 10010" 388 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 $grp_key src_vni 10010 | grep \" via \"" 389 log_test $? 1 "MDB entry default outgoing interface" 390 391 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 $grp_key permanent dst $vtep_ip src_vni 10010 via veth0" 392 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 $grp_key src_vni 10010 | grep \"via veth0\"" 393 log_test $? 0 "MDB entry outgoing interface replacement" 394 395 run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 $grp_key dst $vtep_ip src_vni 10010" 396 397 # Common error cases. 398 run_cmd "bridge -n $ns1 mdb add dev vx0 port veth0 $grp_key permanent dst $vtep_ip src_vni 10010" 399 log_test $? 255 "MDB entry with mismatch between device and port" 400 401 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key temp dst $vtep_ip src_vni 10010" 402 log_test $? 255 "MDB entry with temp state" 403 404 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key permanent vid 10 dst $vtep_ip src_vni 10010" 405 log_test $? 255 "MDB entry with VLAN" 406 407 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp 01:02:03:04:05:06 permanent dst $vtep_ip src_vni 10010" 408 log_test $? 255 "MDB entry MAC address" 409 410 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key permanent" 411 log_test $? 255 "MDB entry without extended parameters" 412 413 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key permanent proto 3 dst $vtep_ip src_vni 10010" 414 log_test $? 255 "MDB entry with an invalid protocol" 415 416 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key permanent dst $vtep_ip vni $((2 ** 24)) src_vni 10010" 417 log_test $? 255 "MDB entry with an invalid destination VNI" 418 419 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key permanent dst $vtep_ip src_vni $((2 ** 24))" 420 log_test $? 255 "MDB entry with an invalid source VNI" 421 422 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key permanent src_vni 10010" 423 log_test $? 255 "MDB entry without a remote destination IP" 424 425 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key permanent dst $vtep_ip src_vni 10010" 426 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 $grp_key permanent dst $vtep_ip src_vni 10010" 427 log_test $? 255 "Duplicate MDB entries" 428 run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 $grp_key dst $vtep_ip src_vni 10010" 429} 430 431basic_star_g_ipv4_ipv4() 432{ 433 local ns1=$ns1_v4 434 local grp_key="grp 239.1.1.1" 435 local vtep_ip=198.51.100.100 436 437 echo 438 echo "Control path: Basic (*, G) operations - IPv4 overlay / IPv4 underlay" 439 echo "--------------------------------------------------------------------" 440 441 basic_common $ns1 "$grp_key" $vtep_ip 442} 443 444basic_star_g_ipv6_ipv4() 445{ 446 local ns1=$ns1_v4 447 local grp_key="grp ff0e::1" 448 local vtep_ip=198.51.100.100 449 450 echo 451 echo "Control path: Basic (*, G) operations - IPv6 overlay / IPv4 underlay" 452 echo "--------------------------------------------------------------------" 453 454 basic_common $ns1 "$grp_key" $vtep_ip 455} 456 457basic_star_g_ipv4_ipv6() 458{ 459 local ns1=$ns1_v6 460 local grp_key="grp 239.1.1.1" 461 local vtep_ip=2001:db8:1000::1 462 463 echo 464 echo "Control path: Basic (*, G) operations - IPv4 overlay / IPv6 underlay" 465 echo "--------------------------------------------------------------------" 466 467 basic_common $ns1 "$grp_key" $vtep_ip 468} 469 470basic_star_g_ipv6_ipv6() 471{ 472 local ns1=$ns1_v6 473 local grp_key="grp ff0e::1" 474 local vtep_ip=2001:db8:1000::1 475 476 echo 477 echo "Control path: Basic (*, G) operations - IPv6 overlay / IPv6 underlay" 478 echo "--------------------------------------------------------------------" 479 480 basic_common $ns1 "$grp_key" $vtep_ip 481} 482 483basic_sg_ipv4_ipv4() 484{ 485 local ns1=$ns1_v4 486 local grp_key="grp 239.1.1.1 src 192.0.2.129" 487 local vtep_ip=198.51.100.100 488 489 echo 490 echo "Control path: Basic (S, G) operations - IPv4 overlay / IPv4 underlay" 491 echo "--------------------------------------------------------------------" 492 493 basic_common $ns1 "$grp_key" $vtep_ip 494} 495 496basic_sg_ipv6_ipv4() 497{ 498 local ns1=$ns1_v4 499 local grp_key="grp ff0e::1 src 2001:db8:100::1" 500 local vtep_ip=198.51.100.100 501 502 echo 503 echo "Control path: Basic (S, G) operations - IPv6 overlay / IPv4 underlay" 504 echo "---------------------------------------------------------------------" 505 506 basic_common $ns1 "$grp_key" $vtep_ip 507} 508 509basic_sg_ipv4_ipv6() 510{ 511 local ns1=$ns1_v6 512 local grp_key="grp 239.1.1.1 src 192.0.2.129" 513 local vtep_ip=2001:db8:1000::1 514 515 echo 516 echo "Control path: Basic (S, G) operations - IPv4 overlay / IPv6 underlay" 517 echo "--------------------------------------------------------------------" 518 519 basic_common $ns1 "$grp_key" $vtep_ip 520} 521 522basic_sg_ipv6_ipv6() 523{ 524 local ns1=$ns1_v6 525 local grp_key="grp ff0e::1 src 2001:db8:100::1" 526 local vtep_ip=2001:db8:1000::1 527 528 echo 529 echo "Control path: Basic (S, G) operations - IPv6 overlay / IPv6 underlay" 530 echo "--------------------------------------------------------------------" 531 532 basic_common $ns1 "$grp_key" $vtep_ip 533} 534 535star_g_common() 536{ 537 local ns1=$1; shift 538 local grp=$1; shift 539 local src1=$1; shift 540 local src2=$1; shift 541 local src3=$1; shift 542 local vtep_ip=$1; shift 543 local all_zeros_grp=$1; shift 544 545 # Test control path operations specific to (*, G) entries. 546 547 # Basic add, replace and delete behavior. 548 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $src1 dst $vtep_ip src_vni 10010" 549 log_test $? 0 "(*, G) MDB entry addition with source list" 550 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010" 551 log_test $? 0 "(*, G) MDB entry presence after addition" 552 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010" 553 log_test $? 0 "(S, G) MDB entry presence after addition" 554 555 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $src1 dst $vtep_ip src_vni 10010" 556 log_test $? 0 "(*, G) MDB entry replacement with source list" 557 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010" 558 log_test $? 0 "(*, G) MDB entry presence after replacement" 559 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010" 560 log_test $? 0 "(S, G) MDB entry presence after replacement" 561 562 run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep_ip src_vni 10010" 563 log_test $? 0 "(*, G) MDB entry deletion" 564 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010" 565 log_test $? 254 "(*, G) MDB entry presence after deletion" 566 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010" 567 log_test $? 254 "(S, G) MDB entry presence after deletion" 568 569 # Default filter mode and replacement. 570 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp permanent dst $vtep_ip src_vni 10010" 571 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010 | grep exclude" 572 log_test $? 0 "(*, G) MDB entry default filter mode" 573 574 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode include source_list $src1 dst $vtep_ip src_vni 10010" 575 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010 | grep include" 576 log_test $? 0 "(*, G) MDB entry after replacing filter mode to \"include\"" 577 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010" 578 log_test $? 0 "(S, G) MDB entry after replacing filter mode to \"include\"" 579 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010 | grep blocked" 580 log_test $? 1 "\"blocked\" flag after replacing filter mode to \"include\"" 581 582 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $src1 dst $vtep_ip src_vni 10010" 583 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010 | grep exclude" 584 log_test $? 0 "(*, G) MDB entry after replacing filter mode to \"exclude\"" 585 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grep grp $grp src $src1 src_vni 10010" 586 log_test $? 0 "(S, G) MDB entry after replacing filter mode to \"exclude\"" 587 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010 | grep blocked" 588 log_test $? 0 "\"blocked\" flag after replacing filter mode to \"exclude\"" 589 590 run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep_ip src_vni 10010" 591 592 # Default source list and replacement. 593 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp permanent dst $vtep_ip src_vni 10010" 594 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010 | grep source_list" 595 log_test $? 1 "(*, G) MDB entry default source list" 596 597 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $src1,$src2,$src3 dst $vtep_ip src_vni 10010" 598 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010" 599 log_test $? 0 "(S, G) MDB entry of 1st source after replacing source list" 600 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src2 src_vni 10010" 601 log_test $? 0 "(S, G) MDB entry of 2nd source after replacing source list" 602 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src3 src_vni 10010" 603 log_test $? 0 "(S, G) MDB entry of 3rd source after replacing source list" 604 605 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $src1,$src3 dst $vtep_ip src_vni 10010" 606 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010" 607 log_test $? 0 "(S, G) MDB entry of 1st source after removing source" 608 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src2 src_vni 10010" 609 log_test $? 254 "(S, G) MDB entry of 2nd source after removing source" 610 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src3 src_vni 10010" 611 log_test $? 0 "(S, G) MDB entry of 3rd source after removing source" 612 613 run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep_ip src_vni 10010" 614 615 # Default protocol and replacement. 616 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $src1 dst $vtep_ip src_vni 10010" 617 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010 | grep \"proto static\"" 618 log_test $? 0 "(*, G) MDB entry default protocol" 619 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010 | grep \"proto static\"" 620 log_test $? 0 "(S, G) MDB entry default protocol" 621 622 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $src1 proto bgp dst $vtep_ip src_vni 10010" 623 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010 | grep \"proto bgp\"" 624 log_test $? 0 "(*, G) MDB entry protocol after replacement" 625 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010 | grep \"proto bgp\"" 626 log_test $? 0 "(S, G) MDB entry protocol after replacement" 627 628 run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep_ip src_vni 10010" 629 630 # Default destination port and replacement. 631 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $src1 dst $vtep_ip src_vni 10010" 632 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010 | grep \" dst_port \"" 633 log_test $? 1 "(*, G) MDB entry default destination port" 634 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010 | grep \" dst_port \"" 635 log_test $? 1 "(S, G) MDB entry default destination port" 636 637 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $src1 dst $vtep_ip dst_port 1234 src_vni 10010" 638 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010 | grep \" dst_port 1234 \"" 639 log_test $? 0 "(*, G) MDB entry destination port after replacement" 640 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010 | grep \" dst_port 1234 \"" 641 log_test $? 0 "(S, G) MDB entry destination port after replacement" 642 643 run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep_ip src_vni 10010" 644 645 # Default destination VNI and replacement. 646 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $src1 dst $vtep_ip src_vni 10010" 647 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010 | grep \" vni \"" 648 log_test $? 1 "(*, G) MDB entry default destination VNI" 649 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010 | grep \" vni \"" 650 log_test $? 1 "(S, G) MDB entry default destination VNI" 651 652 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $src1 dst $vtep_ip vni 1234 src_vni 10010" 653 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010 | grep \" vni 1234 \"" 654 log_test $? 0 "(*, G) MDB entry destination VNI after replacement" 655 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010 | grep \" vni 1234 \"" 656 log_test $? 0 "(S, G) MDB entry destination VNI after replacement" 657 658 run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep_ip src_vni 10010" 659 660 # Default outgoing interface and replacement. 661 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $src1 dst $vtep_ip src_vni 10010" 662 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010 | grep \" via \"" 663 log_test $? 1 "(*, G) MDB entry default outgoing interface" 664 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010 | grep \" via \"" 665 log_test $? 1 "(S, G) MDB entry default outgoing interface" 666 667 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $src1 dst $vtep_ip src_vni 10010 via veth0" 668 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src_vni 10010 | grep \" via veth0 \"" 669 log_test $? 0 "(*, G) MDB entry outgoing interface after replacement" 670 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src1 src_vni 10010 | grep \" via veth0 \"" 671 log_test $? 0 "(S, G) MDB entry outgoing interface after replacement" 672 673 run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep_ip src_vni 10010" 674 675 # Error cases. 676 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $all_zeros_grp permanent filter_mode exclude dst $vtep_ip src_vni 10010" 677 log_test $? 255 "All-zeros group with filter mode" 678 679 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $all_zeros_grp permanent source_list $src1 dst $vtep_ip src_vni 10010" 680 log_test $? 255 "All-zeros group with source list" 681 682 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp permanent filter_mode include dst $vtep_ip src_vni 10010" 683 log_test $? 255 "(*, G) INCLUDE with an empty source list" 684 685 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $grp dst $vtep_ip src_vni 10010" 686 log_test $? 255 "Invalid source in source list" 687 688 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $all_zeros_grp dst $vtep_ip src_vni 10010" 689 log_test $? 255 "All-zeros source in source list" 690 691 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp permanent source_list $src1 dst $vtep_ip src_vni 10010" 692 log_test $? 255 "Source list without filter mode" 693} 694 695star_g_ipv4_ipv4() 696{ 697 local ns1=$ns1_v4 698 local grp=239.1.1.1 699 local src1=192.0.2.129 700 local src2=192.0.2.130 701 local src3=192.0.2.131 702 local vtep_ip=198.51.100.100 703 local all_zeros_grp=0.0.0.0 704 705 echo 706 echo "Control path: (*, G) operations - IPv4 overlay / IPv4 underlay" 707 echo "--------------------------------------------------------------" 708 709 star_g_common $ns1 $grp $src1 $src2 $src3 $vtep_ip $all_zeros_grp 710} 711 712star_g_ipv6_ipv4() 713{ 714 local ns1=$ns1_v4 715 local grp=ff0e::1 716 local src1=2001:db8:100::1 717 local src2=2001:db8:100::2 718 local src3=2001:db8:100::3 719 local vtep_ip=198.51.100.100 720 local all_zeros_grp=:: 721 722 echo 723 echo "Control path: (*, G) operations - IPv6 overlay / IPv4 underlay" 724 echo "--------------------------------------------------------------" 725 726 star_g_common $ns1 $grp $src1 $src2 $src3 $vtep_ip $all_zeros_grp 727} 728 729star_g_ipv4_ipv6() 730{ 731 local ns1=$ns1_v6 732 local grp=239.1.1.1 733 local src1=192.0.2.129 734 local src2=192.0.2.130 735 local src3=192.0.2.131 736 local vtep_ip=2001:db8:1000::1 737 local all_zeros_grp=0.0.0.0 738 739 echo 740 echo "Control path: (*, G) operations - IPv4 overlay / IPv6 underlay" 741 echo "--------------------------------------------------------------" 742 743 star_g_common $ns1 $grp $src1 $src2 $src3 $vtep_ip $all_zeros_grp 744} 745 746star_g_ipv6_ipv6() 747{ 748 local ns1=$ns1_v6 749 local grp=ff0e::1 750 local src1=2001:db8:100::1 751 local src2=2001:db8:100::2 752 local src3=2001:db8:100::3 753 local vtep_ip=2001:db8:1000::1 754 local all_zeros_grp=:: 755 756 echo 757 echo "Control path: (*, G) operations - IPv6 overlay / IPv6 underlay" 758 echo "--------------------------------------------------------------" 759 760 star_g_common $ns1 $grp $src1 $src2 $src3 $vtep_ip $all_zeros_grp 761} 762 763sg_common() 764{ 765 local ns1=$1; shift 766 local grp=$1; shift 767 local src=$1; shift 768 local vtep_ip=$1; shift 769 local all_zeros_grp=$1; shift 770 771 # Test control path operations specific to (S, G) entries. 772 773 # Default filter mode. 774 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp src $src permanent dst $vtep_ip src_vni 10010" 775 run_cmd "bridge -n $ns1 -d -s mdb get dev vx0 grp $grp src $src src_vni 10010 | grep include" 776 log_test $? 0 "(S, G) MDB entry default filter mode" 777 778 run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp src $src permanent dst $vtep_ip src_vni 10010" 779 780 # Error cases. 781 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp src $src permanent filter_mode include dst $vtep_ip src_vni 10010" 782 log_test $? 255 "(S, G) with filter mode" 783 784 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp src $src permanent source_list $src dst $vtep_ip src_vni 10010" 785 log_test $? 255 "(S, G) with source list" 786 787 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp src $grp permanent dst $vtep_ip src_vni 10010" 788 log_test $? 255 "(S, G) with an invalid source list" 789 790 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp src $all_zeros_grp permanent dst $vtep_ip src_vni 10010" 791 log_test $? 255 "(S, G) with an all-zeros source" 792 793 run_cmd "bridge -n $ns1 mdb add dev vx0 port vx0 grp $all_zeros_grp src $src permanent dst $vtep_ip src_vni 10010" 794 log_test $? 255 "All-zeros group with source" 795} 796 797sg_ipv4_ipv4() 798{ 799 local ns1=$ns1_v4 800 local grp=239.1.1.1 801 local src=192.0.2.129 802 local vtep_ip=198.51.100.100 803 local all_zeros_grp=0.0.0.0 804 805 echo 806 echo "Control path: (S, G) operations - IPv4 overlay / IPv4 underlay" 807 echo "--------------------------------------------------------------" 808 809 sg_common $ns1 $grp $src $vtep_ip $all_zeros_grp 810} 811 812sg_ipv6_ipv4() 813{ 814 local ns1=$ns1_v4 815 local grp=ff0e::1 816 local src=2001:db8:100::1 817 local vtep_ip=198.51.100.100 818 local all_zeros_grp=:: 819 820 echo 821 echo "Control path: (S, G) operations - IPv6 overlay / IPv4 underlay" 822 echo "--------------------------------------------------------------" 823 824 sg_common $ns1 $grp $src $vtep_ip $all_zeros_grp 825} 826 827sg_ipv4_ipv6() 828{ 829 local ns1=$ns1_v6 830 local grp=239.1.1.1 831 local src=192.0.2.129 832 local vtep_ip=2001:db8:1000::1 833 local all_zeros_grp=0.0.0.0 834 835 echo 836 echo "Control path: (S, G) operations - IPv4 overlay / IPv6 underlay" 837 echo "--------------------------------------------------------------" 838 839 sg_common $ns1 $grp $src $vtep_ip $all_zeros_grp 840} 841 842sg_ipv6_ipv6() 843{ 844 local ns1=$ns1_v6 845 local grp=ff0e::1 846 local src=2001:db8:100::1 847 local vtep_ip=2001:db8:1000::1 848 local all_zeros_grp=:: 849 850 echo 851 echo "Control path: (S, G) operations - IPv6 overlay / IPv6 underlay" 852 echo "--------------------------------------------------------------" 853 854 sg_common $ns1 $grp $src $vtep_ip $all_zeros_grp 855} 856 857ipv4_grps_get() 858{ 859 local max_grps=$1; shift 860 local i 861 862 for i in $(seq 0 $((max_grps - 1))); do 863 echo "239.1.1.$i" 864 done 865} 866 867ipv6_grps_get() 868{ 869 local max_grps=$1; shift 870 local i 871 872 for i in $(seq 0 $((max_grps - 1))); do 873 echo "ff0e::$(printf %x $i)" 874 done 875} 876 877dump_common() 878{ 879 local ns1=$1; shift 880 local local_addr=$1; shift 881 local remote_prefix=$1; shift 882 local fn=$1; shift 883 local max_vxlan_devs=2 884 local max_remotes=64 885 local max_grps=256 886 local num_entries 887 local batch_file 888 local grp 889 local i j 890 891 # The kernel maintains various markers for the MDB dump. Add a test for 892 # large scale MDB dump to make sure that all the configured entries are 893 # dumped and that the markers are used correctly. 894 895 # Create net devices. 896 for i in $(seq 1 $max_vxlan_devs); do 897 ip -n $ns1 link add name vx-test${i} up type vxlan \ 898 local $local_addr dstport 4789 external vnifilter 899 done 900 901 # Create batch file with MDB entries. 902 batch_file=$(mktemp) 903 for i in $(seq 1 $max_vxlan_devs); do 904 for j in $(seq 1 $max_remotes); do 905 for grp in $($fn $max_grps); do 906 echo "mdb add dev vx-test${i} port vx-test${i} grp $grp permanent dst ${remote_prefix}${j}" >> $batch_file 907 done 908 done 909 done 910 911 # Program the batch file and check for expected number of entries. 912 bridge -n $ns1 -b $batch_file 913 for i in $(seq 1 $max_vxlan_devs); do 914 num_entries=$(bridge -n $ns1 mdb show dev vx-test${i} | grep "permanent" | wc -l) 915 [[ $num_entries -eq $((max_grps * max_remotes)) ]] 916 log_test $? 0 "Large scale dump - VXLAN device #$i" 917 done 918 919 rm -rf $batch_file 920} 921 922dump_ipv4_ipv4() 923{ 924 local ns1=$ns1_v4 925 local local_addr=192.0.2.1 926 local remote_prefix=198.51.100. 927 local fn=ipv4_grps_get 928 929 echo 930 echo "Control path: Large scale MDB dump - IPv4 overlay / IPv4 underlay" 931 echo "-----------------------------------------------------------------" 932 933 dump_common $ns1 $local_addr $remote_prefix $fn 934} 935 936dump_ipv6_ipv4() 937{ 938 local ns1=$ns1_v4 939 local local_addr=192.0.2.1 940 local remote_prefix=198.51.100. 941 local fn=ipv6_grps_get 942 943 echo 944 echo "Control path: Large scale MDB dump - IPv6 overlay / IPv4 underlay" 945 echo "-----------------------------------------------------------------" 946 947 dump_common $ns1 $local_addr $remote_prefix $fn 948} 949 950dump_ipv4_ipv6() 951{ 952 local ns1=$ns1_v6 953 local local_addr=2001:db8:1::1 954 local remote_prefix=2001:db8:1000:: 955 local fn=ipv4_grps_get 956 957 echo 958 echo "Control path: Large scale MDB dump - IPv4 overlay / IPv6 underlay" 959 echo "-----------------------------------------------------------------" 960 961 dump_common $ns1 $local_addr $remote_prefix $fn 962} 963 964dump_ipv6_ipv6() 965{ 966 local ns1=$ns1_v6 967 local local_addr=2001:db8:1::1 968 local remote_prefix=2001:db8:1000:: 969 local fn=ipv6_grps_get 970 971 echo 972 echo "Control path: Large scale MDB dump - IPv6 overlay / IPv6 underlay" 973 echo "-----------------------------------------------------------------" 974 975 dump_common $ns1 $local_addr $remote_prefix $fn 976} 977 978flush() 979{ 980 local num_entries 981 982 echo 983 echo "Control path: Flush" 984 echo "-------------------" 985 986 # Add entries with different attributes and check that they are all 987 # flushed when the flush command is given with no parameters. 988 989 # Different source VNI. 990 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 198.51.100.1 src_vni 10010" 991 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.2 permanent dst 198.51.100.1 src_vni 10011" 992 993 # Different routing protocol. 994 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.3 permanent proto bgp dst 198.51.100.1 src_vni 10010" 995 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.4 permanent proto zebra dst 198.51.100.1 src_vni 10010" 996 997 # Different destination IP. 998 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.5 permanent dst 198.51.100.1 src_vni 10010" 999 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.6 permanent dst 198.51.100.2 src_vni 10010" 1000 1001 # Different destination port. 1002 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.7 permanent dst 198.51.100.1 dst_port 11111 src_vni 10010" 1003 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.8 permanent dst 198.51.100.1 dst_port 22222 src_vni 10010" 1004 1005 # Different VNI. 1006 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.9 permanent dst 198.51.100.1 vni 10010 src_vni 10010" 1007 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.10 permanent dst 198.51.100.1 vni 10020 src_vni 10010" 1008 1009 run_cmd "bridge -n $ns1_v4 mdb flush dev vx0" 1010 num_entries=$(bridge -n $ns1_v4 mdb show dev vx0 | wc -l) 1011 [[ $num_entries -eq 0 ]] 1012 log_test $? 0 "Flush all" 1013 1014 # Check that entries are flushed when port is specified as the VXLAN 1015 # device and that an error is returned when port is specified as a 1016 # different net device. 1017 1018 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 198.51.100.1 src_vni 10010" 1019 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 198.51.100.2 src_vni 10010" 1020 1021 run_cmd "bridge -n $ns1_v4 mdb flush dev vx0 port vx0" 1022 run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010" 1023 log_test $? 254 "Flush by port - matching" 1024 1025 run_cmd "bridge -n $ns1_v4 mdb flush dev vx0 port veth0" 1026 log_test $? 255 "Flush by port - non-matching" 1027 1028 # Check that when flushing by source VNI only entries programmed with 1029 # the specified source VNI are flushed and the rest are not. 1030 1031 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 198.51.100.1 src_vni 10010" 1032 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 198.51.100.2 src_vni 10010" 1033 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 198.51.100.1 src_vni 10011" 1034 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 198.51.100.2 src_vni 10011" 1035 1036 run_cmd "bridge -n $ns1_v4 mdb flush dev vx0 src_vni 10010" 1037 1038 run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010" 1039 log_test $? 254 "Flush by source VNI - matching" 1040 run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10011" 1041 log_test $? 0 "Flush by source VNI - non-matching" 1042 1043 run_cmd "bridge -n $ns1_v4 mdb flush dev vx0" 1044 1045 # Check that all entries are flushed when "permanent" is specified and 1046 # that an error is returned when "nopermanent" is specified. 1047 1048 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 198.51.100.1 src_vni 10010" 1049 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 198.51.100.2 src_vni 10010" 1050 1051 run_cmd "bridge -n $ns1_v4 mdb flush dev vx0 permanent" 1052 run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010" 1053 log_test $? 254 "Flush by \"permanent\" state" 1054 1055 run_cmd "bridge -n $ns1_v4 mdb flush dev vx0 nopermanent" 1056 log_test $? 255 "Flush by \"nopermanent\" state" 1057 1058 # Check that when flushing by routing protocol only entries programmed 1059 # with the specified routing protocol are flushed and the rest are not. 1060 1061 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent proto bgp dst 198.51.100.1 src_vni 10010" 1062 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent proto zebra dst 198.51.100.2 src_vni 10010" 1063 1064 run_cmd "bridge -n $ns1_v4 mdb flush dev vx0 proto bgp" 1065 1066 run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep \"proto bgp\"" 1067 log_test $? 1 "Flush by routing protocol - matching" 1068 run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep \"proto zebra\"" 1069 log_test $? 0 "Flush by routing protocol - non-matching" 1070 1071 run_cmd "bridge -n $ns1_v4 mdb flush dev vx0" 1072 1073 # Check that when flushing by destination IP only entries programmed 1074 # with the specified destination IP are flushed and the rest are not. 1075 1076 # IPv4. 1077 1078 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 198.51.100.1 src_vni 10010" 1079 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 198.51.100.2 src_vni 10010" 1080 1081 run_cmd "bridge -n $ns1_v4 mdb flush dev vx0 dst 198.51.100.2" 1082 1083 run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep 198.51.100.2" 1084 log_test $? 1 "Flush by IPv4 destination IP - matching" 1085 run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep 198.51.100.1" 1086 log_test $? 0 "Flush by IPv4 destination IP - non-matching" 1087 1088 run_cmd "bridge -n $ns1_v4 mdb flush dev vx0" 1089 1090 # IPv6. 1091 1092 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 2001:db8:1000::1 src_vni 10010" 1093 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 2001:db8:1000::2 src_vni 10010" 1094 1095 run_cmd "bridge -n $ns1_v4 mdb flush dev vx0 dst 2001:db8:1000::2" 1096 1097 run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep 2001:db8:1000::2" 1098 log_test $? 1 "Flush by IPv6 destination IP - matching" 1099 run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep 2001:db8:1000::1" 1100 log_test $? 0 "Flush by IPv6 destination IP - non-matching" 1101 1102 run_cmd "bridge -n $ns1_v4 mdb flush dev vx0" 1103 1104 # Check that when flushing by UDP destination port only entries 1105 # programmed with the specified port are flushed and the rest are not. 1106 1107 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst_port 11111 dst 198.51.100.1 src_vni 10010" 1108 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst_port 22222 dst 198.51.100.2 src_vni 10010" 1109 1110 run_cmd "bridge -n $ns1_v4 mdb flush dev vx0 dst_port 11111" 1111 1112 run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep \"dst_port 11111\"" 1113 log_test $? 1 "Flush by UDP destination port - matching" 1114 run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep \"dst_port 22222\"" 1115 log_test $? 0 "Flush by UDP destination port - non-matching" 1116 1117 run_cmd "bridge -n $ns1_v4 mdb flush dev vx0" 1118 1119 # When not specifying a UDP destination port for an entry, traffic is 1120 # encapsulated with the device's UDP destination port. Check that when 1121 # flushing by the device's UDP destination port only entries programmed 1122 # with this port are flushed and the rest are not. 1123 1124 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 198.51.100.1 src_vni 10010" 1125 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst_port 22222 dst 198.51.100.2 src_vni 10010" 1126 1127 run_cmd "bridge -n $ns1_v4 mdb flush dev vx0 dst_port 4789" 1128 1129 run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep 198.51.100.1" 1130 log_test $? 1 "Flush by device's UDP destination port - matching" 1131 run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep 198.51.100.2" 1132 log_test $? 0 "Flush by device's UDP destination port - non-matching" 1133 1134 run_cmd "bridge -n $ns1_v4 mdb flush dev vx0" 1135 1136 # Check that when flushing by destination VNI only entries programmed 1137 # with the specified destination VNI are flushed and the rest are not. 1138 1139 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent vni 20010 dst 198.51.100.1 src_vni 10010" 1140 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent vni 20011 dst 198.51.100.2 src_vni 10010" 1141 1142 run_cmd "bridge -n $ns1_v4 mdb flush dev vx0 vni 20010" 1143 1144 run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep \" vni 20010\"" 1145 log_test $? 1 "Flush by destination VNI - matching" 1146 run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep \" vni 20011\"" 1147 log_test $? 0 "Flush by destination VNI - non-matching" 1148 1149 run_cmd "bridge -n $ns1_v4 mdb flush dev vx0" 1150 1151 # When not specifying a destination VNI for an entry, traffic is 1152 # encapsulated with the source VNI. Check that when flushing by a 1153 # destination VNI that is equal to the source VNI only such entries are 1154 # flushed and the rest are not. 1155 1156 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent dst 198.51.100.1 src_vni 10010" 1157 run_cmd "bridge -n $ns1_v4 mdb add dev vx0 port vx0 grp 239.1.1.1 permanent vni 20010 dst 198.51.100.2 src_vni 10010" 1158 1159 run_cmd "bridge -n $ns1_v4 mdb flush dev vx0 vni 10010" 1160 1161 run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep 198.51.100.1" 1162 log_test $? 1 "Flush by destination VNI equal to source VNI - matching" 1163 run_cmd "bridge -n $ns1_v4 -d -s mdb get dev vx0 grp 239.1.1.1 src_vni 10010 | grep 198.51.100.2" 1164 log_test $? 0 "Flush by destination VNI equal to source VNI - non-matching" 1165 1166 run_cmd "bridge -n $ns1_v4 mdb flush dev vx0" 1167 1168 # Test that an error is returned when trying to flush using VLAN ID. 1169 1170 run_cmd "bridge -n $ns1_v4 mdb flush dev vx0 vid 10" 1171 log_test $? 255 "Flush by VLAN ID" 1172} 1173 1174################################################################################ 1175# Tests - Data path 1176 1177encap_params_common() 1178{ 1179 local ns1=$1; shift 1180 local ns2=$1; shift 1181 local vtep1_ip=$1; shift 1182 local vtep2_ip=$1; shift 1183 local plen=$1; shift 1184 local enc_ethtype=$1; shift 1185 local grp=$1; shift 1186 local grp_dmac=$1; shift 1187 local src=$1; shift 1188 local mz=$1; shift 1189 1190 # Test that packets forwarded by the VXLAN MDB are encapsulated with 1191 # the correct parameters. Transmit packets from the first namespace and 1192 # check that they hit the corresponding filters on the ingress of the 1193 # second namespace. 1194 1195 run_cmd "tc -n $ns2 qdisc replace dev veth0 clsact" 1196 run_cmd "tc -n $ns2 qdisc replace dev vx0 clsact" 1197 run_cmd "ip -n $ns2 address replace $vtep1_ip/$plen dev lo" 1198 run_cmd "ip -n $ns2 address replace $vtep2_ip/$plen dev lo" 1199 1200 # Check destination IP. 1201 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent dst $vtep1_ip src_vni 10010" 1202 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent dst $vtep2_ip src_vni 10020" 1203 1204 run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 101 proto all flower enc_dst_ip $vtep1_ip action pass" 1205 run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 1206 tc_check_packets "$ns2" "dev vx0 ingress" 101 1 1207 log_test $? 0 "Destination IP - match" 1208 1209 run_cmd "ip netns exec $ns1 $mz br0.20 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 1210 tc_check_packets "$ns2" "dev vx0 ingress" 101 1 1211 log_test $? 0 "Destination IP - no match" 1212 1213 run_cmd "tc -n $ns2 filter del dev vx0 ingress pref 1 handle 101 flower" 1214 run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep2_ip src_vni 10020" 1215 run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep1_ip src_vni 10010" 1216 1217 # Check destination port. 1218 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent dst $vtep1_ip src_vni 10010" 1219 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent dst $vtep1_ip dst_port 1111 src_vni 10020" 1220 1221 run_cmd "tc -n $ns2 filter replace dev veth0 ingress pref 1 handle 101 proto $enc_ethtype flower ip_proto udp dst_port 4789 action pass" 1222 run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 1223 tc_check_packets "$ns2" "dev veth0 ingress" 101 1 1224 log_test $? 0 "Default destination port - match" 1225 1226 run_cmd "ip netns exec $ns1 $mz br0.20 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 1227 tc_check_packets "$ns2" "dev veth0 ingress" 101 1 1228 log_test $? 0 "Default destination port - no match" 1229 1230 run_cmd "tc -n $ns2 filter replace dev veth0 ingress pref 1 handle 101 proto $enc_ethtype flower ip_proto udp dst_port 1111 action pass" 1231 run_cmd "ip netns exec $ns1 $mz br0.20 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 1232 tc_check_packets "$ns2" "dev veth0 ingress" 101 1 1233 log_test $? 0 "Non-default destination port - match" 1234 1235 run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 1236 tc_check_packets "$ns2" "dev veth0 ingress" 101 1 1237 log_test $? 0 "Non-default destination port - no match" 1238 1239 run_cmd "tc -n $ns2 filter del dev veth0 ingress pref 1 handle 101 flower" 1240 run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep1_ip src_vni 10020" 1241 run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep1_ip src_vni 10010" 1242 1243 # Check default VNI. 1244 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent dst $vtep1_ip src_vni 10010" 1245 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent dst $vtep1_ip src_vni 10020" 1246 1247 run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 101 proto all flower enc_key_id 10010 action pass" 1248 run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 1249 tc_check_packets "$ns2" "dev vx0 ingress" 101 1 1250 log_test $? 0 "Default destination VNI - match" 1251 1252 run_cmd "ip netns exec $ns1 $mz br0.20 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 1253 tc_check_packets "$ns2" "dev vx0 ingress" 101 1 1254 log_test $? 0 "Default destination VNI - no match" 1255 1256 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent dst $vtep1_ip vni 10020 src_vni 10010" 1257 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent dst $vtep1_ip vni 10010 src_vni 10020" 1258 1259 run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 101 proto all flower enc_key_id 10020 action pass" 1260 run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 1261 tc_check_packets "$ns2" "dev vx0 ingress" 101 1 1262 log_test $? 0 "Non-default destination VNI - match" 1263 1264 run_cmd "ip netns exec $ns1 $mz br0.20 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 1265 tc_check_packets "$ns2" "dev vx0 ingress" 101 1 1266 log_test $? 0 "Non-default destination VNI - no match" 1267 1268 run_cmd "tc -n $ns2 filter del dev vx0 ingress pref 1 handle 101 flower" 1269 run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep1_ip src_vni 10020" 1270 run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep1_ip src_vni 10010" 1271} 1272 1273encap_params_ipv4_ipv4() 1274{ 1275 local ns1=$ns1_v4 1276 local ns2=$ns2_v4 1277 local vtep1_ip=198.51.100.100 1278 local vtep2_ip=198.51.100.200 1279 local plen=32 1280 local enc_ethtype="ip" 1281 local grp=239.1.1.1 1282 local grp_dmac=01:00:5e:01:01:01 1283 local src=192.0.2.129 1284 1285 echo 1286 echo "Data path: Encapsulation parameters - IPv4 overlay / IPv4 underlay" 1287 echo "------------------------------------------------------------------" 1288 1289 encap_params_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $enc_ethtype \ 1290 $grp $grp_dmac $src "mausezahn" 1291} 1292 1293encap_params_ipv6_ipv4() 1294{ 1295 local ns1=$ns1_v4 1296 local ns2=$ns2_v4 1297 local vtep1_ip=198.51.100.100 1298 local vtep2_ip=198.51.100.200 1299 local plen=32 1300 local enc_ethtype="ip" 1301 local grp=ff0e::1 1302 local grp_dmac=33:33:00:00:00:01 1303 local src=2001:db8:100::1 1304 1305 echo 1306 echo "Data path: Encapsulation parameters - IPv6 overlay / IPv4 underlay" 1307 echo "------------------------------------------------------------------" 1308 1309 encap_params_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $enc_ethtype \ 1310 $grp $grp_dmac $src "mausezahn -6" 1311} 1312 1313encap_params_ipv4_ipv6() 1314{ 1315 local ns1=$ns1_v6 1316 local ns2=$ns2_v6 1317 local vtep1_ip=2001:db8:1000::1 1318 local vtep2_ip=2001:db8:2000::1 1319 local plen=128 1320 local enc_ethtype="ipv6" 1321 local grp=239.1.1.1 1322 local grp_dmac=01:00:5e:01:01:01 1323 local src=192.0.2.129 1324 1325 echo 1326 echo "Data path: Encapsulation parameters - IPv4 overlay / IPv6 underlay" 1327 echo "------------------------------------------------------------------" 1328 1329 encap_params_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $enc_ethtype \ 1330 $grp $grp_dmac $src "mausezahn" 1331} 1332 1333encap_params_ipv6_ipv6() 1334{ 1335 local ns1=$ns1_v6 1336 local ns2=$ns2_v6 1337 local vtep1_ip=2001:db8:1000::1 1338 local vtep2_ip=2001:db8:2000::1 1339 local plen=128 1340 local enc_ethtype="ipv6" 1341 local grp=ff0e::1 1342 local grp_dmac=33:33:00:00:00:01 1343 local src=2001:db8:100::1 1344 1345 echo 1346 echo "Data path: Encapsulation parameters - IPv6 overlay / IPv6 underlay" 1347 echo "------------------------------------------------------------------" 1348 1349 encap_params_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $enc_ethtype \ 1350 $grp $grp_dmac $src "mausezahn -6" 1351} 1352 1353starg_exclude_ir_common() 1354{ 1355 local ns1=$1; shift 1356 local ns2=$1; shift 1357 local vtep1_ip=$1; shift 1358 local vtep2_ip=$1; shift 1359 local plen=$1; shift 1360 local grp=$1; shift 1361 local grp_dmac=$1; shift 1362 local valid_src=$1; shift 1363 local invalid_src=$1; shift 1364 local mz=$1; shift 1365 1366 # Install a (*, G) EXCLUDE MDB entry with one source and two remote 1367 # VTEPs. Make sure that the source in the source list is not forwarded 1368 # and that a source not in the list is forwarded. Remove one of the 1369 # VTEPs from the entry and make sure that packets are only forwarded to 1370 # the remaining VTEP. 1371 1372 run_cmd "tc -n $ns2 qdisc replace dev vx0 clsact" 1373 run_cmd "ip -n $ns2 address replace $vtep1_ip/$plen dev lo" 1374 run_cmd "ip -n $ns2 address replace $vtep2_ip/$plen dev lo" 1375 1376 run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 101 proto all flower enc_dst_ip $vtep1_ip action pass" 1377 run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 102 proto all flower enc_dst_ip $vtep2_ip action pass" 1378 1379 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $invalid_src dst $vtep1_ip src_vni 10010" 1380 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $invalid_src dst $vtep2_ip src_vni 10010" 1381 1382 # Check that invalid source is not forwarded to any VTEP. 1383 run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $invalid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 1384 tc_check_packets "$ns2" "dev vx0 ingress" 101 0 1385 log_test $? 0 "Block excluded source - first VTEP" 1386 tc_check_packets "$ns2" "dev vx0 ingress" 102 0 1387 log_test $? 0 "Block excluded source - second VTEP" 1388 1389 # Check that valid source is forwarded to both VTEPs. 1390 run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $valid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 1391 tc_check_packets "$ns2" "dev vx0 ingress" 101 1 1392 log_test $? 0 "Forward valid source - first VTEP" 1393 tc_check_packets "$ns2" "dev vx0 ingress" 102 1 1394 log_test $? 0 "Forward valid source - second VTEP" 1395 1396 # Remove second VTEP. 1397 run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep2_ip src_vni 10010" 1398 1399 # Check that invalid source is not forwarded to any VTEP. 1400 run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $invalid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 1401 tc_check_packets "$ns2" "dev vx0 ingress" 101 1 1402 log_test $? 0 "Block excluded source after removal - first VTEP" 1403 tc_check_packets "$ns2" "dev vx0 ingress" 102 1 1404 log_test $? 0 "Block excluded source after removal - second VTEP" 1405 1406 # Check that valid source is forwarded to the remaining VTEP. 1407 run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $valid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 1408 tc_check_packets "$ns2" "dev vx0 ingress" 101 2 1409 log_test $? 0 "Forward valid source after removal - first VTEP" 1410 tc_check_packets "$ns2" "dev vx0 ingress" 102 1 1411 log_test $? 0 "Forward valid source after removal - second VTEP" 1412} 1413 1414starg_exclude_ir_ipv4_ipv4() 1415{ 1416 local ns1=$ns1_v4 1417 local ns2=$ns2_v4 1418 local vtep1_ip=198.51.100.100 1419 local vtep2_ip=198.51.100.200 1420 local plen=32 1421 local grp=239.1.1.1 1422 local grp_dmac=01:00:5e:01:01:01 1423 local valid_src=192.0.2.129 1424 local invalid_src=192.0.2.145 1425 1426 echo 1427 echo "Data path: (*, G) EXCLUDE - IR - IPv4 overlay / IPv4 underlay" 1428 echo "-------------------------------------------------------------" 1429 1430 starg_exclude_ir_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $grp \ 1431 $grp_dmac $valid_src $invalid_src "mausezahn" 1432} 1433 1434starg_exclude_ir_ipv6_ipv4() 1435{ 1436 local ns1=$ns1_v4 1437 local ns2=$ns2_v4 1438 local vtep1_ip=198.51.100.100 1439 local vtep2_ip=198.51.100.200 1440 local plen=32 1441 local grp=ff0e::1 1442 local grp_dmac=33:33:00:00:00:01 1443 local valid_src=2001:db8:100::1 1444 local invalid_src=2001:db8:200::1 1445 1446 echo 1447 echo "Data path: (*, G) EXCLUDE - IR - IPv6 overlay / IPv4 underlay" 1448 echo "-------------------------------------------------------------" 1449 1450 starg_exclude_ir_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $grp \ 1451 $grp_dmac $valid_src $invalid_src "mausezahn -6" 1452} 1453 1454starg_exclude_ir_ipv4_ipv6() 1455{ 1456 local ns1=$ns1_v6 1457 local ns2=$ns2_v6 1458 local vtep1_ip=2001:db8:1000::1 1459 local vtep2_ip=2001:db8:2000::1 1460 local plen=128 1461 local grp=239.1.1.1 1462 local grp_dmac=01:00:5e:01:01:01 1463 local valid_src=192.0.2.129 1464 local invalid_src=192.0.2.145 1465 1466 echo 1467 echo "Data path: (*, G) EXCLUDE - IR - IPv4 overlay / IPv6 underlay" 1468 echo "-------------------------------------------------------------" 1469 1470 starg_exclude_ir_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $grp \ 1471 $grp_dmac $valid_src $invalid_src "mausezahn" 1472} 1473 1474starg_exclude_ir_ipv6_ipv6() 1475{ 1476 local ns1=$ns1_v6 1477 local ns2=$ns2_v6 1478 local vtep1_ip=2001:db8:1000::1 1479 local vtep2_ip=2001:db8:2000::1 1480 local plen=128 1481 local grp=ff0e::1 1482 local grp_dmac=33:33:00:00:00:01 1483 local valid_src=2001:db8:100::1 1484 local invalid_src=2001:db8:200::1 1485 1486 echo 1487 echo "Data path: (*, G) EXCLUDE - IR - IPv6 overlay / IPv6 underlay" 1488 echo "-------------------------------------------------------------" 1489 1490 starg_exclude_ir_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $grp \ 1491 $grp_dmac $valid_src $invalid_src "mausezahn -6" 1492} 1493 1494starg_include_ir_common() 1495{ 1496 local ns1=$1; shift 1497 local ns2=$1; shift 1498 local vtep1_ip=$1; shift 1499 local vtep2_ip=$1; shift 1500 local plen=$1; shift 1501 local grp=$1; shift 1502 local grp_dmac=$1; shift 1503 local valid_src=$1; shift 1504 local invalid_src=$1; shift 1505 local mz=$1; shift 1506 1507 # Install a (*, G) INCLUDE MDB entry with one source and two remote 1508 # VTEPs. Make sure that the source in the source list is forwarded and 1509 # that a source not in the list is not forwarded. Remove one of the 1510 # VTEPs from the entry and make sure that packets are only forwarded to 1511 # the remaining VTEP. 1512 1513 run_cmd "tc -n $ns2 qdisc replace dev vx0 clsact" 1514 run_cmd "ip -n $ns2 address replace $vtep1_ip/$plen dev lo" 1515 run_cmd "ip -n $ns2 address replace $vtep2_ip/$plen dev lo" 1516 1517 run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 101 proto all flower enc_dst_ip $vtep1_ip action pass" 1518 run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 102 proto all flower enc_dst_ip $vtep2_ip action pass" 1519 1520 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode include source_list $valid_src dst $vtep1_ip src_vni 10010" 1521 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode include source_list $valid_src dst $vtep2_ip src_vni 10010" 1522 1523 # Check that invalid source is not forwarded to any VTEP. 1524 run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $invalid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 1525 tc_check_packets "$ns2" "dev vx0 ingress" 101 0 1526 log_test $? 0 "Block excluded source - first VTEP" 1527 tc_check_packets "$ns2" "dev vx0 ingress" 102 0 1528 log_test $? 0 "Block excluded source - second VTEP" 1529 1530 # Check that valid source is forwarded to both VTEPs. 1531 run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $valid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 1532 tc_check_packets "$ns2" "dev vx0 ingress" 101 1 1533 log_test $? 0 "Forward valid source - first VTEP" 1534 tc_check_packets "$ns2" "dev vx0 ingress" 102 1 1535 log_test $? 0 "Forward valid source - second VTEP" 1536 1537 # Remove second VTEP. 1538 run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep2_ip src_vni 10010" 1539 1540 # Check that invalid source is not forwarded to any VTEP. 1541 run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $invalid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 1542 tc_check_packets "$ns2" "dev vx0 ingress" 101 1 1543 log_test $? 0 "Block excluded source after removal - first VTEP" 1544 tc_check_packets "$ns2" "dev vx0 ingress" 102 1 1545 log_test $? 0 "Block excluded source after removal - second VTEP" 1546 1547 # Check that valid source is forwarded to the remaining VTEP. 1548 run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $valid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 1549 tc_check_packets "$ns2" "dev vx0 ingress" 101 2 1550 log_test $? 0 "Forward valid source after removal - first VTEP" 1551 tc_check_packets "$ns2" "dev vx0 ingress" 102 1 1552 log_test $? 0 "Forward valid source after removal - second VTEP" 1553} 1554 1555starg_include_ir_ipv4_ipv4() 1556{ 1557 local ns1=$ns1_v4 1558 local ns2=$ns2_v4 1559 local vtep1_ip=198.51.100.100 1560 local vtep2_ip=198.51.100.200 1561 local plen=32 1562 local grp=239.1.1.1 1563 local grp_dmac=01:00:5e:01:01:01 1564 local valid_src=192.0.2.129 1565 local invalid_src=192.0.2.145 1566 1567 echo 1568 echo "Data path: (*, G) INCLUDE - IR - IPv4 overlay / IPv4 underlay" 1569 echo "-------------------------------------------------------------" 1570 1571 starg_include_ir_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $grp \ 1572 $grp_dmac $valid_src $invalid_src "mausezahn" 1573} 1574 1575starg_include_ir_ipv6_ipv4() 1576{ 1577 local ns1=$ns1_v4 1578 local ns2=$ns2_v4 1579 local vtep1_ip=198.51.100.100 1580 local vtep2_ip=198.51.100.200 1581 local plen=32 1582 local grp=ff0e::1 1583 local grp_dmac=33:33:00:00:00:01 1584 local valid_src=2001:db8:100::1 1585 local invalid_src=2001:db8:200::1 1586 1587 echo 1588 echo "Data path: (*, G) INCLUDE - IR - IPv6 overlay / IPv4 underlay" 1589 echo "-------------------------------------------------------------" 1590 1591 starg_include_ir_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $grp \ 1592 $grp_dmac $valid_src $invalid_src "mausezahn -6" 1593} 1594 1595starg_include_ir_ipv4_ipv6() 1596{ 1597 local ns1=$ns1_v6 1598 local ns2=$ns2_v6 1599 local vtep1_ip=2001:db8:1000::1 1600 local vtep2_ip=2001:db8:2000::1 1601 local plen=128 1602 local grp=239.1.1.1 1603 local grp_dmac=01:00:5e:01:01:01 1604 local valid_src=192.0.2.129 1605 local invalid_src=192.0.2.145 1606 1607 echo 1608 echo "Data path: (*, G) INCLUDE - IR - IPv4 overlay / IPv6 underlay" 1609 echo "-------------------------------------------------------------" 1610 1611 starg_include_ir_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $grp \ 1612 $grp_dmac $valid_src $invalid_src "mausezahn" 1613} 1614 1615starg_include_ir_ipv6_ipv6() 1616{ 1617 local ns1=$ns1_v6 1618 local ns2=$ns2_v6 1619 local vtep1_ip=2001:db8:1000::1 1620 local vtep2_ip=2001:db8:2000::1 1621 local plen=128 1622 local grp=ff0e::1 1623 local grp_dmac=33:33:00:00:00:01 1624 local valid_src=2001:db8:100::1 1625 local invalid_src=2001:db8:200::1 1626 1627 echo 1628 echo "Data path: (*, G) INCLUDE - IR - IPv6 overlay / IPv6 underlay" 1629 echo "-------------------------------------------------------------" 1630 1631 starg_include_ir_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $grp \ 1632 $grp_dmac $valid_src $invalid_src "mausezahn -6" 1633} 1634 1635starg_exclude_p2mp_common() 1636{ 1637 local ns1=$1; shift 1638 local ns2=$1; shift 1639 local mcast_grp=$1; shift 1640 local plen=$1; shift 1641 local grp=$1; shift 1642 local grp_dmac=$1; shift 1643 local valid_src=$1; shift 1644 local invalid_src=$1; shift 1645 local mz=$1; shift 1646 1647 # Install a (*, G) EXCLUDE MDB entry with one source and one multicast 1648 # group to which packets are sent. Make sure that the source in the 1649 # source list is not forwarded and that a source not in the list is 1650 # forwarded. 1651 1652 run_cmd "tc -n $ns2 qdisc replace dev vx0 clsact" 1653 run_cmd "ip -n $ns2 address replace $mcast_grp/$plen dev veth0 autojoin" 1654 1655 run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 101 proto all flower enc_dst_ip $mcast_grp action pass" 1656 1657 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode exclude source_list $invalid_src dst $mcast_grp src_vni 10010 via veth0" 1658 1659 # Check that invalid source is not forwarded. 1660 run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $invalid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 1661 tc_check_packets "$ns2" "dev vx0 ingress" 101 0 1662 log_test $? 0 "Block excluded source" 1663 1664 # Check that valid source is forwarded. 1665 run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $valid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 1666 tc_check_packets "$ns2" "dev vx0 ingress" 101 1 1667 log_test $? 0 "Forward valid source" 1668 1669 # Remove the VTEP from the multicast group. 1670 run_cmd "ip -n $ns2 address del $mcast_grp/$plen dev veth0" 1671 1672 # Check that valid source is not received anymore. 1673 run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $valid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 1674 tc_check_packets "$ns2" "dev vx0 ingress" 101 1 1675 log_test $? 0 "Receive of valid source after removal from group" 1676} 1677 1678starg_exclude_p2mp_ipv4_ipv4() 1679{ 1680 local ns1=$ns1_v4 1681 local ns2=$ns2_v4 1682 local mcast_grp=238.1.1.1 1683 local plen=32 1684 local grp=239.1.1.1 1685 local grp_dmac=01:00:5e:01:01:01 1686 local valid_src=192.0.2.129 1687 local invalid_src=192.0.2.145 1688 1689 echo 1690 echo "Data path: (*, G) EXCLUDE - P2MP - IPv4 overlay / IPv4 underlay" 1691 echo "---------------------------------------------------------------" 1692 1693 starg_exclude_p2mp_common $ns1 $ns2 $mcast_grp $plen $grp $grp_dmac \ 1694 $valid_src $invalid_src "mausezahn" 1695} 1696 1697starg_exclude_p2mp_ipv6_ipv4() 1698{ 1699 local ns1=$ns1_v4 1700 local ns2=$ns2_v4 1701 local mcast_grp=238.1.1.1 1702 local plen=32 1703 local grp=ff0e::1 1704 local grp_dmac=33:33:00:00:00:01 1705 local valid_src=2001:db8:100::1 1706 local invalid_src=2001:db8:200::1 1707 1708 echo 1709 echo "Data path: (*, G) EXCLUDE - P2MP - IPv6 overlay / IPv4 underlay" 1710 echo "---------------------------------------------------------------" 1711 1712 starg_exclude_p2mp_common $ns1 $ns2 $mcast_grp $plen $grp $grp_dmac \ 1713 $valid_src $invalid_src "mausezahn -6" 1714} 1715 1716starg_exclude_p2mp_ipv4_ipv6() 1717{ 1718 local ns1=$ns1_v6 1719 local ns2=$ns2_v6 1720 local mcast_grp=ff0e::2 1721 local plen=128 1722 local grp=239.1.1.1 1723 local grp_dmac=01:00:5e:01:01:01 1724 local valid_src=192.0.2.129 1725 local invalid_src=192.0.2.145 1726 1727 echo 1728 echo "Data path: (*, G) EXCLUDE - P2MP - IPv4 overlay / IPv6 underlay" 1729 echo "---------------------------------------------------------------" 1730 1731 starg_exclude_p2mp_common $ns1 $ns2 $mcast_grp $plen $grp $grp_dmac \ 1732 $valid_src $invalid_src "mausezahn" 1733} 1734 1735starg_exclude_p2mp_ipv6_ipv6() 1736{ 1737 local ns1=$ns1_v6 1738 local ns2=$ns2_v6 1739 local mcast_grp=ff0e::2 1740 local plen=128 1741 local grp=ff0e::1 1742 local grp_dmac=33:33:00:00:00:01 1743 local valid_src=2001:db8:100::1 1744 local invalid_src=2001:db8:200::1 1745 1746 echo 1747 echo "Data path: (*, G) EXCLUDE - P2MP - IPv6 overlay / IPv6 underlay" 1748 echo "---------------------------------------------------------------" 1749 1750 starg_exclude_p2mp_common $ns1 $ns2 $mcast_grp $plen $grp $grp_dmac \ 1751 $valid_src $invalid_src "mausezahn -6" 1752} 1753 1754starg_include_p2mp_common() 1755{ 1756 local ns1=$1; shift 1757 local ns2=$1; shift 1758 local mcast_grp=$1; shift 1759 local plen=$1; shift 1760 local grp=$1; shift 1761 local grp_dmac=$1; shift 1762 local valid_src=$1; shift 1763 local invalid_src=$1; shift 1764 local mz=$1; shift 1765 1766 # Install a (*, G) INCLUDE MDB entry with one source and one multicast 1767 # group to which packets are sent. Make sure that the source in the 1768 # source list is forwarded and that a source not in the list is not 1769 # forwarded. 1770 1771 run_cmd "tc -n $ns2 qdisc replace dev vx0 clsact" 1772 run_cmd "ip -n $ns2 address replace $mcast_grp/$plen dev veth0 autojoin" 1773 1774 run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 101 proto all flower enc_dst_ip $mcast_grp action pass" 1775 1776 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent filter_mode include source_list $valid_src dst $mcast_grp src_vni 10010 via veth0" 1777 1778 # Check that invalid source is not forwarded. 1779 run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $invalid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 1780 tc_check_packets "$ns2" "dev vx0 ingress" 101 0 1781 log_test $? 0 "Block excluded source" 1782 1783 # Check that valid source is forwarded. 1784 run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $valid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 1785 tc_check_packets "$ns2" "dev vx0 ingress" 101 1 1786 log_test $? 0 "Forward valid source" 1787 1788 # Remove the VTEP from the multicast group. 1789 run_cmd "ip -n $ns2 address del $mcast_grp/$plen dev veth0" 1790 1791 # Check that valid source is not received anymore. 1792 run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $valid_src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 1793 tc_check_packets "$ns2" "dev vx0 ingress" 101 1 1794 log_test $? 0 "Receive of valid source after removal from group" 1795} 1796 1797starg_include_p2mp_ipv4_ipv4() 1798{ 1799 local ns1=$ns1_v4 1800 local ns2=$ns2_v4 1801 local mcast_grp=238.1.1.1 1802 local plen=32 1803 local grp=239.1.1.1 1804 local grp_dmac=01:00:5e:01:01:01 1805 local valid_src=192.0.2.129 1806 local invalid_src=192.0.2.145 1807 1808 echo 1809 echo "Data path: (*, G) INCLUDE - P2MP - IPv4 overlay / IPv4 underlay" 1810 echo "---------------------------------------------------------------" 1811 1812 starg_include_p2mp_common $ns1 $ns2 $mcast_grp $plen $grp $grp_dmac \ 1813 $valid_src $invalid_src "mausezahn" 1814} 1815 1816starg_include_p2mp_ipv6_ipv4() 1817{ 1818 local ns1=$ns1_v4 1819 local ns2=$ns2_v4 1820 local mcast_grp=238.1.1.1 1821 local plen=32 1822 local grp=ff0e::1 1823 local grp_dmac=33:33:00:00:00:01 1824 local valid_src=2001:db8:100::1 1825 local invalid_src=2001:db8:200::1 1826 1827 echo 1828 echo "Data path: (*, G) INCLUDE - P2MP - IPv6 overlay / IPv4 underlay" 1829 echo "---------------------------------------------------------------" 1830 1831 starg_include_p2mp_common $ns1 $ns2 $mcast_grp $plen $grp $grp_dmac \ 1832 $valid_src $invalid_src "mausezahn -6" 1833} 1834 1835starg_include_p2mp_ipv4_ipv6() 1836{ 1837 local ns1=$ns1_v6 1838 local ns2=$ns2_v6 1839 local mcast_grp=ff0e::2 1840 local plen=128 1841 local grp=239.1.1.1 1842 local grp_dmac=01:00:5e:01:01:01 1843 local valid_src=192.0.2.129 1844 local invalid_src=192.0.2.145 1845 1846 echo 1847 echo "Data path: (*, G) INCLUDE - P2MP - IPv4 overlay / IPv6 underlay" 1848 echo "---------------------------------------------------------------" 1849 1850 starg_include_p2mp_common $ns1 $ns2 $mcast_grp $plen $grp $grp_dmac \ 1851 $valid_src $invalid_src "mausezahn" 1852} 1853 1854starg_include_p2mp_ipv6_ipv6() 1855{ 1856 local ns1=$ns1_v6 1857 local ns2=$ns2_v6 1858 local mcast_grp=ff0e::2 1859 local plen=128 1860 local grp=ff0e::1 1861 local grp_dmac=33:33:00:00:00:01 1862 local valid_src=2001:db8:100::1 1863 local invalid_src=2001:db8:200::1 1864 1865 echo 1866 echo "Data path: (*, G) INCLUDE - P2MP - IPv6 overlay / IPv6 underlay" 1867 echo "---------------------------------------------------------------" 1868 1869 starg_include_p2mp_common $ns1 $ns2 $mcast_grp $plen $grp $grp_dmac \ 1870 $valid_src $invalid_src "mausezahn -6" 1871} 1872 1873egress_vni_translation_common() 1874{ 1875 local ns1=$1; shift 1876 local ns2=$1; shift 1877 local mcast_grp=$1; shift 1878 local plen=$1; shift 1879 local proto=$1; shift 1880 local grp=$1; shift 1881 local grp_dmac=$1; shift 1882 local src=$1; shift 1883 local mz=$1; shift 1884 1885 # When P2MP tunnels are used with optimized inter-subnet multicast 1886 # (OISM) [1], the ingress VTEP does not perform VNI translation and 1887 # uses the VNI of the source broadcast domain (BD). If the egress VTEP 1888 # is a member in the source BD, then no VNI translation is needed. 1889 # Otherwise, the egress VTEP needs to translate the VNI to the 1890 # supplementary broadcast domain (SBD) VNI, which is usually the L3VNI. 1891 # 1892 # In this test, remove the VTEP in the second namespace from VLAN 10 1893 # (VNI 10010) and make sure that a packet sent from this VLAN on the 1894 # first VTEP is received by the SVI corresponding to the L3VNI (14000 / 1895 # VLAN 4000) on the second VTEP. 1896 # 1897 # The second VTEP will be able to decapsulate the packet with VNI 10010 1898 # because this VNI is configured on its shared VXLAN device. Later, 1899 # when ingressing the bridge, the VNI to VLAN lookup will fail because 1900 # the VTEP is not a member in VLAN 10, which will cause the packet to 1901 # be tagged with VLAN 4000 since it is configured as PVID. 1902 # 1903 # [1] https://datatracker.ietf.org/doc/html/draft-ietf-bess-evpn-irb-mcast 1904 1905 run_cmd "tc -n $ns2 qdisc replace dev br0.4000 clsact" 1906 run_cmd "ip -n $ns2 address replace $mcast_grp/$plen dev veth0 autojoin" 1907 run_cmd "tc -n $ns2 filter replace dev br0.4000 ingress pref 1 handle 101 proto $proto flower src_ip $src dst_ip $grp action pass" 1908 1909 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp src $src permanent dst $mcast_grp src_vni 10010 via veth0" 1910 1911 # Remove the second VTEP from VLAN 10. 1912 run_cmd "bridge -n $ns2 vlan del vid 10 dev vx0" 1913 1914 # Make sure that packets sent from the first VTEP over VLAN 10 are 1915 # received by the SVI corresponding to the L3VNI (14000 / VLAN 4000) on 1916 # the second VTEP, since it is configured as PVID. 1917 run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 1918 tc_check_packets "$ns2" "dev br0.4000 ingress" 101 1 1919 log_test $? 0 "Egress VNI translation - PVID configured" 1920 1921 # Remove PVID flag from VLAN 4000 on the second VTEP and make sure 1922 # packets are no longer received by the SVI interface. 1923 run_cmd "bridge -n $ns2 vlan add vid 4000 dev vx0" 1924 run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 1925 tc_check_packets "$ns2" "dev br0.4000 ingress" 101 1 1926 log_test $? 0 "Egress VNI translation - no PVID configured" 1927 1928 # Reconfigure the PVID and make sure packets are received again. 1929 run_cmd "bridge -n $ns2 vlan add vid 4000 dev vx0 pvid" 1930 run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 1931 tc_check_packets "$ns2" "dev br0.4000 ingress" 101 2 1932 log_test $? 0 "Egress VNI translation - PVID reconfigured" 1933} 1934 1935egress_vni_translation_ipv4_ipv4() 1936{ 1937 local ns1=$ns1_v4 1938 local ns2=$ns2_v4 1939 local mcast_grp=238.1.1.1 1940 local plen=32 1941 local proto="ipv4" 1942 local grp=239.1.1.1 1943 local grp_dmac=01:00:5e:01:01:01 1944 local src=192.0.2.129 1945 1946 echo 1947 echo "Data path: Egress VNI translation - IPv4 overlay / IPv4 underlay" 1948 echo "----------------------------------------------------------------" 1949 1950 egress_vni_translation_common $ns1 $ns2 $mcast_grp $plen $proto $grp \ 1951 $grp_dmac $src "mausezahn" 1952} 1953 1954egress_vni_translation_ipv6_ipv4() 1955{ 1956 local ns1=$ns1_v4 1957 local ns2=$ns2_v4 1958 local mcast_grp=238.1.1.1 1959 local plen=32 1960 local proto="ipv6" 1961 local grp=ff0e::1 1962 local grp_dmac=33:33:00:00:00:01 1963 local src=2001:db8:100::1 1964 1965 echo 1966 echo "Data path: Egress VNI translation - IPv6 overlay / IPv4 underlay" 1967 echo "----------------------------------------------------------------" 1968 1969 egress_vni_translation_common $ns1 $ns2 $mcast_grp $plen $proto $grp \ 1970 $grp_dmac $src "mausezahn -6" 1971} 1972 1973egress_vni_translation_ipv4_ipv6() 1974{ 1975 local ns1=$ns1_v6 1976 local ns2=$ns2_v6 1977 local mcast_grp=ff0e::2 1978 local plen=128 1979 local proto="ipv4" 1980 local grp=239.1.1.1 1981 local grp_dmac=01:00:5e:01:01:01 1982 local src=192.0.2.129 1983 1984 echo 1985 echo "Data path: Egress VNI translation - IPv4 overlay / IPv6 underlay" 1986 echo "----------------------------------------------------------------" 1987 1988 egress_vni_translation_common $ns1 $ns2 $mcast_grp $plen $proto $grp \ 1989 $grp_dmac $src "mausezahn" 1990} 1991 1992egress_vni_translation_ipv6_ipv6() 1993{ 1994 local ns1=$ns1_v6 1995 local ns2=$ns2_v6 1996 local mcast_grp=ff0e::2 1997 local plen=128 1998 local proto="ipv6" 1999 local grp=ff0e::1 2000 local grp_dmac=33:33:00:00:00:01 2001 local src=2001:db8:100::1 2002 2003 echo 2004 echo "Data path: Egress VNI translation - IPv6 overlay / IPv6 underlay" 2005 echo "----------------------------------------------------------------" 2006 2007 egress_vni_translation_common $ns1 $ns2 $mcast_grp $plen $proto $grp \ 2008 $grp_dmac $src "mausezahn -6" 2009} 2010 2011all_zeros_mdb_common() 2012{ 2013 local ns1=$1; shift 2014 local ns2=$1; shift 2015 local vtep1_ip=$1; shift 2016 local vtep2_ip=$1; shift 2017 local vtep3_ip=$1; shift 2018 local vtep4_ip=$1; shift 2019 local plen=$1; shift 2020 local ipv4_grp=239.1.1.1 2021 local ipv4_grp_dmac=01:00:5e:01:01:01 2022 local ipv4_unreg_grp=239.2.2.2 2023 local ipv4_unreg_grp_dmac=01:00:5e:02:02:02 2024 local ipv4_ll_grp=224.0.0.100 2025 local ipv4_ll_grp_dmac=01:00:5e:00:00:64 2026 local ipv4_src=192.0.2.129 2027 local ipv6_grp=ff0e::1 2028 local ipv6_grp_dmac=33:33:00:00:00:01 2029 local ipv6_unreg_grp=ff0e::2 2030 local ipv6_unreg_grp_dmac=33:33:00:00:00:02 2031 local ipv6_ll_grp=ff02::1 2032 local ipv6_ll_grp_dmac=33:33:00:00:00:01 2033 local ipv6_src=2001:db8:100::1 2034 2035 # Install all-zeros (catchall) MDB entries for IPv4 and IPv6 traffic 2036 # and make sure they only forward unregistered IP multicast traffic 2037 # which is not link-local. Also make sure that each entry only forwards 2038 # traffic from the matching address family. 2039 2040 # Associate two different VTEPs with one all-zeros MDB entry: Two with 2041 # the IPv4 entry (0.0.0.0) and another two with the IPv6 one (::). 2042 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp 0.0.0.0 permanent dst $vtep1_ip src_vni 10010" 2043 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp 0.0.0.0 permanent dst $vtep2_ip src_vni 10010" 2044 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp :: permanent dst $vtep3_ip src_vni 10010" 2045 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp :: permanent dst $vtep4_ip src_vni 10010" 2046 2047 # Associate one VTEP from each set with a regular MDB entry: One with 2048 # an IPv4 entry and another with an IPv6 one. 2049 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $ipv4_grp permanent dst $vtep1_ip src_vni 10010" 2050 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $ipv6_grp permanent dst $vtep3_ip src_vni 10010" 2051 2052 # Add filters to match on decapsulated traffic in the second namespace. 2053 run_cmd "tc -n $ns2 qdisc replace dev vx0 clsact" 2054 run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 101 proto all flower enc_dst_ip $vtep1_ip action pass" 2055 run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 102 proto all flower enc_dst_ip $vtep2_ip action pass" 2056 run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 103 proto all flower enc_dst_ip $vtep3_ip action pass" 2057 run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 104 proto all flower enc_dst_ip $vtep4_ip action pass" 2058 2059 # Configure the VTEP addresses in the second namespace to enable 2060 # decapsulation. 2061 run_cmd "ip -n $ns2 address replace $vtep1_ip/$plen dev lo" 2062 run_cmd "ip -n $ns2 address replace $vtep2_ip/$plen dev lo" 2063 run_cmd "ip -n $ns2 address replace $vtep3_ip/$plen dev lo" 2064 run_cmd "ip -n $ns2 address replace $vtep4_ip/$plen dev lo" 2065 2066 # Send registered IPv4 multicast and make sure it only arrives to the 2067 # first VTEP. 2068 run_cmd "ip netns exec $ns1 mausezahn br0.10 -a own -b $ipv4_grp_dmac -A $ipv4_src -B $ipv4_grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 2069 tc_check_packets "$ns2" "dev vx0 ingress" 101 1 2070 log_test $? 0 "Registered IPv4 multicast - first VTEP" 2071 tc_check_packets "$ns2" "dev vx0 ingress" 102 0 2072 log_test $? 0 "Registered IPv4 multicast - second VTEP" 2073 2074 # Send unregistered IPv4 multicast that is not link-local and make sure 2075 # it arrives to the first and second VTEPs. 2076 run_cmd "ip netns exec $ns1 mausezahn br0.10 -a own -b $ipv4_unreg_grp_dmac -A $ipv4_src -B $ipv4_unreg_grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 2077 tc_check_packets "$ns2" "dev vx0 ingress" 101 2 2078 log_test $? 0 "Unregistered IPv4 multicast - first VTEP" 2079 tc_check_packets "$ns2" "dev vx0 ingress" 102 1 2080 log_test $? 0 "Unregistered IPv4 multicast - second VTEP" 2081 2082 # Send IPv4 link-local multicast traffic and make sure it does not 2083 # arrive to any VTEP. 2084 run_cmd "ip netns exec $ns1 mausezahn br0.10 -a own -b $ipv4_ll_grp_dmac -A $ipv4_src -B $ipv4_ll_grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 2085 tc_check_packets "$ns2" "dev vx0 ingress" 101 2 2086 log_test $? 0 "Link-local IPv4 multicast - first VTEP" 2087 tc_check_packets "$ns2" "dev vx0 ingress" 102 1 2088 log_test $? 0 "Link-local IPv4 multicast - second VTEP" 2089 2090 # Send registered IPv4 multicast using a unicast MAC address and make 2091 # sure it does not arrive to any VTEP. 2092 run_cmd "ip netns exec $ns1 mausezahn br0.10 -a own -b 00:11:22:33:44:55 -A $ipv4_src -B $ipv4_grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 2093 tc_check_packets "$ns2" "dev vx0 ingress" 101 2 2094 log_test $? 0 "Registered IPv4 multicast with a unicast MAC - first VTEP" 2095 tc_check_packets "$ns2" "dev vx0 ingress" 102 1 2096 log_test $? 0 "Registered IPv4 multicast with a unicast MAC - second VTEP" 2097 2098 # Send registered IPv4 multicast using a broadcast MAC address and make 2099 # sure it does not arrive to any VTEP. 2100 run_cmd "ip netns exec $ns1 mausezahn br0.10 -a own -b bcast -A $ipv4_src -B $ipv4_grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 2101 tc_check_packets "$ns2" "dev vx0 ingress" 101 2 2102 log_test $? 0 "Registered IPv4 multicast with a broadcast MAC - first VTEP" 2103 tc_check_packets "$ns2" "dev vx0 ingress" 102 1 2104 log_test $? 0 "Registered IPv4 multicast with a broadcast MAC - second VTEP" 2105 2106 # Make sure IPv4 traffic did not reach the VTEPs associated with 2107 # IPv6 entries. 2108 tc_check_packets "$ns2" "dev vx0 ingress" 103 0 2109 log_test $? 0 "IPv4 traffic - third VTEP" 2110 tc_check_packets "$ns2" "dev vx0 ingress" 104 0 2111 log_test $? 0 "IPv4 traffic - fourth VTEP" 2112 2113 # Reset IPv4 filters before testing IPv6 traffic. 2114 run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 101 proto all flower enc_dst_ip $vtep1_ip action pass" 2115 run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 102 proto all flower enc_dst_ip $vtep2_ip action pass" 2116 2117 # Send registered IPv6 multicast and make sure it only arrives to the 2118 # third VTEP. 2119 run_cmd "ip netns exec $ns1 mausezahn -6 br0.10 -a own -b $ipv6_grp_dmac -A $ipv6_src -B $ipv6_grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 2120 tc_check_packets "$ns2" "dev vx0 ingress" 103 1 2121 log_test $? 0 "Registered IPv6 multicast - third VTEP" 2122 tc_check_packets "$ns2" "dev vx0 ingress" 104 0 2123 log_test $? 0 "Registered IPv6 multicast - fourth VTEP" 2124 2125 # Send unregistered IPv6 multicast that is not link-local and make sure 2126 # it arrives to the third and fourth VTEPs. 2127 run_cmd "ip netns exec $ns1 mausezahn -6 br0.10 -a own -b $ipv6_unreg_grp_dmac -A $ipv6_src -B $ipv6_unreg_grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 2128 tc_check_packets "$ns2" "dev vx0 ingress" 103 2 2129 log_test $? 0 "Unregistered IPv6 multicast - third VTEP" 2130 tc_check_packets "$ns2" "dev vx0 ingress" 104 1 2131 log_test $? 0 "Unregistered IPv6 multicast - fourth VTEP" 2132 2133 # Send IPv6 link-local multicast traffic and make sure it does not 2134 # arrive to any VTEP. 2135 run_cmd "ip netns exec $ns1 mausezahn -6 br0.10 -a own -b $ipv6_ll_grp_dmac -A $ipv6_src -B $ipv6_ll_grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 2136 tc_check_packets "$ns2" "dev vx0 ingress" 103 2 2137 log_test $? 0 "Link-local IPv6 multicast - third VTEP" 2138 tc_check_packets "$ns2" "dev vx0 ingress" 104 1 2139 log_test $? 0 "Link-local IPv6 multicast - fourth VTEP" 2140 2141 # Send registered IPv6 multicast using a unicast MAC address and make 2142 # sure it does not arrive to any VTEP. 2143 run_cmd "ip netns exec $ns1 mausezahn -6 br0.10 -a own -b 00:11:22:33:44:55 -A $ipv6_src -B $ipv6_grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 2144 tc_check_packets "$ns2" "dev vx0 ingress" 103 2 2145 log_test $? 0 "Registered IPv6 multicast with a unicast MAC - third VTEP" 2146 tc_check_packets "$ns2" "dev vx0 ingress" 104 1 2147 log_test $? 0 "Registered IPv6 multicast with a unicast MAC - fourth VTEP" 2148 2149 # Send registered IPv6 multicast using a broadcast MAC address and make 2150 # sure it does not arrive to any VTEP. 2151 run_cmd "ip netns exec $ns1 mausezahn -6 br0.10 -a own -b bcast -A $ipv6_src -B $ipv6_grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 2152 tc_check_packets "$ns2" "dev vx0 ingress" 103 2 2153 log_test $? 0 "Registered IPv6 multicast with a broadcast MAC - third VTEP" 2154 tc_check_packets "$ns2" "dev vx0 ingress" 104 1 2155 log_test $? 0 "Registered IPv6 multicast with a broadcast MAC - fourth VTEP" 2156 2157 # Make sure IPv6 traffic did not reach the VTEPs associated with 2158 # IPv4 entries. 2159 tc_check_packets "$ns2" "dev vx0 ingress" 101 0 2160 log_test $? 0 "IPv6 traffic - first VTEP" 2161 tc_check_packets "$ns2" "dev vx0 ingress" 102 0 2162 log_test $? 0 "IPv6 traffic - second VTEP" 2163} 2164 2165all_zeros_mdb_ipv4() 2166{ 2167 local ns1=$ns1_v4 2168 local ns2=$ns2_v4 2169 local vtep1_ip=198.51.100.101 2170 local vtep2_ip=198.51.100.102 2171 local vtep3_ip=198.51.100.103 2172 local vtep4_ip=198.51.100.104 2173 local plen=32 2174 2175 echo 2176 echo "Data path: All-zeros MDB entry - IPv4 underlay" 2177 echo "----------------------------------------------" 2178 2179 all_zeros_mdb_common $ns1 $ns2 $vtep1_ip $vtep2_ip $vtep3_ip \ 2180 $vtep4_ip $plen 2181} 2182 2183all_zeros_mdb_ipv6() 2184{ 2185 local ns1=$ns1_v6 2186 local ns2=$ns2_v6 2187 local vtep1_ip=2001:db8:1000::1 2188 local vtep2_ip=2001:db8:2000::1 2189 local vtep3_ip=2001:db8:3000::1 2190 local vtep4_ip=2001:db8:4000::1 2191 local plen=128 2192 2193 echo 2194 echo "Data path: All-zeros MDB entry - IPv6 underlay" 2195 echo "----------------------------------------------" 2196 2197 all_zeros_mdb_common $ns1 $ns2 $vtep1_ip $vtep2_ip $vtep3_ip \ 2198 $vtep4_ip $plen 2199} 2200 2201mdb_fdb_common() 2202{ 2203 local ns1=$1; shift 2204 local ns2=$1; shift 2205 local vtep1_ip=$1; shift 2206 local vtep2_ip=$1; shift 2207 local plen=$1; shift 2208 local proto=$1; shift 2209 local grp=$1; shift 2210 local grp_dmac=$1; shift 2211 local src=$1; shift 2212 local mz=$1; shift 2213 2214 # Install an MDB entry and an FDB entry and make sure that the FDB 2215 # entry only forwards traffic that was not forwarded by the MDB. 2216 2217 # Associate the MDB entry with one VTEP and the FDB entry with another 2218 # VTEP. 2219 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp permanent dst $vtep1_ip src_vni 10010" 2220 run_cmd "bridge -n $ns1 fdb add 00:00:00:00:00:00 dev vx0 self static dst $vtep2_ip src_vni 10010" 2221 2222 # Add filters to match on decapsulated traffic in the second namespace. 2223 run_cmd "tc -n $ns2 qdisc replace dev vx0 clsact" 2224 run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 101 proto $proto flower ip_proto udp dst_port 54321 enc_dst_ip $vtep1_ip action pass" 2225 run_cmd "tc -n $ns2 filter replace dev vx0 ingress pref 1 handle 102 proto $proto flower ip_proto udp dst_port 54321 enc_dst_ip $vtep2_ip action pass" 2226 2227 # Configure the VTEP addresses in the second namespace to enable 2228 # decapsulation. 2229 run_cmd "ip -n $ns2 address replace $vtep1_ip/$plen dev lo" 2230 run_cmd "ip -n $ns2 address replace $vtep2_ip/$plen dev lo" 2231 2232 # Send IP multicast traffic and make sure it is forwarded by the MDB 2233 # and only arrives to the first VTEP. 2234 run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 2235 tc_check_packets "$ns2" "dev vx0 ingress" 101 1 2236 log_test $? 0 "IP multicast - first VTEP" 2237 tc_check_packets "$ns2" "dev vx0 ingress" 102 0 2238 log_test $? 0 "IP multicast - second VTEP" 2239 2240 # Send broadcast traffic and make sure it is forwarded by the FDB and 2241 # only arrives to the second VTEP. 2242 run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b bcast -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 2243 tc_check_packets "$ns2" "dev vx0 ingress" 101 1 2244 log_test $? 0 "Broadcast - first VTEP" 2245 tc_check_packets "$ns2" "dev vx0 ingress" 102 1 2246 log_test $? 0 "Broadcast - second VTEP" 2247 2248 # Remove the MDB entry and make sure that IP multicast is now forwarded 2249 # by the FDB to the second VTEP. 2250 run_cmd "bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp dst $vtep1_ip src_vni 10010" 2251 run_cmd "ip netns exec $ns1 $mz br0.10 -a own -b $grp_dmac -A $src -B $grp -t udp sp=12345,dp=54321 -p 100 -c 1 -q" 2252 tc_check_packets "$ns2" "dev vx0 ingress" 101 1 2253 log_test $? 0 "IP multicast after removal - first VTEP" 2254 tc_check_packets "$ns2" "dev vx0 ingress" 102 2 2255 log_test $? 0 "IP multicast after removal - second VTEP" 2256} 2257 2258mdb_fdb_ipv4_ipv4() 2259{ 2260 local ns1=$ns1_v4 2261 local ns2=$ns2_v4 2262 local vtep1_ip=198.51.100.100 2263 local vtep2_ip=198.51.100.200 2264 local plen=32 2265 local proto="ipv4" 2266 local grp=239.1.1.1 2267 local grp_dmac=01:00:5e:01:01:01 2268 local src=192.0.2.129 2269 2270 echo 2271 echo "Data path: MDB with FDB - IPv4 overlay / IPv4 underlay" 2272 echo "------------------------------------------------------" 2273 2274 mdb_fdb_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $proto $grp \ 2275 $grp_dmac $src "mausezahn" 2276} 2277 2278mdb_fdb_ipv6_ipv4() 2279{ 2280 local ns1=$ns1_v4 2281 local ns2=$ns2_v4 2282 local vtep1_ip=198.51.100.100 2283 local vtep2_ip=198.51.100.200 2284 local plen=32 2285 local proto="ipv6" 2286 local grp=ff0e::1 2287 local grp_dmac=33:33:00:00:00:01 2288 local src=2001:db8:100::1 2289 2290 echo 2291 echo "Data path: MDB with FDB - IPv6 overlay / IPv4 underlay" 2292 echo "------------------------------------------------------" 2293 2294 mdb_fdb_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $proto $grp \ 2295 $grp_dmac $src "mausezahn -6" 2296} 2297 2298mdb_fdb_ipv4_ipv6() 2299{ 2300 local ns1=$ns1_v6 2301 local ns2=$ns2_v6 2302 local vtep1_ip=2001:db8:1000::1 2303 local vtep2_ip=2001:db8:2000::1 2304 local plen=128 2305 local proto="ipv4" 2306 local grp=239.1.1.1 2307 local grp_dmac=01:00:5e:01:01:01 2308 local src=192.0.2.129 2309 2310 echo 2311 echo "Data path: MDB with FDB - IPv4 overlay / IPv6 underlay" 2312 echo "------------------------------------------------------" 2313 2314 mdb_fdb_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $proto $grp \ 2315 $grp_dmac $src "mausezahn" 2316} 2317 2318mdb_fdb_ipv6_ipv6() 2319{ 2320 local ns1=$ns1_v6 2321 local ns2=$ns2_v6 2322 local vtep1_ip=2001:db8:1000::1 2323 local vtep2_ip=2001:db8:2000::1 2324 local plen=128 2325 local proto="ipv6" 2326 local grp=ff0e::1 2327 local grp_dmac=33:33:00:00:00:01 2328 local src=2001:db8:100::1 2329 2330 echo 2331 echo "Data path: MDB with FDB - IPv6 overlay / IPv6 underlay" 2332 echo "------------------------------------------------------" 2333 2334 mdb_fdb_common $ns1 $ns2 $vtep1_ip $vtep2_ip $plen $proto $grp \ 2335 $grp_dmac $src "mausezahn -6" 2336} 2337 2338mdb_grp1_loop() 2339{ 2340 local ns1=$1; shift 2341 local vtep1_ip=$1; shift 2342 local grp1=$1; shift 2343 2344 while true; do 2345 bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp1 dst $vtep1_ip src_vni 10010 2346 bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp1 permanent dst $vtep1_ip src_vni 10010 2347 done >/dev/null 2>&1 2348} 2349 2350mdb_grp2_loop() 2351{ 2352 local ns1=$1; shift 2353 local vtep1_ip=$1; shift 2354 local vtep2_ip=$1; shift 2355 local grp2=$1; shift 2356 2357 while true; do 2358 bridge -n $ns1 mdb del dev vx0 port vx0 grp $grp2 dst $vtep1_ip src_vni 10010 2359 bridge -n $ns1 mdb add dev vx0 port vx0 grp $grp2 permanent dst $vtep1_ip src_vni 10010 2360 bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp2 permanent dst $vtep2_ip src_vni 10010 2361 done >/dev/null 2>&1 2362} 2363 2364mdb_torture_common() 2365{ 2366 local ns1=$1; shift 2367 local vtep1_ip=$1; shift 2368 local vtep2_ip=$1; shift 2369 local grp1=$1; shift 2370 local grp1_dmac=$1; shift 2371 local grp2=$1; shift 2372 local grp2_dmac=$1; shift 2373 local src=$1; shift 2374 local mz=$1; shift 2375 local pid1 2376 local pid2 2377 local pid3 2378 local pid4 2379 2380 # Continuously send two streams that are forwarded by two different MDB 2381 # entries. The first entry will be added and deleted in a loop. This 2382 # allows us to test that the data path does not use freed MDB entry 2383 # memory. The second entry will have two remotes, one that is added and 2384 # deleted in a loop and another that is replaced in a loop. This allows 2385 # us to test that the data path does not use freed remote entry memory. 2386 # The test is considered successful if nothing crashed. 2387 2388 # Create the MDB entries that will be continuously deleted / replaced. 2389 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp1 permanent dst $vtep1_ip src_vni 10010" 2390 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp2 permanent dst $vtep1_ip src_vni 10010" 2391 run_cmd "bridge -n $ns1 mdb replace dev vx0 port vx0 grp $grp2 permanent dst $vtep2_ip src_vni 10010" 2392 2393 mdb_grp1_loop $ns1 $vtep1_ip $grp1 & 2394 pid1=$! 2395 mdb_grp2_loop $ns1 $vtep1_ip $vtep2_ip $grp2 & 2396 pid2=$! 2397 ip netns exec $ns1 $mz br0.10 -a own -b $grp1_dmac -A $src -B $grp1 -t udp sp=12345,dp=54321 -p 100 -c 0 -q & 2398 pid3=$! 2399 ip netns exec $ns1 $mz br0.10 -a own -b $grp2_dmac -A $src -B $grp2 -t udp sp=12345,dp=54321 -p 100 -c 0 -q & 2400 pid4=$! 2401 2402 sleep 30 2403 kill -9 $pid1 $pid2 $pid3 $pid4 2404 wait $pid1 $pid2 $pid3 $pid4 2>/dev/null 2405 2406 log_test 0 0 "Torture test" 2407} 2408 2409mdb_torture_ipv4_ipv4() 2410{ 2411 local ns1=$ns1_v4 2412 local vtep1_ip=198.51.100.100 2413 local vtep2_ip=198.51.100.200 2414 local grp1=239.1.1.1 2415 local grp1_dmac=01:00:5e:01:01:01 2416 local grp2=239.2.2.2 2417 local grp2_dmac=01:00:5e:02:02:02 2418 local src=192.0.2.129 2419 2420 echo 2421 echo "Data path: MDB torture test - IPv4 overlay / IPv4 underlay" 2422 echo "----------------------------------------------------------" 2423 2424 mdb_torture_common $ns1 $vtep1_ip $vtep2_ip $grp1 $grp1_dmac $grp2 \ 2425 $grp2_dmac $src "mausezahn" 2426} 2427 2428mdb_torture_ipv6_ipv4() 2429{ 2430 local ns1=$ns1_v4 2431 local vtep1_ip=198.51.100.100 2432 local vtep2_ip=198.51.100.200 2433 local grp1=ff0e::1 2434 local grp1_dmac=33:33:00:00:00:01 2435 local grp2=ff0e::2 2436 local grp2_dmac=33:33:00:00:00:02 2437 local src=2001:db8:100::1 2438 2439 echo 2440 echo "Data path: MDB torture test - IPv6 overlay / IPv4 underlay" 2441 echo "----------------------------------------------------------" 2442 2443 mdb_torture_common $ns1 $vtep1_ip $vtep2_ip $grp1 $grp1_dmac $grp2 \ 2444 $grp2_dmac $src "mausezahn -6" 2445} 2446 2447mdb_torture_ipv4_ipv6() 2448{ 2449 local ns1=$ns1_v6 2450 local vtep1_ip=2001:db8:1000::1 2451 local vtep2_ip=2001:db8:2000::1 2452 local grp1=239.1.1.1 2453 local grp1_dmac=01:00:5e:01:01:01 2454 local grp2=239.2.2.2 2455 local grp2_dmac=01:00:5e:02:02:02 2456 local src=192.0.2.129 2457 2458 echo 2459 echo "Data path: MDB torture test - IPv4 overlay / IPv6 underlay" 2460 echo "----------------------------------------------------------" 2461 2462 mdb_torture_common $ns1 $vtep1_ip $vtep2_ip $grp1 $grp1_dmac $grp2 \ 2463 $grp2_dmac $src "mausezahn" 2464} 2465 2466mdb_torture_ipv6_ipv6() 2467{ 2468 local ns1=$ns1_v6 2469 local vtep1_ip=2001:db8:1000::1 2470 local vtep2_ip=2001:db8:2000::1 2471 local grp1=ff0e::1 2472 local grp1_dmac=33:33:00:00:00:01 2473 local grp2=ff0e::2 2474 local grp2_dmac=33:33:00:00:00:02 2475 local src=2001:db8:100::1 2476 2477 echo 2478 echo "Data path: MDB torture test - IPv6 overlay / IPv6 underlay" 2479 echo "----------------------------------------------------------" 2480 2481 mdb_torture_common $ns1 $vtep1_ip $vtep2_ip $grp1 $grp1_dmac $grp2 \ 2482 $grp2_dmac $src "mausezahn -6" 2483} 2484 2485################################################################################ 2486# Usage 2487 2488usage() 2489{ 2490 cat <<EOF 2491usage: ${0##*/} OPTS 2492 2493 -t <test> Test(s) to run (default: all) 2494 (options: $TESTS) 2495 -c Control path tests only 2496 -d Data path tests only 2497 -p Pause on fail 2498 -P Pause after each test before cleanup 2499 -v Verbose mode (show commands and output) 2500EOF 2501} 2502 2503################################################################################ 2504# Main 2505 2506trap cleanup EXIT 2507 2508while getopts ":t:cdpPvh" opt; do 2509 case $opt in 2510 t) TESTS=$OPTARG;; 2511 c) TESTS=${CONTROL_PATH_TESTS};; 2512 d) TESTS=${DATA_PATH_TESTS};; 2513 p) PAUSE_ON_FAIL=yes;; 2514 P) PAUSE=yes;; 2515 v) VERBOSE=$(($VERBOSE + 1));; 2516 h) usage; exit 0;; 2517 *) usage; exit 1;; 2518 esac 2519done 2520 2521# Make sure we don't pause twice. 2522[ "${PAUSE}" = "yes" ] && PAUSE_ON_FAIL=no 2523 2524if [ "$(id -u)" -ne 0 ];then 2525 echo "SKIP: Need root privileges" 2526 exit $ksft_skip; 2527fi 2528 2529if [ ! -x "$(command -v ip)" ]; then 2530 echo "SKIP: Could not run test without ip tool" 2531 exit $ksft_skip 2532fi 2533 2534if [ ! -x "$(command -v bridge)" ]; then 2535 echo "SKIP: Could not run test without bridge tool" 2536 exit $ksft_skip 2537fi 2538 2539if [ ! -x "$(command -v mausezahn)" ]; then 2540 echo "SKIP: Could not run test without mausezahn tool" 2541 exit $ksft_skip 2542fi 2543 2544if [ ! -x "$(command -v jq)" ]; then 2545 echo "SKIP: Could not run test without jq tool" 2546 exit $ksft_skip 2547fi 2548 2549bridge mdb help 2>&1 | grep -q "flush" 2550if [ $? -ne 0 ]; then 2551 echo "SKIP: iproute2 bridge too old, missing VXLAN MDB flush support" 2552 exit $ksft_skip 2553fi 2554 2555# Start clean. 2556cleanup 2557 2558for t in $TESTS 2559do 2560 setup; $t; cleanup; 2561done 2562 2563if [ "$TESTS" != "none" ]; then 2564 printf "\nTests passed: %3d\n" ${nsuccess} 2565 printf "Tests failed: %3d\n" ${nfail} 2566fi 2567 2568exit $ret 2569