From: Ben Pfaff Date: Wed, 8 Apr 2009 16:44:52 +0000 (-0700) Subject: dpif: Improve dpif_execute() log messages. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2ef15eeea204174b3cf58d1ae95dfbe7825a30d;p=openvswitch dpif: Improve dpif_execute() log messages. --- diff --git a/lib/dpif.c b/lib/dpif.c index 7e19c1af..4da55332 100644 --- a/lib/dpif.c +++ b/lib/dpif.c @@ -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