secchan: Remove idle flows from datapath even if their rules haven't expired.
authorBen Pfaff <blp@nicira.com>
Tue, 17 Mar 2009 17:54:33 +0000 (10:54 -0700)
committerBen Pfaff <blp@nicira.com>
Tue, 17 Mar 2009 17:54:33 +0000 (10:54 -0700)
secchan/ofproto.c

index 3846ffbf6d85bb78feb3536f14382123dd06a793..1eec332df69f816a5d7f2b3c8591d34f250f70c3 100644 (file)
@@ -2886,6 +2886,19 @@ send_flow_exp(struct ofproto *p, struct rule *rule,
     }
 }
 
+static void
+uninstall_idle_flow(struct ofproto *ofproto, struct rule *rule)
+{
+    assert(rule->installed);
+    assert(!rule->cr.wc.wildcards);
+
+    rule_uninstall(ofproto, rule);
+    if (rule->super) {
+        classifier_remove(&ofproto->cls, &rule->cr);
+        rule_destroy(rule);
+    }
+}
+
 static void
 expire_rule(struct cls_rule *cls_rule, void *p_)
 {
@@ -2902,11 +2915,17 @@ expire_rule(struct cls_rule *cls_rule, void *p_)
                    : LLONG_MAX);
     expire = MIN(hard_expire, idle_expire);
     if (expire == LLONG_MAX) {
+        if (rule->installed && time_msec() >= rule->used + 5000) {
+            uninstall_idle_flow(p, rule);
+        }
         return;
     }
 
     now = time_msec();
     if (now < expire) {
+        if (rule->installed && now >= rule->used + 5000) {
+            uninstall_idle_flow(p, rule);
+        }
         return;
     }