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 | |
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')
-rwxr-xr-x | testsuite/tests/bridge/vlan/show.t | 30 | ||||
-rwxr-xr-x | testsuite/tests/bridge/vlan/tunnelshow.t | 33 | ||||
-rwxr-xr-x | testsuite/tests/ip/link/add_type_bareudp.t | 86 | ||||
-rwxr-xr-x | testsuite/tests/ip/link/add_type_xfrm.t | 17 | ||||
-rwxr-xr-x | testsuite/tests/ip/link/new_link.t | 15 | ||||
-rwxr-xr-x | testsuite/tests/ip/link/show_dev_wo_vf_rate.t | 6 | ||||
-rwxr-xr-x | testsuite/tests/ip/neigh/basic.t | 13 | ||||
-rwxr-xr-x | testsuite/tests/ip/netns/set_nsid.t | 22 | ||||
-rwxr-xr-x | testsuite/tests/ip/netns/set_nsid_batch.t | 18 | ||||
-rwxr-xr-x | testsuite/tests/ip/route/add_default_route.t | 35 | ||||
-rwxr-xr-x | testsuite/tests/ip/rule/dsfield.t | 29 | ||||
-rwxr-xr-x | testsuite/tests/ip/tunnel/add_tunnel.t | 27 | ||||
-rw-r--r-- | testsuite/tests/ss/ss1.dump | bin | 0 -> 720 bytes | |||
-rwxr-xr-x | testsuite/tests/ss/ssfilter.t | 48 | ||||
-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 |
19 files changed, 855 insertions, 0 deletions
diff --git a/testsuite/tests/bridge/vlan/show.t b/testsuite/tests/bridge/vlan/show.t new file mode 100755 index 0000000..3def202 --- /dev/null +++ b/testsuite/tests/bridge/vlan/show.t @@ -0,0 +1,30 @@ +#!/bin/sh + +. lib/generic.sh + +ts_log "[Testing vlan show]" + +BR_DEV="$(rand_dev)" +VX0_DEV="$(rand_dev)" +VX1_DEV="$(rand_dev)" + +ts_ip "$0" "Add $BR_DEV bridge interface" link add $BR_DEV type bridge + +ts_ip "$0" "Add $VX0_DEV vxlan interface" \ + link add $VX0_DEV type vxlan dstport 4789 external +ts_ip "$0" "Enslave $VX0_DEV under $BR_DEV" \ + link set dev $VX0_DEV master $BR_DEV +ts_bridge "$0" "Delete default vlan from $VX0_DEV" \ + vlan del dev $VX0_DEV vid 1 +ts_ip "$0" "Add $VX1_DEV vxlan interface" \ + link add $VX1_DEV type vxlan dstport 4790 external +ts_ip "$0" "Enslave $VX1_DEV under $BR_DEV" \ + link set dev $VX1_DEV master $BR_DEV + +# Test that bridge ports without vlans do not appear in the output +ts_bridge "$0" "Show vlan" vlan +test_on_not "$VX0_DEV" + +# Test that bridge ports without tunnels do not appear in the output +ts_bridge "$0" "Show vlan tunnel info" vlan tunnelshow +test_lines_count 1 # header only diff --git a/testsuite/tests/bridge/vlan/tunnelshow.t b/testsuite/tests/bridge/vlan/tunnelshow.t new file mode 100755 index 0000000..3e9c12a --- /dev/null +++ b/testsuite/tests/bridge/vlan/tunnelshow.t @@ -0,0 +1,33 @@ +#!/bin/sh + +. lib/generic.sh + +ts_log "[Testing tunnelshow]" + +BR_DEV="$(rand_dev)" +VX_DEV="$(rand_dev)" + +ts_ip "$0" "Add $BR_DEV bridge interface" link add $BR_DEV type bridge + +ts_ip "$0" "Add $VX_DEV vxlan interface" \ + link add $VX_DEV type vxlan dstport 4789 external +ts_ip "$0" "Enslave $VX_DEV under $BR_DEV" \ + link set dev $VX_DEV master $BR_DEV +ts_ip "$0" "Set vlan_tunnel on $VX_DEV" \ + link set dev $VX_DEV type bridge_slave vlan_tunnel on + +ts_bridge "$0" "Add single vlan" vlan add dev $VX_DEV vid 1000 +ts_bridge "$0" "Add single tunnel" \ + vlan add dev $VX_DEV vid 1000 tunnel_info id 1000 +ts_bridge "$0" "Add vlan range" vlan add dev $VX_DEV vid 1010-1020 +ts_bridge "$0" "Add tunnel range" \ + vlan add dev $VX_DEV vid 1010-1020 tunnel_info id 1010-1020 +ts_bridge "$0" "Add single vlan" vlan add dev $VX_DEV vid 1030 +ts_bridge "$0" "Add tunnel with vni > 16k" \ + vlan add dev $VX_DEV vid 1030 tunnel_info id 65556 + +ts_bridge "$0" "Show tunnel info" vlan tunnelshow dev $VX_DEV +test_on "1030\s+65556" +test_lines_count 4 + +ts_bridge "$0" "Dump tunnel info" -j vlan tunnelshow dev $VX_DEV diff --git a/testsuite/tests/ip/link/add_type_bareudp.t b/testsuite/tests/ip/link/add_type_bareudp.t new file mode 100755 index 0000000..8a2a1ed --- /dev/null +++ b/testsuite/tests/ip/link/add_type_bareudp.t @@ -0,0 +1,86 @@ +#!/bin/sh + +. lib/generic.sh + +ts_log "[Testing Add BareUDP interface (unicast MPLS)]" +NEW_DEV="$(rand_dev)" + +ts_ip "$0" "Add $NEW_DEV BareUDP interface (unicast MPLS)" link add dev $NEW_DEV type bareudp dstport 6635 ethertype mpls_uc + +ts_ip "$0" "Show $NEW_DEV BareUDP interface (unicast MPLS)" -d link show dev $NEW_DEV +test_on "$NEW_DEV" +test_on "dstport 6635" +test_on "ethertype mpls_uc" +test_on "nomultiproto" + +ts_ip "$0" "Del $NEW_DEV BareUDP interface (unicast MPLS)" link del dev $NEW_DEV + + +ts_log "[Testing Add BareUDP interface (multicast MPLS)]" +NEW_DEV="$(rand_dev)" + +ts_ip "$0" "Add $NEW_DEV BareUDP interface (multicast MPLS)" link add dev $NEW_DEV type bareudp dstport 6635 ethertype mpls_mc + +ts_ip "$0" "Show $NEW_DEV BareUDP interface (multicast MPLS)" -d link show dev $NEW_DEV +test_on "$NEW_DEV" +test_on "dstport 6635" +test_on "ethertype mpls_mc" +test_on "nomultiproto" + +ts_ip "$0" "Del $NEW_DEV BareUDP interface (multicast MPLS)" link del dev $NEW_DEV + + +ts_log "[Testing Add BareUDP interface (unicast and multicast MPLS)]" +NEW_DEV="$(rand_dev)" + +ts_ip "$0" "Add $NEW_DEV BareUDP interface (unicast and multicast MPLS)" link add dev $NEW_DEV type bareudp dstport 6635 ethertype mpls_uc multiproto + +ts_ip "$0" "Show $NEW_DEV BareUDP interface (unicast and multicast MPLS)" -d link show dev $NEW_DEV +test_on "$NEW_DEV" +test_on "dstport 6635" +test_on "ethertype mpls_uc" +test_on "multiproto" + +ts_ip "$0" "Del $NEW_DEV BareUDP interface (unicast and multicast MPLS)" link del dev $NEW_DEV + + +ts_log "[Testing Add BareUDP interface (IPv4)]" +NEW_DEV="$(rand_dev)" + +ts_ip "$0" "Add $NEW_DEV BareUDP interface (IPv4)" link add dev $NEW_DEV type bareudp dstport 6635 ethertype ipv4 + +ts_ip "$0" "Show $NEW_DEV BareUDP interface (IPv4)" -d link show dev $NEW_DEV +test_on "$NEW_DEV" +test_on "dstport 6635" +test_on "ethertype ip" +test_on "nomultiproto" + +ts_ip "$0" "Del $NEW_DEV BareUDP interface (IPv4)" link del dev $NEW_DEV + + +ts_log "[Testing Add BareUDP interface (IPv6)]" +NEW_DEV="$(rand_dev)" + +ts_ip "$0" "Add $NEW_DEV BareUDP interface (IPv6)" link add dev $NEW_DEV type bareudp dstport 6635 ethertype ipv6 + +ts_ip "$0" "Show $NEW_DEV BareUDP interface (IPv6)" -d link show dev $NEW_DEV +test_on "$NEW_DEV" +test_on "dstport 6635" +test_on "ethertype ipv6" +test_on "nomultiproto" + +ts_ip "$0" "Del $NEW_DEV BareUDP interface (IPv6)" link del dev $NEW_DEV + + +ts_log "[Testing Add BareUDP interface (IPv4 and IPv6)]" +NEW_DEV="$(rand_dev)" + +ts_ip "$0" "Add $NEW_DEV BareUDP interface (IPv4 and IPv6)" link add dev $NEW_DEV type bareudp dstport 6635 ethertype ipv4 multiproto + +ts_ip "$0" "Show $NEW_DEV BareUDP interface (IPv4 and IPv6)" -d link show dev $NEW_DEV +test_on "$NEW_DEV" +test_on "dstport 6635" +test_on "ethertype ip" +test_on "multiproto" + +ts_ip "$0" "Del $NEW_DEV BareUDP interface (IPv4 and IPv6)" link del dev $NEW_DEV diff --git a/testsuite/tests/ip/link/add_type_xfrm.t b/testsuite/tests/ip/link/add_type_xfrm.t new file mode 100755 index 0000000..caba0e4 --- /dev/null +++ b/testsuite/tests/ip/link/add_type_xfrm.t @@ -0,0 +1,17 @@ +#!/bin/sh + +. lib/generic.sh + +ts_log "[Testing Add XFRM Interface, With IF-ID]" + +PHYS_DEV="lo" +NEW_DEV="$(rand_dev)" +IF_ID="0xf" + +ts_ip "$0" "Add $NEW_DEV xfrm interface" link add dev $NEW_DEV type xfrm dev $PHYS_DEV if_id $IF_ID + +ts_ip "$0" "Show $NEW_DEV xfrm interface" -d link show dev $NEW_DEV +test_on "$NEW_DEV" +test_on "if_id $IF_ID" + +ts_ip "$0" "Del $NEW_DEV xfrm interface" link del dev $NEW_DEV diff --git a/testsuite/tests/ip/link/new_link.t b/testsuite/tests/ip/link/new_link.t new file mode 100755 index 0000000..c17650a --- /dev/null +++ b/testsuite/tests/ip/link/new_link.t @@ -0,0 +1,15 @@ +#!/bin/sh + +. lib/generic.sh + +ts_log "[Testing add/del virtual links]" + +NEW_DEV="$(rand_dev)" + +ts_ip "$0" "Add $NEW_DEV dummy interface" link add dev $NEW_DEV type dummy + +ts_ip "$0" "Show $NEW_DEV dummy interface" link show dev $NEW_DEV +test_on "$NEW_DEV" +test_lines_count 2 + +ts_ip "$0" "Del $NEW_DEV dummy interface" link del dev $NEW_DEV diff --git a/testsuite/tests/ip/link/show_dev_wo_vf_rate.t b/testsuite/tests/ip/link/show_dev_wo_vf_rate.t new file mode 100755 index 0000000..5b3c004 --- /dev/null +++ b/testsuite/tests/ip/link/show_dev_wo_vf_rate.t @@ -0,0 +1,6 @@ +#!/bin/sh + +. lib/generic.sh + +NL_FILE="tests/ip/link/dev_wo_vf_rate.nl" +ts_ip "$0" "Show VF devices w/o VF rate info" -d monitor file $NL_FILE diff --git a/testsuite/tests/ip/neigh/basic.t b/testsuite/tests/ip/neigh/basic.t new file mode 100755 index 0000000..9c13c8e --- /dev/null +++ b/testsuite/tests/ip/neigh/basic.t @@ -0,0 +1,13 @@ +#!/bin/sh + +. lib/generic.sh + +ts_log "[Testing add/get neigh]" + +NEW_DEV="$(rand_dev)" +ts_ip "$0" "Add $NEW_DEV dummy interface" link add dev $NEW_DEV type dummy +ts_ip "$0" "Add $NEW_DEV neighbor 192.0.2.2 " neigh add 192.0.2.2 lladdr 02:00:00:00:00:01 dev $NEW_DEV +ts_ip "$0" "List neighbors " neigh list +test_on '02:00:00:00:00:01' +ts_ip "$0" "Get $NEW_DEV neighbor 192.0.2.2 " --json neigh get 192.0.2.2 dev $NEW_DEV +test_on '"lladdr":"02:00:00:00:00:01"' diff --git a/testsuite/tests/ip/netns/set_nsid.t b/testsuite/tests/ip/netns/set_nsid.t new file mode 100755 index 0000000..8f8c779 --- /dev/null +++ b/testsuite/tests/ip/netns/set_nsid.t @@ -0,0 +1,22 @@ +#!/bin/sh + +. lib/generic.sh + +ts_log "[Testing netns nsid]" + +NS=testnsid +NSID=99 + +ts_ip "$0" "Add new netns $NS" netns add $NS +ts_ip "$0" "Set $NS nsid to $NSID" netns set $NS $NSID + +ts_ip "$0" "List netns" netns list +test_on "$NS \(id: $NSID\)" + +ts_ip "$0" "List netns without explicit list or show" netns +test_on "$NS \(id: $NSID\)" + +ts_ip "$0" "List nsid" netns list-id +test_on "$NSID \(iproute2 netns name: $NS\)" + +ts_ip "$0" "Delete netns $NS" netns del $NS diff --git a/testsuite/tests/ip/netns/set_nsid_batch.t b/testsuite/tests/ip/netns/set_nsid_batch.t new file mode 100755 index 0000000..196fd4b --- /dev/null +++ b/testsuite/tests/ip/netns/set_nsid_batch.t @@ -0,0 +1,18 @@ +#!/bin/sh + +. lib/generic.sh + +ts_log "[Testing netns nsid in batch mode]" + +NS=testnsid +NSID=99 +BATCHFILE=`mktemp` + +echo "netns add $NS" >> $BATCHFILE +echo "netns set $NS $NSID" >> $BATCHFILE +echo "netns list-id" >> $BATCHFILE +ts_ip "$0" "Add ns, set nsid and list in batch mode" -b $BATCHFILE +test_on "nsid $NSID \(iproute2 netns name: $NS\)" +rm -f $BATCHFILE + +ts_ip "$0" "Delete netns $NS" netns del $NS diff --git a/testsuite/tests/ip/route/add_default_route.t b/testsuite/tests/ip/route/add_default_route.t new file mode 100755 index 0000000..ded4edc --- /dev/null +++ b/testsuite/tests/ip/route/add_default_route.t @@ -0,0 +1,35 @@ +#!/bin/sh + +. lib/generic.sh + +ts_log "[Testing add default route]" + +DEV=dummy0 + +ts_ip "$0" "Add new interface $DEV" link add $DEV type dummy +ts_ip "$0" "Set $DEV into UP state" link set up dev $DEV + +ts_ip "$0" "Add 1.1.1.1/24 addr on $DEV" addr add 1.1.1.1/24 dev $DEV +ts_ip "$0" "Add default route via 1.1.1.2" route add default via 1.1.1.2 + +ts_ip "$0" "Show IPv4 default route" -4 route show default +test_on "default via 1.1.1.2 dev $DEV" +test_lines_count 1 + +ts_ip "$0" "Add another IPv4 route dst 2.2.2.0/24" -4 route add 2.2.2.0/24 dev $DEV +ts_ip "$0" "Show IPv4 default route" -4 route show default +test_on "default via 1.1.1.2 dev $DEV" +test_lines_count 1 + +ts_ip "$0" "Add dead:beef::1/64 addr on $DEV" -6 addr add dead:beef::1/64 dev $DEV +ts_ip "$0" "Add default route via dead:beef::2" route add default via dead:beef::2 +ts_ip "$0" "Show IPv6 default route" -6 route show default +test_on "default via dead:beef::2 dev $DEV" +test_lines_count 1 + +ts_ip "$0" "Add another IPv6 route dst cafe:babe::/64" -6 route add cafe:babe::/64 dev $DEV +ts_ip "$0" "Show IPv6 default route" -6 route show default +test_on "default via dead:beef::2 dev $DEV" +test_lines_count 1 + +ts_ip "$0" "Del $DEV dummy interface" link del dev $DEV diff --git a/testsuite/tests/ip/rule/dsfield.t b/testsuite/tests/ip/rule/dsfield.t new file mode 100755 index 0000000..79ad4e2 --- /dev/null +++ b/testsuite/tests/ip/rule/dsfield.t @@ -0,0 +1,29 @@ +#!/bin/sh + +. lib/generic.sh + +ts_log "[Testing rule with option dsfield/tos]" + +ts_ip "$0" "Add IPv4 rule with dsfield 0x10" -4 rule add dsfield 0x10 +ts_ip "$0" "Show IPv4 rule with dsfield 0x10" -4 rule show dsfield 0x10 +test_on "tos 0x10" +test_lines_count 1 +ts_ip "$0" "Delete IPv4 rule with dsfield 0x10" -4 rule del dsfield 0x10 + +ts_ip "$0" "Add IPv4 rule with tos 0x10" -4 rule add tos 0x10 +ts_ip "$0" "Show IPv4 rule with tos 0x10" -4 rule show tos 0x10 +test_on "tos 0x10" +test_lines_count 1 +ts_ip "$0" "Delete IPv4 rule with tos 0x10" -4 rule del tos 0x10 + +ts_ip "$0" "Add IPv6 rule with dsfield 0x10" -6 rule add dsfield 0x10 +ts_ip "$0" "Show IPv6 rule with dsfield 0x10" -6 rule show dsfield 0x10 +test_on "tos 0x10" +test_lines_count 1 +ts_ip "$0" "Delete IPv6 rule with dsfield 0x10" -6 rule del dsfield 0x10 + +ts_ip "$0" "Add IPv6 rule with tos 0x10" -6 rule add tos 0x10 +ts_ip "$0" "Show IPv6 rule with tos 0x10" -6 rule show tos 0x10 +test_on "tos 0x10" +test_lines_count 1 +ts_ip "$0" "Delete IPv6 rule with tos 0x10" -6 rule del tos 0x10 diff --git a/testsuite/tests/ip/tunnel/add_tunnel.t b/testsuite/tests/ip/tunnel/add_tunnel.t new file mode 100755 index 0000000..65db431 --- /dev/null +++ b/testsuite/tests/ip/tunnel/add_tunnel.t @@ -0,0 +1,27 @@ +#!/bin/sh + +. lib/generic.sh + +TUNNEL_NAME="tunnel_test_ip" +KMODS="ip6_gre ip6_tunnel ip_gre ip_tunnel gre" + +# unload kernel modules to remove dummy interfaces only if they were not in use beforehand +kmods_remove= +# note that checkbashism reports command -v, but dash supports it and it's POSIX 2008 compliant +if command -v lsmod >/dev/null 2>&1 && command -v rmmod >/dev/null 2>&1; then + for i in $KMODS; do + lsmod | grep -q "^$i" || kmods_remove="$kmods_remove $i"; + done +fi + +ts_log "[Testing add/del tunnels]" + +ts_ip "$0" "Add GRE tunnel over IPv4" tunnel add name $TUNNEL_NAME mode gre local 1.1.1.1 remote 2.2.2.2 +ts_ip "$0" "Del GRE tunnel over IPv4" tunnel del $TUNNEL_NAME + +ts_ip "$0" "Add GRE tunnel over IPv6" tunnel add name $TUNNEL_NAME mode ip6gre local dead:beef::1 remote dead:beef::2 +ts_ip "$0" "Del GRE tunnel over IPv6" tunnel del $TUNNEL_NAME + +for mod in $kmods_remove; do + sudo rmmod "$mod" +done diff --git a/testsuite/tests/ss/ss1.dump b/testsuite/tests/ss/ss1.dump Binary files differnew file mode 100644 index 0000000..9c27323 --- /dev/null +++ b/testsuite/tests/ss/ss1.dump diff --git a/testsuite/tests/ss/ssfilter.t b/testsuite/tests/ss/ssfilter.t new file mode 100755 index 0000000..4c2315c --- /dev/null +++ b/testsuite/tests/ss/ssfilter.t @@ -0,0 +1,48 @@ +#!/bin/sh + +. lib/generic.sh + +# % ./misc/ss -Htna +# LISTEN 0 128 0.0.0.0:22 0.0.0.0:* +# ESTAB 0 0 10.0.0.1:22 10.0.0.1:36266 +# ESTAB 0 0 10.0.0.1:36266 10.0.0.1:22 +# ESTAB 0 0 10.0.0.1:22 10.0.0.2:50312 +export TCPDIAG_FILE="$(dirname $0)/ss1.dump" + +ts_log "[Testing ssfilter]" + +ts_ss "$0" "Match dport = 22" -Htna dport = 22 +test_on "ESTAB 0 0 10.0.0.1:36266 10.0.0.1:22" + +ts_ss "$0" "Match dport 22" -Htna dport 22 +test_on "ESTAB 0 0 10.0.0.1:36266 10.0.0.1:22" + +ts_ss "$0" "Match (dport)" -Htna '( dport = 22 )' +test_on "ESTAB 0 0 10.0.0.1:36266 10.0.0.1:22" + +ts_ss "$0" "Match src = 0.0.0.0" -Htna src = 0.0.0.0 +test_on "LISTEN 0 128 0.0.0.0:22 0.0.0.0:\*" + +ts_ss "$0" "Match src 0.0.0.0" -Htna src 0.0.0.0 +test_on "LISTEN 0 128 0.0.0.0:22 0.0.0.0:\*" + +ts_ss "$0" "Match src sport" -Htna src 0.0.0.0 sport = 22 +test_on "LISTEN 0 128 0.0.0.0:22 0.0.0.0:\*" + +ts_ss "$0" "Match src and sport" -Htna src 0.0.0.0 and sport = 22 +test_on "LISTEN 0 128 0.0.0.0:22 0.0.0.0:\*" + +ts_ss "$0" "Match src and sport and dport" -Htna src 10.0.0.1 and sport = 22 and dport = 50312 +test_on "ESTAB 0 0 10.0.0.1:22 10.0.0.2:50312" + +ts_ss "$0" "Match src and sport and (dport)" -Htna 'src 10.0.0.1 and sport = 22 and ( dport = 50312 )' +test_on "ESTAB 0 0 10.0.0.1:22 10.0.0.2:50312" + +ts_ss "$0" "Match src and (sport and dport)" -Htna 'src 10.0.0.1 and ( sport = 22 and dport = 50312 )' +test_on "ESTAB 0 0 10.0.0.1:22 10.0.0.2:50312" + +ts_ss "$0" "Match (src and sport) and dport" -Htna '( src 10.0.0.1 and sport = 22 ) and dport = 50312' +test_on "ESTAB 0 0 10.0.0.1:22 10.0.0.2:50312" + +ts_ss "$0" "Match (src or src) and dst" -Htna '( src 0.0.0.0 or src 10.0.0.1 ) and dst 10.0.0.2' +test_on "ESTAB 0 0 10.0.0.1:22 10.0.0.2:50312" 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" |