revalidator: Use xcache when revalidation is required.
authorJoe Stringer <joestringer@nicira.com>
Thu, 5 Jun 2014 06:08:40 +0000 (06:08 +0000)
committerJoe Stringer <joestringer@nicira.com>
Thu, 5 Jun 2014 01:21:50 +0000 (13:21 +1200)
One of the reasons that xlate_cache was introduced was to ensure that
statistics were attributed to the correct rules and interfaces according
to the flow that was installed into the datapath, rather than according
to the current state of the flow table.

This patch makes the revalidators use the xlate_cache to attribute stats
when full revalidation is required, as the statistics belong to the old
ruleset. However, when revalidating, the rules may have changed while
leaving the datapath flows intact, so we still re-create the xcache at
that point.

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Acked-by: Alex Wang <alexw@nicira.com>
ofproto/ofproto-dpif-upcall.c

index 3a75690..57a01e0 100644 (file)
@@ -1149,10 +1149,17 @@ revalidate_ukey(struct udpif *udpif, struct udpif_key *ukey,
     }
 
     may_learn = push.n_packets > 0;
-    if (ukey->xcache && !udpif->need_revalidate) {
+    if (ukey->xcache) {
         xlate_push_stats(ukey->xcache, may_learn, &push);
-        ok = true;
-        goto exit;
+        if (udpif->need_revalidate) {
+            xlate_cache_clear(ukey->xcache);
+            push.n_packets = 0;
+            push.n_bytes = 0;
+            may_learn = false;
+        } else {
+            ok = true;
+            goto exit;
+        }
     }
 
     error = xlate_receive(udpif->backer, NULL, ukey->key, ukey->key_len, &flow,
@@ -1161,9 +1168,6 @@ revalidate_ukey(struct udpif *udpif, struct udpif_key *ukey,
         goto exit;
     }
 
-    if (udpif->need_revalidate) {
-        xlate_cache_clear(ukey->xcache);
-    }
     if (!ukey->xcache) {
         ukey->xcache = xlate_cache_new();
     }