[ovs-dev,RFC,10/14] ovn-controller: Split addr_sets from runtime_data.

Message ID 1532480380-97578-11-git-send-email-hzhou8@ebay.com
State RFC
Headers show
Series
  • ovn-controller incremental processing.
Related show

Commit Message

Han Zhou July 25, 2018, 12:59 a.m.
Signed-off-by: Han Zhou <hzhou8@ebay.com>
---
 ovn/controller/ovn-controller.c | 75 ++++++++++++++++++++++++++++++++---------
 1 file changed, 60 insertions(+), 15 deletions(-)

Patch

diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c
index e19c29f..65a5aa7 100644
--- a/ovn/controller/ovn-controller.c
+++ b/ovn/controller/ovn-controller.c
@@ -601,6 +601,52 @@  const char *ovs_engine_node_names[] = {
     OVS_NODES
 #undef OVS_NODE
 
+struct ed_type_addr_sets {
+    struct shash addr_sets;
+    struct sset new;
+    struct sset deleted;
+    struct sset updated;
+};
+
+static void
+en_addr_sets_init(struct engine_node *node)
+{
+    struct ed_type_addr_sets *as = (struct ed_type_addr_sets *)node->data;
+    shash_init(&as->addr_sets);
+    sset_init(&as->new);
+    sset_init(&as->deleted);
+    sset_init(&as->updated);
+}
+
+static void
+en_addr_sets_cleanup(struct engine_node *node)
+{
+    struct ed_type_addr_sets *as = (struct ed_type_addr_sets *)node->data;
+    expr_const_sets_destroy(&as->addr_sets);
+    shash_destroy(&as->addr_sets);
+    sset_destroy(&as->new);
+    sset_destroy(&as->deleted);
+    sset_destroy(&as->updated);
+}
+
+static void
+en_addr_sets_run(struct engine_node *node)
+{
+    struct ed_type_addr_sets *as = (struct ed_type_addr_sets *)node->data;
+
+    sset_clear(&as->new);
+    sset_clear(&as->deleted);
+    sset_clear(&as->updated);
+    expr_const_sets_destroy(&as->addr_sets);
+
+    struct sbrec_address_set_table *as_table =
+        (struct sbrec_address_set_table *)EN_OVSDB_GET(
+            engine_get_input("SB_address_set", node));
+
+    addr_sets_init(as_table, &as->addr_sets);
+
+    node->changed = true;
+}
 
 struct ed_type_runtime_data {
     /* Contains "struct local_datapath" nodes. */
@@ -617,7 +663,6 @@  struct ed_type_runtime_data {
      * <datapath-tunnel-key>_<port-tunnel-key> */
     struct sset local_lport_ids;
     struct sset active_tunnels;
-    struct shash addr_sets;
     struct shash port_groups;
 
     /* connection tracking zones. */
@@ -641,7 +686,6 @@  en_runtime_data_init(struct engine_node *node)
     sset_init(&data->local_lports);
     sset_init(&data->local_lport_ids);
     sset_init(&data->active_tunnels);
-    shash_init(&data->addr_sets);
     shash_init(&data->port_groups);
     shash_init(&data->pending_ct_zones);
     simap_init(&data->ct_zones);
@@ -659,8 +703,6 @@  en_runtime_data_cleanup(struct engine_node *node)
     struct ed_type_runtime_data *data =
         (struct ed_type_runtime_data *)node->data;
 
-    expr_const_sets_destroy(&data->addr_sets);
-    shash_destroy(&data->addr_sets);
     expr_const_sets_destroy(&data->port_groups);
     shash_destroy(&data->port_groups);
 
@@ -689,7 +731,6 @@  en_runtime_data_run(struct engine_node *node)
     struct sset *local_lports = &data->local_lports;
     struct sset *local_lport_ids = &data->local_lport_ids;
     struct sset *active_tunnels = &data->active_tunnels;
-    struct shash *addr_sets = &data->addr_sets;
     struct shash *port_groups = &data->port_groups;
     unsigned long *ct_zone_bitmap = data->ct_zone_bitmap;
     struct shash *pending_ct_zones = &data->pending_ct_zones;
@@ -710,7 +751,6 @@  en_runtime_data_run(struct engine_node *node)
         sset_destroy(local_lports);
         sset_destroy(local_lport_ids);
         sset_destroy(active_tunnels);
-        expr_const_sets_destroy(addr_sets);
         expr_const_sets_destroy(port_groups);
         sset_init(local_lports);
         sset_init(local_lport_ids);
@@ -777,11 +817,6 @@  en_runtime_data_run(struct engine_node *node)
                 active_tunnels, local_datapaths,
                 local_lports, local_lport_ids);
 
-    struct sbrec_address_set_table *as_table =
-        (struct sbrec_address_set_table *)EN_OVSDB_GET(
-            engine_get_input("SB_address_set", node));
-    addr_sets_init(as_table, addr_sets);
-
     struct sbrec_port_group_table *pg_table =
         (struct sbrec_port_group_table *)EN_OVSDB_GET(
             engine_get_input("SB_port_group", node));
@@ -875,7 +910,6 @@  en_flow_output_run(struct engine_node *node)
     struct sset *local_lports = &rt_data->local_lports;
     struct sset *local_lport_ids = &rt_data->local_lport_ids;
     struct sset *active_tunnels = &rt_data->active_tunnels;
-    struct shash *addr_sets = &rt_data->addr_sets;
     struct shash *port_groups = &rt_data->port_groups;
     struct simap *ct_zones = &rt_data->ct_zones;
 
@@ -892,6 +926,10 @@  en_flow_output_run(struct engine_node *node)
         engine_ovsdb_node_get_index(
                 engine_get_input("SB_chassis", node),
                 "name");
+    struct ed_type_addr_sets *as_data =
+        (struct ed_type_addr_sets *)engine_get_input("addr_sets", node)->data;
+    struct shash *addr_sets = &as_data->addr_sets;
+
     const struct sbrec_chassis *chassis = NULL;
     if (chassis_id) {
         chassis = chassis_lookup_by_name(sbrec_chassis_by_name, chassis_id);
@@ -985,8 +1023,10 @@  flow_output_sb_logical_flow_handler(struct engine_node *node)
     struct hmap *local_datapaths = &data->local_datapaths;
     struct sset *local_lport_ids = &data->local_lport_ids;
     struct sset *active_tunnels = &data->active_tunnels;
-    struct shash *addr_sets = &data->addr_sets;
     struct shash *port_groups = &data->port_groups;
+    struct ed_type_addr_sets *as_data =
+        (struct ed_type_addr_sets *)engine_get_input("addr_sets", node)->data;
+    struct shash *addr_sets = &as_data->addr_sets;
 
     struct ovsrec_open_vswitch_table *ovs_table =
         (struct ovsrec_open_vswitch_table *)EN_OVSDB_GET(
@@ -1259,6 +1299,7 @@  main(int argc, char *argv[])
 
     struct ed_type_runtime_data ed_runtime_data;
     struct ed_type_flow_output ed_flow_output;
+    struct ed_type_addr_sets ed_addr_sets;
 
 #define SB_NODE(NAME, NAME_STR) ENGINE_NODE_SB(NAME, NAME_STR);
     SB_NODES
@@ -1277,6 +1318,11 @@  main(int argc, char *argv[])
 
     ENGINE_NODE(runtime_data, "runtime_data");
     ENGINE_NODE(flow_output, "flow_output");
+    ENGINE_NODE(addr_sets, "addr_sets");
+
+    engine_add_input(&en_addr_sets, &en_sb_address_set, NULL);
+
+    engine_add_input(&en_flow_output, &en_addr_sets, NULL);
     engine_add_input(&en_flow_output, &en_runtime_data, NULL);
 
     engine_add_input(&en_flow_output, &en_ovs_open_vswitch, NULL);
@@ -1303,7 +1349,6 @@  main(int argc, char *argv[])
     engine_add_input(&en_runtime_data, &en_ovs_interface, NULL);
 
     engine_add_input(&en_runtime_data, &en_sb_chassis, NULL);
-    engine_add_input(&en_runtime_data, &en_sb_address_set, NULL);
     engine_add_input(&en_runtime_data, &en_sb_port_group, NULL);
     engine_add_input(&en_runtime_data, &en_sb_datapath_binding, NULL);
     engine_add_input(&en_runtime_data, &en_sb_port_binding, runtime_data_sb_port_binding_handler);
@@ -1463,7 +1508,7 @@  main(int argc, char *argv[])
             if (br_int && chassis) {
                 char *error = ofctrl_inject_pkt(br_int, pending_pkt.flow_s,
                                                 &ed_runtime_data.port_groups,
-                                                &ed_runtime_data.addr_sets);
+                                                &ed_addr_sets.addr_sets);
                 if (error) {
                     unixctl_command_reply_error(pending_pkt.conn, error);
                     free(error);