ofproto-dpif: Move code closer to left margin in facet_check_consistency().
authorBen Pfaff <blp@nicira.com>
Sat, 5 May 2012 00:05:08 +0000 (17:05 -0700)
committerBen Pfaff <blp@nicira.com>
Wed, 9 May 2012 19:58:54 +0000 (12:58 -0700)
This makes an upcoming commit break up fewer lines.

Signed-off-by: Ben Pfaff <blp@nicira.com>
ofproto/ofproto-dpif.c

index c16b984d7ef5c310cbeb13c91688901ff73fe533..5290afb973b28333bc0f36dea040a534eb8c93f5 100644 (file)
@@ -3736,9 +3736,12 @@ facet_check_consistency(struct facet *facet)
     /* Check the datapath actions for consistency. */
     ofpbuf_use_stub(&odp_actions, odp_actions_stub, sizeof odp_actions_stub);
     LIST_FOR_EACH (subfacet, list_node, &facet->subfacets) {
+        struct odputil_keybuf keybuf;
         struct action_xlate_ctx ctx;
         bool actions_changed;
         bool should_install;
+        struct ofpbuf key;
+        struct ds s;
 
         action_xlate_ctx_init(&ctx, ofproto, &facet->flow,
                               subfacet->initial_tci, rule, 0, NULL);
@@ -3756,48 +3759,49 @@ facet_check_consistency(struct facet *facet)
         actions_changed = (subfacet->actions_len != odp_actions.size
                            || memcmp(subfacet->actions, odp_actions.data,
                                      subfacet->actions_len));
-        if (should_install != subfacet->installed || actions_changed) {
-            if (ok) {
-                may_log = !VLOG_DROP_WARN(&rl);
-                ok = false;
-            }
-
-            if (may_log) {
-                struct odputil_keybuf keybuf;
-                struct ofpbuf key;
-                struct ds s;
-
-                ds_init(&s);
-                subfacet_get_key(subfacet, &keybuf, &key);
-                odp_flow_key_format(key.data, key.size, &s);
+        if (should_install == subfacet->installed && !actions_changed) {
+            continue;
+        }
 
-                ds_put_cstr(&s, ": inconsistency in subfacet");
-                if (should_install != subfacet->installed) {
-                    enum odp_key_fitness fitness = subfacet->key_fitness;
+        /* Inconsistency! */
+        if (ok) {
+            may_log = !VLOG_DROP_WARN(&rl);
+            ok = false;
+        }
+        if (!may_log) {
+            /* Rate-limited, skip reporting. */
+            continue;
+        }
 
-                    ds_put_format(&s, " (should%s have been installed)",
-                                  should_install ? "" : " not");
-                    ds_put_format(&s, " (may_set_up_flow=%s, fitness=%s)",
-                                  ctx.may_set_up_flow ? "true" : "false",
-                                  odp_key_fitness_to_string(fitness));
-                }
-                if (actions_changed) {
-                    ds_put_cstr(&s, " (actions were: ");
-                    format_odp_actions(&s, subfacet->actions,
-                                       subfacet->actions_len);
-                    ds_put_cstr(&s, ") (correct actions: ");
-                    format_odp_actions(&s, odp_actions.data, odp_actions.size);
-                    ds_put_char(&s, ')');
-                } else {
-                    ds_put_cstr(&s, " (actions: ");
-                    format_odp_actions(&s, subfacet->actions,
-                                       subfacet->actions_len);
-                    ds_put_char(&s, ')');
-                }
-                VLOG_WARN("%s", ds_cstr(&s));
-                ds_destroy(&s);
-            }
+        ds_init(&s);
+        subfacet_get_key(subfacet, &keybuf, &key);
+        odp_flow_key_format(key.data, key.size, &s);
+
+        ds_put_cstr(&s, ": inconsistency in subfacet");
+        if (should_install != subfacet->installed) {
+            enum odp_key_fitness fitness = subfacet->key_fitness;
+
+            ds_put_format(&s, " (should%s have been installed)",
+                          should_install ? "" : " not");
+            ds_put_format(&s, " (may_set_up_flow=%s, fitness=%s)",
+                          ctx.may_set_up_flow ? "true" : "false",
+                          odp_key_fitness_to_string(fitness));
+        }
+        if (actions_changed) {
+            ds_put_cstr(&s, " (actions were: ");
+            format_odp_actions(&s, subfacet->actions,
+                               subfacet->actions_len);
+            ds_put_cstr(&s, ") (correct actions: ");
+            format_odp_actions(&s, odp_actions.data, odp_actions.size);
+            ds_put_char(&s, ')');
+        } else {
+            ds_put_cstr(&s, " (actions: ");
+            format_odp_actions(&s, subfacet->actions,
+                               subfacet->actions_len);
+            ds_put_char(&s, ')');
         }
+        VLOG_WARN("%s", ds_cstr(&s));
+        ds_destroy(&s);
     }
     ofpbuf_uninit(&odp_actions);