This new engine now maintains the transit-switch related data for ovn-ic
daemon which was earlier maintained by the ic engine node invoked the
ts_run() function. The inputs to this engine node are:
   en_enum_datapaths;
   en_icsb_datapath_binding;
   en_nb_logical_switch;
   en_icnb_ic_nb_global;
   en_icnb_transit_switch;
   en_icsb_encap;

In order to achieve this, we refactor in the following way:
* Introduce ts_init() which initializes this data.
* Introduce ts_destroy() which clears this data for a new iteration.
* Introduce ts_run() which invokes the full recompute of the engine.

This engine node becomes an input to 'ic' node.

Signed-off-by: Paulo Guilherme Silva <[email protected]>
---
 ic/automake.mk        |   2 +
 ic/en-ic.c            |  16 +--
 ic/en-ts.c            | 282 ++++++++++++++++++++++++++++++++++++++++++
 ic/en-ts.h            |  23 ++++
 ic/inc-proc-ic.c      |  16 ++-
 ic/ovn-ic.c           | 171 +------------------------
 ic/ovn-ic.h           |   1 -
 lib/stopwatch-names.h |   1 +
 8 files changed, 322 insertions(+), 190 deletions(-)
 create mode 100644 ic/en-ts.c
 create mode 100644 ic/en-ts.h

diff --git a/ic/automake.mk b/ic/automake.mk
index 180fcb252..84a487dc1 100644
--- a/ic/automake.mk
+++ b/ic/automake.mk
@@ -8,6 +8,8 @@ ic_ovn_ic_SOURCES = ic/ovn-ic.c \
        ic/en-gateway.h \
        ic/en-enum-datapaths.c \
        ic/en-enum-datapaths.h \
+       ic/en-ts.c \
+       ic/en-ts.h \
        ic/en-tr.c \
        ic/en-tr.h \
        ic/en-port-binding.c \
