ofproto: Iterate through exact-match rules first during expiration.
authorBen Pfaff <blp@nicira.com>
Wed, 29 Sep 2010 20:04:03 +0000 (13:04 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 7 Oct 2010 17:30:54 +0000 (10:30 -0700)
A wildcarded flow is idle only if all of its subrules have expired because
they were idle, so unless we expire exact-match rules first it is possible
that a wildcarded flow fails to expire as soon as it should.

(The current implementation of classifier_for_each() iterates through
exact-match rules before wildcarded rules, but nothing in the interface
guarantees that.)

ofproto/ofproto.c

index 859f416fe1312ea85baf5bef9103e64ab3d986ad..cc90f91ce8bb0e3f7d9706463b2e6b05162c60b5 100644 (file)
@@ -4258,9 +4258,13 @@ ofproto_expire(struct ofproto *ofproto)
     /* Update 'used' for each flow in the datapath. */
     ofproto_update_used(ofproto);
 
-    /* Expire idle flows. */
+    /* Expire idle flows.
+     *
+     * A wildcarded flow is idle only when all of its subrules have expired due
+     * to becoming idle, so iterate through the exact-match flows first. */
     cbdata.ofproto = ofproto;
-    classifier_for_each(&ofproto->cls, CLS_INC_ALL, rule_expire, &cbdata);
+    classifier_for_each(&ofproto->cls, CLS_INC_EXACT, rule_expire, &cbdata);
+    classifier_for_each(&ofproto->cls, CLS_INC_WILD, rule_expire, &cbdata);
 
     /* Let the hook know that we're at a stable point: all outstanding data
      * in existing flows has been accounted to the account_cb.  Thus, the