secchan: Optimize no-change case in modify_flow().
authorBen Pfaff <blp@nicira.com>
Wed, 29 Apr 2009 22:42:59 +0000 (15:42 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 1 May 2009 17:55:28 +0000 (10:55 -0700)
secchan/ofproto.c

index 5b7e169f1a89f41d327a30554b472aa27829bea2..8b194986481b0c311b96a451d08c646fc7cbdf7f 100644 (file)
@@ -2497,9 +2497,16 @@ modify_flow(struct ofproto *p, const struct ofp_flow_mod *ofm,
     if (command == OFPFC_DELETE) {
         rule_remove(p, rule);
     } else {
+        size_t actions_len = n_actions * sizeof *rule->actions;
+
+        if (n_actions == rule->n_actions
+            && !memcmp(ofm->actions, rule->actions, actions_len))
+        {
+            return 0;
+        }
+
         free(rule->actions);
-        rule->actions = xmemdup(ofm->actions,
-                                n_actions * sizeof *rule->actions);
+        rule->actions = xmemdup(ofm->actions, actions_len);
         rule->n_actions = n_actions;
 
         if (rule->cr.wc.wildcards) {