#include "packets.h"
#include "type-props.h"
#include "unaligned.h"
+#include "odp-util.h"
#include "util.h"
static void ofp_print_queue_name(struct ds *string, uint32_t port);
ofp_packet_to_string(const void *data, size_t len)
{
struct ds ds = DS_EMPTY_INITIALIZER;
+ const struct pkt_metadata md = PKT_METADATA_INITIALIZER(ODPP_NONE);
struct ofpbuf buf;
struct flow flow;
ofpbuf_use_const(&buf, data, len);
- flow_extract(&buf, 0, 0, NULL, NULL, &flow);
+ flow_extract(&buf, &md, &flow);
flow_format(&ds, &flow);
if (buf.l7) {
case OFP13_VERSION:
return; /* no ports in ofp13_switch_features */
default:
- NOT_REACHED();
+ OVS_NOT_REACHED();
}
ofp_print_phy_ports(string, oh->version, &b);
ofp_print_duration(struct ds *string, unsigned int sec, unsigned int nsec)
{
ds_put_format(string, "%u", sec);
+
+ /* If there are no fractional seconds, don't print any decimals.
+ *
+ * If the fractional seconds can be expressed exactly as milliseconds,
+ * print 3 decimals. Open vSwitch provides millisecond precision for most
+ * time measurements, so printing 3 decimals every time makes it easier to
+ * spot real changes in flow dumps that refresh themselves quickly.
+ *
+ * If the fractional seconds are more precise than milliseconds, print the
+ * number of decimals needed to express them exactly.
+ */
if (nsec > 0) {
- ds_put_format(string, ".%09u", nsec);
- while (string->string[string->length - 1] == '0') {
- string->length--;
+ unsigned int msec = nsec / 1000000;
+ if (msec * 1000000 == nsec) {
+ ds_put_format(string, ".%03u", msec);
+ } else {
+ ds_put_format(string, ".%09u", nsec);
+ while (string->string[string->length - 1] == '0') {
+ string->length--;
+ }
}
}
ds_put_char(string, 's');
break;
default:
- NOT_REACHED();
+ OVS_NOT_REACHED();
}
}
ds_put_cstr(string, "slave");
break;
default:
- NOT_REACHED();
+ OVS_NOT_REACHED();
}
if (generation_id != UINT64_MAX) {
ds_put_cstr(string, "experimenter_data_changed");
break;
default:
- NOT_REACHED();
+ OVS_NOT_REACHED();
}
}