summaryrefslogtreecommitdiff
path: root/ofproto/ofproto-dpif-ipfix.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2017-06-05 18:04:50 -0700
committerBen Pfaff <blp@ovn.org>2017-08-09 13:06:49 -0700
commitf88ee3a599461f390bce7d0b00c182d7a1f5cb6e (patch)
tree8a235d1544486760fb5037e90096364f2cd74d58 /ofproto/ofproto-dpif-ipfix.c
parent87da4e2f6b9a4a91ba906e0ec6964690a5be1afa (diff)
downloadopenvswitch-f88ee3a599461f390bce7d0b00c182d7a1f5cb6e.tar.gz
ofproto-dpif-ipfix: Use common OVS functions for getting current time.
OVS has common infrastructure functions for getting the current time, but this code was not using them. It is not clear why, so this commit changes it to use them. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Andy Zhou <azhou@ovn.org>
Diffstat (limited to 'ofproto/ofproto-dpif-ipfix.c')
-rw-r--r--ofproto/ofproto-dpif-ipfix.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/ofproto/ofproto-dpif-ipfix.c b/ofproto/ofproto-dpif-ipfix.c
index 5549b4951..fcba02e45 100644
--- a/ofproto/ofproto-dpif-ipfix.c
+++ b/ofproto/ofproto-dpif-ipfix.c
@@ -1865,6 +1865,14 @@ ipfix_update_stats(struct dpif_ipfix_exporter *exporter,
}
}
+/* Returns the current time in the form used by IPFIX (microseconds since the
+ * epoch). */
+static uint64_t
+ipfix_now(void)
+{
+ return time_wall_msec() * 1000ULL;
+}
+
/* Add an entry into a flow cache. The entry is either aggregated into
* an existing entry with the same flow key and free()d, or it is
* inserted into the cache. And IPFIX stats will be updated */
@@ -2103,7 +2111,6 @@ ipfix_cache_entry_init(struct ipfix_flow_cache_entry *entry,
}
{
- struct timeval now;
uint64_t layer2_octet_delta_count;
/* Calculate the total matched octet count by considering as
@@ -2111,8 +2118,7 @@ ipfix_cache_entry_init(struct ipfix_flow_cache_entry *entry,
* length. */
layer2_octet_delta_count = packet_delta_count * ethernet_total_length;
- xgettimeofday(&now);
- entry->flow_end_timestamp_usec = now.tv_usec + 1000000LL * now.tv_sec;
+ entry->flow_end_timestamp_usec = ipfix_now();
entry->flow_start_timestamp_usec = entry->flow_end_timestamp_usec;
if (ipfix_actions && ipfix_actions->output_action) {
@@ -2662,19 +2668,12 @@ dpif_ipfix_cache_expire(struct dpif_ipfix_exporter *exporter,
static void
get_export_time_now(uint64_t *export_time_usec, uint32_t *export_time_sec)
{
- struct timeval export_time;
- xgettimeofday(&export_time);
-
- *export_time_usec = export_time.tv_usec + 1000000LL * export_time.tv_sec;
+ *export_time_usec = ipfix_now();
/* The IPFIX start and end deltas are negative deltas relative to
* the export time, so set the export time 1 second off to
* calculate those deltas. */
- if (export_time.tv_usec == 0) {
- *export_time_sec = export_time.tv_sec;
- } else {
- *export_time_sec = export_time.tv_sec + 1;
- }
+ *export_time_sec = DIV_ROUND_UP(*export_time_usec, 1000000);
}
static void