OpenFlow packet and byte counters have always been something of an approximation in Open vSwitch. First, they are updated only periodically. Second, they can be misattributed because statistics collection does a retranslation and gives the statistics to whichever OpenFlow flow or flows they happen to hit, which could be different from the original set of flows because the OpenFlow flow table may have changed.
This commit is intended to somewhat improve on the second point, by always attributing statistics to the set of flows that were cached at the datapath flow's initial translation by the revalidator. This reduces the race in which the flow table could have changed to the interval between the initial installation and the first translation by the revalidator. We plan to start having the thread that does the initial installation also create the ukey, which would eliminate that interval entirely. At that point, packets could get lost from OpenFlow statistics because of the periodic collection of datapath statistics, but they should no longer be misattributed. Signed-off-by: Ben Pfaff <b...@nicira.com> --- ofproto/ofproto-dpif-upcall.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index b5e1253..954449c 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -1307,13 +1307,11 @@ revalidate_ukey(struct udpif *udpif, struct udpif_key *ukey, /* We will push the stats, so update the ukey stats cache. */ ukey->stats = f->stats; - if (!push.n_packets && !udpif->need_revalidate) { - ok = true; - goto exit; - } - - if (ukey->xcache && !udpif->need_revalidate) { + if (ukey->xcache) { xlate_push_stats(ukey->xcache, &push); + memset(&push, 0, sizeof push); + } + if (!push.n_packets && !udpif->need_revalidate) { ok = true; goto exit; } -- 1.7.10.4 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev