Classes form a tree, where each class has a single parent. A
class may have multiple children. Some qdiscs allow for runtime
addition of classes (CBQ, HTB) while others (PRIO) are created
with a static number of children.
Qdiscs which allow dynamic addition of classes can have zero or
more subclasses to which traffic may be enqueued.
Furthermore, each class contains a leaf qdisc
which by default
has pfifo
behaviour, although another qdisc can be attached in
place. This qdisc may again contain classes, but each class can
have only one leaf qdisc.
When a packet enters a classful qdisc it can be classified
to one
of the classes within. Three criteria are available, although not
all qdiscs will use all three:
tc filters
If tc filters are attached to a class, they are consulted
first for relevant instructions. Filters can match on all
fields of a packet header, as well as on the firewall mark
applied by iptables.
Type of Service
Some qdiscs have built in rules for classifying packets
based on the TOS field.
skb->priority
Userspace programs can encode a class-id in the
'skb->priority' field using the SO_PRIORITY option.
Each node within the tree can have its own filters but higher
level filters may also point directly to lower classes.
If classification did not succeed, packets are enqueued to the
leaf qdisc attached to that class. Check qdisc specific manpages
for details, however.