This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / net / sched / cls_u32.c
index 30d26d4..e2d7c0e 100644 (file)
@@ -64,20 +64,17 @@ struct tc_u_knode
        struct tc_u_hnode       *ht_up;
 #ifdef CONFIG_NET_CLS_ACT
        struct tc_action        *action;
+#ifdef CONFIG_NET_CLS_IND
+       char                     indev[IFNAMSIZ];
+#endif
 #else
 #ifdef CONFIG_NET_CLS_POLICE
        struct tcf_police       *police;
 #endif
-#endif
-#ifdef CONFIG_NET_CLS_IND
-       char                     indev[IFNAMSIZ];
 #endif
        u8                      fshift;
        struct tcf_result       res;
        struct tc_u_hnode       *ht_down;
-#ifdef CONFIG_CLS_U32_PERF
-       struct tc_u32_pcnt      *pf;
-#endif
        struct tc_u32_sel       sel;
 };
 
@@ -123,9 +120,6 @@ static int u32_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_re
        int sdepth = 0;
        int off2 = 0;
        int sel = 0;
-#ifdef CONFIG_CLS_U32_PERF
-       int j;
-#endif
        int i;
 
 next_ht:
@@ -136,8 +130,7 @@ next_knode:
                struct tc_u32_key *key = n->sel.keys;
 
 #ifdef CONFIG_CLS_U32_PERF
-               n->pf->rcnt +=1;
-               j = 0;
+               n->sel.rcnt +=1;
 #endif
                for (i = n->sel.nkeys; i>0; i--, key++) {
 
@@ -146,8 +139,7 @@ next_knode:
                                goto next_knode;
                        }
 #ifdef CONFIG_CLS_U32_PERF
-                       n->pf->kcnts[j] +=1;
-                       j++;
+                       key->kcnt +=1;
 #endif
                }
                if (n->ht_down == NULL) {
@@ -155,6 +147,7 @@ check_terminal:
                        if (n->sel.flags&TC_U32_TERMINAL) {
 
                                *res = n->res;
+#ifdef CONFIG_NET_CLS_ACT
 #ifdef CONFIG_NET_CLS_IND
                                /* yes, i know it sucks but the feature is 
                                ** optional dammit! - JHS */
@@ -171,9 +164,8 @@ check_terminal:
                                }
 #endif
 #ifdef CONFIG_CLS_U32_PERF
-                               n->pf->rhit +=1;
+               n->sel.rhit +=1;
 #endif
-#ifdef CONFIG_NET_CLS_ACT
                                if (n->action) {
                                        int pol_res = tcf_action_exec(skb, n->action);
                                        if (skb->tc_classid > 0) {
@@ -366,10 +358,6 @@ static int u32_destroy_key(struct tcf_proto *tp, struct tc_u_knode *n)
 #endif
        if (n->ht_down)
                n->ht_down->refcnt--;
-#ifdef CONFIG_CLS_U32_PERF
-       if (n && (NULL != n->pf))
-               kfree(n->pf);
-#endif
        kfree(n);
        return 0;
 }
@@ -583,18 +571,6 @@ static int u32_set_parms(struct Qdisc *q, unsigned long base,
                tcf_action_destroy(act, TCA_ACT_UNBIND);
        }
 
-
-#else
-#ifdef CONFIG_NET_CLS_POLICE
-       if (tb[TCA_U32_POLICE-1]) {
-               struct tcf_police *police = tcf_police_locate(tb[TCA_U32_POLICE-1], est);
-               sch_tree_lock(q);
-               police = xchg(&n->police, police);
-               sch_tree_unlock(q);
-               tcf_police_release(police, TCA_ACT_UNBIND);
-       }
-#endif
-#endif
 #ifdef CONFIG_NET_CLS_IND
        n->indev[0] = 0;
        if(tb[TCA_U32_INDEV-1]) {
@@ -605,10 +581,21 @@ static int u32_set_parms(struct Qdisc *q, unsigned long base,
                        return  -EINVAL;
                }
                sprintf(n->indev, "%s", (char*)RTA_DATA(input_dev));
-               printk("got IND %s\n",n->indev);
        }
 #endif
 
+#else
+#ifdef CONFIG_NET_CLS_POLICE
+       if (tb[TCA_U32_POLICE-1]) {
+               struct tcf_police *police = tcf_police_locate(tb[TCA_U32_POLICE-1], est);
+               sch_tree_lock(q);
+               police = xchg(&n->police, police);
+               sch_tree_unlock(q);
+               tcf_police_release(police, TCA_ACT_UNBIND);
+       }
+#endif
+#endif
+
        return 0;
 }
 
@@ -695,20 +682,17 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle,
 
        s = RTA_DATA(tb[TCA_U32_SEL-1]);
 
+#ifdef CONFIG_CLS_U32_PERF
+       if (RTA_PAYLOAD(tb[TCA_U32_SEL-1]) < 
+               (s->nkeys*sizeof(struct tc_u32_key)) + sizeof(struct tc_u32_sel)) {
+                       printk("Please upgrade your iproute2 tools or compile proper options in!\n");
+                       return -EINVAL;
+}
+#endif
        n = kmalloc(sizeof(*n) + s->nkeys*sizeof(struct tc_u32_key), GFP_KERNEL);
        if (n == NULL)
                return -ENOBUFS;
-
        memset(n, 0, sizeof(*n) + s->nkeys*sizeof(struct tc_u32_key));
-#ifdef CONFIG_CLS_U32_PERF
-       n->pf = kmalloc(sizeof(struct tc_u32_pcnt) + s->nkeys*sizeof(__u64), GFP_KERNEL);
-       if (n->pf == NULL) {
-               kfree(n);
-               return -ENOBUFS;
-       }
-       memset(n->pf, 0, sizeof(struct tc_u32_pcnt) + s->nkeys*sizeof(__u64));
-#endif
-
        memcpy(&n->sel, s, sizeof(*s) + s->nkeys*sizeof(struct tc_u32_key));
        n->ht_up = ht;
        n->handle = handle;
@@ -737,10 +721,6 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle,
                *arg = (unsigned long)n;
                return 0;
        }
