classifier: Tolerate old==new in cls_rule_moved().
authorBen Pfaff <blp@nicira.com>
Thu, 5 Mar 2009 01:16:16 +0000 (17:16 -0800)
committerBen Pfaff <blp@nicira.com>
Thu, 5 Mar 2009 01:34:50 +0000 (17:34 -0800)
The primary purpose of cls_rule_moved() is to deal gracefully with memory
blocks that have been realloc()'d.  realloc() can return the original
memory block so it's best to tolerate that instead of assert-failing.

lib/classifier.c

index c27113b3510eaca347028e210854073cc50103b7..52cad76013af97bc1d4d773a5f8f37529e4b0a9a 100644 (file)
@@ -117,11 +117,12 @@ void
 cls_rule_moved(struct classifier *cls, struct cls_rule *old,
                struct cls_rule *new)
 {
-    assert(old != new);
-    if (new->wc.wildcards) {
-        list_moved(&new->node.list);
-    } else {
-        hmap_moved(&cls->exact_table, &old->node.hmap, &new->node.hmap);
+    if (old != new) {
+        if (new->wc.wildcards) {
+            list_moved(&new->node.list);
+        } else {
+            hmap_moved(&cls->exact_table, &old->node.hmap, &new->node.hmap);
+        }
     }
 }