When ovn-controller reconnects to the ovs-vswitchd, it deletes all the OF flows in the switch. It doesn't install the flows again, leaving the datapath broken unless ovn-controller is restarted or ovn-northd updates the SB DB.
The reason for this is - lflow_reset_processing() is not called after the reconnection - the hmap "installed_flows" is not cleared, because of which ofctrl_put skips adding the flows to the switch. This patch fixes the issue and also adds a test case to test this scenario. Signed-off-by: Numan Siddique <nusid...@redhat.com> --- ovn/controller/ofctrl.c | 7 +++++++ tests/ovn.at | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/ovn/controller/ofctrl.c b/ovn/controller/ofctrl.c index 79d840d..d9104de 100644 --- a/ovn/controller/ofctrl.c +++ b/ovn/controller/ofctrl.c @@ -20,6 +20,7 @@ #include "flow.h" #include "hash.h" #include "hindex.h" +#include "lflow.h" #include "ofctrl.h" #include "openflow/openflow.h" #include "openvswitch/dynamic-string.h" @@ -369,6 +370,7 @@ run_S_CLEAR_FLOWS(void) /* Clear installed_flows, to match the state of the switch. */ ovn_flow_table_clear(); + lflow_reset_processing(); /* Clear existing groups, to match the state of the switch. */ if (groups) { @@ -803,6 +805,11 @@ ovn_flow_table_clear(void) hindex_remove(&uuid_flow_table, &f->uuid_hindex_node); ovn_flow_destroy(f); } + + HMAP_FOR_EACH_SAFE (f, next, match_hmap_node, &installed_flows) { + hmap_remove(&installed_flows, &f->match_hmap_node); + ovn_flow_destroy(f); + } } static void diff --git a/tests/ovn.at b/tests/ovn.at index 72868be..c5a6b75 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -4069,3 +4069,55 @@ AT_CHECK([cat received2.packets], [0], [expout]) OVN_CLEANUP([hv1]) AT_CLEANUP + +AT_SETUP([ovn -- ovs-vswitchd restart]) +AT_KEYWORDS([vswitchd restart]) +AT_SKIP_IF([test $HAVE_PYTHON = no]) +ovn_start + +ovn-nbctl ls-add ls1 + +ovn-nbctl lsp-add ls1 ls1-lp1 \ +-- lsp-set-addresses ls1-lp1 "f0:00:00:00:00:01 10.0.0.4" + +ovn-nbctl lsp-set-port-security ls1-lp1 "f0:00:00:00:00:01 10.0.0.4" + +net_add n1 +sim_add hv1 + +as hv1 +ovs-vsctl add-br br-phys +ovn_attach n1 br-phys 192.168.0.1 +ovs-vsctl -- add-port br-int hv1-vif1 -- \ + set interface hv1-vif1 external-ids:iface-id=ls1-lp1 \ + options:tx_pcap=hv1/vif1-tx.pcap \ + options:rxq_pcap=hv1/vif1-rx.pcap \ + ofport-request=1 + +ovn_populate_arp +sleep 2 + +as hv1 ovs-vsctl show + +echo "---------------------" +ovn-sbctl dump-flows +echo "---------------------" + +echo "------ hv1 dump ----------" +as hv1 ovs-ofctl dump-flows br-int +total_flows=`as hv1 ovs-ofctl dump-flows br-int | wc -l` + +echo "Total flows before vswitchd restart = " $total_flows + +as hv1 +OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) +start_daemon ovs-vswitchd --enable-dummy=system -vvconn -vofproto_dpif -vunixctl + +sleep 2 +total_flows_after_restart=`as hv1 ovs-ofctl dump-flows br-int | wc -l` +echo "Total flows after vswitchd restart = " $total_flows_after_restart + +AT_CHECK([test "${total_flows}" = "${total_flows_after_restart}"]) + +OVN_CLEANUP([hv1]) +AT_CLEANUP -- 2.7.4 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev