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

Change

The change function on a class is used to change the properties associated with a class. However, the change function is also used to create classes at times. As an example, let us see the cbq_change function in net/sched/sch_cbq.c in detail. The cbq_change function is invoked with the queuing discipline, the class ID of the class whose properties need to be changed or added and the new properties that need to associated to the class. This can be seen below:

static int
cbq_change(struct Qdisc *sch, u32 classid, u32 parentid, struct rtattr **tca,
unsigned long *arg)
{
.
.
}

After performing some initial checks, the properties specified are associated to the class one by one. This can be seen the following portion of the code:

if (tb[TCA_CBQ_WRROPT-1]) {
    cbq_rmprio(q, cl);
    cbq_set_wrr(cl, RTA_DATA(tb[TCA_CBQ_WRROPT-1]));
}
    
if (tb[TCA_CBQ_OVL_STRATEGY-1])
    cbq_set_overlimit(cl, RTA_DATA(tb[TCA_CBQ_OVL_STRATEGY-1]));

This portion of the code sets the priorities and weighted round robin parameters for a class. It also sets the overlimit information. These details about the CBQ will be discussed in more detail in a later section. It should be noted that this function can be used to not only change the properties of an existing class, but it can also be used to create a new class with the properties specified. This fact is clear from the following portions of the code.

static int
cbq_change(struct Qdisc *sch, u32 classid, u32 parentid, struct rtattr **tca,
unsigned long *arg)
{
struct cbq_class *cl = (struct cbq_class*)*arg;
.
.
if (cl) {
  /* Change properties */
  .
  .
  return 0;
  }

/* Create a new class and assign the properties to the class */
.
.
.
}

The change 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.


next up previous
Next: Delete Up: Classes Previous: Put
Saravanan Radhakrishnan
1999-09-30