|
|
bbaaef |
From f4984801e417fc2c9c92d5d34f9621a4a338aae3 Mon Sep 17 00:00:00 2001
|
|
|
bbaaef |
From: Dumitru Ceara <dceara@redhat.com>
|
|
|
bbaaef |
Date: Wed, 27 Nov 2019 14:15:38 +0100
|
|
|
bbaaef |
Subject: [PATCH ovn 3/4] ovn-controller: Add separate I-P engine node for
|
|
|
bbaaef |
processing ct-zones.
|
|
|
bbaaef |
|
|
|
bbaaef |
Signed-off-by: Dumitru Ceara <dceara@redhat.com>
|
|
|
bbaaef |
Signed-off-by: Han Zhou <hzhou@ovn.org>
|
|
|
bbaaef |
|
|
|
bbaaef |
(cherry picked from upstream commit 2117ba0a91f36206d0f3665e8680c15f1f6fa0a0)
|
|
|
bbaaef |
|
|
|
bbaaef |
Change-Id: I4980ad2641e02356c85c259e71a905bc94dcb833
|
|
|
bbaaef |
---
|
|
|
bbaaef |
ovn/controller/ovn-controller.c | 117 ++++++++++++++++++++++++++--------------
|
|
|
bbaaef |
1 file changed, 78 insertions(+), 39 deletions(-)
|
|
|
bbaaef |
|
|
|
bbaaef |
diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c
|
|
|
bbaaef |
index 8c474e9..20e5ce4 100644
|
|
|
bbaaef |
--- a/ovn/controller/ovn-controller.c
|
|
|
bbaaef |
+++ b/ovn/controller/ovn-controller.c
|
|
|
bbaaef |
@@ -897,11 +897,6 @@ struct ed_type_runtime_data {
|
|
|
bbaaef |
* <datapath-tunnel-key>_<port-tunnel-key> */
|
|
|
bbaaef |
struct sset local_lport_ids;
|
|
|
bbaaef |
struct sset active_tunnels;
|
|
|
bbaaef |
-
|
|
|
bbaaef |
- /* connection tracking zones. */
|
|
|
bbaaef |
- unsigned long ct_zone_bitmap[BITMAP_N_LONGS(MAX_CT_ZONES)];
|
|
|
bbaaef |
- struct shash pending_ct_zones;
|
|
|
bbaaef |
- struct simap ct_zones;
|
|
|
bbaaef |
};
|
|
|
bbaaef |
|
|
|
bbaaef |
static void
|
|
|
bbaaef |
@@ -909,24 +904,11 @@ en_runtime_data_init(struct engine_node *node)
|
|
|
bbaaef |
{
|
|
|
bbaaef |
struct ed_type_runtime_data *data =
|
|
|
bbaaef |
(struct ed_type_runtime_data *)node->data;
|
|
|
bbaaef |
- struct ovsrec_open_vswitch_table *ovs_table =
|
|
|
bbaaef |
- (struct ovsrec_open_vswitch_table *)EN_OVSDB_GET(
|
|
|
bbaaef |
- engine_get_input("OVS_open_vswitch", node));
|
|
|
bbaaef |
- struct ovsrec_bridge_table *bridge_table =
|
|
|
bbaaef |
- (struct ovsrec_bridge_table *)EN_OVSDB_GET(
|
|
|
bbaaef |
- engine_get_input("OVS_bridge", node));
|
|
|
bbaaef |
+
|
|
|
bbaaef |
hmap_init(&data->local_datapaths);
|
|
|
bbaaef |
sset_init(&data->local_lports);
|
|
|
bbaaef |
sset_init(&data->local_lport_ids);
|
|
|
bbaaef |
sset_init(&data->active_tunnels);
|
|
|
bbaaef |
- shash_init(&data->pending_ct_zones);
|
|
|
bbaaef |
- simap_init(&data->ct_zones);
|
|
|
bbaaef |
-
|
|
|
bbaaef |
- /* Initialize connection tracking zones. */
|
|
|
bbaaef |
- memset(data->ct_zone_bitmap, 0, sizeof data->ct_zone_bitmap);
|
|
|
bbaaef |
- bitmap_set1(data->ct_zone_bitmap, 0); /* Zone 0 is reserved. */
|
|
|
bbaaef |
- restore_ct_zones(bridge_table, ovs_table,
|
|
|
bbaaef |
- &data->ct_zones, data->ct_zone_bitmap);
|
|
|
bbaaef |
}
|
|
|
bbaaef |
|
|
|
bbaaef |
static void
|
|
|
bbaaef |
@@ -946,9 +928,6 @@ en_runtime_data_cleanup(struct engine_node *node)
|
|
|
bbaaef |
free(cur_node);
|
|
|
bbaaef |
}
|
|
|
bbaaef |
hmap_destroy(&data->local_datapaths);
|
|
|
bbaaef |
-
|
|
|
bbaaef |
- simap_destroy(&data->ct_zones);
|
|
|
bbaaef |
- shash_destroy(&data->pending_ct_zones);
|
|
|
bbaaef |
}
|
|
|
bbaaef |
|
|
|
bbaaef |
static void
|
|
|
bbaaef |
@@ -960,9 +939,6 @@ en_runtime_data_run(struct engine_node *node)
|
|
|
bbaaef |
struct sset *local_lports = &data->local_lports;
|
|
|
bbaaef |
struct sset *local_lport_ids = &data->local_lport_ids;
|
|
|
bbaaef |
struct sset *active_tunnels = &data->active_tunnels;
|
|
|
bbaaef |
- unsigned long *ct_zone_bitmap = data->ct_zone_bitmap;
|
|
|
bbaaef |
- struct shash *pending_ct_zones = &data->pending_ct_zones;
|
|
|
bbaaef |
- struct simap *ct_zones = &data->ct_zones;
|
|
|
bbaaef |
|
|
|
bbaaef |
static bool first_run = true;
|
|
|
bbaaef |
if (first_run) {
|
|
|
bbaaef |
@@ -1056,9 +1032,6 @@ en_runtime_data_run(struct engine_node *node)
|
|
|
bbaaef |
ovs_table, local_datapaths,
|
|
|
bbaaef |
local_lports, local_lport_ids);
|
|
|
bbaaef |
|
|
|
bbaaef |
- update_ct_zones(local_lports, local_datapaths, ct_zones,
|
|
|
bbaaef |
- ct_zone_bitmap, pending_ct_zones);
|
|
|
bbaaef |
-
|
|
|
bbaaef |
engine_set_node_state(node, EN_UPDATED);
|
|
|
bbaaef |
}
|
|
|
bbaaef |
|
|
|
bbaaef |
@@ -1100,6 +1073,55 @@ runtime_data_sb_port_binding_handler(struct engine_node *node)
|
|
|
bbaaef |
return !changed;
|
|
|
bbaaef |
}
|
|
|
bbaaef |
|
|
|
bbaaef |
+/* Connection tracking zones. */
|
|
|
bbaaef |
+struct ed_type_ct_zones {
|
|
|
bbaaef |
+ unsigned long bitmap[BITMAP_N_LONGS(MAX_CT_ZONES)];
|
|
|
bbaaef |
+ struct shash pending;
|
|
|
bbaaef |
+ struct simap current;
|
|
|
bbaaef |
+};
|
|
|
bbaaef |
+
|
|
|
bbaaef |
+static void
|
|
|
bbaaef |
+en_ct_zones_init(struct engine_node *node)
|
|
|
bbaaef |
+{
|
|
|
bbaaef |
+ struct ed_type_ct_zones *data = node->data;
|
|
|
bbaaef |
+ struct ovsrec_open_vswitch_table *ovs_table =
|
|
|
bbaaef |
+ (struct ovsrec_open_vswitch_table *)EN_OVSDB_GET(
|
|
|
bbaaef |
+ engine_get_input("OVS_open_vswitch", node));
|
|
|
bbaaef |
+ struct ovsrec_bridge_table *bridge_table =
|
|
|
bbaaef |
+ (struct ovsrec_bridge_table *)EN_OVSDB_GET(
|
|
|
bbaaef |
+ engine_get_input("OVS_bridge", node));
|
|
|
bbaaef |
+
|
|
|
bbaaef |
+ shash_init(&data->pending);
|
|
|
bbaaef |
+ simap_init(&data->current);
|
|
|
bbaaef |
+
|
|
|
bbaaef |
+ memset(data->bitmap, 0, sizeof data->bitmap);
|
|
|
bbaaef |
+ bitmap_set1(data->bitmap, 0); /* Zone 0 is reserved. */
|
|
|
bbaaef |
+ restore_ct_zones(bridge_table, ovs_table, &data->current, data->bitmap);
|
|
|
bbaaef |
+}
|
|
|
bbaaef |
+
|
|
|
bbaaef |
+static void
|
|
|
bbaaef |
+en_ct_zones_cleanup(struct engine_node *node)
|
|
|
bbaaef |
+{
|
|
|
bbaaef |
+ struct ed_type_ct_zones *data = node->data;
|
|
|
bbaaef |
+
|
|
|
bbaaef |
+ simap_destroy(&data->current);
|
|
|
bbaaef |
+ shash_destroy(&data->pending);
|
|
|
bbaaef |
+}
|
|
|
bbaaef |
+
|
|
|
bbaaef |
+static void
|
|
|
bbaaef |
+en_ct_zones_run(struct engine_node *node)
|
|
|
bbaaef |
+{
|
|
|
bbaaef |
+ struct ed_type_ct_zones *data = node->data;
|
|
|
bbaaef |
+ struct ed_type_runtime_data *rt_data =
|
|
|
bbaaef |
+ (struct ed_type_runtime_data *)engine_get_input(
|
|
|
bbaaef |
+ "runtime_data", node)->data;
|
|
|
bbaaef |
+
|
|
|
bbaaef |
+ update_ct_zones(&rt_data->local_lports, &rt_data->local_datapaths,
|
|
|
bbaaef |
+ &data->current, data->bitmap, &data->pending);
|
|
|
bbaaef |
+
|
|
|
bbaaef |
+ engine_set_node_state(node, EN_UPDATED);
|
|
|
bbaaef |
+}
|
|
|
bbaaef |
+
|
|
|
bbaaef |
struct ed_type_mff_ovn_geneve {
|
|
|
bbaaef |
enum mf_field_id mff_ovn_geneve;
|
|
|
bbaaef |
};
|
|
|
bbaaef |
@@ -1177,7 +1199,11 @@ en_flow_output_run(struct engine_node *node)
|
|
|
bbaaef |
struct sset *local_lports = &rt_data->local_lports;
|
|
|
bbaaef |
struct sset *local_lport_ids = &rt_data->local_lport_ids;
|
|
|
bbaaef |
struct sset *active_tunnels = &rt_data->active_tunnels;
|
|
|
bbaaef |
- struct simap *ct_zones = &rt_data->ct_zones;
|
|
|
bbaaef |
+
|
|
|
bbaaef |
+ struct ed_type_ct_zones *ct_zones_data =
|
|
|
bbaaef |
+ (struct ed_type_ct_zones *)engine_get_input(
|
|
|
bbaaef |
+ "ct_zones", node)->data;
|
|
|
bbaaef |
+ struct simap *ct_zones = &ct_zones_data->current;
|
|
|
bbaaef |
|
|
|
bbaaef |
struct ed_type_mff_ovn_geneve *ed_mff_ovn_geneve =
|
|
|
bbaaef |
(struct ed_type_mff_ovn_geneve *)engine_get_input(
|
|
|
bbaaef |
@@ -1407,7 +1433,11 @@ flow_output_sb_port_binding_handler(struct engine_node *node)
|
|
|
bbaaef |
"runtime_data", node)->data;
|
|
|
bbaaef |
struct hmap *local_datapaths = &data->local_datapaths;
|
|
|
bbaaef |
struct sset *active_tunnels = &data->active_tunnels;
|
|
|
bbaaef |
- struct simap *ct_zones = &data->ct_zones;
|
|
|
bbaaef |
+
|
|
|
bbaaef |
+ struct ed_type_ct_zones *ct_zones_data =
|
|
|
bbaaef |
+ (struct ed_type_ct_zones *)engine_get_input(
|
|
|
bbaaef |
+ "ct_zones", node)->data;
|
|
|
bbaaef |
+ struct simap *ct_zones = &ct_zones_data->current;
|
|
|
bbaaef |
|
|
|
bbaaef |
struct ed_type_mff_ovn_geneve *ed_mff_ovn_geneve =
|
|
|
bbaaef |
(struct ed_type_mff_ovn_geneve *)engine_get_input(
|
|
|
bbaaef |
@@ -1510,7 +1540,11 @@ flow_output_sb_multicast_group_handler(struct engine_node *node)
|
|
|
bbaaef |
(struct ed_type_runtime_data *)engine_get_input(
|
|
|
bbaaef |
"runtime_data", node)->data;
|
|
|
bbaaef |
struct hmap *local_datapaths = &data->local_datapaths;
|
|
|
bbaaef |
- struct simap *ct_zones = &data->ct_zones;
|
|
|
bbaaef |
+
|
|
|
bbaaef |
+ struct ed_type_ct_zones *ct_zones_data =
|
|
|
bbaaef |
+ (struct ed_type_ct_zones *)engine_get_input(
|
|
|
bbaaef |
+ "ct_zones", node)->data;
|
|
|
bbaaef |
+ struct simap *ct_zones = &ct_zones_data->current;
|
|
|
bbaaef |
|
|
|
bbaaef |
struct ed_type_mff_ovn_geneve *ed_mff_ovn_geneve =
|
|
|
bbaaef |
(struct ed_type_mff_ovn_geneve *)engine_get_input(
|
|
|
bbaaef |
@@ -1817,6 +1851,7 @@ main(int argc, char *argv[])
|
|
|
bbaaef |
stopwatch_create(CONTROLLER_LOOP_STOPWATCH_NAME, SW_MS);
|
|
|
bbaaef |
|
|
|
bbaaef |
/* Define inc-proc-engine nodes. */
|
|
|
bbaaef |
+ struct ed_type_ct_zones ed_ct_zones;
|
|
|
bbaaef |
struct ed_type_runtime_data ed_runtime_data;
|
|
|
bbaaef |
struct ed_type_mff_ovn_geneve ed_mff_ovn_geneve;
|
|
|
bbaaef |
struct ed_type_ofctrl_is_connected ed_ofctrl_is_connected;
|
|
|
bbaaef |
@@ -1824,6 +1859,7 @@ main(int argc, char *argv[])
|
|
|
bbaaef |
struct ed_type_addr_sets ed_addr_sets;
|
|
|
bbaaef |
struct ed_type_port_groups ed_port_groups;
|
|
|
bbaaef |
|
|
|
bbaaef |
+ ENGINE_NODE(ct_zones, "ct_zones");
|
|
|
bbaaef |
ENGINE_NODE(runtime_data, "runtime_data");
|
|
|
bbaaef |
ENGINE_NODE(mff_ovn_geneve, "mff_ovn_geneve");
|
|
|
bbaaef |
ENGINE_NODE(ofctrl_is_connected, "ofctrl_is_connected");
|
|
|
bbaaef |
@@ -1863,6 +1899,7 @@ main(int argc, char *argv[])
|
|
|
bbaaef |
engine_add_input(&en_flow_output, &en_port_groups,
|
|
|
bbaaef |
flow_output_port_groups_handler);
|
|
|
bbaaef |
engine_add_input(&en_flow_output, &en_runtime_data, NULL);
|
|
|
bbaaef |
+ engine_add_input(&en_flow_output, &en_ct_zones, NULL);
|
|
|
bbaaef |
engine_add_input(&en_flow_output, &en_mff_ovn_geneve, NULL);
|
|
|
bbaaef |
|
|
|
bbaaef |
engine_add_input(&en_flow_output, &en_ovs_open_vswitch, NULL);
|
|
|
bbaaef |
@@ -1882,6 +1919,10 @@ main(int argc, char *argv[])
|
|
|
bbaaef |
engine_add_input(&en_flow_output, &en_sb_dhcpv6_options, NULL);
|
|
|
bbaaef |
engine_add_input(&en_flow_output, &en_sb_dns, NULL);
|
|
|
bbaaef |
|
|
|
bbaaef |
+ engine_add_input(&en_ct_zones, &en_ovs_open_vswitch, NULL);
|
|
|
bbaaef |
+ engine_add_input(&en_ct_zones, &en_ovs_bridge, NULL);
|
|
|
bbaaef |
+ engine_add_input(&en_ct_zones, &en_runtime_data, NULL);
|
|
|
bbaaef |
+
|
|
|
bbaaef |
engine_add_input(&en_runtime_data, &en_ofctrl_is_connected, NULL);
|
|
|
bbaaef |
|
|
|
bbaaef |
engine_add_input(&en_runtime_data, &en_ovs_open_vswitch, NULL);
|
|
|
bbaaef |
@@ -1907,7 +1948,7 @@ main(int argc, char *argv[])
|
|
|
bbaaef |
meter_table_list, &ed_flow_output.meter_table);
|
|
|
bbaaef |
|
|
|
bbaaef |
unixctl_command_register("ct-zone-list", "", 0, 0,
|
|
|
bbaaef |
- ct_zone_list, &ed_runtime_data.ct_zones);
|
|
|
bbaaef |
+ ct_zone_list, &ed_ct_zones.current);
|
|
|
bbaaef |
|
|
|
bbaaef |
struct pending_pkt pending_pkt = { .conn = NULL };
|
|
|
bbaaef |
unixctl_command_register("inject-pkt", "MICROFLOW", 1, 1, inject_pkt,
|
|
|
bbaaef |
@@ -1983,7 +2024,7 @@ main(int argc, char *argv[])
|
|
|
bbaaef |
}
|
|
|
bbaaef |
|
|
|
bbaaef |
if (br_int) {
|
|
|
bbaaef |
- ofctrl_run(br_int, &ed_runtime_data.pending_ct_zones);
|
|
|
bbaaef |
+ ofctrl_run(br_int, &ed_ct_zones.pending);
|
|
|
bbaaef |
|
|
|
bbaaef |
if (chassis) {
|
|
|
bbaaef |
patch_run(ovs_idl_txn,
|
|
|
bbaaef |
@@ -2024,8 +2065,7 @@ main(int argc, char *argv[])
|
|
|
bbaaef |
stopwatch_stop(CONTROLLER_LOOP_STOPWATCH_NAME,
|
|
|
bbaaef |
time_msec());
|
|
|
bbaaef |
if (ovs_idl_txn) {
|
|
|
bbaaef |
- commit_ct_zones(br_int,
|
|
|
bbaaef |
- &ed_runtime_data.pending_ct_zones);
|
|
|
bbaaef |
+ commit_ct_zones(br_int, &ed_ct_zones.pending);
|
|
|
bbaaef |
bfd_run(ovsrec_interface_table_get(ovs_idl_loop.idl),
|
|
|
bbaaef |
br_int, chassis,
|
|
|
bbaaef |
sbrec_ha_chassis_group_table_get(
|
|
|
bbaaef |
@@ -2033,7 +2073,7 @@ main(int argc, char *argv[])
|
|
|
bbaaef |
sbrec_sb_global_table_get(ovnsb_idl_loop.idl));
|
|
|
bbaaef |
}
|
|
|
bbaaef |
ofctrl_put(&ed_flow_output.flow_table,
|
|
|
bbaaef |
- &ed_runtime_data.pending_ct_zones,
|
|
|
bbaaef |
+ &ed_ct_zones.pending,
|
|
|
bbaaef |
sbrec_meter_table_get(ovnsb_idl_loop.idl),
|
|
|
bbaaef |
get_nb_cfg(sbrec_sb_global_table_get(
|
|
|
bbaaef |
ovnsb_idl_loop.idl)),
|
|
|
bbaaef |
@@ -2134,11 +2174,10 @@ main(int argc, char *argv[])
|
|
|
bbaaef |
|
|
|
bbaaef |
if (ovsdb_idl_loop_commit_and_wait(&ovs_idl_loop) == 1) {
|
|
|
bbaaef |
struct shash_node *iter, *iter_next;
|
|
|
bbaaef |
- SHASH_FOR_EACH_SAFE (iter, iter_next,
|
|
|
bbaaef |
- &ed_runtime_data.pending_ct_zones) {
|
|
|
bbaaef |
+ SHASH_FOR_EACH_SAFE (iter, iter_next, &ed_ct_zones.pending) {
|
|
|
bbaaef |
struct ct_zone_pending_entry *ctzpe = iter->data;
|
|
|
bbaaef |
if (ctzpe->state == CT_ZONE_DB_SENT) {
|
|
|
bbaaef |
- shash_delete(&ed_runtime_data.pending_ct_zones, iter);
|
|
|
bbaaef |
+ shash_delete(&ed_ct_zones.pending, iter);
|
|
|
bbaaef |
free(ctzpe);
|
|
|
bbaaef |
}
|
|
|
bbaaef |
}
|
|
|
bbaaef |
--
|
|
|
bbaaef |
1.8.3.1
|
|
|
bbaaef |
|