ovsdb: Change the way connection duration time is reported in Manager table.
[openvswitch] / ofproto / ofproto.c
index 2efb03afd32a6e4be217c9a51417ad3639471fd7..c7872baf7a3baac5b57542c66e19db8d515cb5df 100644 (file)
@@ -1396,9 +1396,15 @@ ofproto_get_ofproto_controller_info(const struct ofproto * ofproto,
         cinfo->pairs.values[cinfo->pairs.n++] =
             xstrdup(rconn_get_state(rconn));
 
-        cinfo->pairs.keys[cinfo->pairs.n] = "time_in_state";
-        cinfo->pairs.values[cinfo->pairs.n++] =
-            xasprintf("%u", rconn_get_state_elapsed(rconn));
+        if (rconn_is_admitted(rconn)) {
+            cinfo->pairs.keys[cinfo->pairs.n] = "time_connected";
+            cinfo->pairs.values[cinfo->pairs.n++] =
+                xasprintf("%ld", time_now() - rconn_get_last_connection(rconn));
+        } else {
+            cinfo->pairs.keys[cinfo->pairs.n] = "time_disconnected";
+            cinfo->pairs.values[cinfo->pairs.n++] =
+                xasprintf("%d", rconn_failure_duration(rconn));
+        }
     }
 }
 
@@ -2161,12 +2167,10 @@ facet_execute(struct ofproto *ofproto, struct facet *facet,
     assert(ofpbuf_headroom(packet) >= sizeof(struct ofp_packet_in));
 
     flow_extract_stats(&facet->flow, packet, &stats);
+    stats.used = time_msec();
     if (execute_odp_actions(ofproto, &facet->flow,
                             facet->actions, facet->actions_len, packet)) {
-        facet->used = time_msec();
         facet_update_stats(ofproto, facet, &stats);
-        netflow_flow_update_time(ofproto->netflow,
-                                 &facet->nf_flow, facet->used);
     }
 }
 
@@ -3896,7 +3900,7 @@ static void
 facet_update_stats(struct ofproto *ofproto, struct facet *facet,
                    const struct dpif_flow_stats *stats)
 {
-    if (stats->n_packets) {
+    if (stats->n_packets || stats->used > facet->used) {
         facet_update_time(ofproto, facet, stats->used);
         facet->packet_count += stats->n_packets;
         facet->byte_count += stats->n_bytes;