From 6fe9c1c9babad37c9274b9bfe2d48ac65eb99916 Mon Sep 17 00:00:00 2001 From: Mikhail Ushanov Date: May 11 2020 23:00:52 +0000 Subject: feat: add patches to fix flow-restore issue Signed-off-by: Mikhail Ushanov --- diff --git a/0001-Revert-ovs-save-Handle-cases-of-upgrades-from-very-o.patch b/0001-Revert-ovs-save-Handle-cases-of-upgrades-from-very-o.patch new file mode 100644 index 0000000..0cf640c --- /dev/null +++ b/0001-Revert-ovs-save-Handle-cases-of-upgrades-from-very-o.patch @@ -0,0 +1,38 @@ +From 463656017c1d36ec6e90f1f4a561f0a4161a191d Mon Sep 17 00:00:00 2001 +From: Mikhail Ushanov +Date: Sun, 10 May 2020 22:19:06 +0300 +Subject: [PATCH 1/2] Revert "ovs-save: Handle cases of upgrades from very old + OVS versions." + +This reverts commit fe772f5395a61def37758318d910865f92268ae6. + +Signed-off-by: Mikhail Ushanov +--- + utilities/ovs-save | 11 ----------- + 1 file changed, 11 deletions(-) + +diff --git a/utilities/ovs-save b/utilities/ovs-save +index 7d810cb40..1ba36e9de 100755 +--- a/utilities/ovs-save ++++ b/utilities/ovs-save +@@ -110,17 +110,6 @@ save_flows () { + exit 1 + fi + +- # OVS 2.7 and earlier do not enable OpenFlow 1.4 (by default) and lack +- # other features needed to save and restore flows. Don't try. +- case `ovs-appctl version | sed 1q` in +- "ovs-vswitchd (Open vSwitch) 1."*.*) +- return +- ;; +- "ovs-vswitchd (Open vSwitch) 2."[0-7].*) +- return +- ;; +- esac +- + workdir=$(mktemp -d "${TMPDIR:-/tmp}/ovs-save.XXXXXXXXXX") + for bridge in "$@"; do + # Get the highest enabled OpenFlow version +-- +2.26.2 + diff --git a/0002-connmgr-fix-flow-restore-wait-not-work-with-controll.patch b/0002-connmgr-fix-flow-restore-wait-not-work-with-controll.patch new file mode 100644 index 0000000..d6551c3 --- /dev/null +++ b/0002-connmgr-fix-flow-restore-wait-not-work-with-controll.patch @@ -0,0 +1,159 @@ +From a7c0231c589d8f05515762ae14aed2953640cc94 Mon Sep 17 00:00:00 2001 +From: wenxu +Date: Sat, 9 May 2020 17:32:22 +0800 +Subject: [PATCH 2/2] connmgr: fix flow-restore-wait not work with controller + connects + +When restart the vswitchd with flow-restore-wait. The Vswitch doesn't +connect to the controller util the flow-restore-wait finished. + +Because when bridge_configure_remotes() calls bridge_get_controllers(), +it first checks if flow-restore-wait has been set, and if so, +it ignores any controllers in the controller database and +sets n_controllers to 0. + +So after the flows restore in ovs and remove the flow-restore-wait. +The vswitchd will connect the controller. But it will flush all +the flows we restored. + +In the connmgr_set_controllers if (had_controllers != connmgr_has_controllers(mgr)) +it will flush all the flows through ofproto_flush_flows(mgr->ofproto); +This make flow-restore-wait feature not work at all with controller connects. + +This patch record the flow-restore-wait event and it will avoid the flow +flush if it experience a flow-restore-wait event.. + +Signed-off-by: wenxu +Signed-off-by: Mikhail Ushanov +--- + ofproto/connmgr.c | 16 ++++++++++++++-- + ofproto/connmgr.h | 3 ++- + ofproto/ofproto.c | 5 +++-- + ofproto/ofproto.h | 3 ++- + vswitchd/bridge.c | 9 ++++++--- + 5 files changed, 27 insertions(+), 9 deletions(-) + +diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c +index d975a532b..76c72daa1 100644 +--- a/ofproto/connmgr.c ++++ b/ofproto/connmgr.c +@@ -230,6 +230,8 @@ struct connmgr { + size_t n_extra_remotes; + int in_band_queue; + ++ bool flow_restore; ++ + ATOMIC(int) want_packet_in_on_miss; /* Sum of ofconns' values. */ + }; + +@@ -570,7 +572,8 @@ connmgr_free_controller_info(struct shash *info) + /* Changes 'mgr''s set of controllers to the 'n_controllers' controllers in + * 'controllers'. */ + void +-connmgr_set_controllers(struct connmgr *mgr, struct shash *controllers) ++connmgr_set_controllers(struct connmgr *mgr, struct shash *controllers, ++ bool flow_restore) + OVS_EXCLUDED(ofproto_mutex) + { + bool had_controllers = connmgr_has_controllers(mgr); +@@ -610,8 +613,17 @@ connmgr_set_controllers(struct connmgr *mgr, struct shash *controllers) + update_in_band_remotes(mgr); + update_fail_open(mgr); + if (had_controllers != connmgr_has_controllers(mgr)) { +- ofproto_flush_flows(mgr->ofproto); ++ if (had_controllers == false && ++ mgr->flow_restore == true && ++ flow_restore == false) { ++ goto out; ++ } else { ++ ofproto_flush_flows(mgr->ofproto); ++ } + } ++ ++out: ++ mgr->flow_restore = flow_restore; + } + + /* Drops the connections between 'mgr' and all of its primary and secondary +diff --git a/ofproto/connmgr.h b/ofproto/connmgr.h +index 079c8437c..e164ea139 100644 +--- a/ofproto/connmgr.h ++++ b/ofproto/connmgr.h +@@ -74,7 +74,8 @@ void connmgr_retry(struct connmgr *); + bool connmgr_has_controllers(const struct connmgr *); + void connmgr_get_controller_info(struct connmgr *, struct shash *); + void connmgr_free_controller_info(struct shash *); +-void connmgr_set_controllers(struct connmgr *, struct shash *); ++void connmgr_set_controllers(struct connmgr *, struct shash *, ++ bool flow_restore); + void connmgr_reconnect(const struct connmgr *); + + int connmgr_set_snoops(struct connmgr *, const struct sset *snoops); +diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c +index 715da0607..b8b8beeed 100644 +--- a/ofproto/ofproto.c ++++ b/ofproto/ofproto.c +@@ -641,9 +641,10 @@ ofproto_set_datapath_id(struct ofproto *p, uint64_t datapath_id) + } + + void +-ofproto_set_controllers(struct ofproto *p, struct shash *controllers) ++ofproto_set_controllers(struct ofproto *p, struct shash *controllers, ++ bool flow_restore) + { +- connmgr_set_controllers(p->connmgr, controllers); ++ connmgr_set_controllers(p->connmgr, controllers, flow_restore); + } + + void +diff --git a/ofproto/ofproto.h b/ofproto/ofproto.h +index 6e4afffa1..def36a006 100644 +--- a/ofproto/ofproto.h ++++ b/ofproto/ofproto.h +@@ -326,7 +326,8 @@ int ofproto_port_query_by_name(const struct ofproto *, const char *devname, + /* Top-level configuration. */ + uint64_t ofproto_get_datapath_id(const struct ofproto *); + void ofproto_set_datapath_id(struct ofproto *, uint64_t datapath_id); +-void ofproto_set_controllers(struct ofproto *, struct shash *controllers); ++void ofproto_set_controllers(struct ofproto *, struct shash *controllers, ++ bool flow_restore); + void ofproto_set_fail_mode(struct ofproto *, enum ofproto_fail_mode fail_mode); + void ofproto_reconnect_controllers(struct ofproto *); + void ofproto_set_extra_in_band_remotes(struct ofproto *, +diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c +index 2976771ae..94ebd2f6d 100644 +--- a/vswitchd/bridge.c ++++ b/vswitchd/bridge.c +@@ -3576,6 +3576,8 @@ bridge_configure_remotes(struct bridge *br, + + enum ofproto_fail_mode fail_mode; + ++ bool flow_restore; ++ + /* Check if we should disable in-band control on this bridge. */ + disable_in_band = smap_get_bool(&br->cfg->other_config, "disable-in-band", + false); +@@ -3591,8 +3593,9 @@ bridge_configure_remotes(struct bridge *br, + ofproto_set_extra_in_band_remotes(br->ofproto, managers, n_managers); + } + +- n_controllers = (ofproto_get_flow_restore_wait() ? 0 +- : bridge_get_controllers(br, &controllers)); ++ flow_restore = ofproto_get_flow_restore_wait(); ++ n_controllers = flow_restore ? 0 ++ : bridge_get_controllers(br, &controllers); + + /* The set of controllers to pass down to ofproto. */ + struct shash ocs = SHASH_INITIALIZER(&ocs); +@@ -3688,7 +3691,7 @@ bridge_configure_remotes(struct bridge *br, + }; + shash_add(&ocs, c->target, oc); + } +- ofproto_set_controllers(br->ofproto, &ocs); ++ ofproto_set_controllers(br->ofproto, &ocs, flow_restore); + shash_destroy_free_data(&ocs); + + /* Set the fail-mode. */ +-- +2.26.2 + diff --git a/openvswitch.spec b/openvswitch.spec index b2a30c7..2892741 100644 --- a/openvswitch.spec +++ b/openvswitch.spec @@ -62,11 +62,13 @@ Epoch: 1 %endif +%global infratag .cmpt + Name: openvswitch Summary: Open vSwitch daemon/database/utilities URL: http://www.openvswitch.org/ Version: 2.12.0 -Release: 2%{?commit0:.%{date}git%{shortcommit0}}%{?dist} +Release: 3%{?commit0:.%{date}git%{shortcommit0}}%{infratag}%{?dist} # Nearly all of openvswitch is ASL 2.0. The bugtool is LGPLv2+, and the # lib/sflow*.[ch] files are SISSL @@ -87,6 +89,10 @@ Source: http://openvswitch.org/releases/%{name}-%{version}.tar.gz # OVS (including OVN) backports (0 - 300) Patch001: python3-dict-change.patch +# Fix restore-flow issue +Patch002: 0001-Revert-ovs-save-Handle-cases-of-upgrades-from-very-o.patch +Patch003: 0002-connmgr-fix-flow-restore-wait-not-work-with-controll.patch + BuildRequires: gcc gcc-c++ make BuildRequires: autoconf automake libtool BuildRequires: systemd-units openssl openssl-devel