diff --git a/ic/en-ic.c b/ic/en-ic.c
index e9450a290..14c5c29cb 100644
--- a/ic/en-ic.c
+++ b/ic/en-ic.c
@@ -48,22 +48,14 @@ ic_get_input_data(struct engine_node *node,
         EN_OVSDB_GET(engine_get_input("NB_logical_switch", node));
     input_data->nbrec_logical_router_table =
         EN_OVSDB_GET(engine_get_input("NB_logical_router", node));
-    input_data->sbrec_sb_global_table =
-        EN_OVSDB_GET(engine_get_input("SB_sb_global", node));
     input_data->sbrec_chassis_table =
         EN_OVSDB_GET(engine_get_input("SB_chassis", node));
-    input_data->icnbrec_ic_nb_global_table =
-        EN_OVSDB_GET(engine_get_input("ICNB_ic_nb_global", node));
-    input_data->icnbrec_transit_switch_table =
-        EN_OVSDB_GET(engine_get_input("ICNB_transit_switch", node));
+    input_data->sbrec_sb_global_table =
+        EN_OVSDB_GET(engine_get_input("SB_sb_global", node));
     input_data->icsbrec_ic_sb_global_table =
         EN_OVSDB_GET(engine_get_input("ICSB_ic_sb_global", node));
     input_data->icsbrec_availability_zone_table =
         EN_OVSDB_GET(engine_get_input("ICSB_availability_zone", node));
-    input_data->icsbrec_encap_table =
-        EN_OVSDB_GET(engine_get_input("ICSB_encap", node));
-    input_data->icsbrec_datapath_binding_table =
-        EN_OVSDB_GET(engine_get_input("ICSB_datapath_binding", node));
 
     /* Indexes */
     input_data->nbrec_ls_by_name =
@@ -102,10 +94,6 @@ ic_get_input_data(struct engine_node *node,
         engine_ovsdb_node_get_index(
             engine_get_input("SB_service_monitor", node),
             "sbrec_service_monitor_by_remote_type_logical_port");
-    input_data->icnbrec_transit_switch_by_name =
-        engine_ovsdb_node_get_index(
-            engine_get_input("ICNB_transit_switch", node),
-            "icnbrec_transit_switch_by_name");
     input_data->icsbrec_service_monitor_by_source_az =
         engine_ovsdb_node_get_index(
             engine_get_input("ICSB_service_monitor", node),
diff --git a/ic/en-ts.c b/ic/en-ts.c
new file mode 100644
index 000000000..4f9322326
--- /dev/null
+++ b/ic/en-ts.c
@@ -0,0 +1,282 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+#include <config.h>
+
+#include <getopt.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+/* OVS includes. */
+#include "openvswitch/vlog.h"
+
+/* OVN includes. */
+#include "ovn-ic.h"
+#include "en-ts.h"
+#include "en-enum-datapaths.h"
+#include "inc-proc-ic.h"
+#include "lib/inc-proc-eng.h"
+#include "lib/ovn-nb-idl.h"
+#include "lib/ovn-ic-nb-idl.h"
+#include "lib/ovn-ic-sb-idl.h"
+#include "lib/ovn-util.h"
+#include "lib/stopwatch-names.h"
+#include "coverage.h"
+#include "stopwatch.h"
+#include "stopwatch-names.h"
+
+VLOG_DEFINE_THIS_MODULE(en_transit_switch);
+COVERAGE_DEFINE(ts_run);
+
+static void
+ts_run(const struct engine_context *eng_ctx,
+       struct ed_type_transit_switch *ts_data,
+       struct ed_type_enum_datapaths *dp_node_data,
+       const struct nbrec_logical_switch_table *nbrec_ls_table,
+       const struct icnbrec_ic_nb_global_table *icnbrec_nb_global_table,
+       const struct icnbrec_transit_switch_table *icnbrec_ts_table,
+       const struct icsbrec_encap_table *icsbrec_encap_table,
+       const struct icsbrec_datapath_binding_table *icsbrec_dp_table);
+static void ts_init(struct ed_type_transit_switch *data);
+static void ts_destroy(struct ed_type_transit_switch *data);
+
+enum engine_node_state
+en_ts_run(struct engine_node *node, void *data)
+{
+    const struct engine_context *eng_ctx = engine_get_context();
+    struct ed_type_transit_switch *ts_data = data;
+
+    struct ed_type_enum_datapaths *dp_node_data =
+        engine_get_input_data("enum_datapaths", node);
+
+    const struct nbrec_logical_switch_table *nbrec_ls_table =
+        EN_OVSDB_GET(engine_get_input("NB_logical_switch", node));
+    const struct icnbrec_ic_nb_global_table *icnbrec_nb_global_table =
+        EN_OVSDB_GET(engine_get_input("ICNB_ic_nb_global", node));
+    const struct icnbrec_transit_switch_table *icnbrec_ts_table =
+        EN_OVSDB_GET(engine_get_input("ICNB_transit_switch", node));
+    const struct icsbrec_encap_table *icsbrec_encap_table =
+        EN_OVSDB_GET(engine_get_input("ICSB_encap", node));
+    const struct icsbrec_datapath_binding_table *icsbrec_dp_table =
+        EN_OVSDB_GET(engine_get_input("ICSB_datapath_binding", node));
+
+    COVERAGE_INC(ts_run);
+    stopwatch_start(OVN_IC_TRANSIT_SWITCH_RUN_STOPWATCH_NAME, time_usec());
+    ts_run(eng_ctx, ts_data, dp_node_data, nbrec_ls_table,
+           icnbrec_nb_global_table, icnbrec_ts_table, icsbrec_encap_table,
+           icsbrec_dp_table);
+    stopwatch_stop(OVN_IC_TRANSIT_SWITCH_RUN_STOPWATCH_NAME, time_usec());
+
+    return EN_UPDATED;
+}
+
+void *
+en_ts_init(struct engine_node *node OVS_UNUSED,
+           struct engine_arg *arg OVS_UNUSED)
+{
+    struct ed_type_transit_switch *data = xzalloc(sizeof *data);
+    ts_init(data);
+    return data;
+}
+
+void
+en_ts_cleanup(void *data)
+{
+    ts_destroy(data);
+}
+
+static void
+ts_init(struct ed_type_transit_switch *data)
+{
+    shash_init(&data->isb_ts_dps);
+    hmap_init(&data->dp_tnlids);
+}
+
+static void
+ts_destroy(struct ed_type_transit_switch *data)
+{
+    shash_destroy(&data->isb_ts_dps);
+    ovn_destroy_tnlids(&data->dp_tnlids);
+}
+
+static void
+ts_run(const struct engine_context *eng_ctx,
+       struct ed_type_transit_switch *ts_data OVS_UNUSED,
+       struct ed_type_enum_datapaths *dp_node_data,
+       const struct nbrec_logical_switch_table *nbrec_ls_table,
+       const struct icnbrec_ic_nb_global_table *icnbrec_nb_global_table,
+       const struct icnbrec_transit_switch_table *icnbrec_ts_table,
+       const struct icsbrec_encap_table *icsbrec_encap_table,
+       const struct icsbrec_datapath_binding_table *icsbrec_dp_table)
+{
+    const struct icnbrec_transit_switch *ts;
+    bool dp_key_refresh = false;
+    bool vxlan_mode = false;
+    const struct icnbrec_ic_nb_global *ic_nb =
+        icnbrec_ic_nb_global_table_first(icnbrec_nb_global_table);
+
+    if (ic_nb && smap_get_bool(&ic_nb->options, "vxlan_mode", false)) {
+        const struct icsbrec_encap *encap;
+        ICSBREC_ENCAP_TABLE_FOR_EACH (encap, icsbrec_encap_table) {
+            if (!strcmp(encap->type, "vxlan")) {
+                vxlan_mode = true;
+                break;
+            }
+        }
+    }
+
+    /* Sync INB TS to AZ NB */
+    if (eng_ctx->ovnnb_idl_txn) {
+        struct shash nb_tses = SHASH_INITIALIZER(&nb_tses);
+        const struct nbrec_logical_switch *ls;
+
+        /* Get current NB Logical_Switch with other_config:interconn-ts */
+        NBREC_LOGICAL_SWITCH_TABLE_FOR_EACH (ls, nbrec_ls_table) {
+            const char *ts_name = smap_get(&ls->other_config, "interconn-ts");
+            if (ts_name) {
+                shash_add(&nb_tses, ts_name, ls);
+            }
+        }
+
+        /* Create/update NB Logical_Switch for each TS */
+        ICNBREC_TRANSIT_SWITCH_TABLE_FOR_EACH (ts, icnbrec_ts_table) {
+            ls = shash_find_and_delete(&nb_tses, ts->name);
+            if (!ls) {
+                ls = nbrec_logical_switch_insert(eng_ctx->ovnnb_idl_txn);
+                nbrec_logical_switch_set_name(ls, ts->name);
+                nbrec_logical_switch_update_other_config_setkey(ls,
+                                                                "interconn-ts",
+                                                                ts->name);
+                nbrec_logical_switch_update_other_config_setkey(
+                        ls, "ic-vxlan_mode", vxlan_mode ? "true" : "false");
+            } else {
+                bool _vxlan_mode = smap_get_bool(&ls->other_config,
+                                                 "ic-vxlan_mode", false);
+                if (_vxlan_mode != vxlan_mode) {
+                    dp_key_refresh = true;
+                    nbrec_logical_switch_update_other_config_setkey(
+                            ls, "ic-vxlan_mode",
+                            vxlan_mode ? "true" : "false");
+                }
+            }
+
+            const struct icsbrec_datapath_binding *isb_dp;
+            isb_dp = shash_find_data(&dp_node_data->isb_ts_dps, ts->name);
+            if (!isb_dp) {
+                const struct icsbrec_datapath_binding *raw;
+                ICSBREC_DATAPATH_BINDING_TABLE_FOR_EACH (raw,
+                                                         icsbrec_dp_table) {
+                    if (raw->transit_switch && !strcmp(raw->transit_switch,
+                                                       ts->name)) {
+                        isb_dp = raw;
+                        break;
+                    }
+                }
+            } else {
+                int64_t nb_tnl_key = smap_get_int(&ls->other_config,
+                                                  "requested-tnl-key",
+                                                  0);
+                if (nb_tnl_key != isb_dp->tunnel_key) {
+                    VLOG_DBG("Set other_config:requested-tnl-key %"PRId64
+                             " for transit switch %s in NB.",
+                             isb_dp->tunnel_key, ts->name);
+                    char *tnl_key_str = xasprintf("%"PRId64,
+                                                  isb_dp->tunnel_key);
+                    nbrec_logical_switch_update_other_config_setkey(
+                        ls, "requested-tnl-key", tnl_key_str);
+                    free(tnl_key_str);
+                }
+            }
+        }
+
+        /* Delete extra NB Logical_Switch with other_config:interconn-ts */
+        struct shash_node *node;
+        SHASH_FOR_EACH (node, &nb_tses) {
+            nbrec_logical_switch_delete(node->data);
+        }
+        shash_destroy(&nb_tses);
+    }
+
+    /* Sync TS between INB and ISB.  This is performed after syncing with AZ
+     * SB, to avoid uncommitted ISB datapath tunnel key to be synced back to
+     * AZ. */
+    if (eng_ctx->ovnisb_idl_txn) {
+        /* Create ISB Datapath_Binding */
+        ICNBREC_TRANSIT_SWITCH_TABLE_FOR_EACH (ts, icnbrec_ts_table) {
+            const struct icsbrec_datapath_binding *isb_dp =
+                shash_find_and_delete(&dp_node_data->isb_ts_dps, ts->name);
+
+            if (!isb_dp) {
+                const struct icsbrec_datapath_binding *raw_isb;
+                ICSBREC_DATAPATH_BINDING_TABLE_FOR_EACH (raw_isb,
+                                                         icsbrec_dp_table) {
+                    if (raw_isb->n_nb_ic_uuid > 0 &&
+                        uuid_equals(&raw_isb->nb_ic_uuid[0],
+                                    &ts->header_.uuid)) {
+                        isb_dp = raw_isb;
+                        if (isb_dp->transit_switch) {
+                            shash_find_and_delete(&dp_node_data->isb_ts_dps,
+                                                  isb_dp->transit_switch);
+                        }
+                        break;
+                    }
+                }
+            }
+
+            if (!isb_dp) {
+                /* Allocate tunnel key */
+                int64_t dp_key = allocate_dp_key(&dp_node_data->dp_tnlids,
+                                                 vxlan_mode,
+                                                 "transit switch datapath");
+                if (!dp_key) {
+                    continue;
+                }
+
+                isb_dp =
+                    icsbrec_datapath_binding_insert(eng_ctx->ovnisb_idl_txn);
+                icsbrec_datapath_binding_set_transit_switch(isb_dp, ts->name);
+                icsbrec_datapath_binding_set_tunnel_key(isb_dp, dp_key);
+                icsbrec_datapath_binding_set_nb_ic_uuid(isb_dp,
+                                                        &ts->header_.uuid, 1);
+                icsbrec_datapath_binding_set_type(isb_dp, "transit-switch");
+            } else if (dp_key_refresh) {
+                /* Refresh tunnel key since encap mode has changed. */
+                int64_t dp_key = allocate_dp_key(&dp_node_data->dp_tnlids,
+                                                 vxlan_mode,
+                                                 "transit switch datapath");
+                if (dp_key) {
+                    icsbrec_datapath_binding_set_tunnel_key(isb_dp, dp_key);
+                }
+            }
+
+            if (!isb_dp->type) {
+                icsbrec_datapath_binding_set_type(isb_dp, "transit-switch");
+            }
+
+            if (!isb_dp->nb_ic_uuid) {
+                icsbrec_datapath_binding_set_nb_ic_uuid(isb_dp,
+                                                        &ts->header_.uuid, 1);
+            }
+        }
+
+        struct shash_node *node, *next;
+        SHASH_FOR_EACH_SAFE (node, next, &dp_node_data->isb_ts_dps) {
+            struct icsbrec_datapath_binding *isb_dp_to_del = node->data;
+            if (isb_dp_to_del->n_nb_ic_uuid > 0) {
+                icsbrec_datapath_binding_delete(isb_dp_to_del);
+            }
+            shash_delete(&dp_node_data->isb_ts_dps, node);
+        }
+    }
+}
diff --git a/ic/en-ts.h b/ic/en-ts.h
new file mode 100644
index 000000000..c63c1aef7
--- /dev/null
+++ b/ic/en-ts.h
@@ -0,0 +1,23 @@
+#ifndef EN_IC_TS_RUN_H
+#define EN_IC_TS_RUN_H 1
+
+#include <config.h>
+
+#include <stdbool.h>
+#include <getopt.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+/* OVN includes. */
+#include "lib/inc-proc-eng.h"
+
+struct ed_type_transit_switch {
+    struct hmap dp_tnlids;
+    struct shash isb_ts_dps;
+};
+
+void *en_ts_init(struct engine_node *, struct engine_arg *);
+enum engine_node_state en_ts_run(struct engine_node *, void *data);
+void en_ts_cleanup(void *data);
+
+#endif
diff --git a/ic/inc-proc-ic.c b/ic/inc-proc-ic.c
index 6ac60c677..af282fad6 100644
--- a/ic/inc-proc-ic.c
+++ b/ic/inc-proc-ic.c
@@ -29,6 +29,7 @@
 #include "en-ic.h"
 #include "en-gateway.h"
 #include "en-enum-datapaths.h"
+#include "en-ts.h"
 #include "en-tr.h"
 #include "en-port-binding.h"
 #include "en-route.h"
@@ -166,6 +167,7 @@ static ENGINE_NODE(ic, SB_WRITE);
 static ENGINE_NODE(gateway, SB_WRITE);
 static ENGINE_NODE(enum_datapaths);
 static ENGINE_NODE(tr);
+static ENGINE_NODE(ts, SB_WRITE);
 static ENGINE_NODE(port_binding, SB_WRITE);
 static ENGINE_NODE(route);
 
@@ -182,6 +184,13 @@ void inc_proc_ic_init(struct ovsdb_idl_loop *nb,
     engine_add_input(&en_enum_datapaths, &en_icnb_transit_switch, NULL);
     engine_add_input(&en_enum_datapaths, &en_icsb_datapath_binding, NULL);
 
+    engine_add_input(&en_ts, &en_enum_datapaths, NULL);
+    engine_add_input(&en_ts, &en_icsb_datapath_binding, NULL);
+    engine_add_input(&en_ts, &en_nb_logical_switch, NULL);
+    engine_add_input(&en_ts, &en_icnb_ic_nb_global, NULL);
+    engine_add_input(&en_ts, &en_icnb_transit_switch, NULL);
+    engine_add_input(&en_ts, &en_icsb_encap, NULL);
+
     engine_add_input(&en_tr, &en_enum_datapaths, NULL);
     engine_add_input(&en_tr, &en_icsb_datapath_binding, NULL);
     engine_add_input(&en_tr, &en_nb_logical_router, NULL);
@@ -206,6 +215,7 @@ void inc_proc_ic_init(struct ovsdb_idl_loop *nb,
 
     engine_add_input(&en_ic, &en_gateway, NULL);
     engine_add_input(&en_ic, &en_enum_datapaths, NULL);
+    engine_add_input(&en_ic, &en_ts, NULL);
     engine_add_input(&en_ic, &en_tr, NULL);
     engine_add_input(&en_ic, &en_port_binding, NULL);
     engine_add_input(&en_ic, &en_route, NULL);
@@ -224,15 +234,9 @@ void inc_proc_ic_init(struct ovsdb_idl_loop *nb,
     engine_add_input(&en_ic, &en_sb_port_binding, NULL);
     engine_add_input(&en_ic, &en_sb_service_monitor, NULL);
 
-    engine_add_input(&en_ic, &en_icnb_ic_nb_global, NULL);
-    engine_add_input(&en_ic, &en_icnb_transit_switch, NULL);
-
-    engine_add_input(&en_ic, &en_icsb_port_binding, NULL);
     engine_add_input(&en_ic, &en_icsb_ic_sb_global, NULL);
     engine_add_input(&en_ic, &en_icsb_availability_zone, NULL);
-    engine_add_input(&en_ic, &en_icsb_encap, NULL);
     engine_add_input(&en_ic, &en_icsb_service_monitor, NULL);
-    engine_add_input(&en_ic, &en_icsb_datapath_binding, NULL);
 
     struct engine_arg engine_arg = {
         .nb_idl = nb->idl,
diff --git a/ic/ovn-ic.c b/ic/ovn-ic.c
index 08241337d..301b54fb2 100644
--- a/ic/ovn-ic.c
+++ b/ic/ovn-ic.c
@@ -179,173 +179,6 @@ ic_pb_get_type(const struct icsbrec_port_binding *isb_pb)
     return IC_SWITCH_PORT;
 }
 
-static void
-ts_run(struct engine_context *ctx,
-       struct ic_input *ic,
-       struct hmap *dp_tnlids,
-       struct shash *isb_ts_dps)
-{
-    const struct icnbrec_transit_switch *ts;
-    bool dp_key_refresh = false;
-    bool vxlan_mode = false;
-    const struct icnbrec_ic_nb_global *ic_nb =
-        icnbrec_ic_nb_global_table_first(ic->icnbrec_ic_nb_global_table);
-
-    if (ic_nb && smap_get_bool(&ic_nb->options, "vxlan_mode", false)) {
-        const struct icsbrec_encap *encap;
-        ICSBREC_ENCAP_TABLE_FOR_EACH (encap, ic->icsbrec_encap_table) {
-            if (!strcmp(encap->type, "vxlan")) {
-                vxlan_mode = true;
-                break;
-            }
-        }
-    }
-
-    /* Sync INB TS to AZ NB */
-    if (ctx->ovnnb_idl_txn) {
-        struct shash nb_tses = SHASH_INITIALIZER(&nb_tses);
-        const struct nbrec_logical_switch *ls;
-
-        /* Get current NB Logical_Switch with other_config:interconn-ts */
-        NBREC_LOGICAL_SWITCH_TABLE_FOR_EACH (ls,
-                                             ic->nbrec_logical_switch_table) {
-            const char *ts_name = smap_get(&ls->other_config, "interconn-ts");
-            if (ts_name) {
-                shash_add(&nb_tses, ts_name, ls);
-            }
-        }
-
-        /* Create/update NB Logical_Switch for each TS */
-        ICNBREC_TRANSIT_SWITCH_TABLE_FOR_EACH (ts,
-            ic->icnbrec_transit_switch_table) {
-            ls = shash_find_and_delete(&nb_tses, ts->name);
-            if (!ls) {
-                ls = nbrec_logical_switch_insert(ctx->ovnnb_idl_txn);
-                nbrec_logical_switch_set_name(ls, ts->name);
-                nbrec_logical_switch_update_other_config_setkey(ls,
-                                                                "interconn-ts",
-                                                                ts->name);
-                nbrec_logical_switch_update_other_config_setkey(
-                        ls, "ic-vxlan_mode", vxlan_mode ? "true" : "false");
-            } else {
-                bool _vxlan_mode = smap_get_bool(&ls->other_config,
-                                                 "ic-vxlan_mode", false);
-                if (_vxlan_mode != vxlan_mode) {
-                    dp_key_refresh = true;
-                    nbrec_logical_switch_update_other_config_setkey(
-                            ls, "ic-vxlan_mode",
-                            vxlan_mode ? "true" : "false");
-                }
-            }
-
-            const struct icsbrec_datapath_binding *isb_dp;
-            isb_dp = shash_find_data(isb_ts_dps, ts->name);
-            if (!isb_dp) {
-                const struct icsbrec_datapath_binding *raw;
-                ICSBREC_DATAPATH_BINDING_TABLE_FOR_EACH (raw,
-                    ic->icsbrec_datapath_binding_table) {
-                    if (raw->transit_switch && !strcmp(raw->transit_switch,
-                                                       ts->name)) {
-                        isb_dp = raw;
-                        break;
-                    }
-                }
-            } else {
-                int64_t nb_tnl_key = smap_get_int(&ls->other_config,
-                                                  "requested-tnl-key",
-                                                  0);
-                if (nb_tnl_key != isb_dp->tunnel_key) {
-                    VLOG_DBG("Set other_config:requested-tnl-key %"PRId64
-                             " for transit switch %s in NB.",
-                             isb_dp->tunnel_key, ts->name);
-                    char *tnl_key_str = xasprintf("%"PRId64,
-                                                  isb_dp->tunnel_key);
-                    nbrec_logical_switch_update_other_config_setkey(
-                        ls, "requested-tnl-key", tnl_key_str);
-                    free(tnl_key_str);
-                }
-            }
-        }
-
-        /* Delete extra NB Logical_Switch with other_config:interconn-ts */
-        struct shash_node *node;
-        SHASH_FOR_EACH (node, &nb_tses) {
-            nbrec_logical_switch_delete(node->data);
-        }
-        shash_destroy(&nb_tses);
-    }
-
-    /* Sync TS between INB and ISB.  This is performed after syncing with AZ
-     * SB, to avoid uncommitted ISB datapath tunnel key to be synced back to
-     * AZ. */
-    if (ctx->ovnisb_idl_txn) {
-        /* Create ISB Datapath_Binding */
-        ICNBREC_TRANSIT_SWITCH_TABLE_FOR_EACH (ts,
-            ic->icnbrec_transit_switch_table) {
-            const struct icsbrec_datapath_binding *isb_dp =
-                shash_find_and_delete(isb_ts_dps, ts->name);
-
-            if (!isb_dp) {
-                const struct icsbrec_datapath_binding *raw_isb;
-                ICSBREC_DATAPATH_BINDING_TABLE_FOR_EACH (raw_isb,
-                    ic->icsbrec_datapath_binding_table) {
-                    if (raw_isb->n_nb_ic_uuid > 0 &&
-                        uuid_equals(&raw_isb->nb_ic_uuid[0],
-                                    &ts->header_.uuid)) {
-                        isb_dp = raw_isb;
-                        if (isb_dp->transit_switch) {
-                            shash_find_and_delete(isb_ts_dps,
-                                                  isb_dp->transit_switch);
-                        }
-                        break;
-                    }
-                }
-            }
-
-            if (!isb_dp) {
-                /* Allocate tunnel key */
-                int64_t dp_key = allocate_dp_key(dp_tnlids, vxlan_mode,
-                                                 "transit switch datapath");
-                if (!dp_key) {
-                    continue;
-                }
-
-                isb_dp = icsbrec_datapath_binding_insert(ctx->ovnisb_idl_txn);
-                icsbrec_datapath_binding_set_transit_switch(isb_dp, ts->name);
-                icsbrec_datapath_binding_set_tunnel_key(isb_dp, dp_key);
-                icsbrec_datapath_binding_set_nb_ic_uuid(isb_dp,
-                                                        &ts->header_.uuid, 1);
-                icsbrec_datapath_binding_set_type(isb_dp, "transit-switch");
-            } else if (dp_key_refresh) {
-                /* Refresh tunnel key since encap mode has changed. */
-                int64_t dp_key = allocate_dp_key(dp_tnlids, vxlan_mode,
-                                                 "transit switch datapath");
-                if (dp_key) {
-                    icsbrec_datapath_binding_set_tunnel_key(isb_dp, dp_key);
-                }
-            }
-
-            if (!isb_dp->type) {
-                icsbrec_datapath_binding_set_type(isb_dp, "transit-switch");
-            }
-
-            if (!isb_dp->nb_ic_uuid) {
-                icsbrec_datapath_binding_set_nb_ic_uuid(isb_dp,
-                                                        &ts->header_.uuid, 1);
-            }
-        }
-
-        struct shash_node *node, *next;
-        SHASH_FOR_EACH_SAFE (node, next, isb_ts_dps) {
-            struct icsbrec_datapath_binding *isb_dp_to_del = node->data;
-            if (isb_dp_to_del->n_nb_ic_uuid > 0) {
-                icsbrec_datapath_binding_delete(isb_dp_to_del);
-            }
-            shash_delete(isb_ts_dps, node);
-        }
-    }
-}
-
 const struct nbrec_logical_router_port *
 get_lrp_by_lrp_name(struct ovsdb_idl_index *nbrec_lrp_by_name,
                     const char *lrp_name)
@@ -959,10 +792,9 @@ inc_proc_graph_dump(const char *end_node)
 
 void
 ovn_db_run(struct ic_input *input_data,
-           struct ic_data *ic_data,
+           struct ic_data *ic_data OVS_UNUSED,
            struct engine_context *eng_ctx)
 {
-    ts_run(eng_ctx, input_data, ic_data->dp_tnlids, ic_data->isb_ts_dps);
     sync_service_monitor(eng_ctx, input_data);
 }
 
@@ -1371,6 +1203,7 @@ main(int argc, char *argv[])
     stopwatch_create(OVN_IC_ROUTE_RUN_STOPWATCH_NAME, SW_MS);
     stopwatch_create(OVN_IC_GATEWAY_RUN_STOPWATCH_NAME, SW_MS);
     stopwatch_create(OVN_IC_TRANSIT_ROUTER_RUN_STOPWATCH_NAME, SW_MS);
+    stopwatch_create(OVN_IC_TRANSIT_SWITCH_RUN_STOPWATCH_NAME, SW_MS);
 
     /* Initialize incremental processing engine for ovn-northd */
     inc_proc_ic_init(&ovnnb_idl_loop, &ovnsb_idl_loop,
diff --git a/ic/ovn-ic.h b/ic/ovn-ic.h
index 225dc73f5..7e057cc1b 100644
--- a/ic/ovn-ic.h
+++ b/ic/ovn-ic.h
@@ -29,7 +29,6 @@ struct ic_input {
 
     /* InterconnectNorthbound table references */
     const struct icnbrec_transit_switch_table *icnbrec_transit_switch_table;
-    const struct icnbrec_ic_nb_global_table *icnbrec_ic_nb_global_table;
 
     /* InterconnectSouthbound table references */
     const struct icsbrec_encap_table *icsbrec_encap_table;
diff --git a/lib/stopwatch-names.h b/lib/stopwatch-names.h
index f6e1bc023..c9fe2e639 100644
--- a/lib/stopwatch-names.h
+++ b/lib/stopwatch-names.h
@@ -44,6 +44,7 @@
 #define IC_OVN_DB_RUN_STOPWATCH_NAME "ovn_db_run"
 #define OVN_IC_GATEWAY_RUN_STOPWATCH_NAME "gateway_run"
 #define OVN_IC_ENUM_DATAPATHS_RUN_STOPWATCH_NAME "enum_datapaths_run"
+#define OVN_IC_TRANSIT_SWITCH_RUN_STOPWATCH_NAME "transit_switch_run"
 #define OVN_IC_TRANSIT_ROUTER_RUN_STOPWATCH_NAME "transit_router_run"
 #define OVN_IC_PORT_BINDING_RUN_STOPWATCH_NAME "port_binding_run"
 #define OVN_IC_ROUTE_RUN_STOPWATCH_NAME "route_run"
-- 
2.34.1


-- 




_'Esta mensagem é direcionada apenas para os endereços constantes no 
cabeçalho inicial. Se você não está listado nos endereços constantes no 
cabeçalho, pedimos-lhe que desconsidere completamente o conteúdo dessa 
mensagem e cuja cópia, encaminhamento e/ou execução das ações citadas estão 
imediatamente anuladas e proibidas'._


* **'Apesar do Magazine Luiza tomar 
todas as precauções razoáveis para assegurar que nenhum vírus esteja 
presente nesse e-mail, a empresa não poderá aceitar a responsabilidade por 
quaisquer perdas ou danos causados por esse e-mail ou por seus anexos'.*



_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to