next up previous
Next: Get Up: Filters Previous: Init

Destroy

The destroy function on a filter is used to remove a filter. The cbq_destroy function which was discussed previously, also results in the destroy function on the filters being called. If the filter or any of its elements are registered with classes, the destroy function on a filter calls the unbind_tcf function to de-register from these classes. The unbind_tcf function was discussed in the previous section on classes. It also removes any policer that had been attached to filter. Let us look at the tcindex_destroy function in net/sched/cls_tcindex.c as an example.

static void tcindex_destroy(struct tcf_proto *tp)
{
 struct tcindex_data *p = PRIV(tp);
 struct tcindex_filter *f;
 int i;

 for (i = 0; i < HASH_SIZE; i++)
  while (p->h[i]) {
  unsigned long cl;

  f = p->h[i];
  p->h[i] = f->next;
  cl = xchg(&f->res.class,0);
  if (cl) tp->q->ops->cl_ops->unbind_tcf(tp->q,cl);
#ifdef CONFIG_NET_CLS_POLICE
  tcf_police_release(f->police);
#endif
  kfree(f);
  }
 kfree(p);
 tp->root = NULL;
}

This function shows that the destroy function on a filter unbinds itself from all the classes to which it was bound (using bind_tcf function on the class) and removes the policer that was attached to it. The destroy function takes the tcf_proto structure as an input to determine the filter that needs to be deleted and to determine the classes and queues to which it is attached. It then frees the memory that is occupied by the filter. For more complicated filters like the u32, the destroy function is a lot more complicated than this. The destroy function is invoked from the tc_ctl_tfilter function in net/sched/cls_api.c.


next up previous
Next: Get Up: Filters Previous: Init
Saravanan Radhakrishnan
1999-09-30