next up previous
Next: Destroy Up: Queuing Disciplines Previous: Init


The reset function of a queuing discipline is used to reset the queuing discipline to its initial state. It clears all queuing disciplines, timers are stopped etc. The reset of a queuing discipline also results in a reset of the queuing discipline of the classes of this queuing discipline. As an example, let us take a look at the FIFO queuing discipline. The fifo_reset (in net/sched/sch_fifo.c) function is shown below:

static void
fifo_reset(struct Qdisc* sch)
    struct sk_buff *skb;

    while ((skb=__skb_dequeue(&sch->q)) != NULL)
    sch->stats.backlog = 0;

In this example, the reset function results in the queue being drained, and the memory occupied by these packets are recovered. The backlog is set to zero. This is a simple example, which did not involve timers. A slightly more complicated example is discussed next. Let us take a look at the function tbf_reset (in net/sched/sch_tbf.c):

static void
tbf_reset(struct Qdisc* sch)
 struct tbf_sched_data *q = (struct tbf_sched_data *)sch->data;

 sch->stats.backlog = 0;
 q->tokens = q->buffer;
 q->ptokens = q->mtu;
 sch->flags &= ~TCQ_F_THROTTLED;
This example involves clearing of the backlog as well as resetting of the timers. This explains the operations of the reset function of a queuing discipline.

Saravanan Radhakrishnan