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

Get

As already mentioned, every filter has an internal ID corresponding to the handle. This mapping can be obtained with the help of the get function on the filter. This is similar to the get function on a class. The tcf_result structure, which is used in the case of classes, is also used in the case of filters. As an example, let us look at the tcindex_get function in net/sched/cls_tcindex.c.

static unsigned long tcindex_get(struct tcf_proto *tp, u32 handle)
{
 DPRINTK("tcindex_get(tp %p,handle 0x%08x)\n",tp,handle);
return (unsigned long) lookup(PRIV(tp),handle);
}

static struct tcindex_filter *lookup(struct tcindex_data *p,__u16 key)
{
 struct tcindex_filter *f;

 for (f = p->h[HASH(key)]; f; f = f->next)
  if (f->key == key) break;
 return f;
}

This tcindex_get function takes as input the 32-bit handle and a pointer to the tcf_proto structure, which contains the the information about the filter. It then calls the lookup function, which walks through the filter list to determine the filter with the specified handle. The lookup function returns the corresponding tcindex_filter structure, which contains the tcf_result structure as a member. The get function on a filter is invoked from the tc_ctl_tfilter function in net/sched/cls_api.c. If the tc_ctl_tfilter function is invoked to delete a filter, the get function returns the internal ID, which can then be used to call the destroy function on a filter.



Saravanan Radhakrishnan
1999-09-30