From 42c3641cc473cfb3ae7d80363835da7df85cad2e Mon Sep 17 00:00:00 2001 From: Jesse Gross Date: Thu, 12 Nov 2009 15:58:18 -0800 Subject: [PATCH] ofproto: Distinguish stats from before and after action changes. When a rule is revalidated and the actions change don't lump all the stats together. This will clear the stats in the datapath and send a NetFlow expiration message. This could already happen before in certain circumstances so this change makes it more consistent. --- secchan/ofproto.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/secchan/ofproto.c b/secchan/ofproto.c index 200633eb6..be1f5de60 100644 --- a/secchan/ofproto.c +++ b/secchan/ofproto.c @@ -1649,14 +1649,27 @@ rule_reinstall(struct ofproto *ofproto, struct rule *rule) static void rule_update_actions(struct ofproto *ofproto, struct rule *rule) { - bool actions_changed = rule_make_actions(ofproto, rule, NULL); + bool actions_changed; + uint16_t new_out_iface, old_out_iface; + + old_out_iface = rule->nf_flow.output_iface; + actions_changed = rule_make_actions(ofproto, rule, NULL); + if (rule->may_install) { if (rule->installed) { if (actions_changed) { - /* XXX should really do rule_post_uninstall() for the *old* set - * of actions, and distinguish the old stats from the new. */ struct odp_flow_put put; - do_put_flow(ofproto, rule, ODPPF_CREATE | ODPPF_MODIFY, &put); + do_put_flow(ofproto, rule, ODPPF_CREATE | ODPPF_MODIFY + | ODPPF_ZERO_STATS, &put); + update_stats(ofproto, rule, &put.flow.stats); + + /* Temporarily set the old output iface so that NetFlow + * messages have the correct output interface for the old + * stats. */ + new_out_iface = rule->nf_flow.output_iface; + rule->nf_flow.output_iface = old_out_iface; + rule_post_uninstall(ofproto, rule); + rule->nf_flow.output_iface = new_out_iface; } } else { rule_install(ofproto, rule, NULL); -- 2.43.0