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

Change

The change function on a filter is used to change the properties of a filter. This is similar to the change function on classes and queuing disciplines. The configuration parameters are passed using a mechanism that is similar to the way the parameters are passed for classes and queuing disciplines. When the change function is invoked on a filter, if new elements are added to the filter, or if a new filter is added to a class, the unbind_tcf function is called to remove the binding between the class and the filter, which is then followed by the bind_tcf function on the class to bind the filter with new properties to the class. If any policer is attached to the filter, then its properties are also modified. As an example, let us take a look at the tcindex_change function in net/sched/cls_tcindex.c.

static int tcindex_change(struct tcf_proto *tp,u32 handle,struct rtattr **tca,
unsigned long *arg)
{
.
.
if (rtattr_parse(tb,TCA_TCINDEX_MAX,RTA_DATA(opt),RTA_PAYLOAD(opt)) < 0)
   return -EINVAL;
if (tb[TCA_TCINDEX_MASK-1]) {
.
.
.
if (tb[TCA_TCINDEX_CLASSID-1]) {
  unsigned long cl = xchg(&f->res.class,0);

  if (cl)
   tp->q->ops->cl_ops->unbind_tcf(tp->q,cl);
  f->res.class = tp->q->ops->cl_ops->bind_tcf(tp->q, f->res.classid);
.
.
  if (tb[TCA_TCINDEX_POLICE-1]) {
   struct tcf_police *police = tcf_police_locate(tb[TCA_TCINDEX_POLICE-1]);
   tcf_police_release(xchg(&f->police,police));
  }
.
.

}
This function shows how a change function on a filter is processed. First, the properties associated with the filter are changed. This is followed by unbinding and binding the filter to the classes to which it is attached. Finally, the policer attached to the filter is also modified. The change function on a filter is invoked from the tc_ctl_tfilter function in net/sched/cls_api.c.


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