h2_destroy()
{
vlan_destroy $h2 20
vlan_destroy $h2 10
tc qdisc del dev $h2 clsact
simple_if_fini $h2
}
rp1_set_addr()
{
ip address add dev $rp1 192.0.2.17/28
ip route add 192.0.2.32/28 nexthop via 192.0.2.18
ip route add 192.0.2.48/28 nexthop via 192.0.2.18
}
rp1_unset_addr()
{
ip route del 192.0.2.48/28 nexthop via 192.0.2.18
ip route del 192.0.2.32/28 nexthop via 192.0.2.18
ip address del dev $rp1 192.0.2.17/28
}
switch_create()
{
ip link add name br1 type bridge vlan_filtering 1 vlan_default_pvid 0 \
mcast_snooping 0 # Make sure the bridge uses the MAC address of the local port and not # that of the VxLAN's device.
ip link set dev br1 address $(mac_get $swp1)
ip link set dev br1 up
ip link set dev $rp1 up
rp1_set_addr
ip link add name vx10 type vxlan id 1000 \
local 192.0.2.17 dstport "$VXPORT" \
nolearning noudpcsum tos inherit ttl 100
ip link set dev vx10 up
ip link set dev vx10 master br1
bridge vlan add vid 10 dev vx10 pvid untagged
ip link add name vx20 type vxlan id 2000 \
local 192.0.2.17 dstport "$VXPORT" \
nolearning noudpcsum tos inherit ttl 100
ip link set dev vx20 up
ip link set dev vx20 master br1
bridge vlan add vid 20 dev vx20 pvid untagged
ip link set dev $swp1 master br1
ip link set dev $swp1 up
bridge vlan add vid 10 dev $swp1
bridge vlan add vid 20 dev $swp1
ip link set dev $swp2 master br1
ip link set dev $swp2 up
bridge vlan add vid 10 dev $swp2
bridge vlan add vid 20 dev $swp2
bridge fdb append dev vx10 00:00:00:00:00:00 dst 192.0.2.34 self
bridge fdb append dev vx10 00:00:00:00:00:00 dst 192.0.2.50 self
bridge fdb append dev vx20 00:00:00:00:00:00 dst 192.0.2.34 self
bridge fdb append dev vx20 00:00:00:00:00:00 dst 192.0.2.50 self
}
switch_destroy()
{
bridge fdb del dev vx20 00:00:00:00:00:00 dst 192.0.2.50 self
bridge fdb del dev vx20 00:00:00:00:00:00 dst 192.0.2.34 self
bridge fdb del dev vx10 00:00:00:00:00:00 dst 192.0.2.50 self
bridge fdb del dev vx10 00:00:00:00:00:00 dst 192.0.2.34 self
bridge vlan del vid 20 dev $swp2
bridge vlan del vid 10 dev $swp2
ip link set dev $swp2 down
ip link set dev $swp2 nomaster
bridge vlan del vid 20 dev $swp1
bridge vlan del vid 10 dev $swp1
ip link set dev $swp1 down
ip link set dev $swp1 nomaster
bridge vlan del vid 20 dev vx20
ip link set dev vx20 nomaster
ip link set dev vx20 down
ip link del dev vx20
bridge vlan del vid 10 dev vx10
ip link set dev vx10 nomaster
vrp2_destroy()
{
tc qdisc del dev v1 clsact
__simple_if_fini v3 192.0.2.49/28
__simple_if_fini v1 192.0.2.33/28
simple_if_fini $rp2 192.0.2.18/28
}
ns_init_common()
{
local in_if=$1; shift
local in_addr=$1; shift
local other_in_addr=$1; shift
local nh_addr=$1; shift
local host_addr1=$1; shift
local host_addr2=$1; shift
ip link set dev $in_if up
ip address add dev $in_if $in_addr/28
tc qdisc add dev $in_if clsact
ip link add name br2 type bridge vlan_filtering 1 vlan_default_pvid 0
ip link set dev br2 up
ip link add name w1 type veth peer name w2
ip link set dev w1 master br2
ip link set dev w1 up
bridge vlan add vid 10 dev w1
bridge vlan add vid 20 dev w1
ip link add name vx10 type vxlan id 1000 local $in_addr \
dstport "$VXPORT"
ip link set dev vx10 up
bridge fdb append dev vx10 00:00:00:00:00:00 dst 192.0.2.17 self
bridge fdb append dev vx10 00:00:00:00:00:00 dst $other_in_addr self
ip link set dev vx10 master br2
tc qdisc add dev vx10 clsact
bridge vlan add vid 10 dev vx10 pvid untagged
ip link add name vx20 type vxlan id 2000 local $in_addr \
dstport "$VXPORT"
ip link set dev vx20 up
bridge fdb append dev vx20 00:00:00:00:00:00 dst 192.0.2.17 self
bridge fdb append dev vx20 00:00:00:00:00:00 dst $other_in_addr self
ip link set dev vx20 master br2
tc qdisc add dev vx20 clsact
ns2_destroy
ns1_destroy
vrp2_destroy
ip link del dev v3
ip link del dev v1
switch_destroy
h2_destroy
h1_destroy
forwarding_restore
vrf_cleanup
}
# For the first round of tests, vx10 and vx20 were the first devices to get # attached to the bridge, and that at the point that the local IP is already # configured. Try the other scenario of attaching these devices to a bridge # that already has local ports members, and only then assign the local IP.
reapply_config()
{
log_info "Reapplying configuration"
bridge fdb del dev vx20 00:00:00:00:00:00 dst 192.0.2.50 self
bridge fdb del dev vx20 00:00:00:00:00:00 dst 192.0.2.34 self
bridge fdb del dev vx10 00:00:00:00:00:00 dst 192.0.2.50 self
bridge fdb del dev vx10 00:00:00:00:00:00 dst 192.0.2.34 self
ip link set dev vx20 nomaster
ip link set dev vx10 nomaster
rp1_unset_addr
sleep 5
ip link set dev vx10 master br1
bridge vlan add vid 10 dev vx10 pvid untagged
ip link set dev vx20 master br1
bridge vlan add vid 20 dev vx20 pvid untagged
bridge fdb append dev vx10 00:00:00:00:00:00 dst 192.0.2.34 self
bridge fdb append dev vx10 00:00:00:00:00:00 dst 192.0.2.50 self
bridge fdb append dev vx20 00:00:00:00:00:00 dst 192.0.2.34 self
bridge fdb append dev vx20 00:00:00:00:00:00 dst 192.0.2.50 self
rp1_set_addr
sleep 5
}
ping_ipv4()
{
ping_test $h1.10 192.0.2.2 ": local->local vid 10"
ping_test $h1.20 198.51.100.2 ": local->local vid 20"
ping_test $h1.10 192.0.2.3 ": local->remote 1 vid 10"
ping_test $h1.10 192.0.2.4 ": local->remote 2 vid 10"
ping_test $h1.20 198.51.100.3 ": local->remote 1 vid 20"
ping_test $h1.20 198.51.100.4 ": local->remote 2 vid 20"
}
maybe_in_ns()
{ echo ${1:+in_ns} $1
}
__flood_counter_add_del()
{
local add_del=$1; shift
local dev=$1; shift
local ns=$1; shift
# Putting the ICMP capture both to HW and to SW will end up # double-counting the packets that are trapped to slow path, such as for # the unicast test. Adding either skip_hw or skip_sw fixes this problem, # but with skip_hw, the flooded packets are not counted at all, because # those are dropped due to MAC address mismatch; and skip_sw is a no-go # for veth-based topologies. # # So try to install with skip_sw and fall back to skip_sw if that fails.
flood_fetch_stats()
{
local counters=("${@}")
local counter
for counter in "${counters[@]}"; do
flood_fetch_stat $counter done
}
vxlan_flood_test()
{
local mac=$1; shift
local dst=$1; shift
local vid=$1; shift
local -a expects=("${@}")
local -a counters=($h2 "vx10 ns1""vx20 ns1""vx10 ns2""vx20 ns2")
local counter
local key
# Packets reach the local host tagged whereas they reach the VxLAN # devices untagged. In order to be able to use the same filter for # all counters, make sure the packets also reach the local host # untagged
bridge vlan add vid $vid dev $swp2 untagged for counter in "${counters[@]}"; do
flood_counter_install $counter done
local -a t0s=($(flood_fetch_stats "${counters[@]}"))
$MZ $h1 -Q $vid -c 10 -d 100msec -p 64 -b $mac -B $dst -t icmp -q
sleep 1
local -a t1s=($(flood_fetch_stats "${counters[@]}"))
for key in ${!t0s[@]}; do
local delta=$((t1s[$key] - t0s[$key]))
local expect=${expects[$key]}
# Add entries with arbitrary destination IP. Verify that packets are # not duplicated (this can happen if hardware floods the packets, and # then traps them due to misconfiguration, so software data path repeats # flooding and resends packets).
bridge fdb append dev vx10 00:00:00:00:00:00 dst 203.0.113.1 self
bridge fdb append dev vx20 00:00:00:00:00:00 dst 203.0.113.2 self
__test_learning()
{
local -a expects=(0 0 0 0 0)
local mac=$1; shift
local dst=$1; shift
local vid=$1; shift
local idx1=$1; shift
local idx2=$1; shift
local vx=vx$vid
log_test "VXLAN: learning toggling on bridge port"
}
test_learning()
{
local mac=de:ad:be:ef:13:37
local dst=192.0.2.100
local vid=10
# Enable learning on the VxLAN devices and set ageing time to 30 seconds
ip link set dev br1 type bridge ageing_time 3000
ip link set dev vx10 type vxlan ageing 30
ip link set dev vx10 type vxlan learning
ip link set dev vx20 type vxlan ageing 30
ip link set dev vx20 type vxlan learning
reapply_config
log_info "learning vlan 10"
__test_learning $mac $dst $vid 1 3
log_info "learning vlan 20"
mac=ca:fe:be:ef:13:37
dst=198.51.100.100
vid=20
__test_learning $mac $dst $vid 2 4
# Restore previous settings
ip link set dev vx20 type vxlan nolearning
ip link set dev vx20 type vxlan ageing 300
ip link set dev vx10 type vxlan nolearning
ip link set dev vx10 type vxlan ageing 300
ip link set dev br1 type bridge ageing_time 30000
reapply_config
}
test_all()
{
log_info "Running tests with UDP port $VXPORT"
tests_run
}
trap cleanup EXIT
setup_prepare
setup_wait
test_all
exit $EXIT_STATUS
Messung V0.5
¤ Dauer der Verarbeitung: 0.14 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.