next up previous
Next: Change Up: Classes Previous: Get


The put function is invoked when a class previously referenced using the get function is de-referenced. It decrements the usage count of the class. If the usage count reaches zero, put may remove the class itself. As an example, let us take a look at the cbq_put function in net/sched/sch_cbq.c.

static void cbq_put(struct Qdisc *q, unsigned long arg)
    struct cbq_class *cl = (struct cbq_class*)arg;

    if (--cl->refcnt == 0)

As shown above, the cbq_put function decrements the usage count of the class, and if zero, destroys the class. The put function is invoked in the tc_ctl_tclass function in net/sched/sch_api.c. The tc_ctl_tclass function is invoked whenever an attempt is made to create, delete or change a class.

Saravanan Radhakrishnan