1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3# 4# Verify that permanent mdb entries can be added to and deleted from bridge 5# interfaces that are down, and works correctly when done so. 6 7ALL_TESTS="add_del_to_port_down" 8NUM_NETIFS=4 9 10TEST_GROUP="239.10.10.10" 11TEST_GROUP_MAC="01:00:5e:0a:0a:0a" 12 13source lib.sh 14 15 16add_del_to_port_down() { 17 RET=0 18 19 ip link set dev $swp2 down 20 bridge mdb add dev br0 port "$swp2" grp $TEST_GROUP permanent 2>/dev/null 21 check_err $? "Failed adding mdb entry" 22 23 ip link set dev $swp2 up 24 setup_wait_dev $swp2 25 mcast_packet_test $TEST_GROUP_MAC 192.0.2.1 $TEST_GROUP $h1 $h2 26 check_fail $? "Traffic to $TEST_GROUP wasn't forwarded" 27 28 ip link set dev $swp2 down 29 bridge mdb show dev br0 | grep -q "$TEST_GROUP permanent" 2>/dev/null 30 check_err $? "MDB entry did not persist after link up/down" 31 32 bridge mdb del dev br0 port "$swp2" grp $TEST_GROUP 2>/dev/null 33 check_err $? "Failed deleting mdb entry" 34 35 ip link set dev $swp2 up 36 setup_wait_dev $swp2 37 mcast_packet_test $TEST_GROUP_MAC 192.0.2.1 $TEST_GROUP $h1 $h2 38 check_err $? "Traffic to $TEST_GROUP was forwarded after entry removed" 39 40 log_test "MDB add/del entry to port with state down " 41} 42 43h1_create() 44{ 45 simple_if_init $h1 192.0.2.1/24 2001:db8:1::1/64 46} 47 48h1_destroy() 49{ 50 simple_if_fini $h1 192.0.2.1/24 2001:db8:1::1/64 51} 52 53h2_create() 54{ 55 simple_if_init $h2 192.0.2.2/24 2001:db8:1::2/64 56} 57 58h2_destroy() 59{ 60 simple_if_fini $h2 192.0.2.2/24 2001:db8:1::2/64 61} 62 63switch_create() 64{ 65 # Enable multicast filtering 66 ip link add dev br0 type bridge mcast_snooping 1 mcast_querier 1 67 68 ip link set dev $swp1 master br0 69 ip link set dev $swp2 master br0 70 71 ip link set dev br0 up 72 ip link set dev $swp1 up 73 74 bridge link set dev $swp2 mcast_flood off 75 # Bridge currently has a "grace time" at creation time before it 76 # forwards multicast according to the mdb. Since we disable the 77 # mcast_flood setting per port 78 sleep 10 79} 80 81switch_destroy() 82{ 83 ip link set dev $swp1 down 84 ip link set dev $swp2 down 85 ip link del dev br0 86} 87 88setup_prepare() 89{ 90 h1=${NETIFS[p1]} 91 swp1=${NETIFS[p2]} 92 93 swp2=${NETIFS[p3]} 94 h2=${NETIFS[p4]} 95 96 vrf_prepare 97 98 h1_create 99 h2_create 100 switch_create 101} 102 103cleanup() 104{ 105 pre_cleanup 106 107 switch_destroy 108 h1_destroy 109 h2_destroy 110 111 vrf_cleanup 112} 113 114trap cleanup EXIT 115 116setup_prepare 117tests_run 118exit $EXIT_STATUS 119