Commit bbb774d9 authored by Benjamin Poirier's avatar Benjamin Poirier Committed by David S. Miller
Browse files

net: Add tests for bonding and team address list management



Test that the bonding and team drivers clean up an underlying device's
address lists (dev->uc, dev->mc) when the aggregated device is deleted.

Test addition and removal of the LACPDU multicast address on underlying
devices by the bonding driver.

v2:
* add lag_lib.sh to TEST_FILES

v3:
* extend bond_listen_lacpdu_multicast test to init_state up and down cases
* remove some superfluous shell syntax and 'set dev ... up' commands

Signed-off-by: default avatarBenjamin Poirier <bpoirier@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bd602342
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -19948,6 +19948,7 @@ S: Supported
F:	drivers/net/team/
F:	include/linux/if_team.h
F:	include/uapi/linux/if_team.h
F:	tools/testing/selftests/net/team/
TECHNOLOGIC SYSTEMS TS-5500 PLATFORM SUPPORT
M:	"Savoir-faire Linux Inc." <kernel@savoirfairelinux.com>
+1 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ TARGETS += damon
TARGETS += drivers/dma-buf
TARGETS += drivers/s390x/uvdevice
TARGETS += drivers/net/bonding
TARGETS += drivers/net/team
TARGETS += efivarfs
TARGETS += exec
TARGETS += filesystems
+4 −1
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0
# Makefile for net selftests

TEST_PROGS := bond-break-lacpdu-tx.sh
TEST_PROGS := bond-break-lacpdu-tx.sh \
	      dev_addr_lists.sh

TEST_FILES := lag_lib.sh

include ../../../lib.mk
+1 −0
Original line number Diff line number Diff line
CONFIG_BONDING=y
CONFIG_MACVLAN=y
+109 −0
Original line number Diff line number Diff line
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# Test bond device handling of addr lists (dev->uc, mc)
#

ALL_TESTS="
	bond_cleanup_mode1
	bond_cleanup_mode4
	bond_listen_lacpdu_multicast_case_down
	bond_listen_lacpdu_multicast_case_up
"

REQUIRE_MZ=no
NUM_NETIFS=0
lib_dir=$(dirname "$0")
source "$lib_dir"/../../../net/forwarding/lib.sh

source "$lib_dir"/lag_lib.sh


destroy()
{
	local ifnames=(dummy1 dummy2 bond1 mv0)
	local ifname

	for ifname in "${ifnames[@]}"; do
		ip link del "$ifname" &>/dev/null
	done
}

cleanup()
{
	pre_cleanup

	destroy
}


# bond driver control paths vary between modes that have a primary slave
# (bond_uses_primary()) and others. Test both kinds of modes.

bond_cleanup_mode1()
{
	RET=0

	test_LAG_cleanup "bonding" "active-backup"
}

bond_cleanup_mode4() {
	RET=0

	test_LAG_cleanup "bonding" "802.3ad"
}

bond_listen_lacpdu_multicast()
{
	# Initial state of bond device, up | down
	local init_state=$1
	local lacpdu_mc="01:80:c2:00:00:02"

	ip link add dummy1 type dummy
	ip link add bond1 "$init_state" type bond mode 802.3ad
	ip link set dev dummy1 master bond1
	if [ "$init_state" = "down" ]; then
		ip link set dev bond1 up
	fi

	grep_bridge_fdb "$lacpdu_mc" bridge fdb show brport dummy1 >/dev/null
	check_err $? "LACPDU multicast address not present on slave (1)"

	ip link set dev bond1 down

	not grep_bridge_fdb "$lacpdu_mc" bridge fdb show brport dummy1 >/dev/null
	check_err $? "LACPDU multicast address still present on slave"

	ip link set dev bond1 up

	grep_bridge_fdb "$lacpdu_mc" bridge fdb show brport dummy1 >/dev/null
	check_err $? "LACPDU multicast address not present on slave (2)"

	cleanup

	log_test "bonding LACPDU multicast address to slave (from bond $init_state)"
}

# The LACPDU mc addr is added by different paths depending on the initial state
# of the bond when enslaving a device. Test both cases.

bond_listen_lacpdu_multicast_case_down()
{
	RET=0

	bond_listen_lacpdu_multicast "down"
}

bond_listen_lacpdu_multicast_case_up()
{
	RET=0

	bond_listen_lacpdu_multicast "up"
}


trap cleanup EXIT

tests_run

exit "$EXIT_STATUS"
Loading