aboutsummaryrefslogtreecommitdiff
path: root/lib/dpif.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-06-08 14:03:47 -0700
committerBen Pfaff <blp@nicira.com>2011-06-09 09:21:24 -0700
commit01545c1a3c626ce2748a0d7f58719b2c4c9c6f5c (patch)
tree03fba22bfdeae06bb5cdd066184c967d42963626 /lib/dpif.c
parent9cb8877cf7d1d86101a8f27829ad47ea0c8b1fe5 (diff)
dpif: Improve logging of upcalls.
The kernel now provides the entire flow key for a packet sent up to userspace, but dpif_recv() would only log the in_port. This change makes userspace log the entire flow key. This would have made a bug that I recently looked at a bit easier to investigate.
Diffstat (limited to 'lib/dpif.c')
-rw-r--r--lib/dpif.c42
1 files changed, 28 insertions, 14 deletions
diff --git a/lib/dpif.c b/lib/dpif.c
index 1106d6be..4e3788d4 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -952,6 +952,18 @@ dpif_execute(struct dpif *dpif,
return error;
}
+/* Returns a string that represents 'type', for use in log messages. */
+const char *
+dpif_upcall_type_to_string(enum dpif_upcall_type type)
+{
+ switch (type) {
+ case DPIF_UC_MISS: return "miss";
+ case DPIF_UC_ACTION: return "action";
+ case DPIF_UC_SAMPLE: return "sample";
+ case DPIF_N_UC_TYPES: default: return "<unknown>";
+ }
+}
+
static bool OVS_UNUSED
is_valid_listen_mask(int listen_mask)
{
@@ -1045,20 +1057,22 @@ dpif_recv(struct dpif *dpif, struct dpif_upcall *upcall)
{
int error = dpif->dpif_class->recv(dpif, upcall);
if (!error && !VLOG_DROP_DBG(&dpmsg_rl)) {
- struct flow flow;
- char *s;
-
- s = ofp_packet_to_string(upcall->packet->data,
- upcall->packet->size, upcall->packet->size);
- odp_flow_key_to_flow(upcall->key, upcall->key_len, &flow);
-
- VLOG_DBG("%s: %s upcall on port %"PRIu16": %s", dpif_name(dpif),
- (upcall->type == DPIF_UC_MISS ? "miss"
- : upcall->type == DPIF_UC_ACTION ? "action"
- : upcall->type == DPIF_UC_SAMPLE ? "sample"
- : "<unknown>"),
- flow.in_port, s);
- free(s);
+ struct ds flow;
+ char *packet;
+
+ packet = ofp_packet_to_string(upcall->packet->data,
+ upcall->packet->size,
+ upcall->packet->size);
+
+ ds_init(&flow);
+ odp_flow_key_format(upcall->key, upcall->key_len, &flow);
+
+ VLOG_DBG("%s: %s upcall:\n%s\n%s",
+ dpif_name(dpif), dpif_upcall_type_to_string(upcall->type),
+ ds_cstr(&flow), packet);
+
+ ds_destroy(&flow);
+ free(packet);
}
return error;
}