tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower
tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower
tc filter del dev $h2 ingress protocol ip pref 3 handle 103 flower
tc filter del dev $h2 ingress protocol ip pref 4 handle 104 flower
tc filter add dev $h2 ingress protocol 802.1q pref 1 handle 101 \
flower vlan_id 75 $tcflags action drop
tc filter add dev $h2 ingress protocol 802.1q pref 2 handle 102 \
flower vlan_id 85 $tcflags action drop
$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -B 192.0.2.11 -Q 0:85 -t ip -q
tc_check_packets "dev $h2 ingress" 101 0
check_err $? "Matched on specified VLAN when should not"
tc_check_packets "dev $h2 ingress" 102 1
check_err $? "Did not match on specified VLAN"
tc filter del dev $h2 ingress protocol 802.1q pref 2 handle 102 flower
tc filter del dev $h2 ingress protocol 802.1q pref 1 handle 101 flower
vlan_destroy $h2 75
vlan_destroy $h2 85
log_test "VLAN match ($tcflags)"
}
match_ip_tos_test()
{
RET=0
tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \
$tcflags dst_ip 192.0.2.2 ip_tos 0x20 action drop
tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \
$tcflags dst_ip 192.0.2.2 ip_tos 0x18 action drop
$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
-t ip tos=18 -q
tc_check_packets "dev $h2 ingress" 101 1
check_fail $? "Matched on a wrong filter (0x18)"
tc_check_packets "dev $h2 ingress" 102 1
check_err $? "Did not match on correct filter (0x18)"
$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
-t ip tos=20 -q
tc_check_packets "dev $h2 ingress" 102 2
check_fail $? "Matched on a wrong filter (0x20)"
tc_check_packets "dev $h2 ingress" 101 1
check_err $? "Did not match on correct filter (0x20)"
tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower
tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower
log_test "ip_tos match ($tcflags)"
}
match_ip_ttl_test()
{
RET=0
tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \
$tcflags dst_ip 192.0.2.2 ip_ttl 63 action drop
tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \
$tcflags dst_ip 192.0.2.2 action drop
$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
-t ip "ttl=63" -q
$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
-t ip "ttl=63,mf,frag=256" -q
tc_check_packets "dev $h2 ingress" 102 1
check_fail $? "Matched on the wrong filter (no check on ttl)"
tc_check_packets "dev $h2 ingress" 101 2
check_err $? "Did not match on correct filter (ttl=63)"
$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
-t ip "ttl=255" -q
tc_check_packets "dev $h2 ingress" 101 3
check_fail $? "Matched on a wrong filter (ttl=63)"
tc_check_packets "dev $h2 ingress" 102 1
check_err $? "Did not match on correct filter (no check on ttl)"
tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower
tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower
log_test "ip_ttl match ($tcflags)"
}
match_indev_test()
{
RET=0
tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \
$tcflags indev $h1 dst_mac $h2mac action drop
tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \
$tcflags indev $h2 dst_mac $h2mac action drop
$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \
-t ip -q
tc_check_packets "dev $h2 ingress" 101 1
check_fail $? "Matched on a wrong filter"
tc_check_packets "dev $h2 ingress" 102 1
check_err $? "Did not match on correct filter"
tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower
tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower
log_test "indev match ($tcflags)"
}
# Unfortunately, mausezahn can't build MPLS headers when used in L2 # mode, so we have this function to build Label Stack Entries.
mpls_lse()
{
local label=$1
local tc=$2
local bos=$3
local ttl=$4
tc_check_packets "dev $h2 ingress" 101 1
check_fail $? "Matched on a wrong filter (1)"
tc_check_packets "dev $h2 ingress" 102 1
check_err $? "Did not match on correct filter (1)"
# Need to add a second label to properly mark the Bottom of Stack
pkt="$ethtype $(mpls_lse 0 0 0 255) $(mpls_lse 0 0 1 255)"
$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
tc_check_packets "dev $h2 ingress" 102 2
check_fail $? "Matched on a wrong filter (0)"
tc_check_packets "dev $h2 ingress" 101 1
check_err $? "Did not match on correct filter (0)"
tc filter del dev $h2 ingress protocol mpls_uc pref 2 handle 102 flower
tc filter del dev $h2 ingress protocol mpls_uc pref 1 handle 101 flower
log_test "mpls_bos match ($tcflags)"
}
match_mpls_ttl_test()
{
local ethtype="88 47"; readonly ethtype
local pkt
RET=0
check_tc_mpls_support $h2 || return 0
tc filter add dev $h2 ingress protocol mpls_uc pref 1 handle 101 \
flower $tcflags mpls_ttl 0 action drop
tc filter add dev $h2 ingress protocol mpls_uc pref 2 handle 102 \
flower $tcflags mpls_ttl 255 action drop
# Wrong BOS at depth 1 (not adding a second LSE here since BOS is set # in the first label, so anything that'd follow wouldn't be considered)
pkt="$ethtype $(mpls_lse 0 0 1 0)"
$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
# Wrong BOS at depth 2 (adding a third LSE here since BOS isn't set in # the second label)
pkt="$ethtype $(mpls_lse 0 0 0 0) $(mpls_lse 1048575 7 0 255)"
pkt="$pkt $(mpls_lse 0 0 1 255)"
$MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac "$pkt" -q
# Filters working at depth 1 should match all packets but one
tc_check_packets "dev $h2 ingress" 101 8
check_err $? "Did not match on correct filter"
tc_check_packets "dev $h2 ingress" 102 8
check_err $? "Did not match on correct filter"
tc_check_packets "dev $h2 ingress" 103 8
check_err $? "Did not match on correct filter"
tc_check_packets "dev $h2 ingress" 104 8
check_err $? "Did not match on correct filter"
# Filters working at depth 2 should match all packets but two (because # of the test packet where the label stack depth is just one)
tc_check_packets "dev $h2 ingress" 105 7
check_err $? "Did not match on correct filter"
tc_check_packets "dev $h2 ingress" 106 7
check_err $? "Did not match on correct filter"
tc_check_packets "dev $h2 ingress" 107 7
check_err $? "Did not match on correct filter"
tc_check_packets "dev $h2 ingress" 108 7
check_err $? "Did not match on correct filter"
# Finally, verify the filters that only match on LSE depth
tc_check_packets "dev $h2 ingress" 109 9
check_err $? "Did not match on correct filter"
tc_check_packets "dev $h2 ingress" 110 8
check_err $? "Did not match on correct filter"
tc_check_packets "dev $h2 ingress" 111 1
check_err $? "Did not match on correct filter"
tc filter del dev $h2 ingress protocol mpls_uc pref 11 handle 111 flower
tc filter del dev $h2 ingress protocol mpls_uc pref 10 handle 110 flower
tc filter del dev $h2 ingress protocol mpls_uc pref 9 handle 109 flower
tc filter del dev $h2 ingress protocol mpls_uc pref 8 handle 108 flower
tc filter del dev $h2 ingress protocol mpls_uc pref 7 handle 107 flower
tc filter del dev $h2 ingress protocol mpls_uc pref 6 handle 106 flower
tc filter del dev $h2 ingress protocol mpls_uc pref 5 handle 105 flower
tc filter del dev $h2 ingress protocol mpls_uc pref 4 handle 104 flower
tc filter del dev $h2 ingress protocol mpls_uc pref 3 handle 103 flower
tc filter del dev $h2 ingress protocol mpls_uc pref 2 handle 102 flower
tc filter del dev $h2 ingress protocol mpls_uc pref 1 handle 101 flower
log_test "mpls lse match ($tcflags)"
}
match_erspan_opts_test()
{
RET=0
check_tc_erspan_support $h2 || return 0
# h1 erspan setup
tunnel_create erspan1 erspan 192.0.2.1 192.0.2.2 dev $h1 seq key 1001 \
tos C ttl 64 erspan_ver 1 erspan 6789 # ERSPAN Type II
tunnel_create erspan2 erspan 192.0.2.1 192.0.2.2 dev $h1 seq key 1002 \
tos C ttl 64 erspan_ver 2 erspan_dir egress erspan_hwid 63 \ # ERSPAN Type III
ip link set dev erspan1 master v$h1
ip link set dev erspan2 master v$h1 # h2 erspan setup
ip link add ep-ex type erspan ttl 64 external # To collect tunnel info
ip link set ep-ex up
ip link set dev ep-ex master v$h2
tc qdisc add dev ep-ex clsact
# ERSPAN Type II [decap direction]
tc filter add dev ep-ex ingress protocol ip handle 101 flower \
$tcflags enc_src_ip 192.0.2.1 enc_dst_ip 192.0.2.2 \
enc_key_id 1001 erspan_opts 1:6789:0:0 \
action drop # ERSPAN Type III [decap direction]
tc filter add dev ep-ex ingress protocol ip handle 102 flower \
$tcflags enc_src_ip 192.0.2.1 enc_dst_ip 192.0.2.2 \
enc_key_id 1002 erspan_opts 2:0:1:63 action drop
ep1mac=$(mac_get erspan1)
$MZ erspan1 -c 1 -p 64 -a $ep1mac -b $h2mac -t ip -q
tc_check_packets "dev ep-ex ingress" 101 1
check_err $? "ERSPAN Type II"
ep2mac=$(mac_get erspan2)
$MZ erspan2 -c 1 -p 64 -a $ep1mac -b $h2mac -t ip -q
tc_check_packets "dev ep-ex ingress" 102 1
check_err $? "ERSPAN Type III"
# h2 erspan cleanup
tc qdisc del dev ep-ex clsact
tunnel_destroy ep-ex # h1 erspan cleanup
tunnel_destroy erspan2 # ERSPAN Type III
tunnel_destroy erspan1 # ERSPAN Type II
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.