This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / net / sched / cls_tcindex.c
index c520afb..c696fcf 100644 (file)
@@ -12,8 +12,7 @@
 #include <linux/errno.h>
 #include <linux/netdevice.h>
 #include <net/ip.h>
-#include <net/act_api.h>
-#include <net/pkt_cls.h>
+#include <net/pkt_sched.h>
 #include <net/route.h>
 
 
@@ -160,12 +159,12 @@ static int tcindex_init(struct tcf_proto *tp)
 }
 
 
-static int
-__tcindex_delete(struct tcf_proto *tp, unsigned long arg, int lock)
+static int tcindex_delete(struct tcf_proto *tp, unsigned long arg)
 {
        struct tcindex_data *p = PRIV(tp);
        struct tcindex_filter_result *r = (struct tcindex_filter_result *) arg;
        struct tcindex_filter *f = NULL;
+       unsigned long cl;
 
        DPRINTK("tcindex_delete(tp %p,arg 0x%lx),p %p,f %p\n",tp,arg,p,f);
        if (p->perfect) {
@@ -183,13 +182,13 @@ __tcindex_delete(struct tcf_proto *tp, unsigned long arg, int lock)
 
 found:
                f = *walk;
-               if (lock)
-                       tcf_tree_lock(tp);
+               tcf_tree_lock(tp); 
                *walk = f->next;
-               if (lock)
-                       tcf_tree_unlock(tp);
+               tcf_tree_unlock(tp);
        }
-       tcf_unbind_filter(tp, &r->res);
+       cl = __cls_set_class(&r->res.class,0);
+       if (cl)
+               tp->q->ops->cl_ops->unbind_tcf(tp->q,cl);
 #ifdef CONFIG_NET_CLS_POLICE
        tcf_police_release(r->police, TCA_ACT_UNBIND);
 #endif
@@ -198,10 +197,6 @@ found:
        return 0;
 }
 
-static int tcindex_delete(struct tcf_proto *tp, unsigned long arg)
-{
-       return __tcindex_delete(tp, arg, 1);
-}
 
 /*
  * There are no parameters for tcindex_init, so we overload tcindex_change
@@ -317,19 +312,28 @@ static int tcindex_change(struct tcf_proto *tp,unsigned long base,u32 handle,
        }
        DPRINTK("r=%p\n",r);
        if (tb[TCA_TCINDEX_CLASSID-1]) {
-               r->res.classid = *(__u32 *) RTA_DATA(tb[TCA_TCINDEX_CLASSID-1]);
-               tcf_bind_filter(tp, &r->res, base);
+               unsigned long cl = cls_set_class(tp,&r->res.class,0);
 
+               if (cl)
+                       tp->q->ops->cl_ops->unbind_tcf(tp->q,cl);
+               r->res.classid = *(__u32 *) RTA_DATA(tb[TCA_TCINDEX_CLASSID-1]);
+               r->res.class = tp->q->ops->cl_ops->bind_tcf(tp->q,base,
+                                                           r->res.classid);
                if (!r->res.class) {
                        r->res.classid = 0;
                        return -ENOENT;
                }
-       }
+        }
 #ifdef CONFIG_NET_CLS_POLICE
-       if (tb[TCA_TCINDEX_POLICE-1]) {
-               int err = tcf_change_police(tp, &r->police, tb[TCA_TCINDEX_POLICE-1], NULL);
-               if (err < 0)
-                       return err;
+       {
+               struct tcf_police *police;
+
+               police = tb[TCA_TCINDEX_POLICE-1] ?
+                   tcf_police_locate(tb[TCA_TCINDEX_POLICE-1],NULL) : NULL;
+               tcf_tree_lock(tp);
+               police = xchg(&r->police,police);
+               tcf_tree_unlock(tp);
+               tcf_police_release(police,TCA_ACT_UNBIND);
        }
 #endif
        if (r != &new_filter_result)
@@ -391,7 +395,7 @@ static void tcindex_walk(struct tcf_proto *tp, struct tcf_walker *walker)
 static int tcindex_destroy_element(struct tcf_proto *tp,
     unsigned long arg, struct tcf_walker *walker)
 {
-       return __tcindex_delete(tp, arg, 0);
+       return tcindex_delete(tp,arg);
 }
 
 
@@ -454,8 +458,14 @@ static int tcindex_dump(struct tcf_proto *tp, unsigned long fh,
                if (r->res.class)
                        RTA_PUT(skb, TCA_TCINDEX_CLASSID, 4, &r->res.classid);
 #ifdef CONFIG_NET_CLS_POLICE
-               if (tcf_dump_police(skb, r->police, TCA_TCINDEX_POLICE) < 0)
-                       goto rtattr_failure;
+               if (r->police) {
+                       struct rtattr *p_rta = (struct rtattr *) skb->tail;
+
+                       RTA_PUT(skb,TCA_TCINDEX_POLICE,0,NULL);
+                       if (tcf_police_dump(skb,r->police) < 0)
+                               goto rtattr_failure;
+                       p_rta->rta_len = skb->tail-(u8 *) p_rta;
+               }
 #endif
        }
        rta->rta_len = skb->tail-b;