act_mirred: optimization.
[safe/jmp/linux-2.6] / net / sched / cls_u32.c
index 527db25..07372f6 100644 (file)
@@ -345,7 +345,7 @@ static int u32_delete_key(struct tcf_proto *tp, struct tc_u_knode* key)
                        }
                }
        }
-       BUG_TRAP(0);
+       WARN_ON(1);
        return 0;
 }
 
@@ -368,7 +368,7 @@ static int u32_destroy_hnode(struct tcf_proto *tp, struct tc_u_hnode *ht)
        struct tc_u_common *tp_c = tp->data;
        struct tc_u_hnode **hn;
 
-       BUG_TRAP(!ht->refcnt);
+       WARN_ON(ht->refcnt);
 
        u32_clear_hnode(tp, ht);
 
@@ -380,16 +380,16 @@ static int u32_destroy_hnode(struct tcf_proto *tp, struct tc_u_hnode *ht)
                }
        }
 
-       BUG_TRAP(0);
+       WARN_ON(1);
        return -ENOENT;
 }
 
 static void u32_destroy(struct tcf_proto *tp)
 {
        struct tc_u_common *tp_c = tp->data;
-       struct tc_u_hnode *root_ht = xchg(&tp->root, NULL);
+       struct tc_u_hnode *root_ht = tp->root;
 
-       BUG_TRAP(root_ht != NULL);
+       WARN_ON(root_ht == NULL);
 
        if (root_ht && --root_ht->refcnt == 0)
                u32_destroy_hnode(tp, root_ht);
@@ -407,7 +407,7 @@ static void u32_destroy(struct tcf_proto *tp)
                while ((ht = tp_c->hlist) != NULL) {
                        tp_c->hlist = ht->next;
 
-                       BUG_TRAP(ht->refcnt == 0);
+                       WARN_ON(ht->refcnt != 0);
 
                        kfree(ht);
                }
@@ -479,7 +479,7 @@ static int u32_set_parms(struct tcf_proto *tp, unsigned long base,
        err = -EINVAL;
        if (tb[TCA_U32_LINK]) {
                u32 handle = nla_get_u32(tb[TCA_U32_LINK]);
-               struct tc_u_hnode *ht_down = NULL;
+               struct tc_u_hnode *ht_down = NULL, *ht_old;
 
                if (TC_U32_KEY(handle))
                        goto errout;
@@ -493,11 +493,12 @@ static int u32_set_parms(struct tcf_proto *tp, unsigned long base,
                }
 
                tcf_tree_lock(tp);
-               ht_down = xchg(&n->ht_down, ht_down);
+               ht_old = n->ht_down;
+               n->ht_down = ht_down;
                tcf_tree_unlock(tp);
 
-               if (ht_down)
-                       ht_down->refcnt--;
+               if (ht_old)
+                       ht_old->refcnt--;
        }
        if (tb[TCA_U32_CLASSID]) {
                n->res.classid = nla_get_u32(tb[TCA_U32_CLASSID]);
@@ -637,8 +638,9 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle,
                                break;
 
                n->next = *ins;
-               wmb();
+               tcf_tree_lock(tp);
                *ins = n;
+               tcf_tree_unlock(tp);
 
                *arg = (unsigned long)n;
                return 0;