h1_create()
{
simple_if_init $h1
vlan_create $h1 200 v$h1 192.0.2.1/28 2001:db8:1::1/64
ip 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 nexthop via 2001:db8:1::2
ip route del 192.0.2.16/28 vrf v$h1 nexthop via 192.0.2.2
vlan_destroy $h1 200
simple_if_fini $h1
}
h2_create()
{
simple_if_init $h2
vlan_create $h2 200 v$h2 192.0.2.18/28 2001:db8:2::1/64
ip 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::2
}
h2_destroy()
{
ip -6 route del 2001:db8:1::/64 vrf v$h2 nexthop via 2001:db8:2::2
ip route del 192.0.2.0/28 vrf v$h2 nexthop via 192.0.2.17
vlan_destroy $h2 200
simple_if_fini $h2
}
router_rp1_200_create()
{
ip link add name $rp1.200 link $rp1 type vlan id 200
ip link set dev $rp1.200 addrgenmode eui64
ip link set dev $rp1.200 up
ip address add dev $rp1.200 192.0.2.2/28
ip address add dev $rp1.200 2001:db8:1::2/64
ip stats set dev $rp1.200 l3_stats on
}
router_rp1_200_destroy()
{
ip stats set dev $rp1.200 l3_stats off
ip address del dev $rp1.200 2001:db8:1::2/64
ip address del dev $rp1.200 192.0.2.2/28
ip link del dev $rp1.200
}
router_create()
{
ip link set dev $rp1 up
router_rp1_200_create
ip link set dev $rp2 up
vlan_create $rp2 200 "" 192.0.2.17/28 2001:db8:2::2/64
}
router_destroy()
{
vlan_destroy $rp2 200
ip link set dev $rp2 down
router_rp1_200_destroy
ip link set dev $rp1 down
}
send_packets_rx_ipv4()
{ # Send 21 packets instead of 20, because the first one might trap and go # through the SW datapath, which might not bump the HW counter.
$MZ $h1.200 -c 21 -d 20msec -p 100 \
-a own -b $rp1mac -A 192.0.2.1 -B 192.0.2.18 \
-q -t udp sp=54321,dp=12345
}
send_packets_rx_ipv6()
{
$MZ $h1.200 -6 -c 21 -d 20msec -p 100 \
-a own -b $rp1mac -A 2001:db8:1::1 -B 2001:db8:2::1 \
-q -t udp sp=54321,dp=12345
}
send_packets_tx_ipv4()
{
$MZ $h2.200 -c 21 -d 20msec -p 100 \
-a own -b $rp2mac -A 192.0.2.18 -B 192.0.2.1 \
-q -t udp sp=54321,dp=12345
}
send_packets_tx_ipv6()
{
$MZ $h2.200 -6 -c 21 -d 20msec -p 100 \
-a own -b $rp2mac -A 2001:db8:2::1 -B 2001:db8:1::1 \
-q -t udp sp=54321,dp=12345
}
___test_stats()
{
local dir=$1; shift
local prot=$1; shift
# Make sure everything works well even after stats have been disabled and # reenabled on the same device without touching the L3 configuration.
respin_enablement()
{
log_info "Turning stats off and on again"
ip stats set dev $rp1.200 l3_stats off
ip stats set dev $rp1.200 l3_stats on
}
# For the initial run, l3_stats is enabled on a completely set up netdevice. Now # do it the other way around: enabling the L3 stats on an L2 netdevice, and only # then apply the L3 configuration.
reapply_config()
{
log_info "Reapplying configuration"
router_rp1_200_destroy
ip link add name $rp1.200 link $rp1 type vlan id 200
ip link set dev $rp1.200 addrgenmode none
ip stats set dev $rp1.200 l3_stats on
ip link set dev $rp1.200 addrgenmode eui64
ip link set dev $rp1.200 up
ip address add dev $rp1.200 192.0.2.2/28
ip address add dev $rp1.200 2001:db8:1::2/64
}
__test_stats_report()
{
local dir=$1; shift
local prot=$1; shift
local a
local b
RET=0
a=$(hw_stats_get l3_stats $rp1.200 ${dir} packets)
send_packets_${dir}_${prot}
ip address flush dev $rp1.200
b=$(busywait "$TC_HIT_TIMEOUT" until_counter_is ">= $a + 20" \
hw_stats_get l3_stats $rp1.200 ${dir} packets)
check_err $? "Traffic not reflected in the counter: $a -> $b"
log_test "Test ${dir} packets: stats pushed on loss of L3"
ip stats set dev $rp1.200 l3_stats off
ip link del dev $rp1.200
router_rp1_200_create
}
test_double_enable()
{
RET=0
___test_stats rx ipv4 \
ip stats set dev $rp1.200 l3_stats on
log_test "Test stat retention across a spurious enablement"
}
trap cleanup EXIT
setup_prepare
setup_wait
used=$(ip -j stats show dev $rp1.200 group offload subgroup hw_stats_info |
jq '.[].info.l3_stats.used')
[[ $used = true ]]
check_err $? "hw_stats_info.used=$used"
log_test "l3_stats offloaded"
tests_run
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.