3 # sample script on using the ingress capabilities using u32 classifier
4 # This script tags tcindex based on metering on the ingress
5 # interface the result is used for fast classification and re-marking
6 # on the egress interface
7 # This is an example of a color blind mode marker with PIR configured
8 # based on draft-wahjak-mcm-00.txt (section 3.2)
10 #path to various utilities;
11 #change to reflect yours.
13 IPROUTE=/root/DS-6-beta/iproute2-990530-dsing
20 # The PIR is the excess (in addition to the CIR i.e if always
21 # going to the PIR --> average rate is CIR+PIR)
25 #The CBS is about 60 MTU sized packets
28 #the EBS is about 10 max sized packets
32 meter1=" police rate $CIR1 burst $CBS1 "
33 meter1a=" police rate $PIR1 burst $EBS1 "
34 meter2=" police rate $CIR2 burst $CBS1 "
35 meter2a="police rate $PIR2 burst $CBS1 "
36 meter3=" police rate $CIR2 burst $CBS2 "
37 meter3a=" police rate $PIR2 burst $EBS2 "
38 meter4=" police rate $CIR1 burst $CBS2 "
39 meter5=" police rate $CIR1 burst $CBS2 "
42 # install the ingress qdisc on the ingress interface
43 ############################################################
44 $TC qdisc add dev $INDEV handle ffff: ingress
45 ############################################################
47 ############################################################
49 # All packets are marked with a tcindex value which is used on the egress
50 # NOTE: tcindex 1 maps to AF41, 2->AF42, 3->AF43, 4->BE
52 #anything from subnet 10.2.0.2/24 is passed on with a tcindex value 1
53 #if it doesnt exceed its CIR/CBS + PIR/EBS
55 $TC filter add dev $INDEV parent ffff: protocol ip prio 1 u32 \
56 match ip src 10.2.0.0/24 $meter1 \
58 $TC filter add dev $INDEV parent ffff: protocol ip prio 2 u32 \
59 match ip src 10.2.0.0/24 $meter1a \
63 # if it exceeds the above but not the extra rate/burst below, it gets a
66 $TC filter add dev $INDEV parent ffff: protocol ip prio 3 u32 \
67 match ip src 10.2.0.0/24 $meter2 \
69 $TC filter add dev $INDEV parent ffff: protocol ip prio 4 u32 \
70 match ip src 10.2.0.0/24 $meter2a \
73 # if it exceeds the above but not the rule below, it gets a tcindex value
76 $TC filter add dev $INDEV parent ffff: protocol ip prio 5 u32 \
77 match ip src 10.2.0.0/24 $meter3 \
79 $TC filter add dev $INDEV parent ffff: protocol ip prio 6 u32 \
80 match ip src 10.2.0.0/24 $meter3a \
84 # Anything else (not from the subnet 10.2.0.24/24) gets discarded if it
85 # exceeds 1Mbps and by default goes to BE if it doesnt
87 $TC filter add dev $INDEV parent ffff: protocol ip prio 7 u32 \
88 match ip src 0/0 $meter5 \
92 ######################## Egress side ########################
97 $TC qdisc add $EGDEV handle 1:0 root dsmark indices 64
99 # values of the DSCP to change depending on the class
100 #note that the ECN bits are masked out
102 #AF41 (0x88 is 0x22 shifted to the right by two bits)
104 $TC class change $EGDEV classid 1:1 dsmark mask 0x3 \
107 $TC class change $EGDEV classid 1:2 dsmark mask 0x3 \
110 $TC class change $EGDEV classid 1:3 dsmark mask 0x3 \
113 $TC class change $EGDEV classid 1:3 dsmark mask 0x3 \
119 $TC filter add $EGDEV parent 1:0 protocol ip prio 1 \
120 handle 1 tcindex classid 1:1
121 $TC filter add $EGDEV parent 1:0 protocol ip prio 1 \
122 handle 2 tcindex classid 1:2
123 $TC filter add $EGDEV parent 1:0 protocol ip prio 1 \
124 handle 3 tcindex classid 1:3
125 $TC filter add $EGDEV parent 1:0 protocol ip prio 1 \
126 handle 4 tcindex classid 1:4
130 echo "---- qdisc parameters Ingress ----------"
131 $TC qdisc ls dev $INDEV
132 echo "---- Class parameters Ingress ----------"
133 $TC class ls dev $INDEV
134 echo "---- filter parameters Ingress ----------"
135 $TC filter ls dev $INDEV parent ffff:
137 echo "---- qdisc parameters Egress ----------"
139 echo "---- Class parameters Egress ----------"
141 echo "---- filter parameters Egress ----------"
142 $TC filter ls $EGDEV parent 1:0
144 #deleting the ingress qdisc
145 #$TC qdisc del $INDEV ingress