Skip to content

Commit

Permalink
controller: Store load balancer data in separate node
Browse files Browse the repository at this point in the history
In order to reuse parsed data keep hash map
of 'struct ovn_controller_lb', that is local for the
controller, in separate engine node called 'lb_data'.
Those data will be later on used to determine if we need
to flush CT for changed/removed LB backends.

Reported-at: https://bugzilla.redhat.com/1839103
Signed-off-by: Ales Musil <amusil@redhat.com>
Acked-by: Mark Michelson <mmichels@redhat.com>
Signed-off-by: Dumitru Ceara <dceara@redhat.com>
  • Loading branch information
almusil authored and dceara committed Feb 17, 2023
1 parent a3de2b2 commit 8382127
Show file tree
Hide file tree
Showing 7 changed files with 546 additions and 242 deletions.
244 changes: 68 additions & 176 deletions controller/lflow.c

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions controller/lflow.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ struct lflow_ctx_in {
const struct sbrec_multicast_group_table *mc_group_table;
const struct sbrec_fdb_table *fdb_table;
const struct sbrec_chassis *chassis;
const struct sbrec_load_balancer_table *lb_table;
const struct sbrec_static_mac_binding_table *static_mac_binding_table;
const struct hmap *local_datapaths;
const struct shash *addr_sets;
Expand All @@ -116,6 +115,7 @@ struct lflow_ctx_in {
const struct controller_event_options *controller_event_opts;
const struct smap *template_vars;
const struct flow_collector_ids *collector_ids;
const struct hmap *local_lbs;
bool lb_hairpin_use_ct_mark;
};

Expand Down Expand Up @@ -161,13 +161,16 @@ void lflow_handle_changed_static_mac_bindings(
const struct sbrec_static_mac_binding_table *smb_table,
const struct hmap *local_datapaths,
struct ovn_desired_flow_table *);
bool lflow_handle_changed_lbs(struct lflow_ctx_in *, struct lflow_ctx_out *);
bool lflow_handle_changed_lbs(struct lflow_ctx_in *l_ctx_in,
struct lflow_ctx_out *l_ctx_out,
const struct uuidset *deleted_lbs,
const struct uuidset *updated_lbs,
const struct uuidset *new_lbs,
const struct hmap *old_lbs);
bool lflow_handle_changed_fdbs(struct lflow_ctx_in *, struct lflow_ctx_out *);
void lflow_destroy(void);

bool lflow_add_flows_for_datapath(const struct sbrec_datapath_binding *,
const struct sbrec_load_balancer **dp_lbs,
size_t n_dp_lbs,
struct lflow_ctx_in *,
struct lflow_ctx_out *);
bool lflow_handle_flows_for_lport(const struct sbrec_port_binding *,
Expand All @@ -178,7 +181,4 @@ bool lflow_handle_changed_mc_groups(struct lflow_ctx_in *,
bool lflow_handle_changed_port_bindings(struct lflow_ctx_in *,
struct lflow_ctx_out *);

bool lb_handle_changed_ref(enum objdep_type type, const char *res_name,
struct ovs_list *objs_todo,
const void *in_arg, void *out_arg);
#endif /* controller/lflow.h */
25 changes: 25 additions & 0 deletions controller/local_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,3 +645,28 @@ datapath_is_transit_switch(const struct sbrec_datapath_binding *ldp)
{
return smap_get(&ldp->external_ids, "interconn-ts") != NULL;
}

bool
lb_is_local(const struct sbrec_load_balancer *sbrec_lb,
const struct hmap *local_datapaths)
{
/* Check if the lb is local or not. It is enough to find one datapath
* in "local_datapaths" to consider the LB to be local. */
for (size_t i = 0; i < sbrec_lb->n_datapaths; i++) {
if (get_local_datapath(local_datapaths,
sbrec_lb->datapaths[i]->tunnel_key)) {
return true;
}
}

struct sbrec_logical_dp_group *dp_group = sbrec_lb->datapath_group;

for (size_t i = 0; dp_group && i < dp_group->n_datapaths; i++) {
if (get_local_datapath(local_datapaths,
dp_group->datapaths[i]->tunnel_key)) {
return true;
}
}

return false;
}
3 changes: 3 additions & 0 deletions controller/local_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct sbrec_chassis;
struct ovsdb_idl_index;
struct ovsrec_bridge;
struct ovsrec_interface_table;
struct sbrec_load_balancer;

/* A logical datapath that has some relevance to this hypervisor. A logical
* datapath D is relevant to hypervisor H if:
Expand Down Expand Up @@ -161,5 +162,7 @@ void add_local_datapath_multichassis_port(struct local_datapath *ld,
const void *data);
void remove_local_datapath_multichassis_port(struct local_datapath *ld,
char *logical_port);
bool lb_is_local(const struct sbrec_load_balancer *sbrec_lb,
const struct hmap *local_datapaths);

#endif /* controller/local_data.h */
Loading

0 comments on commit 8382127

Please sign in to comment.