/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
} else if (flow.nw_proto == IPPROTO_SCTP) {
struct sctp_header *sh = buf.l4;
ds_put_format(&ds, " sctp_csum:%"PRIx32,
- ntohl(sh->sctp_csum));
+ ntohl(get_16aligned_be32(&sh->sctp_csum)));
}
}
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');
ds_put_cstr(string, s);
free(s);
}
+ ofpbuf_uninit(&payload);
}
static void
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();
}
}