Skip to content

Commit

Permalink
ovn-controller.c: Refactor init_lflow_ctx.
Browse files Browse the repository at this point in the history
The function gets rt_data and non_vif_data from args but all the other
data from engine inputs, which looks weird. Just unify the pattern and
get all data from engine inputs in the function.

Signed-off-by: Han Zhou <hzhou@ovn.org>
Acked-by: Mark Michelson <mmichels@redhat.com>
Acked-by: Numan Siddique <numans@ovn.org>
  • Loading branch information
hzhou8 committed Feb 24, 2022
1 parent a0f36dd commit 5d157ff
Showing 1 changed file with 14 additions and 47 deletions.
61 changes: 14 additions & 47 deletions controller/ovn-controller.c
Expand Up @@ -2197,8 +2197,6 @@ struct ed_type_lflow_output {

static void
init_lflow_ctx(struct engine_node *node,
struct ed_type_runtime_data *rt_data,
struct ed_type_non_vif_data *non_vif_data,
struct ed_type_lflow_output *fo,
struct lflow_ctx_in *l_ctx_in,
struct lflow_ctx_out *l_ctx_out)
Expand Down Expand Up @@ -2280,6 +2278,12 @@ init_lflow_ctx(struct engine_node *node,

ovs_assert(chassis);

struct ed_type_runtime_data *rt_data =
engine_get_input_data("runtime_data", node);

struct ed_type_non_vif_data *non_vif_data =
engine_get_input_data("non_vif_data", node);

struct ed_type_addr_sets *as_data =
engine_get_input_data("addr_sets", node);
struct shash *addr_sets = &as_data->addr_sets;
Expand Down Expand Up @@ -2366,11 +2370,6 @@ en_lflow_output_cleanup(void *data)
static void
en_lflow_output_run(struct engine_node *node, void *data)
{
struct ed_type_runtime_data *rt_data =
engine_get_input_data("runtime_data", node);
struct ed_type_non_vif_data *non_vif_data =
engine_get_input_data("non_vif_data", node);

struct ovsrec_open_vswitch_table *ovs_table =
(struct ovsrec_open_vswitch_table *)EN_OVSDB_GET(
engine_get_input("OVS_open_vswitch", node));
Expand Down Expand Up @@ -2415,7 +2414,7 @@ en_lflow_output_run(struct engine_node *node, void *data)

struct lflow_ctx_in l_ctx_in;
struct lflow_ctx_out l_ctx_out;
init_lflow_ctx(node, rt_data, non_vif_data, fo, &l_ctx_in, &l_ctx_out);
init_lflow_ctx(node, fo, &l_ctx_in, &l_ctx_out);
lflow_run(&l_ctx_in, &l_ctx_out);

engine_set_node_state(node, EN_UPDATED);
Expand All @@ -2424,15 +2423,10 @@ en_lflow_output_run(struct engine_node *node, void *data)
static bool
lflow_output_sb_logical_flow_handler(struct engine_node *node, void *data)
{
struct ed_type_runtime_data *rt_data =
engine_get_input_data("runtime_data", node);
struct ed_type_non_vif_data *non_vif_data =
engine_get_input_data("non_vif_data", node);

struct ed_type_lflow_output *fo = data;
struct lflow_ctx_in l_ctx_in;
struct lflow_ctx_out l_ctx_out;
init_lflow_ctx(node, rt_data, non_vif_data, fo, &l_ctx_in, &l_ctx_out);
init_lflow_ctx(node, fo, &l_ctx_in, &l_ctx_out);

bool handled = lflow_handle_changed_flows(&l_ctx_in, &l_ctx_out);

Expand Down Expand Up @@ -2468,16 +2462,11 @@ lflow_output_sb_mac_binding_handler(struct engine_node *node, void *data)
static bool
lflow_output_sb_multicast_group_handler(struct engine_node *node, void *data)
{
struct ed_type_runtime_data *rt_data =
engine_get_input_data("runtime_data", node);
struct ed_type_non_vif_data *non_vif_data =
engine_get_input_data("non_vif_data", node);

struct ed_type_lflow_output *lfo = data;

struct lflow_ctx_in l_ctx_in;
struct lflow_ctx_out l_ctx_out;
init_lflow_ctx(node, rt_data, non_vif_data, lfo, &l_ctx_in, &l_ctx_out);
init_lflow_ctx(node, lfo, &l_ctx_in, &l_ctx_out);
if (!lflow_handle_changed_mc_groups(&l_ctx_in, &l_ctx_out)) {
return false;
}
Expand All @@ -2489,16 +2478,11 @@ lflow_output_sb_multicast_group_handler(struct engine_node *node, void *data)
static bool
lflow_output_sb_port_binding_handler(struct engine_node *node, void *data)
{
struct ed_type_runtime_data *rt_data =
engine_get_input_data("runtime_data", node);
struct ed_type_non_vif_data *non_vif_data =
engine_get_input_data("non_vif_data", node);

struct ed_type_lflow_output *lfo = data;

struct lflow_ctx_in l_ctx_in;
struct lflow_ctx_out l_ctx_out;
init_lflow_ctx(node, rt_data, non_vif_data, lfo, &l_ctx_in, &l_ctx_out);
init_lflow_ctx(node, lfo, &l_ctx_in, &l_ctx_out);
if (!lflow_handle_changed_port_bindings(&l_ctx_in, &l_ctx_out)) {
return false;
}
Expand All @@ -2511,11 +2495,6 @@ static bool
_lflow_output_resource_ref_handler(struct engine_node *node, void *data,
enum ref_type ref_type)
{
struct ed_type_runtime_data *rt_data =
engine_get_input_data("runtime_data", node);
struct ed_type_non_vif_data *non_vif_data =
engine_get_input_data("non_vif_data", node);

struct ed_type_addr_sets *as_data =
engine_get_input_data("addr_sets", node);

Expand All @@ -2526,7 +2505,7 @@ _lflow_output_resource_ref_handler(struct engine_node *node, void *data,

struct lflow_ctx_in l_ctx_in;
struct lflow_ctx_out l_ctx_out;
init_lflow_ctx(node, rt_data, non_vif_data, fo, &l_ctx_in, &l_ctx_out);
init_lflow_ctx(node, fo, &l_ctx_in, &l_ctx_out);

bool changed;
const char *ref_name;
Expand Down Expand Up @@ -2613,8 +2592,6 @@ lflow_output_runtime_data_handler(struct engine_node *node,
{
struct ed_type_runtime_data *rt_data =
engine_get_input_data("runtime_data", node);
struct ed_type_non_vif_data *non_vif_data =
engine_get_input_data("non_vif_data", node);

/* There is no tracked data. Fall back to full recompute of
* flow_output. */
Expand All @@ -2634,7 +2611,7 @@ lflow_output_runtime_data_handler(struct engine_node *node,
struct lflow_ctx_out l_ctx_out;
struct ed_type_lflow_output *fo = data;
struct hmap *lbs = NULL;
init_lflow_ctx(node, rt_data, non_vif_data, fo, &l_ctx_in, &l_ctx_out);
init_lflow_ctx(node, fo, &l_ctx_in, &l_ctx_out);

struct tracked_datapath *tdp;
HMAP_FOR_EACH (tdp, node, tracked_dp_bindings) {
Expand Down Expand Up @@ -2672,15 +2649,10 @@ lflow_output_runtime_data_handler(struct engine_node *node,
static bool
lflow_output_sb_load_balancer_handler(struct engine_node *node, void *data)
{
struct ed_type_runtime_data *rt_data =
engine_get_input_data("runtime_data", node);
struct ed_type_non_vif_data *non_vif_data =
engine_get_input_data("non_vif_data", node);

struct ed_type_lflow_output *fo = data;
struct lflow_ctx_in l_ctx_in;
struct lflow_ctx_out l_ctx_out;
init_lflow_ctx(node, rt_data, non_vif_data, fo, &l_ctx_in, &l_ctx_out);
init_lflow_ctx(node, fo, &l_ctx_in, &l_ctx_out);

bool handled = lflow_handle_changed_lbs(&l_ctx_in, &l_ctx_out);

Expand All @@ -2691,15 +2663,10 @@ lflow_output_sb_load_balancer_handler(struct engine_node *node, void *data)
static bool
lflow_output_sb_fdb_handler(struct engine_node *node, void *data)
{
struct ed_type_runtime_data *rt_data =
engine_get_input_data("runtime_data", node);
struct ed_type_non_vif_data *non_vif_data =
engine_get_input_data("non_vif_data", node);

struct ed_type_lflow_output *fo = data;
struct lflow_ctx_in l_ctx_in;
struct lflow_ctx_out l_ctx_out;
init_lflow_ctx(node, rt_data, non_vif_data, fo, &l_ctx_in, &l_ctx_out);
init_lflow_ctx(node, fo, &l_ctx_in, &l_ctx_out);

bool handled = lflow_handle_changed_fdbs(&l_ctx_in, &l_ctx_out);

Expand Down

0 comments on commit 5d157ff

Please sign in to comment.