Skip to content

Commit 9651ee1

Browse files
pmachatadavem330
authored andcommitted
selftests: mlxsw: Test FID RIF MAC vetoing
When a FID RIF is created for a bridge with IP address, its MAC address must obey the same requirements as other RIFs. Test that attempts to change the address incompatibly by attaching a device are vetoed with extack. Signed-off-by: Petr Machata <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 555afaa commit 9651ee1

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

tools/testing/selftests/drivers/net/mlxsw/rtnetlink.sh

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ lib_dir=$(dirname $0)/../../../net/forwarding
1111

1212
ALL_TESTS="
1313
rif_set_addr_test
14+
rif_inherit_bridge_addr_test
15+
rif_non_inherit_bridge_addr_test
1416
"
1517
NUM_NETIFS=2
1618
source $lib_dir/lib.sh
@@ -81,6 +83,83 @@ rif_set_addr_test()
8183
ip link set dev $swp1 addr $swp1_mac
8284
}
8385

86+
rif_inherit_bridge_addr_test()
87+
{
88+
RET=0
89+
90+
# Create first RIF
91+
ip addr add dev $swp1 192.0.2.1/28
92+
check_err $?
93+
94+
# Create a FID RIF
95+
ip link add name br1 up type bridge vlan_filtering 0
96+
ip link set dev $swp2 master br1
97+
ip addr add dev br1 192.0.2.17/28
98+
check_err $?
99+
100+
# Prepare a device with a low MAC address
101+
ip link add name d up type dummy
102+
ip link set dev d addr 00:11:22:33:44:55
103+
104+
# Attach the device to br1. That prompts bridge address change, which
105+
# should be vetoed, thus preventing the attachment.
106+
ip link set dev d master br1 &>/dev/null
107+
check_fail $? "Device with low MAC was permitted to attach a bridge with RIF"
108+
ip link set dev d master br1 2>&1 >/dev/null \
109+
| grep -q mlxsw_spectrum
110+
check_err $? "no extack for bridge attach rejection"
111+
112+
ip link set dev $swp2 addr 00:11:22:33:44:55 &>/dev/null
113+
check_fail $? "Changing swp2's MAC address permitted"
114+
ip link set dev $swp2 addr 00:11:22:33:44:55 2>&1 >/dev/null \
115+
| grep -q mlxsw_spectrum
116+
check_err $? "no extack for bridge port MAC address change rejection"
117+
118+
log_test "RIF - attach port with bad MAC to bridge"
119+
120+
ip link del dev d
121+
ip link del dev br1
122+
ip addr del dev $swp1 192.0.2.1/28
123+
}
124+
125+
rif_non_inherit_bridge_addr_test()
126+
{
127+
local swp2_mac=$(mac_get $swp2)
128+
129+
RET=0
130+
131+
# Create first RIF
132+
ip addr add dev $swp1 192.0.2.1/28
133+
check_err $?
134+
135+
# Create a FID RIF
136+
ip link add name br1 up type bridge vlan_filtering 0
137+
ip link set dev br1 addr $swp2_mac
138+
ip link set dev $swp2 master br1
139+
ip addr add dev br1 192.0.2.17/28
140+
check_err $?
141+
142+
# Prepare a device with a low MAC address
143+
ip link add name d up type dummy
144+
ip link set dev d addr 00:11:22:33:44:55
145+
146+
# Attach the device to br1. Since the bridge address was set, it should
147+
# work.
148+
ip link set dev d master br1 &>/dev/null
149+
check_err $? "Could not attach a device with low MAC to a bridge with RIF"
150+
151+
# Port MAC address change should be allowed for a bridge with set MAC.
152+
ip link set dev $swp2 addr 00:11:22:33:44:55
153+
check_err $? "Changing swp2's MAC address not permitted"
154+
155+
log_test "RIF - attach port with bad MAC to bridge with set MAC"
156+
157+
ip link set dev $swp2 addr $swp2_mac
158+
ip link del dev d
159+
ip link del dev br1
160+
ip addr del dev $swp1 192.0.2.1/28
161+
}
162+
84163
trap cleanup EXIT
85164

86165
setup_prepare

0 commit comments

Comments
 (0)