summaryrefslogtreecommitdiff
path: root/ofproto
diff options
context:
space:
mode:
authorYi-Hung Wei <yihung.wei@gmail.com>2018-04-02 12:46:28 -0700
committerBen Pfaff <blp@ovn.org>2018-04-04 16:02:20 -0700
commit816d224d54324334bc347c3b5ed957631b6a43e0 (patch)
tree16325fd908dd6bf7d6268ec22bad780cc795bbdb /ofproto
parentefae9437d1b3227c0799c1afc24881217e10e9ea (diff)
downloadopenvswitch-816d224d54324334bc347c3b5ed957631b6a43e0.tar.gz
fail-open: Refactor NORMAL flow add/del
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> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'ofproto')
-rw-r--r--ofproto/fail-open.c47
1 files changed, 30 insertions, 17 deletions
diff --git a/ofproto/fail-open.c b/ofproto/fail-open.c
index 03552a92d..ded282895 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;
}