Blame testsuite/tests/tc/pedit.t

Packit Service 3880ab
#!/bin/sh
Packit Service 3880ab
Packit Service 3880ab
. lib/generic.sh
Packit Service 3880ab
Packit Service 3880ab
DEV="$(rand_dev)"
Packit Service 3880ab
ts_ip "$0" "Add $DEV dummy interface" link add dev $DEV type dummy
Packit Service 3880ab
ts_ip "$0" "Enable $DEV" link set $DEV up
Packit Service 3880ab
ts_tc "pedit" "Add ingress qdisc" qdisc add dev $DEV ingress
Packit Service 3880ab
Packit Service 3880ab
Packit Service 3880ab
do_pedit() {
Packit Service 3880ab
	ts_tc "pedit" "Drop ingress qdisc" \
Packit Service 3880ab
		qdisc del dev $DEV ingress
Packit Service 3880ab
	ts_tc "pedit" "Add ingress qdisc" \
Packit Service 3880ab
		qdisc add dev $DEV ingress
Packit Service 3880ab
	ts_tc "pedit" "Add pedit action $*" \
Packit Service 3880ab
		filter add dev $DEV parent ffff: \
Packit Service 3880ab
		u32 match u32 0 0 \
Packit Service 3880ab
		action pedit munge $@
Packit Service 3880ab
	ts_tc "pedit" "Show ingress filters" \
Packit Service 3880ab
		filter show dev $DEV parent ffff:
Packit Service 3880ab
}
Packit Service 3880ab
Packit Service 3880ab
do_pedit offset 12 u32 set 0x12345678
Packit Service 3880ab
test_on "key #0  at 12: val 12345678 mask 00000000"
Packit Service 3880ab
do_pedit offset 12 u16 set 0x1234
Packit Service 3880ab
test_on "key #0  at 12: val 12340000 mask 0000ffff"
Packit Service 3880ab
do_pedit offset 14 u16 set 0x1234
Packit Service 3880ab
test_on "key #0  at 12: val 00001234 mask ffff0000"
Packit Service 3880ab
do_pedit offset 12 u8 set 0x23
Packit Service 3880ab
test_on "key #0  at 12: val 23000000 mask 00ffffff"
Packit Service 3880ab
do_pedit offset 13 u8 set 0x23
Packit Service 3880ab
test_on "key #0  at 12: val 00230000 mask ff00ffff"
Packit Service 3880ab
do_pedit offset 14 u8 set 0x23
Packit Service 3880ab
test_on "key #0  at 12: val 00002300 mask ffff00ff"
Packit Service 3880ab
do_pedit offset 15 u8 set 0x23
Packit Service 3880ab
test_on "key #0  at 12: val 00000023 mask ffffff00"
Packit Service 3880ab
Packit Service 3880ab
do_pedit offset 13 u8 invert
Packit Service 3880ab
test_on "key #0  at 12: val 00ff0000 mask ffffffff"
Packit Service 3880ab
do_pedit offset 13 u8 clear
Packit Service 3880ab
test_on "key #0  at 12: val 00000000 mask ff00ffff"
Packit Service 3880ab
do_pedit offset 13 u8 preserve
Packit Service 3880ab
test_on "key #0  at 12: val 00000000 mask ffffffff"
Packit Service 3880ab
Packit Service 3880ab
# the following set of tests has been auto-generated by running this little
Packit Service 3880ab
# shell script:
Packit Service 3880ab
#
Packit Service 3880ab
# do_it() {
Packit Service 3880ab
#	echo "do_pedit $@"
Packit Service 3880ab
#	tc qd del dev veth0 ingress >/dev/null 2>&1
Packit Service 3880ab
#	tc qd add dev veth0 ingress >/dev/null 2>&1
Packit Service 3880ab
#	tc filter add dev veth0 parent ffff: u32 \
Packit Service 3880ab
#		match u32 0 0 \
Packit Service 3880ab
#		action pedit munge $@ >/dev/null 2>&1
Packit Service 3880ab
#	tc filter show dev veth0 parent ffff: | \
Packit Service 3880ab
#		sed -n 's/^[\t ]*\(key #0.*\)/test_on "\1"/p'
Packit Service 3880ab
# }
Packit Service 3880ab
#
Packit Service 3880ab
# do_it_all() { # (field, val1 [, val2, ...])
Packit Service 3880ab
#	local field=$1
Packit Service 3880ab
#	shift
Packit Service 3880ab
#	for val in $@; do
Packit Service 3880ab
#		do_it ip $field set $val
Packit Service 3880ab
#	done
Packit Service 3880ab
#	for i in preserve invert clear; do
Packit Service 3880ab
#		do_it ip $field $i
Packit Service 3880ab
#	done
Packit Service 3880ab
# }
Packit Service 3880ab
#
Packit Service 3880ab
# do_it_all ihl 0x04 0x40
Packit Service 3880ab
# do_it_all src 1.2.3.4
Packit Service 3880ab
# do_it_all dst 1.2.3.4
Packit Service 3880ab
# do_it_all tos 0x1 0x10
Packit Service 3880ab
# do_it_all protocol 0x23
Packit Service 3880ab
# do_it_all nofrag 0x23 0xf4
Packit Service 3880ab
# do_it_all firstfrag 0x03 0xfa
Packit Service 3880ab
# do_it_all ce 0x23 0x04 0xf3
Packit Service 3880ab
# do_it_all df 0x23 0x04 0xf3
Packit Service 3880ab
# do_it_all mf 0x23 0x04 0xf3
Packit Service 3880ab
# do_it_all dport 0x1234
Packit Service 3880ab
# do_it_all sport 0x1234
Packit Service 3880ab
# do_it_all icmp_type 0x23
Packit Service 3880ab
# do_it_all icmp_code 0x23
Packit Service 3880ab
Packit Service 3880ab
do_pedit ip ihl set 0x04
Packit Service 3880ab
test_on "key #0  at 0: val 04000000 mask f0ffffff"
Packit Service 3880ab
do_pedit ip ihl set 0x40
Packit Service 3880ab
test_on "key #0  at 0: val 00000000 mask f0ffffff"
Packit Service 3880ab
do_pedit ip ihl preserve
Packit Service 3880ab
test_on "key #0  at 0: val 00000000 mask ffffffff"
Packit Service 3880ab
do_pedit ip ihl invert
Packit Service 3880ab
test_on "key #0  at 0: val 0f000000 mask ffffffff"
Packit Service 3880ab
do_pedit ip ihl clear
Packit Service 3880ab
test_on "key #0  at 0: val 00000000 mask f0ffffff"
Packit Service 3880ab
do_pedit ip src set 1.2.3.4
Packit Service 3880ab
test_on "key #0  at 12: val 01020304 mask 00000000"
Packit Service 3880ab
do_pedit ip src preserve
Packit Service 3880ab
test_on "key #0  at 12: val 00000000 mask ffffffff"
Packit Service 3880ab
do_pedit ip src invert
Packit Service 3880ab
test_on "key #0  at 12: val ffffffff mask ffffffff"
Packit Service 3880ab
do_pedit ip src clear
Packit Service 3880ab
test_on "key #0  at 12: val 00000000 mask 00000000"
Packit Service 3880ab
do_pedit ip dst set 1.2.3.4
Packit Service 3880ab
test_on "key #0  at 16: val 01020304 mask 00000000"
Packit Service 3880ab
do_pedit ip dst preserve
Packit Service 3880ab
test_on "key #0  at 16: val 00000000 mask ffffffff"
Packit Service 3880ab
do_pedit ip dst invert
Packit Service 3880ab
test_on "key #0  at 16: val ffffffff mask ffffffff"
Packit Service 3880ab
do_pedit ip dst clear
Packit Service 3880ab
test_on "key #0  at 16: val 00000000 mask 00000000"
Packit Service 3880ab
do_pedit ip tos set 0x1
Packit Service 3880ab
test_on "key #0  at 0: val 00010000 mask ff00ffff"
Packit Service 3880ab
do_pedit ip tos set 0x10
Packit Service 3880ab
test_on "key #0  at 0: val 00100000 mask ff00ffff"
Packit Service 3880ab
do_pedit ip tos preserve
Packit Service 3880ab
test_on "key #0  at 0: val 00000000 mask ffffffff"
Packit Service 3880ab
do_pedit ip tos invert
Packit Service 3880ab
test_on "key #0  at 0: val 00ff0000 mask ffffffff"
Packit Service 3880ab
do_pedit ip tos clear
Packit Service 3880ab
test_on "key #0  at 0: val 00000000 mask ff00ffff"
Packit Service 3880ab
do_pedit ip protocol set 0x23
Packit Service 3880ab
test_on "key #0  at 8: val 00230000 mask ff00ffff"
Packit Service 3880ab
do_pedit ip protocol preserve
Packit Service 3880ab
test_on "key #0  at 8: val 00000000 mask ffffffff"
Packit Service 3880ab
do_pedit ip protocol invert
Packit Service 3880ab
test_on "key #0  at 8: val 00ff0000 mask ffffffff"
Packit Service 3880ab
do_pedit ip protocol clear
Packit Service 3880ab
test_on "key #0  at 8: val 00000000 mask ff00ffff"
Packit Service 3880ab
do_pedit ip nofrag set 0x23
Packit Service 3880ab
test_on "key #0  at 4: val 00002300 mask ffffc0ff"
Packit Service 3880ab
do_pedit ip nofrag set 0xf4
Packit Service 3880ab
test_on "key #0  at 4: val 00003400 mask ffffc0ff"
Packit Service 3880ab
do_pedit ip nofrag preserve
Packit Service 3880ab
test_on "key #0  at 4: val 00000000 mask ffffffff"
Packit Service 3880ab
do_pedit ip nofrag invert
Packit Service 3880ab
test_on "key #0  at 4: val 00003f00 mask ffffffff"
Packit Service 3880ab
do_pedit ip nofrag clear
Packit Service 3880ab
test_on "key #0  at 4: val 00000000 mask ffffc0ff"
Packit Service 3880ab
do_pedit ip firstfrag set 0x03
Packit Service 3880ab
test_on "key #0  at 4: val 00000300 mask ffffe0ff"
Packit Service 3880ab
do_pedit ip firstfrag set 0xfa
Packit Service 3880ab
test_on "key #0  at 4: val 00001a00 mask ffffe0ff"
Packit Service 3880ab
do_pedit ip firstfrag preserve
Packit Service 3880ab
test_on "key #0  at 4: val 00000000 mask ffffffff"
Packit Service 3880ab
do_pedit ip firstfrag invert
Packit Service 3880ab
test_on "key #0  at 4: val 00001f00 mask ffffffff"
Packit Service 3880ab
do_pedit ip firstfrag clear
Packit Service 3880ab
test_on "key #0  at 4: val 00000000 mask ffffe0ff"
Packit Service 3880ab
do_pedit ip ce set 0x23
Packit Service 3880ab
test_on "key #0  at 4: val 00000000 mask ffff7fff"
Packit Service 3880ab
do_pedit ip ce set 0x04
Packit Service 3880ab
test_on "key #0  at 4: val 00000000 mask ffff7fff"
Packit Service 3880ab
do_pedit ip ce set 0xf3
Packit Service 3880ab
test_on "key #0  at 4: val 00008000 mask ffff7fff"
Packit Service 3880ab
do_pedit ip ce preserve
Packit Service 3880ab
test_on "key #0  at 4: val 00000000 mask ffffffff"
Packit Service 3880ab
do_pedit ip ce invert
Packit Service 3880ab
test_on "key #0  at 4: val 00008000 mask ffffffff"
Packit Service 3880ab
do_pedit ip ce clear
Packit Service 3880ab
test_on "key #0  at 4: val 00000000 mask ffff7fff"
Packit Service 3880ab
do_pedit ip df set 0x23
Packit Service 3880ab
test_on "key #0  at 4: val 00000000 mask ffffbfff"
Packit Service 3880ab
do_pedit ip df set 0x04
Packit Service 3880ab
test_on "key #0  at 4: val 00000000 mask ffffbfff"
Packit Service 3880ab
do_pedit ip df set 0xf3
Packit Service 3880ab
test_on "key #0  at 4: val 00004000 mask ffffbfff"
Packit Service 3880ab
do_pedit ip df preserve
Packit Service 3880ab
test_on "key #0  at 4: val 00000000 mask ffffffff"
Packit Service 3880ab
do_pedit ip df invert
Packit Service 3880ab
test_on "key #0  at 4: val 00004000 mask ffffffff"
Packit Service 3880ab
do_pedit ip df clear
Packit Service 3880ab
test_on "key #0  at 4: val 00000000 mask ffffbfff"
Packit Service 3880ab
do_pedit ip mf set 0x23
Packit Service 3880ab
test_on "key #0  at 4: val 00002000 mask ffffdfff"
Packit Service 3880ab
do_pedit ip mf set 0x04
Packit Service 3880ab
test_on "key #0  at 4: val 00000000 mask ffffdfff"
Packit Service 3880ab
do_pedit ip mf set 0xf3
Packit Service 3880ab
test_on "key #0  at 4: val 00002000 mask ffffdfff"
Packit Service 3880ab
do_pedit ip mf preserve
Packit Service 3880ab
test_on "key #0  at 4: val 00000000 mask ffffffff"
Packit Service 3880ab
do_pedit ip mf invert
Packit Service 3880ab
test_on "key #0  at 4: val 00002000 mask ffffffff"
Packit Service 3880ab
do_pedit ip mf clear
Packit Service 3880ab
test_on "key #0  at 4: val 00000000 mask ffffdfff"
Packit Service 3880ab
do_pedit ip dport set 0x1234
Packit Service 3880ab
test_on "key #0  at 20: val 00001234 mask ffff0000"
Packit Service 3880ab
do_pedit ip dport preserve
Packit Service 3880ab
test_on "key #0  at 20: val 00000000 mask ffffffff"
Packit Service 3880ab
do_pedit ip dport invert
Packit Service 3880ab
test_on "key #0  at 20: val 0000ffff mask ffffffff"
Packit Service 3880ab
do_pedit ip dport clear
Packit Service 3880ab
test_on "key #0  at 20: val 00000000 mask ffff0000"
Packit Service 3880ab
do_pedit ip sport set 0x1234
Packit Service 3880ab
test_on "key #0  at 20: val 12340000 mask 0000ffff"
Packit Service 3880ab
do_pedit ip sport preserve
Packit Service 3880ab
test_on "key #0  at 20: val 00000000 mask ffffffff"
Packit Service 3880ab
do_pedit ip sport invert
Packit Service 3880ab
test_on "key #0  at 20: val ffff0000 mask ffffffff"
Packit Service 3880ab
do_pedit ip sport clear
Packit Service 3880ab
test_on "key #0  at 20: val 00000000 mask 0000ffff"
Packit Service 3880ab
do_pedit ip icmp_type set 0x23
Packit Service 3880ab
test_on "key #0  at 20: val 23000000 mask 00ffffff"
Packit Service 3880ab
do_pedit ip icmp_type preserve
Packit Service 3880ab
test_on "key #0  at 20: val 00000000 mask ffffffff"
Packit Service 3880ab
do_pedit ip icmp_type invert
Packit Service 3880ab
test_on "key #0  at 20: val ff000000 mask ffffffff"
Packit Service 3880ab
do_pedit ip icmp_type clear
Packit Service 3880ab
test_on "key #0  at 20: val 00000000 mask 00ffffff"
Packit Service 3880ab
do_pedit ip icmp_code set 0x23
Packit Service 3880ab
test_on "key #0  at 20: val 23000000 mask 00ffffff"
Packit Service 3880ab
do_pedit ip icmp_code preserve
Packit Service 3880ab
test_on "key #0  at 20: val 00000000 mask ffffffff"
Packit Service 3880ab
do_pedit ip icmp_code invert
Packit Service 3880ab
test_on "key #0  at 20: val ff000000 mask ffffffff"
Packit Service 3880ab
do_pedit ip icmp_code clear
Packit Service 3880ab
test_on "key #0  at 20: val 00000000 mask 00ffffff"