Commit 0a368a5c authored by David S. Miller's avatar David S. Miller

Merge branch 'selftests-mlxsw'

Petr Machata says:

====================
selftests: New selftests for out-of-order-operations patches in mlxsw

In the past, the mlxsw driver made the assumption that the user applies
configuration in a bottom-up manner. Thus netdevices needed to be added to
the bridge before IP addresses were configured on that bridge or SVI added
on top of it, because whatever happened before a netdevice was mlxsw upper
was generally ignored by mlxsw. Recently, several patch series were pushed
to introduce the bookkeeping and replays necessary to offload the full
state, not just the immediate configuration step.

In this patchset, introduce new selftests that directly exercise the out of
order code paths in mlxsw.

- Patch #1 adds new tests into the existing selftest router_bridge.sh.
- Patches #2-#5 add new generic selftests.
- Patches #6-#8 add new mlxsw-specific selftests.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 10857e67 67d5ffb9
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
lib_dir=$(dirname $0)/../../../net/forwarding
ALL_TESTS="
bridge_rif_add
bridge_rif_nomaster
bridge_rif_remaster
bridge_rif_nomaster_addr
bridge_rif_nomaster_port
bridge_rif_remaster_port
"
NUM_NETIFS=2
source $lib_dir/lib.sh
source $lib_dir/devlink_lib.sh
setup_prepare()
{
swp1=${NETIFS[p1]}
swp2=${NETIFS[p2]}
team_create lag1 lacp
ip link set dev lag1 addrgenmode none
ip link set dev lag1 address $(mac_get $swp1)
team_create lag2 lacp
ip link set dev lag2 addrgenmode none
ip link set dev lag2 address $(mac_get $swp2)
ip link add name br1 type bridge vlan_filtering 1
ip link set dev br1 addrgenmode none
ip link set dev br1 address $(mac_get lag1)
ip link set dev br1 up
ip link set dev lag1 master br1
ip link set dev $swp1 master lag1
ip link set dev $swp1 up
ip link set dev $swp2 master lag2
ip link set dev $swp2 up
}
cleanup()
{
pre_cleanup
ip link set dev $swp2 nomaster
ip link set dev $swp2 down
ip link set dev $swp1 nomaster
ip link set dev $swp1 down
ip link del dev lag2
ip link set dev lag1 nomaster
ip link del dev lag1
ip link del dev br1
}
bridge_rif_add()
{
RET=0
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
__addr_add_del br1 add 192.0.2.2/28
sleep 1
local rifs_occ_t1=$(devlink_resource_occ_get rifs)
local expected_rifs=$((rifs_occ_t0 + 1))
((expected_rifs == rifs_occ_t1))
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
log_test "Add RIF for bridge on address addition"
}
bridge_rif_nomaster()
{
RET=0
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
ip link set dev lag1 nomaster
sleep 1
local rifs_occ_t1=$(devlink_resource_occ_get rifs)
local expected_rifs=$((rifs_occ_t0 - 1))
((expected_rifs == rifs_occ_t1))
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
log_test "Drop RIF for bridge on LAG deslavement"
}
bridge_rif_remaster()
{
RET=0
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
ip link set dev lag1 master br1
sleep 1
local rifs_occ_t1=$(devlink_resource_occ_get rifs)
local expected_rifs=$((rifs_occ_t0 + 1))
((expected_rifs == rifs_occ_t1))
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
log_test "Add RIF for bridge on LAG reenslavement"
}
bridge_rif_nomaster_addr()
{
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
# Adding an address while the LAG is enslaved shouldn't generate a RIF.
__addr_add_del lag1 add 192.0.2.65/28
sleep 1
local rifs_occ_t1=$(devlink_resource_occ_get rifs)
local expected_rifs=$((rifs_occ_t0))
((expected_rifs == rifs_occ_t1))
check_err $? "After adding IP: Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
# Removing the LAG from the bridge should drop RIF for the bridge (as
# tested in bridge_rif_lag_nomaster), but since the LAG now has an
# address, it should gain a RIF.
ip link set dev lag1 nomaster
sleep 1
local rifs_occ_t2=$(devlink_resource_occ_get rifs)
local expected_rifs=$((rifs_occ_t0))
((expected_rifs == rifs_occ_t2))
check_err $? "After deslaving: Expected $expected_rifs RIFs, $rifs_occ_t2 are used"
log_test "Add RIF for LAG on deslavement from bridge"
__addr_add_del lag1 del 192.0.2.65/28
ip link set dev lag1 master br1
sleep 1
}
bridge_rif_nomaster_port()
{
RET=0
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
ip link set dev $swp1 nomaster
sleep 1
local rifs_occ_t1=$(devlink_resource_occ_get rifs)
local expected_rifs=$((rifs_occ_t0 - 1))
((expected_rifs == rifs_occ_t1))
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
log_test "Drop RIF for bridge on deslavement of port from LAG"
}
bridge_rif_remaster_port()
{
RET=0
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
ip link set dev $swp1 down
ip link set dev $swp1 master lag1
ip link set dev $swp1 up
setup_wait_dev $swp1
local rifs_occ_t1=$(devlink_resource_occ_get rifs)
local expected_rifs=$((rifs_occ_t0 + 1))
((expected_rifs == rifs_occ_t1))
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
log_test "Add RIF for bridge on reenslavement of port to LAG"
}
trap cleanup EXIT
setup_prepare
setup_wait
tests_run
exit $EXIT_STATUS
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
lib_dir=$(dirname $0)/../../../net/forwarding
ALL_TESTS="
lag_rif_add
lag_rif_nomaster
lag_rif_remaster
lag_rif_nomaster_addr
"
NUM_NETIFS=2
source $lib_dir/lib.sh
source $lib_dir/devlink_lib.sh
setup_prepare()
{
swp1=${NETIFS[p1]}
swp2=${NETIFS[p2]}
team_create lag1 lacp
ip link set dev lag1 addrgenmode none
ip link set dev lag1 address $(mac_get $swp1)
team_create lag2 lacp
ip link set dev lag2 addrgenmode none
ip link set dev lag2 address $(mac_get $swp2)
ip link set dev $swp1 master lag1
ip link set dev $swp1 up
ip link set dev $swp2 master lag2
ip link set dev $swp2 up
}
cleanup()
{
pre_cleanup
ip link set dev $swp2 nomaster
ip link set dev $swp2 down
ip link set dev $swp1 nomaster
ip link set dev $swp1 down
ip link del dev lag2
ip link del dev lag1
}
lag_rif_add()
{
RET=0
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
__addr_add_del lag1 add 192.0.2.2/28
sleep 1
local rifs_occ_t1=$(devlink_resource_occ_get rifs)
local expected_rifs=$((rifs_occ_t0 + 1))
((expected_rifs == rifs_occ_t1))
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
log_test "Add RIF for LAG on address addition"
}
lag_rif_nomaster()
{
RET=0
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
ip link set dev $swp1 nomaster
sleep 1
local rifs_occ_t1=$(devlink_resource_occ_get rifs)
local expected_rifs=$((rifs_occ_t0 - 1))
((expected_rifs == rifs_occ_t1))
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
log_test "Drop RIF for LAG on port deslavement"
}
lag_rif_remaster()
{
RET=0
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
ip link set dev $swp1 down
ip link set dev $swp1 master lag1
ip link set dev $swp1 up
setup_wait_dev $swp1
local rifs_occ_t1=$(devlink_resource_occ_get rifs)
local expected_rifs=$((rifs_occ_t0 + 1))
((expected_rifs == rifs_occ_t1))
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
log_test "Add RIF for LAG on port reenslavement"
}
lag_rif_nomaster_addr()
{
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
# Adding an address while the port is LAG'd shouldn't generate a RIF.
__addr_add_del $swp1 add 192.0.2.65/28
sleep 1
local rifs_occ_t1=$(devlink_resource_occ_get rifs)
local expected_rifs=$((rifs_occ_t0))
((expected_rifs == rifs_occ_t1))
check_err $? "After adding IP: Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
# Removing the port from LAG should drop RIF for the LAG (as tested in
# lag_rif_nomaster), but since the port now has an address, it should
# gain a RIF.
ip link set dev $swp1 nomaster
sleep 1
local rifs_occ_t2=$(devlink_resource_occ_get rifs)
local expected_rifs=$((rifs_occ_t0))
((expected_rifs == rifs_occ_t2))
check_err $? "After deslaving: Expected $expected_rifs RIFs, $rifs_occ_t2 are used"
__addr_add_del $swp1 del 192.0.2.65/28
log_test "Add RIF for port on deslavement from LAG"
}
trap cleanup EXIT
setup_prepare
setup_wait
tests_run
exit $EXIT_STATUS
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
lib_dir=$(dirname $0)/../../../net/forwarding
ALL_TESTS="
lag_rif_add
lag_rif_nomaster
lag_rif_remaster
lag_rif_nomaster_addr
"
NUM_NETIFS=2
source $lib_dir/lib.sh
source $lib_dir/devlink_lib.sh
setup_prepare()
{
swp1=${NETIFS[p1]}
swp2=${NETIFS[p2]}
team_create lag1 lacp
ip link set dev lag1 addrgenmode none
ip link set dev lag1 address $(mac_get $swp1)
team_create lag2 lacp
ip link set dev lag2 addrgenmode none
ip link set dev lag2 address $(mac_get $swp2)
ip link set dev $swp1 master lag1
ip link set dev $swp1 up
ip link set dev $swp2 master lag2
ip link set dev $swp2 up
vlan_create lag1 100
ip link set dev lag1.100 addrgenmode none
vlan_create lag1 200
ip link set dev lag1.200 addrgenmode none
}
cleanup()
{
pre_cleanup
ip link del dev lag1.200
ip link del dev lag1.100
ip link set dev $swp2 nomaster
ip link set dev $swp2 down
ip link set dev $swp1 nomaster
ip link set dev $swp1 down
ip link del dev lag2
ip link del dev lag1
}
lag_rif_add()
{
RET=0
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
__addr_add_del lag1.100 add 192.0.2.2/28
__addr_add_del lag1.200 add 192.0.2.18/28
sleep 1
local rifs_occ_t1=$(devlink_resource_occ_get rifs)
local expected_rifs=$((rifs_occ_t0 + 2))
((expected_rifs == rifs_occ_t1))
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
log_test "Add RIFs for LAG VLANs on address addition"
}
lag_rif_nomaster()
{
RET=0
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
ip link set dev $swp1 nomaster
sleep 1
local rifs_occ_t1=$(devlink_resource_occ_get rifs)
local expected_rifs=$((rifs_occ_t0 - 2))
((expected_rifs == rifs_occ_t1))
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
log_test "Drop RIFs for LAG VLANs on port deslavement"
}
lag_rif_remaster()
{
RET=0
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
ip link set dev $swp1 down
ip link set dev $swp1 master lag1
ip link set dev $swp1 up
setup_wait_dev $swp1
local rifs_occ_t1=$(devlink_resource_occ_get rifs)
local expected_rifs=$((rifs_occ_t0 + 2))
((expected_rifs == rifs_occ_t1))
check_err $? "Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
log_test "Add RIFs for LAG VLANs on port reenslavement"
}
lag_rif_nomaster_addr()
{
local rifs_occ_t0=$(devlink_resource_occ_get rifs)
# Adding an address while the port is LAG'd shouldn't generate a RIF.
__addr_add_del $swp1 add 192.0.2.65/28
sleep 1
local rifs_occ_t1=$(devlink_resource_occ_get rifs)
local expected_rifs=$((rifs_occ_t0))
((expected_rifs == rifs_occ_t1))
check_err $? "After adding IP: Expected $expected_rifs RIFs, $rifs_occ_t1 are used"
# Removing the port from LAG should drop two RIFs for the LAG VLANs (as
# tested in lag_rif_nomaster), but since the port now has an address, it
# should gain a RIF.
ip link set dev $swp1 nomaster
sleep 1
local rifs_occ_t2=$(devlink_resource_occ_get rifs)
local expected_rifs=$((rifs_occ_t0 - 1))
((expected_rifs == rifs_occ_t2))
check_err $? "After deslaving: Expected $expected_rifs RIFs, $rifs_occ_t2 are used"
__addr_add_del $swp1 del 192.0.2.65/28
log_test "Add RIF for port on deslavement from LAG"
}
trap cleanup EXIT
setup_prepare
setup_wait
tests_run
exit $EXIT_STATUS
......@@ -64,7 +64,11 @@ TEST_PROGS = bridge_igmp.sh \
q_in_vni_ipv6.sh \
q_in_vni.sh \
router_bridge.sh \
router_bridge_1d.sh \
router_bridge_1d_lag.sh \
router_bridge_lag.sh \
router_bridge_vlan.sh \
router_bridge_vlan_upper.sh \
router_bridge_pvid_vlan_upper.sh \
router_bridge_vlan_upper_pvid.sh \
router_broadcast.sh \
......
......@@ -20,6 +20,9 @@
# +---------------------------------------------------------------------------+
ALL_TESTS="
ping_ipv4
ping_ipv6
config_remaster
ping_ipv4
ping_ipv6
config_remove_pvid
......@@ -28,6 +31,9 @@ ALL_TESTS="
config_add_pvid
ping_ipv4
ping_ipv6
config_late_pvid
ping_ipv4
ping_ipv6
"
NUM_NETIFS=4
source lib.sh
......@@ -86,6 +92,15 @@ router_destroy()
ip link del dev br1
}
config_remaster()
{
log_info "Remaster bridge slave"
ip link set dev $swp1 nomaster
sleep 2
ip link set dev $swp1 master br1
}
config_remove_pvid()
{
log_info "Remove PVID from the bridge"
......@@ -102,6 +117,17 @@ config_add_pvid()
sleep 2
}
config_late_pvid()
{
log_info "Add bridge PVID after enslaving port"
ip link set dev $swp1 nomaster
ip link set dev br1 type bridge vlan_default_pvid 0
sleep 2
ip link set dev $swp1 master br1
ip link set dev br1 type bridge vlan_default_pvid 1
}
setup_prepare()
{
h1=${NETIFS[p1]}
......
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# +---------------------------------------------+ +----------------------+
# | H1 (vrf) | | H2 (vrf) |
# | + $h1.100 + $h1.200 | | + $h2 |
# | | 192.0.2.1/28 | 192.0.2.17/28 | | | 192.0.2.130/28 |
# | | 2001:db8:1::1/64 | 2001:db8:3::1/64 | | | 192.0.2.146/28 |
# | \_________ __________/ | | | 2001:db8:2::2/64 |
# | V | | | 2001:db8:4::2/64 |
# | + $h1 | | | |
# +--------------|------------------------------+ +--|-------------------+
# | |
# +--------------|----------------------------------------|-------------------+
# | SW + $swp1 + $swp2 |
# | | 192.0.2.129/28 |
# | | 192.0.2.145/28 |
# | | 2001:db8:2::1/64 |
# | ________^___________________________ 2001:db8:4::1/64 |
# | / \ |
# | +---|------------------------------+ +---|------------------------------+ |
# | | + $swp1.100 BR1 (802.1d) | | + $swp1.200 BR2 (802.1d) | |
# | | 192.0.2.2/28 | | 192.0.2.18/28 | |
# | | 2001:db8:1::2/64 | | 2001:db8:3::2/64 | |
# | | | | | |
# | +----------------------------------+ +----------------------------------+ |
# +---------------------------------------------------------------------------+
ALL_TESTS="
ping_ipv4
ping_ipv6
config_remaster
ping_ipv4
ping_ipv6
"
NUM_NETIFS=4
source lib.sh
h1_create()
{
simple_if_init $h1
vlan_create $h1 100 v$h1 192.0.2.1/28 2001:db8:1::1/64
vlan_create $h1 200 v$h1 192.0.2.17/28 2001:db8:3::1/64
ip -4 route add 192.0.2.128/28 vrf v$h1 nexthop via 192.0.2.2
ip -4 route add 192.0.2.144/28 vrf v$h1 nexthop via 192.0.2.18
ip -6 route add 2001:db8:2::/64 vrf v$h1 nexthop via 2001:db8:1::2
ip -6 route add 2001:db8:4::/64 vrf v$h1 nexthop via 2001:db8:3::2
}
h1_destroy()
{
ip -6 route del 2001:db8:4::/64 vrf v$h1
ip -6 route del 2001:db8:2::/64 vrf v$h1
ip -4 route del 192.0.2.144/28 vrf v$h1
ip -4 route del 192.0.2.128/28 vrf v$h1
vlan_destroy $h1 200
vlan_destroy $h1 100
simple_if_fini $h1
}
h2_create()
{
simple_if_init $h2 192.0.2.130/28 2001:db8:2::2/64 \
192.0.2.146/28 2001:db8:4::2/64
ip -4 route add 192.0.2.0/28 vrf v$h2 nexthop via 192.0.2.129
ip -4 route add 192.0.2.16/28 vrf v$h2 nexthop via 192.0.2.145
ip -6 route add 2001:db8:1::/64 vrf v$h2 nexthop via 2001:db8:2::1
ip -6 route add 2001:db8:3::/64 vrf v$h2 nexthop via 2001:db8:4::1
}
h2_destroy()
{
ip -6 route del 2001:db8:3::/64 vrf v$h2
ip -6 route del 2001:db8:1::/64 vrf v$h2
ip -4 route del 192.0.2.16/28 vrf v$h2
ip -4 route del 192.0.2.0/28 vrf v$h2
simple_if_fini $h2 192.0.2.130/28 2001:db8:2::2/64 \
192.0.2.146/28 2001:db8:4::2/64
}
router_create()
{
ip link set dev $swp1 up
vlan_create $swp1 100
ip link add name br1 type bridge vlan_filtering 0
ip link set dev br1 address $(mac_get $swp1.100)
ip link set dev $swp1.100 master br1
__addr_add_del br1 add 192.0.2.2/28 2001:db8:1::2/64
ip link set dev br1 up
vlan_create $swp1 200
ip link add name br2 type bridge vlan_filtering 0
ip link set dev br2 address $(mac_get $swp1.200)
ip link set dev $swp1.200 master br2
__addr_add_del br2 add 192.0.2.18/28 2001:db8:3::2/64
ip link set dev br2 up
ip link set dev $swp2 up
__addr_add_del $swp2 add 192.0.2.129/28 2001:db8:2::1/64 \
192.0.2.145/28 2001:db8:4::1/64
}
router_destroy()
{
__addr_add_del $swp2 del 192.0.2.129/28 2001:db8:2::1/64 \
192.0.2.145/28 2001:db8:4::1/64
ip link set dev $swp2 down
__addr_add_del br2 del 192.0.2.18/28 2001:db8:3::2/64
ip link set dev $swp1.200 nomaster
ip link del dev br2
vlan_destroy $swp1 200
__addr_add_del br1 del 192.0.2.2/28 2001:db8:1::2/64
ip link set dev $swp1.100 nomaster
ip link del dev br1
vlan_destroy $swp1 100
ip link set dev $swp1 down
}
config_remaster()
{
log_info "Remaster bridge slaves"
ip link set dev $swp1.100 nomaster
ip link set dev $swp1.200 nomaster
sleep 2
ip link set dev $swp1.200 master br2
ip link set dev $swp1.100 master br1
}
setup_prepare()
{
h1=${NETIFS[p1]}
swp1=${NETIFS[p2]}
swp2=${NETIFS[p3]}
h2=${NETIFS[p4]}
vrf_prepare
h1_create
h2_create
router_create
forwarding_enable
}
cleanup()
{
pre_cleanup
forwarding_restore
router_destroy
h2_destroy
h1_destroy
vrf_cleanup
}
ping_ipv4()
{
ping_test $h1 192.0.2.130 ": via 100"
ping_test $h1 192.0.2.146 ": via 200"
}
ping_ipv6()
{
ping6_test $h1 2001:db8:2::2 ": via 100"
ping6_test $h1 2001:db8:4::2 ": via 200"
}
trap cleanup EXIT
setup_prepare
setup_wait
tests_run
exit $EXIT_STATUS
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# +--------------------------------------------+
# | H1 (vrf) |
# | |
# | + LAG1.100 + LAG1.200 |
# | | 192.0.2.1/28 | 192.0.2.17/28 |
# | | 2001:db8:1::1/64 | 2001:db8:3:1/64 |
# | \___________ _______/ |
# | v |
# | + LAG1 (team) |
# | | |
# | ____^____ |
# | / \ |
# | + $h1 + $h4 |
# | | | |
# +----------|-----------|---------------------+
# | |
# +----------|-----------|---------------------+
# | SW | | |
# | + $swp1 + $swp4 |
# | \____ ____/ |
# | v |
# | LAG2 (team) + |
# | | |
# | _______^______________ |
# | / \ |
# | +------|------------+ +-------|----------+ |
# | | + LAG2.100 | | + LAG2.200 | |
# | | | | | |
# | | BR1 (802.1d) | | BR2 (802.1d) | |
# | | 192.0.2.2/28 | | 192.0.2.18/28 | |
# | | 2001:db8:1::2/64 | | 2001:db8:3:2/64 | |
# | | | | | |
# | +-------------------+ +------------------+ |
# | |
# | + LAG3.100 + LAG3.200 |
# | | 192.0.2.129/28 | 192.0.2.145/28 |
# | | 2001:db8:2::1/64 | 2001:db8:4::1/64 |
# | | | |
# | \_________ ___________/ |
# | v |
# | + LAG3 (team) |
# | ____|____ |
# | / \ |
# | + $swp2 + $swp3 |
# | | | |
# +-------|---------|--------------------------+
# | |
# +-------|---------|--------------------------+
# | | | |
# | + $h2 + $h3 |
# | \____ ___/ |
# | | |
# | + LAG4 (team) |
# | | |
# | __________^__________ |
# | / \ |
# | | | |
# | + LAG4.100 + LAG4.200 |
# | 192.0.2.130/28 192.0.2.146/28 |
# | 2001:db8:2::2/64 2001:db8:4::2/64 |
# | |
# | H2 (vrf) |
# +--------------------------------------------+
ALL_TESTS="
ping_ipv4
ping_ipv6
$(: exercise remastering of LAG2 slaves )
config_deslave_swp4
config_wait
ping_ipv4
ping_ipv6
config_enslave_swp4
config_deslave_swp1
config_wait
ping_ipv4
ping_ipv6
config_deslave_swp4
config_enslave_swp1
config_enslave_swp4
config_wait
ping_ipv4
ping_ipv6
$(: exercise remastering of LAG2 itself )
config_remaster_lag2
config_wait
ping_ipv4
ping_ipv6
$(: exercise remastering of LAG3 slaves )
config_deslave_swp2
config_wait
ping_ipv4
ping_ipv6
config_enslave_swp2
config_deslave_swp3
config_wait
ping_ipv4
ping_ipv6
config_deslave_swp2
config_enslave_swp3
config_enslave_swp2
config_wait
ping_ipv4
ping_ipv6
"
NUM_NETIFS=8
source lib.sh
h1_create()
{
team_create lag1 lacp
ip link set dev lag1 addrgenmode none
ip link set dev lag1 address $(mac_get $h1)
ip link set dev $h1 master lag1
ip link set dev $h4 master lag1
simple_if_init lag1
ip link set dev $h1 up
ip link set dev $h4 up
vlan_create lag1 100 vlag1 192.0.2.1/28 2001:db8:1::1/64
vlan_create lag1 200 vlag1 192.0.2.17/28 2001:db8:3::1/64
ip -4 route add 192.0.2.128/28 vrf vlag1 nexthop via 192.0.2.2
ip -6 route add 2001:db8:2::/64 vrf vlag1 nexthop via 2001:db8:1::2
ip -4 route add 192.0.2.144/28 vrf vlag1 nexthop via 192.0.2.18
ip -6 route add 2001:db8:4::/64 vrf vlag1 nexthop via 2001:db8:3::2
}
h1_destroy()
{
ip -6 route del 2001:db8:4::/64 vrf vlag1
ip -4 route del 192.0.2.144/28 vrf vlag1
ip -6 route del 2001:db8:2::/64 vrf vlag1
ip -4 route del 192.0.2.128/28 vrf vlag1
vlan_destroy lag1 200
vlan_destroy lag1 100
ip link set dev $h4 down
ip link set dev $h1 down
simple_if_fini lag1
ip link set dev $h4 nomaster
ip link set dev $h1 nomaster
team_destroy lag1
}
h2_create()
{
team_create lag4 lacp
ip link set dev lag4 addrgenmode none
ip link set dev lag4 address $(mac_get $h2)
ip link set dev $h2 master lag4
ip link set dev $h3 master lag4
simple_if_init lag4
ip link set dev $h2 up
ip link set dev $h3 up
vlan_create lag4 100 vlag4 192.0.2.130/28 2001:db8:2::2/64
vlan_create lag4 200 vlag4 192.0.2.146/28 2001:db8:4::2/64
ip -4 route add 192.0.2.0/28 vrf vlag4 nexthop via 192.0.2.129
ip -6 route add 2001:db8:1::/64 vrf vlag4 nexthop via 2001:db8:2::1
ip -4 route add 192.0.2.16/28 vrf vlag4 nexthop via 192.0.2.145
ip -6 route add 2001:db8:3::/64 vrf vlag4 nexthop via 2001:db8:4::1
}
h2_destroy()
{
ip -6 route del 2001:db8:3::/64 vrf vlag4
ip -4 route del 192.0.2.16/28 vrf vlag4
ip -6 route del 2001:db8:1::/64 vrf vlag4
ip -4 route del 192.0.2.0/28 vrf vlag4
vlan_destroy lag4 200
vlan_destroy lag4 100
ip link set dev $h3 down
ip link set dev $h2 down
simple_if_fini lag4
ip link set dev $h3 nomaster
ip link set dev $h2 nomaster
team_destroy lag4
}
router_create()
{
team_create lag2 lacp
ip link set dev lag2 addrgenmode none
ip link set dev lag2 address $(mac_get $swp1)
ip link set dev $swp1 master lag2
ip link set dev $swp4 master lag2
vlan_create lag2 100
vlan_create lag2 200
ip link add name br1 type bridge vlan_filtering 0
ip link set dev br1 address $(mac_get lag2.100)
ip link set dev lag2.100 master br1
ip link add name br2 type bridge vlan_filtering 0
ip link set dev br2 address $(mac_get lag2.200)
ip link set dev lag2.200 master br2
ip link set dev $swp1 up
ip link set dev $swp4 up
ip link set dev br1 up
ip link set dev br2 up
__addr_add_del br1 add 192.0.2.2/28 2001:db8:1::2/64
__addr_add_del br2 add 192.0.2.18/28 2001:db8:3::2/64
team_create lag3 lacp
ip link set dev lag3 addrgenmode none
ip link set dev lag3 address $(mac_get $swp2)
ip link set dev $swp2 master lag3
ip link set dev $swp3 master lag3
ip link set dev $swp2 up
ip link set dev $swp3 up
vlan_create lag3 100
vlan_create lag3 200
__addr_add_del lag3.100 add 192.0.2.129/28 2001:db8:2::1/64
__addr_add_del lag3.200 add 192.0.2.145/28 2001:db8:4::1/64
}
router_destroy()
{
__addr_add_del lag3.200 del 192.0.2.145/28 2001:db8:4::1/64
__addr_add_del lag3.100 del 192.0.2.129/28 2001:db8:2::1/64
vlan_destroy lag3 200
vlan_destroy lag3 100
ip link set dev $swp3 down
ip link set dev $swp2 down
ip link set dev $swp3 nomaster
ip link set dev $swp2 nomaster
team_destroy lag3
__addr_add_del br2 del 192.0.2.18/28 2001:db8:3::2/64
__addr_add_del br1 del 192.0.2.2/28 2001:db8:1::2/64
ip link set dev br2 down
ip link set dev br1 down
ip link set dev $swp4 down
ip link set dev $swp1 down
ip link set dev lag2.200 nomaster
ip link del dev br2
ip link set dev lag2.100 nomaster
ip link del dev br1
vlan_destroy lag2 200
vlan_destroy lag2 100
ip link set dev $swp4 nomaster
ip link set dev $swp1 nomaster
team_destroy lag2
}
config_remaster_lag2()
{
log_info "Remaster bridge slaves"
ip link set dev lag2.200 nomaster
ip link set dev lag2.100 nomaster
sleep 2
ip link set dev lag2.100 master br1
ip link set dev lag2.200 master br2
}
config_deslave()
{
local netdev=$1; shift
log_info "Deslave $netdev"
ip link set dev $netdev down
ip link set dev $netdev nomaster
ip link set dev $netdev up
}
config_deslave_swp1()
{
config_deslave $swp1
}
config_deslave_swp2()
{
config_deslave $swp2
}
config_deslave_swp3()
{
config_deslave $swp3
}
config_deslave_swp4()
{
config_deslave $swp4
}
config_enslave()
{
local netdev=$1; shift
local master=$1; shift
log_info "Enslave $netdev to $master"
ip link set dev $netdev down
ip link set dev $netdev master $master
ip link set dev $netdev up
}
config_enslave_swp1()
{
config_enslave $swp1 lag2
}
config_enslave_swp2()
{
config_enslave $swp2 lag3
}
config_enslave_swp3()
{
config_enslave $swp3 lag3
}
config_enslave_swp4()
{
config_enslave $swp4 lag2
}
config_wait()
{
setup_wait_dev lag2
setup_wait_dev lag3
}
setup_prepare()
{
h1=${NETIFS[p1]}
swp1=${NETIFS[p2]}
swp2=${NETIFS[p3]}
h2=${NETIFS[p4]}
swp3=${NETIFS[p5]}
h3=${NETIFS[p6]}
h4=${NETIFS[p7]}
swp4=${NETIFS[p8]}
vrf_prepare
h1_create
h2_create
router_create
forwarding_enable
}
cleanup()
{
pre_cleanup
forwarding_restore
router_destroy
h2_destroy
h1_destroy
vrf_cleanup
}
ping_ipv4()
{
ping_test lag1.100 192.0.2.130 ": via 100"
ping_test lag1.200 192.0.2.146 ": via 200"
}
ping_ipv6()
{
ping6_test lag1.100 2001:db8:2::2 ": via 100"
ping6_test lag1.200 2001:db8:4::2 ": via 200"
}
trap cleanup EXIT
setup_prepare
setup_wait
tests_run
exit $EXIT_STATUS
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# +----------------------------+ +--------------------------+
# | H1 (vrf) | | H2 (vrf) |
# | | | |
# | + LAG1 (team) | | + LAG4 (team) |
# | | 192.0.2.1/28 | | | 192.0.2.130/28 |
# | | 2001:db8:1::1/64 | | | 2001:db8:2::2/64 |
# | __^___ | | __^_____ |
# | / \ | | / \ |
# | + $h1 + $h4 | | + $h2 + $h3 |
# | | | | | | | |
# +----|--------|--------------+ +-|----------|-------------+
# | | | |
# +----|--------|------------------------------------|----------|-------------+
# | SW | | | | |
# | + $swp1 + $swp4 + $swp2 + $swp3 |
# | \__ ___/ \__ _____/ |
# | v v |
# | +------|-------------------------------+ | |
# | | + LAG2 BR1 (802.1q) | + LAG3 (team) |
# | | (team) 192.0.2.2/28 | 192.0.2.129/28 |
# | | 2001:db8:1::2/64 | 2001:db8:2::1/64 |
# | | | |
# | +--------------------------------------+ |
# +---------------------------------------------------------------------------+
: ${ALL_TESTS:="
ping_ipv4
ping_ipv6
$(: exercise remastering of LAG2 slaves )
config_deslave_swp4
config_wait
ping_ipv4
ping_ipv6
config_enslave_swp4
config_deslave_swp1
config_wait
ping_ipv4
ping_ipv6
config_deslave_swp4
config_enslave_swp1
config_enslave_swp4
config_wait
ping_ipv4
ping_ipv6
$(: exercise remastering of LAG2 itself )
config_remaster_lag2
config_wait
ping_ipv4
ping_ipv6
$(: exercise remastering of LAG3 slaves )
config_deslave_swp2
config_wait
ping_ipv4
ping_ipv6
config_enslave_swp2
config_deslave_swp3
config_wait
ping_ipv4
ping_ipv6
config_deslave_swp2
config_enslave_swp3
config_enslave_swp2
config_wait
ping_ipv4
ping_ipv6
$(: move LAG3 to a bridge and then out )
config_remaster_lag3
config_wait
ping_ipv4
ping_ipv6
"}
NUM_NETIFS=8
: ${lib_dir:=.}
source $lib_dir/lib.sh
$EXTRA_SOURCE
h1_create()
{
team_create lag1 lacp
ip link set dev lag1 address $(mac_get $h1)
ip link set dev $h1 master lag1
ip link set dev $h4 master lag1
simple_if_init lag1 192.0.2.1/28 2001:db8:1::1/64
ip link set dev $h1 up
ip link set dev $h4 up
ip -4 route add 192.0.2.128/28 vrf vlag1 nexthop via 192.0.2.2
ip -6 route add 2001:db8:2::/64 vrf vlag1 nexthop via 2001:db8:1::2
}
h1_destroy()
{
ip -6 route del 2001:db8:2::/64 vrf vlag1
ip -4 route del 192.0.2.128/28 vrf vlag1
ip link set dev $h4 down
ip link set dev $h1 down
simple_if_fini lag1 192.0.2.1/28 2001:db8:1::1/64
ip link set dev $h4 nomaster
ip link set dev $h1 nomaster
team_destroy lag1
}
h2_create()
{
team_create lag4 lacp
ip link set dev lag4 address $(mac_get $h2)
ip link set dev $h2 master lag4
ip link set dev $h3 master lag4
simple_if_init lag4 192.0.2.130/28 2001:db8:2::2/64
ip link set dev $h2 up
ip link set dev $h3 up
ip -4 route add 192.0.2.0/28 vrf vlag4 nexthop via 192.0.2.129
ip -6 route add 2001:db8:1::/64 vrf vlag4 nexthop via 2001:db8:2::1
}
h2_destroy()
{
ip -6 route del 2001:db8:1::/64 vrf vlag4
ip -4 route del 192.0.2.0/28 vrf vlag4
ip link set dev $h3 down
ip link set dev $h2 down
simple_if_fini lag4 192.0.2.130/28 2001:db8:2::2/64
ip link set dev $h3 nomaster
ip link set dev $h2 nomaster
team_destroy lag4
}
router_create()
{
team_create lag2 lacp
ip link set dev lag2 address $(mac_get $swp1)
ip link set dev $swp1 master lag2
ip link set dev $swp4 master lag2
ip link add name br1 address $(mac_get lag2) \
type bridge vlan_filtering 1
ip link set dev lag2 master br1
ip link set dev $swp1 up
ip link set dev $swp4 up
ip link set dev br1 up
__addr_add_del br1 add 192.0.2.2/28 2001:db8:1::2/64
team_create lag3 lacp
ip link set dev lag3 address $(mac_get $swp2)
ip link set dev $swp2 master lag3
ip link set dev $swp3 master lag3
ip link set dev $swp2 up
ip link set dev $swp3 up
__addr_add_del lag3 add 192.0.2.129/28 2001:db8:2::1/64
}
router_destroy()
{
__addr_add_del lag3 del 192.0.2.129/28 2001:db8:2::1/64
ip link set dev $swp3 down
ip link set dev $swp2 down
ip link set dev $swp3 nomaster
ip link set dev $swp2 nomaster
team_destroy lag3
__addr_add_del br1 del 192.0.2.2/28 2001:db8:1::2/64
ip link set dev $swp4 down
ip link set dev $swp1 down
ip link set dev br1 down
ip link set dev lag2 nomaster
ip link del dev br1
ip link set dev $swp4 nomaster
ip link set dev $swp1 nomaster
team_destroy lag2
}
config_remaster_lag2()
{
log_info "Remaster bridge slave"
ip link set dev lag2 nomaster
sleep 2
ip link set dev lag2 master br1
}
config_remaster_lag3()
{
log_info "Move lag3 to the bridge, then out again"
ip link set dev lag3 master br1
sleep 2
ip link set dev lag3 nomaster
}
config_deslave()
{
local netdev=$1; shift
log_info "Deslave $netdev"
ip link set dev $netdev down
ip link set dev $netdev nomaster
ip link set dev $netdev up
}
config_deslave_swp1()
{
config_deslave $swp1
}
config_deslave_swp2()
{
config_deslave $swp2
}
config_deslave_swp3()
{
config_deslave $swp3
}
config_deslave_swp4()
{
config_deslave $swp4
}
config_enslave()
{
local netdev=$1; shift
local master=$1; shift
log_info "Enslave $netdev to $master"
ip link set dev $netdev down
ip link set dev $netdev master $master
ip link set dev $netdev up
}
config_enslave_swp1()
{
config_enslave $swp1 lag2
}
config_enslave_swp2()
{
config_enslave $swp2 lag3
}
config_enslave_swp3()
{
config_enslave $swp3 lag3
}
config_enslave_swp4()
{
config_enslave $swp4 lag2
}
config_wait()
{
setup_wait_dev lag2
setup_wait_dev lag3
}
setup_prepare()
{
h1=${NETIFS[p1]}
swp1=${NETIFS[p2]}
swp2=${NETIFS[p3]}
h2=${NETIFS[p4]}
swp3=${NETIFS[p5]}
h3=${NETIFS[p6]}
h4=${NETIFS[p7]}
swp4=${NETIFS[p8]}
vrf_prepare
h1_create
h2_create
router_create
forwarding_enable
}
cleanup()
{
pre_cleanup
forwarding_restore
router_destroy
h2_destroy
h1_destroy
vrf_cleanup
}
ping_ipv4()
{
ping_test lag1 192.0.2.130
}
ping_ipv6()
{
ping6_test lag1 2001:db8:2::2
}
trap cleanup EXIT
setup_prepare
setup_wait
tests_run
exit $EXIT_STATUS
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# +------------------------+ +----------------------+
# | H1 (vrf) | | H2 (vrf) |
# | + $h1.555 | | + $h2.777 |
# | | 192.0.2.1/28 | | | 192.0.2.18/28 |
# | | 2001:db8:1::1/64 | | | 2001:db8:2::2/64 |
# | | | | | |
# | + $h1 | | + $h2 |
# +----|-------------------+ +--|-------------------+
# | |
# +----|--------------------------------------------------|-------------------+
# | SW | | |
# | +--|--------------------------------------------------|-----------------+ |
# | | + $swp1 BR1 (802.1q) + $swp2 | |
# | | | |
# | +------+------------------------------------------+---------------------+ |
# | | | |
# | + br1.555 + br1.777 |
# | 192.0.2.2/28 192.0.2.17/28 |
# | 2001:db8:1::2/64 2001:db8:2::1/64 |
# +---------------------------------------------------------------------------+
ALL_TESTS="
ping_ipv4
ping_ipv6
respin_config
ping_ipv4
ping_ipv6
"
NUM_NETIFS=4
source lib.sh
h1_create()
{
simple_if_init $h1
vlan_create $h1 555 v$h1 192.0.2.1/28 2001:db8:1::1/64
ip -4 route add 192.0.2.16/28 vrf v$h1 nexthop via 192.0.2.2
ip -6 route add 2001:db8:2::/64 vrf v$h1 nexthop via 2001:db8:1::2
}
h1_destroy()
{
ip -6 route del 2001:db8:2::/64 vrf v$h1
ip -4 route del 192.0.2.16/28 vrf v$h1
vlan_destroy $h1 555
simple_if_fini $h1
}
h2_create()
{
simple_if_init $h2
vlan_create $h2 777 v$h2 192.0.2.18/28 2001:db8:2::2/64
ip -4 route add 192.0.2.0/28 vrf v$h2 nexthop via 192.0.2.17
ip -6 route add 2001:db8:1::/64 vrf v$h2 nexthop via 2001:db8:2::1
}
h2_destroy()
{
ip -6 route del 2001:db8:1::/64 vrf v$h2
ip -4 route del 192.0.2.0/28 vrf v$h2
vlan_destroy $h2 777
simple_if_fini $h2
}
router_create()
{
ip link add name br1 address $(mac_get $swp1) \
type bridge vlan_filtering 1
ip link set dev br1 up
ip link set dev $swp1 master br1
ip link set dev $swp2 master br1
ip link set dev $swp1 up
ip link set dev $swp2 up
bridge vlan add dev br1 vid 555 self
bridge vlan add dev br1 vid 777 self
bridge vlan add dev $swp1 vid 555
bridge vlan add dev $swp2 vid 777
vlan_create br1 555 "" 192.0.2.2/28 2001:db8:1::2/64
vlan_create br1 777 "" 192.0.2.17/28 2001:db8:2::1/64
}
router_destroy()
{
vlan_destroy br1 777
vlan_destroy br1 555
bridge vlan del dev $swp2 vid 777
bridge vlan del dev $swp1 vid 555
bridge vlan del dev br1 vid 777 self
bridge vlan del dev br1 vid 555 self
ip link set dev $swp2 down nomaster
ip link set dev $swp1 down nomaster
ip link set dev br1 down
ip link del dev br1
}
setup_prepare()
{
h1=${NETIFS[p1]}
swp1=${NETIFS[p2]}
swp2=${NETIFS[p3]}
h2=${NETIFS[p4]}
vrf_prepare
h1_create
h2_create
router_create
forwarding_enable
}
cleanup()
{
pre_cleanup
forwarding_restore
router_destroy
h2_destroy
h1_destroy
vrf_cleanup
}
ping_ipv4()
{
ping_test $h1 192.0.2.18
}
ping_ipv6()
{
ping6_test $h1 2001:db8:2::2
}
respin_config()
{
log_info "Remaster bridge slave"
ip link set dev $swp2 nomaster
ip link set dev $swp1 nomaster
sleep 2
ip link set dev $swp1 master br1
ip link set dev $swp2 master br1
bridge vlan add dev $swp1 vid 555
bridge vlan add dev $swp2 vid 777
}
trap cleanup EXIT
setup_prepare
setup_wait
tests_run
exit $EXIT_STATUS
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment