This change is to prepare for the future change for multi-threading. Both binding_run() and get_br_int() are needed by pinctrl thread, but we don't want to update SB DB or create bridges in that scenario, so need "readonly" mode for these functions.
Signed-off-by: Han Zhou <[email protected]> --- ovn/controller/binding.c | 11 +++++++---- ovn/controller/binding.h | 2 +- ovn/controller/ovn-controller.c | 10 +++++----- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/ovn/controller/binding.c b/ovn/controller/binding.c index 8080f8f..29673fa 100644 --- a/ovn/controller/binding.c +++ b/ovn/controller/binding.c @@ -368,7 +368,8 @@ consider_local_datapath(struct controller_ctx *ctx, struct hmap *local_datapaths, struct shash *lport_to_iface, struct sset *local_lports, - struct hmap *localnet_ports) + struct hmap *localnet_ports, + bool update_sb) { const struct ovsrec_interface *iface_rec = shash_find_data(lport_to_iface, binding_rec->logical_port); @@ -428,7 +429,7 @@ consider_local_datapath(struct controller_ctx *ctx, our_chassis = false; } - if (ctx->ovnsb_idl_txn) { + if (ctx->ovnsb_idl_txn && update_sb) { if (our_chassis) { if (binding_rec->chassis != chassis_rec) { if (binding_rec->chassis) { @@ -459,7 +460,8 @@ binding_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int, const struct sbrec_chassis *chassis_rec, const struct ldatapath_index *ldatapaths, const struct lport_index *lports, struct hmap *local_datapaths, - struct sset *local_lports) + struct sset *local_lports, + bool update_sb) { if (!chassis_rec) { return; @@ -486,7 +488,8 @@ binding_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int, chassis_rec, binding_rec, sset_is_empty(&egress_ifaces) ? NULL : &qos_map, local_datapaths, &lport_to_iface, - local_lports, &localnet_ports); + local_lports, &localnet_ports, + update_sb); } diff --git a/ovn/controller/binding.h b/ovn/controller/binding.h index 3bfa7d1..5b77f1a 100644 --- a/ovn/controller/binding.h +++ b/ovn/controller/binding.h @@ -32,7 +32,7 @@ void binding_register_ovs_idl(struct ovsdb_idl *); void binding_run(struct controller_ctx *, const struct ovsrec_bridge *br_int, const struct sbrec_chassis *, const struct ldatapath_index *, const struct lport_index *, struct hmap *local_datapaths, - struct sset *all_lports); + struct sset *all_lports, bool update_sb); bool binding_cleanup(struct controller_ctx *, const struct sbrec_chassis *); #endif /* ovn/binding.h */ diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c index 1155657..4537046 100644 --- a/ovn/controller/ovn-controller.c +++ b/ovn/controller/ovn-controller.c @@ -243,7 +243,7 @@ create_br_int(struct controller_ctx *ctx, } static const struct ovsrec_bridge * -get_br_int(struct controller_ctx *ctx) +get_br_int(struct controller_ctx *ctx, bool need_create) { const struct ovsrec_open_vswitch *cfg; cfg = ovsrec_open_vswitch_first(ctx->ovs_idl); @@ -256,7 +256,7 @@ get_br_int(struct controller_ctx *ctx) const struct ovsrec_bridge *br; br = get_bridge(ctx->ovs_idl, br_int_name); - if (!br) { + if (!br && need_create) { return create_br_int(ctx, cfg, br_int_name); } return br; @@ -614,7 +614,7 @@ main(int argc, char *argv[]) * local hypervisor, and localnet ports. */ struct sset local_lports = SSET_INITIALIZER(&local_lports); - const struct ovsrec_bridge *br_int = get_br_int(&ctx); + const struct ovsrec_bridge *br_int = get_br_int(&ctx, true); const char *chassis_id = get_chassis_id(ctx.ovs_idl); struct ldatapath_index ldatapaths; @@ -629,7 +629,7 @@ main(int argc, char *argv[]) chassis = chassis_run(&ctx, chassis_id, br_int); encaps_run(&ctx, br_int, chassis_id); binding_run(&ctx, br_int, chassis, &ldatapaths, &lports, - &local_datapaths, &local_lports); + &local_datapaths, &local_lports, true); } if (br_int && chassis) { @@ -751,7 +751,7 @@ main(int argc, char *argv[]) .ovnsb_idl_txn = ovsdb_idl_loop_run(&ovnsb_idl_loop), }; - const struct ovsrec_bridge *br_int = get_br_int(&ctx); + const struct ovsrec_bridge *br_int = get_br_int(&ctx, false); const char *chassis_id = get_chassis_id(ctx.ovs_idl); const struct sbrec_chassis *chassis = chassis_id ? get_chassis(ctx.ovnsb_idl, chassis_id) : NULL; -- 2.1.0 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
