diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-09 13:14:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-09 13:14:35 +0000 |
commit | 9b8a97db9ec4b795e29e72289005fbc58484ebeb (patch) | |
tree | e24ca2d68215e57b4759fe5c032629821eabb250 /testsuite/tests/tc | |
parent | Initial commit. (diff) | |
download | iproute2-9b8a97db9ec4b795e29e72289005fbc58484ebeb.tar.xz iproute2-9b8a97db9ec4b795e29e72289005fbc58484ebeb.zip |
Adding upstream version 6.8.0.upstream/6.8.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testsuite/tests/tc')
-rwxr-xr-x | testsuite/tests/tc/batch.t | 23 | ||||
-rwxr-xr-x | testsuite/tests/tc/flower_mpls.t | 82 | ||||
-rwxr-xr-x | testsuite/tests/tc/mpls.t | 69 | ||||
-rwxr-xr-x | testsuite/tests/tc/pedit.t | 217 | ||||
-rwxr-xr-x | testsuite/tests/tc/vlan.t | 85 |
5 files changed, 476 insertions, 0 deletions
diff --git a/testsuite/tests/tc/batch.t b/testsuite/tests/tc/batch.t new file mode 100755 index 0000000..50e7ba3 --- /dev/null +++ b/testsuite/tests/tc/batch.t @@ -0,0 +1,23 @@ +#!/bin/sh +. lib/generic.sh + +DEV="$(rand_dev)" +ts_ip "$0" "Add $DEV dummy interface" link add dev $DEV type dummy +ts_ip "$0" "Enable $DEV" link set $DEV up +ts_tc "$0" "Add ingress qdisc" qdisc add dev $DEV clsact + +TMP="$(mktemp)" +echo filt add dev $DEV ingress pref 1000 matchall action pass >> "$TMP" +echo filt add dev $DEV ingress pref 1000 matchall action pass >> "$TMP" + +"$TC" -b "$TMP" 2> $STD_ERR > $STD_OUT +if [ $? -eq 0 ]; then + ts_err "$0: batch passed when it should have failed" +elif [ ! -s $STD_ERR ]; then + ts_err "$0: batch produced no error message" +else + echo "$0: batch failed, as expected" +fi + +rm "$TMP" +ts_ip "$0" "Del $DEV dummy interface" link del dev $DEV diff --git a/testsuite/tests/tc/flower_mpls.t b/testsuite/tests/tc/flower_mpls.t new file mode 100755 index 0000000..430ed13 --- /dev/null +++ b/testsuite/tests/tc/flower_mpls.t @@ -0,0 +1,82 @@ +#!/bin/sh + +. lib/generic.sh + +DEV="$(rand_dev)" +ts_ip "$0" "Add $DEV dummy interface" link add dev $DEV up type dummy +ts_tc "$0" "Add ingress qdisc" qdisc add dev $DEV ingress + +reset_qdisc() +{ + ts_tc "$0" "Remove ingress qdisc" qdisc del dev $DEV ingress + ts_tc "$0" "Add ingress qdisc" qdisc add dev $DEV ingress +} + +ts_tc "$0" "Add MPLS filter matching first LSE with minimal values" \ + filter add dev $DEV ingress protocol mpls_uc flower \ + mpls_label 0 mpls_tc 0 mpls_bos 0 mpls_ttl 0 \ + action drop +ts_tc "$0" "Show ingress filters" filter show dev $DEV ingress +test_on "mpls_label 0" +test_on "mpls_tc 0" +test_on "mpls_bos 0" +test_on "mpls_ttl 0" + +reset_qdisc +ts_tc "$0" "Add MPLS filter matching first LSE with maximal values" \ + filter add dev $DEV ingress protocol mpls_uc flower \ + mpls_label 1048575 mpls_tc 7 mpls_bos 1 mpls_ttl 255 \ + action drop +ts_tc "$0" "Show ingress filters" filter show dev $DEV ingress +test_on "mpls_label 1048575" +test_on "mpls_tc 7" +test_on "mpls_bos 1" +test_on "mpls_ttl 255" + +reset_qdisc +ts_tc "$0" "Add MPLS filter matching second LSE with minimal values" \ + filter add dev $DEV ingress protocol mpls_uc flower \ + mpls lse depth 2 label 0 tc 0 bos 0 ttl 0 \ + action drop +ts_tc "$0" "Show ingress filters" filter show dev $DEV ingress +test_on "mpls" +test_on "lse" +test_on "depth 2" +test_on "label 0" +test_on "tc 0" +test_on "bos 0" +test_on "ttl 0" + +reset_qdisc +ts_tc "$0" "Add MPLS filter matching second LSE with maximal values" \ + filter add dev $DEV ingress protocol mpls_uc flower \ + mpls lse depth 2 label 1048575 tc 7 bos 1 ttl 255 \ + action drop +ts_tc "$0" "Show ingress filters" filter show dev $DEV ingress +test_on "mpls" +test_on "lse" +test_on "depth 2" +test_on "label 1048575" +test_on "tc 7" +test_on "bos 1" +test_on "ttl 255" + +reset_qdisc +ts_tc "$0" "Add MPLS filter matching two LSEs" \ + filter add dev $DEV ingress protocol mpls_uc flower mpls \ + lse depth 1 label 0 tc 0 bos 0 ttl 0 \ + lse depth 2 label 1048575 tc 7 bos 1 ttl 255 \ + action drop +ts_tc "$0" "Show ingress filters" filter show dev $DEV ingress +test_on "mpls" +test_on "lse" +test_on "depth 1" +test_on "label 0" +test_on "tc 0" +test_on "bos 0" +test_on "ttl 0" +test_on "depth 2" +test_on "label 1048575" +test_on "tc 7" +test_on "bos 1" +test_on "ttl 255" diff --git a/testsuite/tests/tc/mpls.t b/testsuite/tests/tc/mpls.t new file mode 100755 index 0000000..cb25f36 --- /dev/null +++ b/testsuite/tests/tc/mpls.t @@ -0,0 +1,69 @@ +#!/bin/sh + +. lib/generic.sh + +DEV="$(rand_dev)" +ts_ip "$0" "Add $DEV dummy interface" link add dev $DEV up type dummy +ts_tc "$0" "Add ingress qdisc" qdisc add dev $DEV ingress + +reset_qdisc() +{ + ts_tc "$0" "Remove ingress qdisc" qdisc del dev $DEV ingress + ts_tc "$0" "Add ingress qdisc" qdisc add dev $DEV ingress +} + +ts_tc "$0" "Add mpls action pop" \ + filter add dev $DEV ingress protocol mpls_uc matchall \ + action mpls pop protocol ip +ts_tc "$0" "Show ingress filters" filter show dev $DEV ingress +test_on "mpls" +test_on "pop protocol ip pipe" + +reset_qdisc +ts_tc "$0" "Add mpls action push" \ + filter add dev $DEV ingress protocol ip matchall \ + action mpls push protocol mpls_uc label 20 tc 3 bos 1 ttl 64 +ts_tc "$0" "Show ingress filters" filter show dev $DEV ingress +test_on "mpls" +test_on "push" +test_on "protocol mpls_uc" +test_on "label 20" +test_on "tc 3" +test_on "bos 1" +test_on "ttl 64" +test_on "pipe" + +reset_qdisc +ts_tc "$0" "Add mpls action mac_push" \ + filter add dev $DEV ingress matchall \ + action mpls mac_push protocol mpls_uc label 20 tc 3 bos 1 ttl 64 +ts_tc "$0" "Show ingress filters" filter show dev $DEV ingress +test_on "mpls" +test_on "mac_push" +test_on "protocol mpls_uc" +test_on "label 20" +test_on "tc 3" +test_on "bos 1" +test_on "ttl 64" +test_on "pipe" + +reset_qdisc +ts_tc "$0" "Add mpls action modify" \ + filter add dev $DEV ingress protocol mpls_uc matchall \ + action mpls modify label 20 tc 3 ttl 64 +ts_tc "$0" "Show ingress filters" filter show dev $DEV ingress +test_on "mpls" +test_on "modify" +test_on "label 20" +test_on "tc 3" +test_on "ttl 64" +test_on "pipe" + +reset_qdisc +ts_tc "$0" "Add mpls action dec_ttl" \ + filter add dev $DEV ingress protocol mpls_uc matchall \ + action mpls dec_ttl +ts_tc "$0" "Show ingress filters" filter show dev $DEV ingress +test_on "mpls" +test_on "dec_ttl" +test_on "pipe" diff --git a/testsuite/tests/tc/pedit.t b/testsuite/tests/tc/pedit.t new file mode 100755 index 0000000..8d531a0 --- /dev/null +++ b/testsuite/tests/tc/pedit.t @@ -0,0 +1,217 @@ +#!/bin/sh + +. lib/generic.sh + +DEV="$(rand_dev)" +ts_ip "$0" "Add $DEV dummy interface" link add dev $DEV type dummy +ts_ip "$0" "Enable $DEV" link set $DEV up +ts_tc "pedit" "Add ingress qdisc" qdisc add dev $DEV ingress + + +do_pedit() { + ts_tc "pedit" "Drop ingress qdisc" \ + qdisc del dev $DEV ingress + ts_tc "pedit" "Add ingress qdisc" \ + qdisc add dev $DEV ingress + ts_tc "pedit" "Add pedit action $*" \ + filter add dev $DEV parent ffff: \ + u32 match u32 0 0 \ + action pedit munge $@ + ts_tc "pedit" "Show ingress filters" \ + filter show dev $DEV parent ffff: +} + +do_pedit offset 12 u32 set 0x12345678 +test_on "key #0 at 12: val 12345678 mask 00000000" +do_pedit offset 12 u16 set 0x1234 +test_on "key #0 at 12: val 12340000 mask 0000ffff" +do_pedit offset 14 u16 set 0x1234 +test_on "key #0 at 12: val 00001234 mask ffff0000" +do_pedit offset 12 u8 set 0x23 +test_on "key #0 at 12: val 23000000 mask 00ffffff" +do_pedit offset 13 u8 set 0x23 +test_on "key #0 at 12: val 00230000 mask ff00ffff" +do_pedit offset 14 u8 set 0x23 +test_on "key #0 at 12: val 00002300 mask ffff00ff" +do_pedit offset 15 u8 set 0x23 +test_on "key #0 at 12: val 00000023 mask ffffff00" + +do_pedit offset 13 u8 invert +test_on "key #0 at 12: val 00ff0000 mask ffffffff" +do_pedit offset 13 u8 clear +test_on "key #0 at 12: val 00000000 mask ff00ffff" +do_pedit offset 13 u8 preserve +test_on "key #0 at 12: val 00000000 mask ffffffff" + +# the following set of tests has been auto-generated by running this little +# shell script: +# +# do_it() { +# echo "do_pedit $@" +# tc qd del dev veth0 ingress >/dev/null 2>&1 +# tc qd add dev veth0 ingress >/dev/null 2>&1 +# tc filter add dev veth0 parent ffff: u32 \ +# match u32 0 0 \ +# action pedit munge $@ >/dev/null 2>&1 +# tc filter show dev veth0 parent ffff: | \ +# sed -n 's/^[\t ]*\(key #0.*\)/test_on "\1"/p' +# } +# +# do_it_all() { # (field, val1 [, val2, ...]) +# local field=$1 +# shift +# for val in $@; do +# do_it ip $field set $val +# done +# for i in preserve invert clear; do +# do_it ip $field $i +# done +# } +# +# do_it_all ihl 0x04 0x40 +# do_it_all src 1.2.3.4 +# do_it_all dst 1.2.3.4 +# do_it_all tos 0x1 0x10 +# do_it_all protocol 0x23 +# do_it_all nofrag 0x23 0xf4 +# do_it_all firstfrag 0x03 0xfa +# do_it_all ce 0x23 0x04 0xf3 +# do_it_all df 0x23 0x04 0xf3 +# do_it_all mf 0x23 0x04 0xf3 +# do_it_all dport 0x1234 +# do_it_all sport 0x1234 +# do_it_all icmp_type 0x23 +# do_it_all icmp_code 0x23 + +do_pedit ip ihl set 0x04 +test_on "key #0 at 0: val 04000000 mask f0ffffff" +do_pedit ip ihl set 0x40 +test_on "key #0 at 0: val 00000000 mask f0ffffff" +do_pedit ip ihl preserve +test_on "key #0 at 0: val 00000000 mask ffffffff" +do_pedit ip ihl invert +test_on "key #0 at 0: val 0f000000 mask ffffffff" +do_pedit ip ihl clear +test_on "key #0 at 0: val 00000000 mask f0ffffff" +do_pedit ip src set 1.2.3.4 +test_on "key #0 at 12: val 01020304 mask 00000000" +do_pedit ip src preserve +test_on "key #0 at 12: val 00000000 mask ffffffff" +do_pedit ip src invert +test_on "key #0 at 12: val ffffffff mask ffffffff" +do_pedit ip src clear +test_on "key #0 at 12: val 00000000 mask 00000000" +do_pedit ip dst set 1.2.3.4 +test_on "key #0 at 16: val 01020304 mask 00000000" +do_pedit ip dst preserve +test_on "key #0 at 16: val 00000000 mask ffffffff" +do_pedit ip dst invert +test_on "key #0 at 16: val ffffffff mask ffffffff" +do_pedit ip dst clear +test_on "key #0 at 16: val 00000000 mask 00000000" +do_pedit ip tos set 0x1 +test_on "key #0 at 0: val 00010000 mask ff00ffff" +do_pedit ip tos set 0x10 +test_on "key #0 at 0: val 00100000 mask ff00ffff" +do_pedit ip tos preserve +test_on "key #0 at 0: val 00000000 mask ffffffff" +do_pedit ip tos invert +test_on "key #0 at 0: val 00ff0000 mask ffffffff" +do_pedit ip tos clear +test_on "key #0 at 0: val 00000000 mask ff00ffff" +do_pedit ip protocol set 0x23 +test_on "key #0 at 8: val 00230000 mask ff00ffff" +do_pedit ip protocol preserve +test_on "key #0 at 8: val 00000000 mask ffffffff" +do_pedit ip protocol invert +test_on "key #0 at 8: val 00ff0000 mask ffffffff" +do_pedit ip protocol clear +test_on "key #0 at 8: val 00000000 mask ff00ffff" +do_pedit ip nofrag set 0x23 +test_on "key #0 at 4: val 00002300 mask ffffc0ff" +do_pedit ip nofrag set 0xf4 +test_on "key #0 at 4: val 00003400 mask ffffc0ff" +do_pedit ip nofrag preserve +test_on "key #0 at 4: val 00000000 mask ffffffff" +do_pedit ip nofrag invert +test_on "key #0 at 4: val 00003f00 mask ffffffff" +do_pedit ip nofrag clear +test_on "key #0 at 4: val 00000000 mask ffffc0ff" +do_pedit ip firstfrag set 0x03 +test_on "key #0 at 4: val 00000300 mask ffffe0ff" +do_pedit ip firstfrag set 0xfa +test_on "key #0 at 4: val 00001a00 mask ffffe0ff" +do_pedit ip firstfrag preserve +test_on "key #0 at 4: val 00000000 mask ffffffff" +do_pedit ip firstfrag invert +test_on "key #0 at 4: val 00001f00 mask ffffffff" +do_pedit ip firstfrag clear +test_on "key #0 at 4: val 00000000 mask ffffe0ff" +do_pedit ip ce set 0x23 +test_on "key #0 at 4: val 00000000 mask ffff7fff" +do_pedit ip ce set 0x04 +test_on "key #0 at 4: val 00000000 mask ffff7fff" +do_pedit ip ce set 0xf3 +test_on "key #0 at 4: val 00008000 mask ffff7fff" +do_pedit ip ce preserve +test_on "key #0 at 4: val 00000000 mask ffffffff" +do_pedit ip ce invert +test_on "key #0 at 4: val 00008000 mask ffffffff" +do_pedit ip ce clear +test_on "key #0 at 4: val 00000000 mask ffff7fff" +do_pedit ip df set 0x23 +test_on "key #0 at 4: val 00000000 mask ffffbfff" +do_pedit ip df set 0x04 +test_on "key #0 at 4: val 00000000 mask ffffbfff" +do_pedit ip df set 0xf3 +test_on "key #0 at 4: val 00004000 mask ffffbfff" +do_pedit ip df preserve +test_on "key #0 at 4: val 00000000 mask ffffffff" +do_pedit ip df invert +test_on "key #0 at 4: val 00004000 mask ffffffff" +do_pedit ip df clear +test_on "key #0 at 4: val 00000000 mask ffffbfff" +do_pedit ip mf set 0x23 +test_on "key #0 at 4: val 00002000 mask ffffdfff" +do_pedit ip mf set 0x04 +test_on "key #0 at 4: val 00000000 mask ffffdfff" +do_pedit ip mf set 0xf3 +test_on "key #0 at 4: val 00002000 mask ffffdfff" +do_pedit ip mf preserve +test_on "key #0 at 4: val 00000000 mask ffffffff" +do_pedit ip mf invert +test_on "key #0 at 4: val 00002000 mask ffffffff" +do_pedit ip mf clear +test_on "key #0 at 4: val 00000000 mask ffffdfff" +do_pedit ip dport set 0x1234 +test_on "key #0 at 20: val 00001234 mask ffff0000" +do_pedit ip dport preserve +test_on "key #0 at 20: val 00000000 mask ffffffff" +do_pedit ip dport invert +test_on "key #0 at 20: val 0000ffff mask ffffffff" +do_pedit ip dport clear +test_on "key #0 at 20: val 00000000 mask ffff0000" +do_pedit ip sport set 0x1234 +test_on "key #0 at 20: val 12340000 mask 0000ffff" +do_pedit ip sport preserve +test_on "key #0 at 20: val 00000000 mask ffffffff" +do_pedit ip sport invert +test_on "key #0 at 20: val ffff0000 mask ffffffff" +do_pedit ip sport clear +test_on "key #0 at 20: val 00000000 mask 0000ffff" +do_pedit ip icmp_type set 0x23 +test_on "key #0 at 20: val 23000000 mask 00ffffff" +do_pedit ip icmp_type preserve +test_on "key #0 at 20: val 00000000 mask ffffffff" +do_pedit ip icmp_type invert +test_on "key #0 at 20: val ff000000 mask ffffffff" +do_pedit ip icmp_type clear +test_on "key #0 at 20: val 00000000 mask 00ffffff" +do_pedit ip icmp_code set 0x23 +test_on "key #0 at 20: val 23000000 mask 00ffffff" +do_pedit ip icmp_code preserve +test_on "key #0 at 20: val 00000000 mask ffffffff" +do_pedit ip icmp_code invert +test_on "key #0 at 20: val ff000000 mask ffffffff" +do_pedit ip icmp_code clear +test_on "key #0 at 20: val 00000000 mask 00ffffff" diff --git a/testsuite/tests/tc/vlan.t b/testsuite/tests/tc/vlan.t new file mode 100755 index 0000000..51529b2 --- /dev/null +++ b/testsuite/tests/tc/vlan.t @@ -0,0 +1,85 @@ +#!/bin/sh + +. lib/generic.sh + +DEV="$(rand_dev)" +ts_ip "$0" "Add $DEV dummy interface" link add dev $DEV up type dummy +ts_tc "$0" "Add ingress qdisc" qdisc add dev $DEV ingress + +reset_qdisc() +{ + ts_tc "$0" "Remove ingress qdisc" qdisc del dev $DEV ingress + ts_tc "$0" "Add ingress qdisc" qdisc add dev $DEV ingress +} + +ts_tc "$0" "Add vlan action pop" \ + filter add dev $DEV ingress matchall action vlan pop +ts_tc "$0" "Show ingress filters" filter show dev $DEV ingress +test_on "vlan" +test_on "pop" +test_on "pipe" + +reset_qdisc +ts_tc "$0" "Add vlan action push (default parameters)" \ + filter add dev $DEV ingress matchall action vlan push id 5 +ts_tc "$0" "Show ingress filters" filter show dev $DEV ingress +test_on "vlan" +test_on "push" +test_on "id 5" +test_on "protocol 802.1Q" +test_on "priority 0" +test_on "pipe" + +reset_qdisc +ts_tc "$0" "Add vlan action push (explicit parameters)" \ + filter add dev $DEV ingress matchall \ + action vlan push id 5 protocol 802.1ad priority 2 +ts_tc "$0" "Show ingress filters" filter show dev $DEV ingress +test_on "vlan" +test_on "push" +test_on "id 5" +test_on "protocol 802.1ad" +test_on "priority 2" +test_on "pipe" + +reset_qdisc +ts_tc "$0" "Add vlan action modify (default parameters)" \ + filter add dev $DEV ingress matchall action vlan modify id 5 +ts_tc "$0" "Show ingress filters" filter show dev $DEV ingress +test_on "vlan" +test_on "modify" +test_on "id 5" +test_on "protocol 802.1Q" +test_on "pipe" + +reset_qdisc +ts_tc "$0" "Add vlan action modify (explicit parameters)" \ + filter add dev $DEV ingress matchall \ + action vlan modify id 5 protocol 802.1ad priority 2 +ts_tc "$0" "Show ingress filters" filter show dev $DEV ingress +test_on "vlan" +test_on "modify" +test_on "id 5" +test_on "protocol 802.1ad" +test_on "priority 2" +test_on "pipe" + +reset_qdisc +ts_tc "$0" "Add vlan action pop_eth" \ + filter add dev $DEV ingress matchall action vlan pop_eth +ts_tc "$0" "Show ingress filters" filter show dev $DEV ingress +test_on "vlan" +test_on "pop_eth" +test_on "pipe" + +reset_qdisc +ts_tc "$0" "Add vlan action push_eth" \ + filter add dev $DEV ingress matchall \ + action vlan push_eth dst_mac 02:00:00:00:00:02 \ + src_mac 02:00:00:00:00:01 +ts_tc "$0" "Show ingress filters" filter show dev $DEV ingress +test_on "vlan" +test_on "push_eth" +test_on "dst_mac 02:00:00:00:00:02" +test_on "src_mac 02:00:00:00:00:01" +test_on "pipe" |