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

Delete

The delete function on a class is used to delete the class. It determines the usage of the class, by checking the reference count, and if zero, de-activates and removes the class. As an example, let us take a look at the cbq_delete function in net/sched/sch_cbq.c.

static int cbq_delete(struct Qdisc *sch, unsigned long arg)
{
 struct cbq_sched_data *q = (struct cbq_sched_data *)sch->data;
 struct cbq_class *cl = (struct cbq_class*)arg;

 if (cl->filters || cl->children || cl == &q->link)
      return -EBUSY;

 start_bh_atomic();

 if (cl->next_alive)
      cbq_deactivate_class(cl);

 if (q->tx_borrowed == cl)
      q->tx_borrowed = q->tx_class;
 if (q->tx_class == cl) {
      q->tx_class = NULL;
      q->tx_borrowed = NULL;
 }

 cbq_unlink_class(cl);
 cbq_adjust_levels(cl->tparent);
 cl->defmap = 0;
 cbq_sync_defmap(cl);

 cbq_rmprio(q, cl);

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

 end_bh_atomic();

 return 0;
}

The above function is an example of the delete function on a class. Let us now look into the walk function.



Saravanan Radhakrishnan
1999-09-30