[ovs-dev] [ovs-discuss] [ACLv2 07/19] ofproto: Make current packet counts more accurate.

Jesse Gross jesse at nicira.com
Fri Sep 4 22:21:04 UTC 2009

Ben Pfaff wrote:
> Jesse Gross <jesse at nicira.com> writes:
>> When the stats for a currently active flow are requested this
>> ensures that the packets not handled by the kernel are counted
>> immediately.  Before, these packets would only be counted once
>> the kernel flow expired and the counts were combined.
> Did you observe that this makes a difference in practice?  I'm
> not sure that a subrule ever has a nonzero packet_count or
> byte_count at a point where query_stats() can see it.  There are
> only a couple of places that update a rule's 'packet_count' or
> 'byte_count', and in each case it looks like
> rule_post_uninstall() is called afterward, which will update the
> parent rule's counters and zero out the subrule's counters.

Yes, I saw this was a problem while testing.  I gather stats using a few 
different methods for various types of counters and some of them were 
lagging 1 packet behind the others until the flow expired, at which 
point they caught up.

What happens is that a packet gets kicked up to userspace and gets 
processed in handle_odp_msg.  This calls rule_execute, which updates the 
subrule's stats.  Until the flow expires the stats for that packet exist 
only in the subrule - not in the datapath because it didn't handle the 
packet and not in the super rule because it hasn't expired yet.  So 
without this change, those packets will be missing if you query before 
flow expiration.

More information about the dev mailing list