diff mbox series

[ovs-dev,1/2] fail-open: Refactor NORMAL flow add/del

Message ID 1522698389-83489-1-git-send-email-yihung.wei@gmail.com
State Accepted
Headers show
Series [ovs-dev,1/2] fail-open: Refactor NORMAL flow add/del | expand

Commit Message

Yi-Hung Wei April 2, 2018, 7:46 p.m. UTC
Pull out the NORMAL flow add and deletion.  It will be useful for
a follow up patch.

Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
---
 ofproto/fail-open.c | 47 ++++++++++++++++++++++++++++++-----------------
 1 file changed, 30 insertions(+), 17 deletions(-)

Comments

Ben Pfaff April 4, 2018, 11:07 p.m. UTC | #1
On Mon, Apr 02, 2018 at 12:46:28PM -0700, Yi-Hung Wei wrote:
> Pull out the NORMAL flow add and deletion.  It will be useful for
> a follow up patch.
> 
> Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>

Applied to master, thanks!
diff mbox series

Patch

diff --git a/ofproto/fail-open.c b/ofproto/fail-open.c
index 03552a92deb5..ded282895a10 100644
--- a/ofproto/fail-open.c
+++ b/ofproto/fail-open.c
@@ -145,6 +145,34 @@  send_bogus_packet_ins(struct fail_open *fo)
     dp_packet_uninit(&b);
 }
 
+static void
+fail_open_del_normal_flow(struct fail_open *fo)
+    OVS_REQUIRES(ofproto_mutex)
+{
+    struct match match;
+
+    match_init_catchall(&match);
+    ofproto_delete_flow(fo->ofproto, &match, FAIL_OPEN_PRIORITY);
+}
+
+static void
+fail_open_add_normal_flow(struct fail_open *fo)
+{
+    struct ofpbuf ofpacts;
+    struct match match;
+
+    /* Set up a flow that matches every packet and directs them to
+     * OFPP_NORMAL. */
+    ofpbuf_init(&ofpacts, OFPACT_OUTPUT_SIZE);
+    ofpact_put_OUTPUT(&ofpacts)->port = OFPP_NORMAL;
+
+    match_init_catchall(&match);
+    ofproto_add_flow(fo->ofproto, &match, FAIL_OPEN_PRIORITY,
+            ofpacts.data, ofpacts.size);
+
+    ofpbuf_uninit(&ofpacts);
+}
+
 /* Enter fail-open mode if we should be in it. */
 void
 fail_open_run(struct fail_open *fo)
@@ -205,14 +233,11 @@  static void
 fail_open_recover(struct fail_open *fo)
     OVS_REQUIRES(ofproto_mutex)
 {
-    struct match match;
-
     VLOG_WARN("No longer in fail-open mode");
     fo->last_disconn_secs = 0;
     fo->next_bogus_packet_in = LLONG_MAX;
 
-    match_init_catchall(&match);
-    ofproto_delete_flow(fo->ofproto, &match, FAIL_OPEN_PRIORITY);
+    fail_open_del_normal_flow(fo);
 }
 
 void
@@ -230,19 +255,7 @@  fail_open_flushed(struct fail_open *fo)
     int disconn_secs = connmgr_failure_duration(fo->connmgr);
     bool open = disconn_secs >= trigger_duration(fo);
     if (open) {
-        struct ofpbuf ofpacts;
-        struct match match;
-
-        /* Set up a flow that matches every packet and directs them to
-         * OFPP_NORMAL. */
-        ofpbuf_init(&ofpacts, OFPACT_OUTPUT_SIZE);
-        ofpact_put_OUTPUT(&ofpacts)->port = OFPP_NORMAL;
-
-        match_init_catchall(&match);
-        ofproto_add_flow(fo->ofproto, &match, FAIL_OPEN_PRIORITY,
-                         ofpacts.data, ofpacts.size);
-
-        ofpbuf_uninit(&ofpacts);
+        fail_open_add_normal_flow(fo);
     }
     fo->fail_open_active = open;
 }