When the enqueue function of a queuing discipline is invoked, the tc_classify function in include/net/pkt_cls.h is called to determine the class to which the packet belongs. The simplest form of classification possible is the specification of the skb->priority field (in struct sk_buff in include/linux/skbuff.h). If skb->priority is specified, then no other classification is attempted. skb->priority is set to sk->priority (in include/net/sock.h) when the packet is created. The value of sk->priority can be specified with the help of the setsockopt call. The SO_PRIORITY option in the setsockopt call needs to be used for this purpose. However till linux kernel version 2.2.3, the value of sk->priority is limited between 0 and 7. Therefore this way of classifying packets does not work. It is worth mentioning at this point that skb->priority may contain other values like the TOS byte in the IP header. All these values are less than 65536, which is the smallest valid class number (as the minimum possible value for the major number of a class is 1). On selecting the class, the enqueue function of the queuing discipline owned by this class is invoked.
In the next section, we will look into the details involved in the implementation of filters.