-#ifdef CONFIG_CLS_U32_PERF
-       if (n && (NULL != n->pf))
-               kfree(n->pf);
-#endif
        kfree(n);
        return err;
 }
@@ -832,6 +812,13 @@ static int u32_dump(struct tcf_proto *tp, unsigned long fh,
 
                        p_rta->rta_len = skb->tail - (u8*)p_rta;
                }
+#ifdef CONFIG_NET_CLS_IND
+               if(strlen(n->indev)) {
+                       struct rtattr * p_rta = (struct rtattr*)skb->tail;
+                       RTA_PUT(skb, TCA_U32_INDEV, IFNAMSIZ, n->indev);
+                       p_rta->rta_len = skb->tail - (u8*)p_rta;
+               }
+#endif
 
 #else
 #ifdef CONFIG_NET_CLS_POLICE
@@ -846,29 +833,14 @@ static int u32_dump(struct tcf_proto *tp, unsigned long fh,
 
                }
 #endif
-#endif
-
-#ifdef CONFIG_NET_CLS_IND
-               if(strlen(n->indev)) {
-                       struct rtattr * p_rta = (struct rtattr*)skb->tail;
-                       RTA_PUT(skb, TCA_U32_INDEV, IFNAMSIZ, n->indev);
-                       p_rta->rta_len = skb->tail - (u8*)p_rta;
-               }
-#endif
-#ifdef CONFIG_CLS_U32_PERF
-               RTA_PUT(skb, TCA_U32_PCNT, 
-               sizeof(struct tc_u32_pcnt) + n->sel.nkeys*sizeof(__u64),
-                       n->pf);
 #endif
        }
 
        rta->rta_len = skb->tail - b;
 #ifdef CONFIG_NET_CLS_ACT
-       if (TC_U32_KEY(n->handle) != 0) {
-               if (TC_U32_KEY(n->handle) && n->action && n->action->type == TCA_OLD_COMPAT) {
-                       if (tcf_action_copy_stats(skb,n->action))
-                               goto rtattr_failure;
-               }
+       if (TC_U32_KEY(n->handle) && n->action && n->action->type == TCA_OLD_COMPAT) {
+               if (tcf_action_copy_stats(skb,n->action))
+                       goto rtattr_failure;
        }
 #else
 #ifdef CONFIG_NET_CLS_POLICE
@@ -903,19 +875,6 @@ static struct tcf_proto_ops cls_u32_ops = {
 
 static int __init init_u32(void)
 {
-       printk("u32 classifier\n");
-#ifdef CONFIG_CLS_U32_PERF
-       printk("    Perfomance counters on\n");
-#endif
-#ifdef CONFIG_NET_CLS_POLICE
-       printk("    OLD policer on \n");
-#endif
-#ifdef CONFIG_NET_CLS_IND
-       printk("    input device check on \n");
-#endif
-#ifdef CONFIG_NET_CLS_ACT
-       printk("    Actions configured \n");
-#endif
        return register_tcf_proto_ops(&cls_u32_ops);
 }