#!/bin/bash # SPDX-License-Identifier: GPL-2.0 # # This test is for checking functionality of flushing FDB entries. # Check that flush works as expected with all the supported arguments and verify # some combinations of arguments.
vxlan_test_flush_by_src_vni()
{ # Set some entries with {vni=x,src_vni=y} and some with the opposite - # {vni=y,src_vni=x}, to verify that when we flush by src_vni=x, entries # with vni=x are not flused.
local vni_1=3000
local vni_2=4000
local src_vni_1=4000
local src_vni_2=3000
local dst_ip=192.0.2.1
# Reconfigure vx10 with 'external' to get 'src_vni' details in # 'bridge fdb' output
$IP link del dev vx10
$IP link add name vx10 type vxlan dstport "$VXPORT" external
# Flush also entries with $nhid_1, and then verify that flushing by # 'nhid' does not return an error when there are no entries with # nexthops.
run_cmd "$BRIDGE fdb flush dev vx10 nhid $nhid_1"
log_test $? 0 "Flush FDB by dev vx10 and nhid $nhid_1"
run_cmd "$BRIDGE fdb flush dev vx10 nhid $nhid_1"
log_test $? 0 "Flush FDB by nhid when there are no entries with nexthop"
}
vxlan_test_flush_by_state()
{
local flush_by_state=$1; shift
local state_1=$1; shift
local exp_state_1=$1; shift
local state_2=$1; shift
local exp_state_2=$1; shift
# Check the entries by dst_ip as not all states appear in 'bridge fdb' # output.
fdb_check_n_entries_by_dev_filter vx10 $mac_pool_1_len dst $dst_ip_1
fdb_check_n_entries_by_dev_filter vx10 $mac_pool_2_len dst $dst_ip_2
run_cmd "$BRIDGE fdb flush dev vx10 $flush_by_state"
log_test $? 0 "Flush FDB by dev vx10 and state $flush_by_state"
fdb_check_n_entries_by_dev_filter vx10 $exp_state_1 dst $dst_ip_1
log_test $? 0 "Test entries with state $state_1"
fdb_check_n_entries_by_dev_filter vx10 $exp_state_2 dst $dst_ip_2
log_test $? 0 "Test entries with state $state_2"
}
vxlan_test_flush_by_permanent()
{ # Entries that are added without state get 'permanent' state by # default, add some entries with flag 'extern_learn' instead of state, # so they will be added with 'permanent' and should be flushed also.
local flush_by_state="permanent"
local state_1="permanent"
local exp_state_1=0
local state_2="extern_learn"
local exp_state_2=0
vxlan_test_flush_by_nopermanent()
{
local flush_by_state="nopermanent"
local state_1="permanent"
local exp_state_1=$mac_pool_1_len
local state_2="static"
local exp_state_2=0
vxlan_test_flush_by_static()
{
local flush_by_state="static"
local state_1="static"
local exp_state_1=0
local state_2="dynamic"
local exp_state_2=$mac_pool_2_len
vxlan_test_flush_by_nostatic()
{
local flush_by_state="nostatic"
local state_1="permanent"
local exp_state_1=$mac_pool_1_len
local state_2="dynamic"
local exp_state_2=0
vxlan_test_flush_by_dynamic()
{
local flush_by_state="dynamic"
local state_1="dynamic"
local exp_state_1=0
local state_2="static"
local exp_state_2=$mac_pool_2_len
vxlan_test_flush_by_nodynamic()
{
local flush_by_state="nodynamic"
local state_1="permanent"
local exp_state_1=0
local state_2="dynamic"
local exp_state_2=$mac_pool_2_len
vxlan_test_flush_by_flag()
{
local flush_by_flag=$1; shift
local flag_1=$1; shift
local exp_flag_1=$1; shift
local flag_2=$1; shift
local exp_flag_2=$1; shift
run_cmd "$BRIDGE fdb flush dev vx10 $flush_by_flag"
log_test $? 0 "Flush FDB by dev vx10 and flag $flush_by_flag"
fdb_check_n_entries_by_dev_filter vx10 $exp_flag_1 dst $dst_ip_1
log_test $? 0 "Test entries with flag $flag_1"
fdb_check_n_entries_by_dev_filter vx10 $exp_flag_2 dst $dst_ip_2
log_test $? 0 "Test entries with flag $flag_2"
}
vxlan_test_flush_by_extern_learn()
{
local flush_by_flag="extern_learn"
local flag_1="extern_learn"
local exp_flag_1=0
local flag_2="router"
local exp_flag_2=$mac_pool_2_len
vxlan_test_flush_by_noextern_learn()
{
local flush_by_flag="noextern_learn"
local flag_1="extern_learn"
local exp_flag_1=$mac_pool_1_len
local flag_2="router"
local exp_flag_2=0
vxlan_test_flush_by_router()
{
local flush_by_flag="router"
local flag_1="router"
local exp_flag_1=0
local flag_2="extern_learn"
local exp_flag_2=$mac_pool_2_len
vxlan_test_flush_by_several_args()
{
local dst_ip_1=192.0.2.1
local dst_ip_2=192.0.2.2
local state_1=permanent
local state_2=static
local vni=3000
local port=1234
local nhid=100
local flag=router
local flush_args
################### Flush by 2 args - nhid and flag ####################
$IP nexthop add id 10 via 192.0.2.1 fdb
$IP nexthop add id $nhid group 10 fdb
run_cmd "$BRIDGE fdb flush dev vx10 nhid $nhid $flag"
log_test $? 0 "Flush FDB by dev vx10 nhid $nhid $flag"
# All entries should be flushed as 'state' is not an argument for flush # filtering.
fdb_check_n_entries_by_dev_filter vx10 0 $state_1
log_test $? 0 "Test entries with state $state_1"
fdb_check_n_entries_by_dev_filter vx10 0 $state_2
log_test $? 0 "Test entries with state $state_2"
################ Flush by 3 args - VNI, port and dst_ip ################
fdb_add_mac_pool_1 vx10 vni $vni port $port dst $dst_ip_1
fdb_add_mac_pool_2 vx10 vni $vni port $port dst $dst_ip_2
flush_args="vni $vni port $port dst $dst_ip_2"
run_cmd "$BRIDGE fdb flush dev vx10 $flush_args"
log_test $? 0 "Flush FDB by dev vx10 $flush_args"
# Only entries with $dst_ip_2 should be flushed, even the rest arguments # match the filter, the flush should be AND of all the arguments.
fdb_check_n_entries_by_dev_filter vx10 $mac_pool_1_len dst $dst_ip_1
log_test $? 0 "Test entries with dst $dst_ip_1"
for vni in "${vnis[@]}"; do
$BRIDGE fdb append $mac dev vx10 dst 192.0.2.1 vni $vni \
src_vni 5000
$BRIDGE fdb append $mac dev vx10 dst 192.0.2.1 vni $vni \
port 1111
$BRIDGE fdb append $mac dev vx10 dst 192.0.2.2 vni $vni \
port 2222 done
}
vxlan_test_flush_by_remote_attributes()
{
local flush_args
# Reconfigure vx10 with 'external' to get 'src_vni' details in # 'bridge fdb' output
$IP link del dev vx10
$IP link add name vx10 type vxlan dstport "$VXPORT" external
# For multicast FDB entries, the VXLAN driver stores a linked list of # remotes for a given key. Verify that only the expected remotes are # flushed.
multicast_fdb_entries_add
## Flush by 3 remote's attributes - destination IP, port and VNI ##
flush_args="dst 192.0.2.1 port 1111 vni 2000"
fdb_check_n_entries_by_dev_filter vx10 1 $flush_args
t0_n_entries=$($BRIDGE fdb show dev vx10 | wc -l)
run_cmd "$BRIDGE fdb flush dev vx10 $flush_args"
log_test $? 0 "Flush FDB by dev vx10 $flush_args"
exp_n_entries=$((t0_n_entries - 1))
t1_n_entries=$($BRIDGE fdb show dev vx10 | wc -l)
[[ $t1_n_entries -eq $exp_n_entries ]]
log_test $? 0 "Check how many entries were flushed"
## Flush by 2 remote's attributes - destination IP and port ##
flush_args="dst 192.0.2.2 port 2222"
exp_n_entries=$((t0_n_entries - 2))
t1_n_entries=$($BRIDGE fdb show dev vx10 | wc -l)
[[ $t1_n_entries -eq $exp_n_entries ]]
log_test $? 0 "Check how many entries were flushed"
## Flush by source VNI, which is not remote's attribute and VNI ##
flush_args="vni 3000 src_vni 5000"
exp_n_entries=$((t0_n_entries -1))
t1_n_entries=$($BRIDGE fdb show dev vx10 | wc -l)
[[ $t1_n_entries -eq $exp_n_entries ]]
log_test $? 0 "Check how many entries were flushed"
# Flush by 1 remote's attribute - destination IP ##
flush_args="dst 192.0.2.1"
exp_n_entries=$((t0_n_entries -2))
t1_n_entries=$($BRIDGE fdb show dev vx10 | wc -l)
[[ $t1_n_entries -eq $exp_n_entries ]]
log_test $? 0 "Check how many entries were flushed"
}
bridge_test_flush_by_dev()
{
local dst_ip=192.0.2.1
local br0_n_ent_t0=$($BRIDGE fdb show dev br0 | wc -l)
local br1_n_ent_t0=$($BRIDGE fdb show dev br1 | wc -l)
# Each 'fdb add' command adds one extra entry in the bridge with the # default vlan.
local exp_br0_n_ent=$(($br0_n_ent_t0 + 2 * $mac_pool_1_len))
local exp_br1_n_ent=$(($br1_n_ent_t0 + 2 * $mac_pool_2_len))
# Such command should fail in VXLAN driver as vlan is not supported, # but the command should flush the entries in the bridge
run_cmd "$BRIDGE fdb flush dev vx10 vlan $vlan_1 master self"
log_test $? 255 \ "Flush FDB by dev vx10, vlan $vlan_1, master and self"
$IP link add name vx10 type vxlan id 1000 dstport "$VXPORT"
$IP link add name vx20 type vxlan id 2000 dstport "$VXPORT"
$IP link add br0 type bridge vlan_filtering 1
$IP link add br1 type bridge vlan_filtering 1
}
cleanup()
{
$IP link del dev br1
$IP link del dev br0
$IP link del dev vx20
$IP link del dev vx10
cleanup_ns ${NS}
}
################################################################################ # main
while getopts :t:pPhvw: o do
case $o in
t) TESTS=$OPTARG;;
p) PAUSE_ON_FAIL=yes;;
P) PAUSE=yes;;
v) VERBOSE=$(($VERBOSE + 1));;
w) PING_TIMEOUT=$OPTARG;;
h) usage; exit 0;;
*) usage; exit 1;;
esac done
# make sure we don't pause twice
[ "${PAUSE}" = "yes" ] && PAUSE_ON_FAIL=no
if [ "$(id -u)" -ne 0 ];then echo"SKIP: Need root privileges"
exit $ksft_skip; fi
if [ ! -x "$(command -v ip)" ]; then echo"SKIP: Could not run test without ip tool"
exit $ksft_skip fi
# Check a flag that is added to flush command as part of VXLAN flush support
bridge fdb help 2>&1 | grep -q "\[no\]router" if [ $? -ne 0 ]; then echo"SKIP: iproute2 too old, missing flush command for VXLAN"
exit $ksft_skip fi
ip link add dev vx10 type vxlan id 1000 2> /dev/null
out=$(bridge fdb flush dev vx10 2>&1 | grep -q "Operation not supported") if [ $? -eq 0 ]; then echo"SKIP: kernel lacks vxlan flush support"
exit $ksft_skip fi
ip link del dev vx10
for t in $TESTS do
setup; $t; cleanup; done
Messung V0.5
¤ Dauer der Verarbeitung: 0.26 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.