next up previous
Next: Tcf_chain Up: Classes Previous: Delete

Walk

The walk function on a class is used to iterate over all the classes of a queuing discipline and invokes a callback function for each of the classes. This is usually used to obtain diagnostic data for all the classes of a queuing discipline. For example, let us take a look at the cbq_walk function in net/sched/sch_cbq.c.

static void cbq_walk(struct Qdisc *sch, struct qdisc_walker *arg)
{
 struct cbq_sched_data *q = (struct cbq_sched_data *)sch->data;
 unsigned h;
.
.

 for (h = 0; h < 16; h++) {
    struct cbq_class *cl;

    for (cl = q->classes[h]; cl; cl = cl->next) {
       if (arg->count < arg->skip) {
	 arg->count++;
	 continue;
    }
     
    if (arg->fn(sch, (unsigned long)cl, arg) {
       arg->stop = 1; 
       break;
    }
.
.
    
}

This portion of the code shows that the walk command iterates over all the classes of a specified queuing discipline and invokes a callback function. The walk function is called from the tc_dump_tclass function in net/sched/sch_api.c, which is invoked when a dump request is made on the class. The portion of the code in tc_dump_tclass that does this shown below:

static int tc_dump_tclass(struct sk_buff *skb, struct netlink_callback *cb)
{
 struct device *dev;
 struct Qdisc *q;
 .
 .
 .
 for (q=dev->qdisc_list, t=0; q; q = q->next, t++) {
   .
   arg.w.fn = qdisc_class_dump;
   .
   q->ops->cl_ops->walk(q, &arg.w);
   .
   .
   }
}

The callback function maps to the qdisc_class_dump function in the same file. In qdisc_class_dump, the tc_fill_tclass function is invoked, which calls the dump function on all the classes. The dump function on a class, which is discussed later is used to dump statistical information about the class.



Saravanan Radhakrishnan
1999-09-30