ofproto: Delete fail-open flow when turning off fail-open mode.
authorBen Pfaff <blp@nicira.com>
Tue, 23 Feb 2010 23:14:15 +0000 (15:14 -0800)
committerBen Pfaff <blp@nicira.com>
Wed, 24 Feb 2010 00:45:34 +0000 (16:45 -0800)
fail_open_destroy() was not deleting the fail-open flow, so turning off
fail-open mode did not work if fail-open had already been triggered.
This commit fixes the problem.

Reported by Paul Ingram <paul@nicira.com>.

ofproto/fail-open.c
ofproto/ofproto.c

index 54a91cdfd76a7f518c24612c4da816955fc7b825..ff77de87ec7ce8d7a4d859f7947e018955f5ed49 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010 Nicira Networks.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -76,6 +76,8 @@ struct fail_open {
     struct rconn_packet_counter *bogus_packet_counter;
 };
 
+static void fail_open_recover(struct fail_open *);
+
 /* Returns true if 'fo' should be in fail-open mode, otherwise false. */
 static inline bool
 should_fail_open(const struct fail_open *fo)
@@ -155,7 +157,15 @@ fail_open_run(struct fail_open *fo)
 void
 fail_open_maybe_recover(struct fail_open *fo)
 {
-    if (fail_open_is_active(fo) && rconn_is_admitted(fo->controller)) {
+    if (rconn_is_admitted(fo->controller)) {
+        fail_open_recover(fo);
+    }
+}
+
+static void
+fail_open_recover(struct fail_open *fo)
+{
+    if (fail_open_is_active(fo)) {
         flow_t flow;
 
         VLOG_WARN("No longer in fail-open mode");
@@ -235,6 +245,7 @@ void
 fail_open_destroy(struct fail_open *fo)
 {
     if (fo) {
+        fail_open_recover(fo);
         /* We don't own fo->controller. */
         switch_status_unregister(fo->ss_cat);
         rconn_packet_counter_destroy(fo->bogus_packet_counter);
index a431cc78f00295aeb05f82b4ab562bf2fd589b11..b1f022f25c9e86efa38e88bf9979821cce01a875 100644 (file)
@@ -679,6 +679,9 @@ ofproto_destroy(struct ofproto *p)
         return;
     }
 
+    /* Destroy fail-open early, because it touches the classifier. */
+    ofproto_set_failure(p, false);
+
     ofproto_flush_flows(p);
     classifier_destroy(&p->cls);
 
@@ -697,7 +700,6 @@ ofproto_destroy(struct ofproto *p)
     switch_status_destroy(p->switch_status);
     in_band_destroy(p->in_band);
     discovery_destroy(p->discovery);
-    fail_open_destroy(p->fail_open);
     pinsched_destroy(p->miss_sched);
     pinsched_destroy(p->action_sched);
     netflow_destroy(p->netflow);