ofproto: Move 'used' from ofproto_dpif into ofproto.
[openvswitch] / ofproto / ofproto.c
index 3dab46a4ea3b7e8f1959cadab5b3e0653eb70a35..b27a41c7fa8e9536071190a4751a9395d8271287 100644 (file)
@@ -2580,7 +2580,7 @@ add_flow(struct ofproto *ofproto, struct ofconn *ofconn,
     rule->cr = fm->cr;
     rule->pending = NULL;
     rule->flow_cookie = fm->cookie;
-    rule->created = rule->modified = time_msec();
+    rule->created = rule->modified = rule->used = time_msec();
     rule->idle_timeout = fm->idle_timeout;
     rule->hard_timeout = fm->hard_timeout;
     rule->table_id = table - ofproto->tables;
@@ -2785,6 +2785,14 @@ ofproto_rule_send_removed(struct rule *rule, uint8_t reason)
     connmgr_send_flow_removed(rule->ofproto->connmgr, &fr);
 }
 
+void
+ofproto_rule_update_used(struct rule *rule, long long int used)
+{
+    if (used > rule->used) {
+        rule->used = used;
+    }
+}
+
 /* Sends an OpenFlow "flow removed" message with the given 'reason' (either
  * OFPRR_HARD_TIMEOUT or OFPRR_IDLE_TIMEOUT), and then removes 'rule' from its
  * ofproto.