dpif: Improve dpif_execute() log messages.
authorBen Pfaff <blp@nicira.com>
Wed, 8 Apr 2009 16:44:52 +0000 (09:44 -0700)
committerBen Pfaff <blp@nicira.com>
Wed, 8 Apr 2009 17:36:20 +0000 (10:36 -0700)
lib/dpif.c

index 7e19c1af62a98012155d72cc5ac1dc67e390861a..4da55332ade014a441e9d215153d54093dba35a6 100644 (file)
@@ -559,24 +559,30 @@ dpif_execute(struct dpif *dpif, uint16_t in_port,
              const struct ofpbuf *buf)
 {
     struct odp_execute execute;
+    int error;
+
     memset(&execute, 0, sizeof execute);
     execute.in_port = in_port;
     execute.actions = (union odp_action *) actions;
     execute.n_actions = n_actions;
     execute.data = buf->data;
     execute.length = buf->size;
-#if 0
-    if (VLOG_IS_DBG_ENABLED()) {
-        char *actions_string = odp_actions_to_string(actions, n_actions);
-        char *packet_string = ofp_packet_to_string(buf->data, buf->size,
-                                                   buf->size);
-        VLOG_DBG("executing %s with in_port=%"PRIu16" on packet %s",
-                 actions_string, in_port, packet_string);
-        free(actions_string);
-        free(packet_string);
+    error = do_ioctl(dpif, ODP_EXECUTE, NULL, &execute);
+
+    if (!(error ? VLOG_DROP_WARN(&error_rl) : VLOG_DROP_DBG(&dpmsg_rl))) {
+        struct ds ds = DS_EMPTY_INITIALIZER;
+        char *packet = ofp_packet_to_string(buf->data, buf->size, buf->size);
+        ds_put_format(&ds, "dp%u: execute ", dpif->minor);
+        format_odp_actions(&ds, actions, n_actions);
+        if (error) {
+            ds_put_format(&ds, " failed (%s)", strerror(error));
+        }
+        ds_put_format(&ds, " on packet %s", packet);
+        vlog(THIS_MODULE, error ? VLL_WARN : VLL_DBG, "%s", ds_cstr(&ds));
+        ds_destroy(&ds);
+        free(packet);
     }
-#endif
-    return do_ioctl(dpif, ODP_EXECUTE, "ODP_EXECUTE", &execute);
+    return error;
 }
 
 int