next up previous
Next: Dump Up: Queuing Disciplines Previous: Reset

Destroy

The destroy function of a queuing discipline is used to remove the queuing discipline. It also removes all the classes and filters associated with queuing discipline. This is implemented in the qdisc_destroy function (in net/sched/sch_generic.c). An important portion of this function is shown is below:

void qdisc_destroy(struct Qdisc *qdisc)
{
.
.
.
for (qp = &qdisc->dev->qdisc_list; (q=*qp) != NULL; qp = &q->next)
.
.
.
}

This portion of the code shows that a linear search is performed to determine the queuing discipline that needs to be destroyed, after which the memory occupied by the queue is released. As an example of the destroy function, let us take a look at the cbq_destroy function (in net/sched/sch_cbq.c):

static void
cbq_destroy(struct Qdisc* sch)
{
 struct cbq_sched_data *q = (struct cbq_sched_data *)sch->data;
 struct cbq_class *cl;
 unsigned h;

 for (h = 0; h < 16; h++) {
  for (cl = q->classes[h]; cl;
    cl = cl->next)
    cbq_destroy_filters(cl);
 }

 for (h = 0; h < 16; h++) {
  for (cl = q->classes[h]; cl; cl = cl->next)
   if (cl != &q->link) cbq_destroy_class(cl);
 }
 qdisc_put_rtab(q->link.R_tab);
}

This function results in the filters and the classes associated with the queuing discipline being deleted. As was already mentioned, the destruction of a class results in the destruction of the queuing discipline owned by that class, which can be seen from the cbq_destroy_class function shown below:

static void cbq_destroy_class(struct cbq_class *cl)
{
    cbq_destroy_filters(cl);
    qdisc_destroy(cl->q);
    qdisc_put_rtab(cl->R_tab);
#ifdef CONFIG_NET_ESTIMATOR
    qdisc_kill_estimator(&cl->stats);
#endif
    kfree(cl);
}

Let us now discuss the last function associated with a queuing discipline, namely the dump function.



Saravanan Radhakrishnan
1999-09-30