Tagging module iproute2 - iproute2-2.6.16-2
[iproute2.git] / examples / diffserv / Edge1
1 #! /bin/sh -x
2 #
3 # sample script on using the ingress capabilities
4 # This script just tags on the ingress interfac using Ipchains
5 # the result is used for fast classification and re-marking
6 # on the egress interface
7 #
8 #path to various utilities;
9 #change to reflect yours.
10 #
11 IPROUTE=/root/DS-6-beta/iproute2-990530-dsing
12 TC=$IPROUTE/tc/tc
13 IP=$IPROUTE/ip/ip
14 IPCHAINS=/root/DS-6-beta/ipchains-1.3.9/ipchains
15 INDEV=eth2
16 EGDEV="dev eth1"
17 #
18 # tag all incoming packets from host 10.2.0.24 to value 1
19 # tag all incoming packets from host 10.2.0.3 to value 2
20 # tag the rest of incoming packets from subnet 10.2.0.0/24 to value 3
21 #These values are used in the egress
22 #
23 ############################################################ 
24 $IPCHAINS -A input -s 10.2.0.4/24 -m 3
25 $IPCHAINS -A input -i $INDEV -s 10.2.0.24 -m 1
26 $IPCHAINS -A input -i $INDEV -s 10.2.0.3 -m 2
27
28 ######################## Egress side ########################
29
30
31 # attach a dsmarker
32 #
33 $TC qdisc add $EGDEV handle 1:0 root dsmark indices 64 set_tc_index
34 #
35 # values of the DSCP to change depending on the class
36 #
37 #becomes EF
38 $TC class change $EGDEV classid 1:1 dsmark mask 0x3 \
39        value 0xb8
40 #becomes AF11
41 $TC class change $EGDEV classid 1:2 dsmark mask 0x3 \
42        value 0x28
43 #becomes AF21
44 $TC class change $EGDEV classid 1:3 dsmark mask 0x3 \
45        value 0x48
46 #
47 #
48 # The class mapping
49 #
50 $TC filter add $EGDEV parent 1:0 protocol ip prio 4 handle 1 fw classid 1:1
51 $TC filter add $EGDEV parent 1:0 protocol ip prio 4 handle 2 fw classid 1:2
52 $TC filter add $EGDEV parent 1:0 protocol ip prio 4 handle 3 fw classid 1:3
53 #
54
55 #
56 echo "---- qdisc parameters Ingress  ----------"
57 $TC qdisc ls dev $INDEV
58 echo "---- Class parameters Ingress  ----------"
59 $TC class ls dev $INDEV
60 echo "---- filter parameters Ingress ----------"
61 $TC filter ls dev $INDEV parent 1:0
62
63 echo "---- qdisc parameters Egress  ----------"
64 $TC qdisc ls $EGDEV
65 echo "---- Class parameters Egress  ----------"
66 $TC class ls $EGDEV
67 echo "---- filter parameters Egress ----------"
68 $TC filter ls $EGDEV parent 1:0