summaryrefslogtreecommitdiff
path: root/ovn/northd/ovn-northd.c
diff options
context:
space:
mode:
Diffstat (limited to 'ovn/northd/ovn-northd.c')
-rw-r--r--ovn/northd/ovn-northd.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
index 151e64873..aa6a18f16 100644
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -1731,9 +1731,9 @@ gateway_chassis_equal(const struct nbrec_gateway_chassis *nb_gwc,
static bool
sbpb_gw_chassis_needs_update(
- const struct sbrec_port_binding *port_binding,
- const struct nbrec_logical_router_port *lrp,
- const struct chassis_index *chassis_index)
+ struct ovsdb_idl_index *sbrec_chassis_by_name,
+ const struct sbrec_port_binding *port_binding,
+ const struct nbrec_logical_router_port *lrp)
{
if (!lrp || !port_binding) {
return false;
@@ -1758,7 +1758,7 @@ sbpb_gw_chassis_needs_update(
}
const struct sbrec_chassis *chassis =
- chassis_lookup_by_name(chassis_index,
+ chassis_lookup_by_name(sbrec_chassis_by_name,
lrp->gateway_chassis[n]->chassis_name);
lrp_gwc_c[lrp_n_gateway_chassis] = chassis;
@@ -1815,8 +1815,8 @@ sbpb_gw_chassis_needs_update(
static void
copy_gw_chassis_from_nbrp_to_sbpb(
struct northd_context *ctx,
+ struct ovsdb_idl_index *sbrec_chassis_by_name,
const struct nbrec_logical_router_port *lrp,
- const struct chassis_index *chassis_index,
const struct sbrec_port_binding *port_binding) {
if (!lrp || !port_binding || !lrp->n_gateway_chassis) {
@@ -1840,7 +1840,8 @@ copy_gw_chassis_from_nbrp_to_sbpb(
}
const struct sbrec_chassis *chassis =
- chassis_lookup_by_name(chassis_index, lrp_gwc->chassis_name);
+ chassis_lookup_by_name(sbrec_chassis_by_name,
+ lrp_gwc->chassis_name);
gw_chassis = xrealloc(gw_chassis, (n_gwc + 1) * sizeof *gw_chassis);
@@ -1861,8 +1862,8 @@ copy_gw_chassis_from_nbrp_to_sbpb(
static void
ovn_port_update_sbrec(struct northd_context *ctx,
+ struct ovsdb_idl_index *sbrec_chassis_by_name,
const struct ovn_port *op,
- const struct chassis_index *chassis_index,
struct hmap *chassis_qdisc_queues)
{
sbrec_port_binding_set_datapath(op->sb, op->od->sb);
@@ -1893,10 +1894,11 @@ ovn_port_update_sbrec(struct northd_context *ctx,
}
if (op->nbrp->n_gateway_chassis) {
- if (sbpb_gw_chassis_needs_update(op->sb, op->nbrp,
- chassis_index)) {
- copy_gw_chassis_from_nbrp_to_sbpb(ctx, op->nbrp,
- chassis_index, op->sb);
+ if (sbpb_gw_chassis_needs_update(sbrec_chassis_by_name,
+ op->sb, op->nbrp)) {
+ copy_gw_chassis_from_nbrp_to_sbpb(ctx,
+ sbrec_chassis_by_name,
+ op->nbrp, op->sb);
}
} else if (redirect_chassis) {
@@ -1904,7 +1906,8 @@ ovn_port_update_sbrec(struct northd_context *ctx,
* to them, and for backwards compatibility convert them
* to a single Gateway_Chassis entry */
const struct sbrec_chassis *chassis =
- chassis_lookup_by_name(chassis_index, redirect_chassis);
+ chassis_lookup_by_name(sbrec_chassis_by_name,
+ redirect_chassis);
if (chassis) {
/* If we found the chassis, and the gw chassis on record
* differs from what we expect go ahead and update */
@@ -2105,8 +2108,9 @@ cleanup_mac_bindings(struct northd_context *ctx, struct hmap *ports)
* using the "struct ovn_datapath"s in 'datapaths' to look up logical
* datapaths. */
static void
-build_ports(struct northd_context *ctx, struct hmap *datapaths,
- const struct chassis_index *chassis_index, struct hmap *ports)
+build_ports(struct northd_context *ctx,
+ struct ovsdb_idl_index *sbrec_chassis_by_name,
+ struct hmap *datapaths, struct hmap *ports)
{
struct ovs_list sb_only, nb_only, both;
struct hmap tag_alloc_table = HMAP_INITIALIZER(&tag_alloc_table);
@@ -2124,7 +2128,8 @@ build_ports(struct northd_context *ctx, struct hmap *datapaths,
if (op->nbsp) {
tag_alloc_create_new_tag(&tag_alloc_table, op->nbsp);
}
- ovn_port_update_sbrec(ctx, op, chassis_index, &chassis_qdisc_queues);
+ ovn_port_update_sbrec(ctx, sbrec_chassis_by_name,
+ op, &chassis_qdisc_queues);
add_tnlid(&op->od->port_tnlids, op->sb->tunnel_key);
if (op->sb->tunnel_key > op->od->port_key_hint) {
@@ -2140,7 +2145,8 @@ build_ports(struct northd_context *ctx, struct hmap *datapaths,
}
op->sb = sbrec_port_binding_insert(ctx->ovnsb_txn);
- ovn_port_update_sbrec(ctx, op, chassis_index, &chassis_qdisc_queues);
+ ovn_port_update_sbrec(ctx, sbrec_chassis_by_name, op,
+ &chassis_qdisc_queues);
sbrec_port_binding_set_logical_port(op->sb, op->key);
sbrec_port_binding_set_tunnel_key(op->sb, tunnel_key);
@@ -6544,7 +6550,8 @@ sync_dns_entries(struct northd_context *ctx, struct hmap *datapaths)
static void
-ovnnb_db_run(struct northd_context *ctx, struct chassis_index *chassis_index,
+ovnnb_db_run(struct northd_context *ctx,
+ struct ovsdb_idl_index *sbrec_chassis_by_name,
struct ovsdb_idl_loop *sb_loop)
{
if (!ctx->ovnsb_txn || !ctx->ovnnb_txn) {
@@ -6552,7 +6559,7 @@ ovnnb_db_run(struct northd_context *ctx, struct chassis_index *chassis_index,
}
struct hmap datapaths, ports, port_groups;
build_datapaths(ctx, &datapaths);
- build_ports(ctx, &datapaths, chassis_index, &ports);
+ build_ports(ctx, sbrec_chassis_by_name, &datapaths, &ports);
build_ipam(&datapaths, &ports);
build_port_group_lswitches(ctx, &port_groups, &ports);
build_lflows(ctx, &datapaths, &ports, &port_groups);
@@ -7188,6 +7195,9 @@ main(int argc, char *argv[])
ovsdb_idl_add_column(ovnsb_idl_loop.idl, &sbrec_chassis_col_nb_cfg);
ovsdb_idl_add_column(ovnsb_idl_loop.idl, &sbrec_chassis_col_name);
+ struct ovsdb_idl_index *sbrec_chassis_by_name
+ = chassis_index_create(ovnsb_idl_loop.idl);
+
/* Ensure that only a single ovn-northd is active in the deployment by
* acquiring a lock called "ovn_northd" on the southbound database
* and then only performing DB transactions if the lock is held. */
@@ -7214,14 +7224,8 @@ main(int argc, char *argv[])
had_lock = false;
}
- struct chassis_index chassis_index;
- bool destroy_chassis_index = false;
if (ovsdb_idl_has_lock(ovnsb_idl_loop.idl)) {
- chassis_index_init(sbrec_chassis_table_get(ovnsb_idl_loop.idl),
- &chassis_index);
- destroy_chassis_index = true;
-
- ovnnb_db_run(&ctx, &chassis_index, &ovnsb_idl_loop);
+ ovnnb_db_run(&ctx, sbrec_chassis_by_name, &ovnsb_idl_loop);
ovnsb_db_run(&ctx, &ovnsb_idl_loop);
if (ctx.ovnsb_txn) {
check_and_add_supported_dhcp_opts_to_sb_db(&ctx);
@@ -7242,10 +7246,6 @@ main(int argc, char *argv[])
if (should_service_stop()) {
exiting = true;
}
-
- if (destroy_chassis_index) {
- chassis_index_destroy(&chassis_index);
- }
}
unixctl_server_destroy(unixctl);