~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/drivers/net/mlxsw/qos_dscp_bridge.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0
  3 
  4 # Test for DSCP prioritization and rewrite. Packets ingress $swp1 with a DSCP
  5 # tag and are prioritized according to the map at $swp1. They egress $swp2 and
  6 # the DSCP value is updated to match the map at that interface. The updated DSCP
  7 # tag is verified at $h2.
  8 #
  9 # ICMP responses are produced with the same DSCP tag that arrived at $h2. They
 10 # go through prioritization at $swp2 and DSCP retagging at $swp1. The tag is
 11 # verified at $h1--it should match the original tag.
 12 #
 13 # +----------------------+                             +----------------------+
 14 # | H1                   |                             |                   H2 |
 15 # |    + $h1             |                             |            $h2 +     |
 16 # |    | 192.0.2.1/28    |                             |   192.0.2.2/28 |     |
 17 # +----|-----------------+                             +----------------|-----+
 18 #      |                                                                |
 19 # +----|----------------------------------------------------------------|-----+
 20 # | SW |                                                                |     |
 21 # |  +-|----------------------------------------------------------------|-+   |
 22 # |  | + $swp1                       BR                           $swp2 + |   |
 23 # |  |   dcb dscp-prio 10:0...17:7            dcb dscp-prio 20:0...27:7   |   |
 24 # |  +--------------------------------------------------------------------+   |
 25 # +---------------------------------------------------------------------------+
 26 
 27 ALL_TESTS="
 28         ping_ipv4
 29         test_dscp
 30 "
 31 
 32 lib_dir=$(dirname $0)/../../../net/forwarding
 33 
 34 NUM_NETIFS=4
 35 source $lib_dir/lib.sh
 36 
 37 h1_create()
 38 {
 39         simple_if_init $h1 192.0.2.1/28
 40         tc qdisc add dev $h1 clsact
 41         dscp_capture_install $h1 10
 42 }
 43 
 44 h1_destroy()
 45 {
 46         dscp_capture_uninstall $h1 10
 47         tc qdisc del dev $h1 clsact
 48         simple_if_fini $h1 192.0.2.1/28
 49 }
 50 
 51 h2_create()
 52 {
 53         simple_if_init $h2 192.0.2.2/28
 54         tc qdisc add dev $h2 clsact
 55         dscp_capture_install $h2 20
 56 }
 57 
 58 h2_destroy()
 59 {
 60         dscp_capture_uninstall $h2 20
 61         tc qdisc del dev $h2 clsact
 62         simple_if_fini $h2 192.0.2.2/28
 63 }
 64 
 65 switch_create()
 66 {
 67         ip link add name br1 type bridge vlan_filtering 1
 68         ip link set dev br1 addrgenmode none
 69         ip link set dev br1 up
 70         ip link set dev $swp1 master br1
 71         ip link set dev $swp1 up
 72         ip link set dev $swp2 master br1
 73         ip link set dev $swp2 up
 74 
 75         dcb app add dev $swp1 dscp-prio 10:0 11:1 12:2 13:3 14:4 15:5 16:6 17:7
 76         dcb app add dev $swp2 dscp-prio 20:0 21:1 22:2 23:3 24:4 25:5 26:6 27:7
 77 }
 78 
 79 switch_destroy()
 80 {
 81         dcb app del dev $swp2 dscp-prio 20:0 21:1 22:2 23:3 24:4 25:5 26:6 27:7
 82         dcb app del dev $swp1 dscp-prio 10:0 11:1 12:2 13:3 14:4 15:5 16:6 17:7
 83 
 84         ip link set dev $swp2 down
 85         ip link set dev $swp2 nomaster
 86         ip link set dev $swp1 down
 87         ip link set dev $swp1 nomaster
 88         ip link del dev br1
 89 }
 90 
 91 setup_prepare()
 92 {
 93         h1=${NETIFS[p1]}
 94         swp1=${NETIFS[p2]}
 95 
 96         swp2=${NETIFS[p3]}
 97         h2=${NETIFS[p4]}
 98 
 99         vrf_prepare
100 
101         h1_create
102         h2_create
103         switch_create
104 }
105 
106 cleanup()
107 {
108         pre_cleanup
109 
110         switch_destroy
111         h2_destroy
112         h1_destroy
113 
114         vrf_cleanup
115 }
116 
117 ping_ipv4()
118 {
119         ping_test $h1 192.0.2.2
120 }
121 
122 dscp_ping_test()
123 {
124         local vrf_name=$1; shift
125         local sip=$1; shift
126         local dip=$1; shift
127         local prio=$1; shift
128         local dev_10=$1; shift
129         local dev_20=$1; shift
130         local key
131 
132         local dscp_10=$(((prio + 10) << 2))
133         local dscp_20=$(((prio + 20) << 2))
134 
135         RET=0
136 
137         local -A t0s
138         eval "t0s=($(dscp_fetch_stats $dev_10 10)
139                    $(dscp_fetch_stats $dev_20 20))"
140 
141         local ping_timeout=$((PING_TIMEOUT * 5))
142         ip vrf exec $vrf_name \
143            ${PING} -Q $dscp_10 ${sip:+-I $sip} $dip \
144                    -c 10 -i 0.5 -w $ping_timeout &> /dev/null
145 
146         local -A t1s
147         eval "t1s=($(dscp_fetch_stats $dev_10 10)
148                    $(dscp_fetch_stats $dev_20 20))"
149 
150         for key in ${!t0s[@]}; do
151                 local expect
152                 if ((key == prio+10 || key == prio+20)); then
153                         expect=10
154                 else
155                         expect=0
156                 fi
157 
158                 local delta=$((t1s[$key] - t0s[$key]))
159                 ((expect == delta))
160                 check_err $? "DSCP $key: Expected to capture $expect packets, got $delta."
161         done
162 
163         log_test "DSCP rewrite: $dscp_10-(prio $prio)-$dscp_20"
164 }
165 
166 test_dscp()
167 {
168         local prio
169 
170         for prio in {0..7}; do
171                 dscp_ping_test v$h1 192.0.2.1 192.0.2.2 $prio $h1 $h2
172         done
173 }
174 
175 trap cleanup EXIT
176 
177 setup_prepare
178 setup_wait
179 
180 tests_run
181 
182 exit $EXIT_STATUS

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php