OVERRIDING CLASSIFICATION WITH TC FILTERS top
CAKE supports overriding of its internal classification of packets
through the tc filter mechanism. Packets can be assigned to different
priority tins by setting the
priority field on the skb, and the flow
hashing can be overridden by setting the
classid parameter.
Tin override
To assign a priority tin, the major number of the priority
field needs to match the qdisc handle of the cake instance; if it
does, the minor number will be interpreted as the tin index. For
example, to classify all ICMP packets as 'bulk', the following filter
can be used:
# tc qdisc replace dev eth0 handle 1: root cake diffserv3
# tc filter add dev eth0 parent 1: protocol ip prio 1 \
u32 match icmp type 0 0 action skbedit priority 1:1
Flow hash override
To override flow hashing, the classid can be set. CAKE will
interpret the major number of the classid as the host hash used in
host isolation mode, and the minor number as the flow hash used for
flow-based queueing. One or both of those can be set, and will be
used if the relevant flow isolation parameter is set (i.e., the major
number will be ignored if CAKE is not configured in hosts mode, and
the minor number will be ignored if CAKE is not configured in flows
mode).
This example will assign all ICMP packets to the first queue:
# tc qdisc replace dev eth0 handle 1: root cake
# tc filter add dev eth0 parent 1: protocol ip prio 1 \
u32 match icmp type 0 0 classid 0:1
If only one of the host and flow overrides is set, CAKE will compute
the other hash from the packet as normal. Note, however, that the
host isolation mode works by assigning a host ID to the flow queue;
so if overriding both host and flow, the same flow cannot have more
than one host assigned. In addition, it is not possible to assign
different source and destination host IDs through the override
mechanism; if a host ID is assigned, it will be used as both source
and destination host.
EXAMPLES top
# tc qdisc delete root dev eth0
# tc qdisc add root dev eth0 cake bandwidth 100Mbit ethernet
# tc -s qdisc show dev eth0
qdisc cake 1: root refcnt 2 bandwidth 100Mbit diffserv3 triple-
isolate rtt 100.0ms noatm overhead 38 mpu 84
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
memory used: 0b of 5000000b
capacity estimate: 100Mbit
min/max network layer size: 65535 / 0
min/max overhead-adjusted size: 65535 / 0
average network hdr offset: 0
Bulk Best Effort Voice
thresh 6250Kbit 100Mbit 25Mbit
target 5.0ms 5.0ms 5.0ms
interval 100.0ms 100.0ms 100.0ms
pk_delay 0us 0us 0us
av_delay 0us 0us 0us
sp_delay 0us 0us 0us
pkts 0 0 0
bytes 0 0 0
way_inds 0 0 0
way_miss 0 0 0
way_cols 0 0 0
drops 0 0 0
marks 0 0 0
ack_drop 0 0 0
sp_flows 0 0 0
bk_flows 0 0 0
un_flows 0 0 0
max_len 0 0 0
quantum 300 1514 762
After some use:
# tc -s qdisc show dev eth0
qdisc cake 1: root refcnt 2 bandwidth 100Mbit diffserv3 triple-
isolate rtt 100.0ms noatm overhead 38 mpu 84
Sent 44709231 bytes 31931 pkt (dropped 45, overlimits 93782 requeues
0)
backlog 33308b 22p requeues 0
memory used: 292352b of 5000000b
capacity estimate: 100Mbit
min/max network layer size: 28 / 1500
min/max overhead-adjusted size: 84 / 1538
average network hdr offset: 14
Bulk Best Effort Voice
thresh 6250Kbit 100Mbit 25Mbit
target 5.0ms 5.0ms 5.0ms
interval 100.0ms 100.0ms 100.0ms
pk_delay 8.7ms 6.9ms 5.0ms
av_delay 4.9ms 5.3ms 3.8ms
sp_delay 727us 1.4ms 511us
pkts 2590 21271 8137
bytes 3081804 30302659 11426206
way_inds 0 46 0
way_miss 3 17 4
way_cols 0 0 0
drops 20 15 10
marks 0 0 0
ack_drop 0 0 0
sp_flows 2 4 1
bk_flows 1 2 1
un_flows 0 0 0
max_len 1514 1514 1514
quantum 300 1514 762