Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: forwarding: Add test cases for unresolved multicast routes

Add IPv4 and IPv6 test cases for unresolved multicast routes, testing
that queued packets are forwarded after installing a matching (S, G)
route.

The test cases can be used to reproduce the bugs fixed in "ipmr: Always
call ip{,6}_mr_forward() from RCU read-side critical section".

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Ido Schimmel and committed by
Jakub Kicinski
2b5a8c8f b07a9b26

+91 -1
+91 -1
tools/testing/selftests/net/forwarding/router_multicast.sh
··· 28 28 # +------------------+ +------------------+ 29 29 # 30 30 31 - ALL_TESTS="mcast_v4 mcast_v6 rpf_v4 rpf_v6" 31 + ALL_TESTS="mcast_v4 mcast_v6 rpf_v4 rpf_v6 unres_v4 unres_v6" 32 32 NUM_NETIFS=6 33 33 source lib.sh 34 34 source tc_common.sh ··· 404 404 tc filter del dev $h1 ingress protocol ipv6 pref 1 handle 1 flower 405 405 406 406 log_test "RPF IPv6" 407 + } 408 + 409 + unres_v4() 410 + { 411 + # Send a multicast packet not corresponding to an installed route, 412 + # causing the kernel to queue the packet for resolution and emit an 413 + # IGMPMSG_NOCACHE notification. smcrouted will react to this 414 + # notification by consulting its (*, G) list and installing an (S, G) 415 + # route, which will be used to forward the queued packet. 416 + 417 + RET=0 418 + 419 + tc filter add dev $h2 ingress protocol ip pref 1 handle 1 flower \ 420 + dst_ip 225.1.2.3 ip_proto udp dst_port 12345 action drop 421 + tc filter add dev $h3 ingress protocol ip pref 1 handle 1 flower \ 422 + dst_ip 225.1.2.3 ip_proto udp dst_port 12345 action drop 423 + 424 + # Forwarding should fail before installing a matching (*, G). 425 + $MZ $h1 -c 1 -p 128 -t udp "ttl=10,sp=54321,dp=12345" \ 426 + -a 00:11:22:33:44:55 -b 01:00:5e:01:02:03 \ 427 + -A 198.51.100.2 -B 225.1.2.3 -q 428 + 429 + tc_check_packets "dev $h2 ingress" 1 0 430 + check_err $? "Multicast received on first host when should not" 431 + tc_check_packets "dev $h3 ingress" 1 0 432 + check_err $? "Multicast received on second host when should not" 433 + 434 + # Create (*, G). Will not be installed in the kernel. 435 + create_mcast_sg $rp1 0.0.0.0 225.1.2.3 $rp2 $rp3 436 + 437 + $MZ $h1 -c 1 -p 128 -t udp "ttl=10,sp=54321,dp=12345" \ 438 + -a 00:11:22:33:44:55 -b 01:00:5e:01:02:03 \ 439 + -A 198.51.100.2 -B 225.1.2.3 -q 440 + 441 + tc_check_packets "dev $h2 ingress" 1 1 442 + check_err $? "Multicast not received on first host" 443 + tc_check_packets "dev $h3 ingress" 1 1 444 + check_err $? "Multicast not received on second host" 445 + 446 + delete_mcast_sg $rp1 0.0.0.0 225.1.2.3 $rp2 $rp3 447 + 448 + tc filter del dev $h3 ingress protocol ip pref 1 handle 1 flower 449 + tc filter del dev $h2 ingress protocol ip pref 1 handle 1 flower 450 + 451 + log_test "Unresolved queue IPv4" 452 + } 453 + 454 + unres_v6() 455 + { 456 + # Send a multicast packet not corresponding to an installed route, 457 + # causing the kernel to queue the packet for resolution and emit an 458 + # MRT6MSG_NOCACHE notification. smcrouted will react to this 459 + # notification by consulting its (*, G) list and installing an (S, G) 460 + # route, which will be used to forward the queued packet. 461 + 462 + RET=0 463 + 464 + tc filter add dev $h2 ingress protocol ipv6 pref 1 handle 1 flower \ 465 + dst_ip ff0e::3 ip_proto udp dst_port 12345 action drop 466 + tc filter add dev $h3 ingress protocol ipv6 pref 1 handle 1 flower \ 467 + dst_ip ff0e::3 ip_proto udp dst_port 12345 action drop 468 + 469 + # Forwarding should fail before installing a matching (*, G). 470 + $MZ $h1 -6 -c 1 -p 128 -t udp "ttl=10,sp=54321,dp=12345" \ 471 + -a 00:11:22:33:44:55 -b 33:33:00:00:00:03 \ 472 + -A 2001:db8:1::2 -B ff0e::3 -q 473 + 474 + tc_check_packets "dev $h2 ingress" 1 0 475 + check_err $? "Multicast received on first host when should not" 476 + tc_check_packets "dev $h3 ingress" 1 0 477 + check_err $? "Multicast received on second host when should not" 478 + 479 + # Create (*, G). Will not be installed in the kernel. 480 + create_mcast_sg $rp1 :: ff0e::3 $rp2 $rp3 481 + 482 + $MZ $h1 -6 -c 1 -p 128 -t udp "ttl=10,sp=54321,dp=12345" \ 483 + -a 00:11:22:33:44:55 -b 33:33:00:00:00:03 \ 484 + -A 2001:db8:1::2 -B ff0e::3 -q 485 + 486 + tc_check_packets "dev $h2 ingress" 1 1 487 + check_err $? "Multicast not received on first host" 488 + tc_check_packets "dev $h3 ingress" 1 1 489 + check_err $? "Multicast not received on second host" 490 + 491 + delete_mcast_sg $rp1 :: ff0e::3 $rp2 $rp3 492 + 493 + tc filter del dev $h3 ingress protocol ipv6 pref 1 handle 1 flower 494 + tc filter del dev $h2 ingress protocol ipv6 pref 1 handle 1 flower 495 + 496 + log_test "Unresolved queue IPv6" 407 497 } 408 498 409 499 trap cleanup EXIT