Pull out the NORMAL flow add and deletion. It will be useful for a follow up patch.
Signed-off-by: Yi-Hung Wei <[email protected]> --- ofproto/fail-open.c | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) 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; } -- 2.7.4 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
