}
void
-binding_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int)
+binding_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int,
+ const char *chassis_id)
{
const struct sbrec_chassis *chassis_rec;
const struct sbrec_binding *binding_rec;
return;
}
- chassis_rec = get_chassis_by_name(ctx->ovnsb_idl, ctx->chassis_id);
+ chassis_rec = get_chassis_by_name(ctx->ovnsb_idl, chassis_id);
if (!chassis_rec) {
return;
}
ovsdb_idl_txn_add_comment(ctx->ovnsb_idl_txn,
"ovn-controller: updating bindings for '%s'",
- ctx->chassis_id);
+ chassis_id);
SBREC_BINDING_FOR_EACH(binding_rec, ctx->ovnsb_idl) {
if (sset_find_and_delete(&lports, binding_rec->logical_port) ||
/* Returns true if the database is all cleaned up, false if more work is
* required. */
bool
-binding_cleanup(struct controller_ctx *ctx)
+binding_cleanup(struct controller_ctx *ctx, const char *chassis_id)
{
if (!ctx->ovnsb_idl_txn) {
return false;
}
const struct sbrec_chassis *chassis_rec
- = get_chassis_by_name(ctx->ovnsb_idl, ctx->chassis_id);
+ = get_chassis_by_name(ctx->ovnsb_idl, chassis_id);
if (!chassis_rec) {
return true;
}
ovsdb_idl_txn_add_comment(ctx->ovnsb_idl_txn,
"ovn-controller: removing all bindings for '%s'",
- ctx->chassis_id);
+ chassis_id);
const struct sbrec_binding *binding_rec;
bool any_changes = false;
struct ovsrec_bridge;
void binding_init(struct controller_ctx *);
-void binding_run(struct controller_ctx *, const struct ovsrec_bridge *br_int);
-bool binding_cleanup(struct controller_ctx *);
+void binding_run(struct controller_ctx *, const struct ovsrec_bridge *br_int,
+ const char *chassis_id);
+bool binding_cleanup(struct controller_ctx *, const char *chassis_id);
#endif /* ovn/binding.h */
}
void
-chassis_run(struct controller_ctx *ctx)
+chassis_run(struct controller_ctx *ctx, const char *chassis_id)
{
if (!ctx->ovnsb_idl_txn) {
return;
struct sbrec_encap *encap_rec;
static bool inited = false;
- chassis_rec = get_chassis_by_name(ctx->ovnsb_idl, ctx->chassis_id);
+ chassis_rec = get_chassis_by_name(ctx->ovnsb_idl, chassis_id);
/* xxx Need to support more than one encap. Also need to support
* xxx encap options. */
ovsdb_idl_txn_add_comment(ctx->ovnsb_idl_txn,
"ovn-controller: registering chassis '%s'",
- ctx->chassis_id);
+ chassis_id);
if (!chassis_rec) {
chassis_rec = sbrec_chassis_insert(ctx->ovnsb_idl_txn);
- sbrec_chassis_set_name(chassis_rec, ctx->chassis_id);
+ sbrec_chassis_set_name(chassis_rec, chassis_id);
}
encap_rec = sbrec_encap_insert(ctx->ovnsb_idl_txn);
/* Returns true if the database is all cleaned up, false if more work is
* required. */
bool
-chassis_cleanup(struct controller_ctx *ctx)
+chassis_cleanup(struct controller_ctx *ctx, const char *chassis_id)
{
/* Delete Chassis row. */
const struct sbrec_chassis *chassis_rec
- = get_chassis_by_name(ctx->ovnsb_idl, ctx->chassis_id);
+ = get_chassis_by_name(ctx->ovnsb_idl, chassis_id);
if (!chassis_rec) {
return true;
}
if (ctx->ovnsb_idl_txn) {
ovsdb_idl_txn_add_comment(ctx->ovnsb_idl_txn,
"ovn-controller: unregistering chassis '%s'",
- ctx->chassis_id);
+ chassis_id);
sbrec_chassis_delete(chassis_rec);
}
return false;
struct ovsrec_bridge;
void chassis_init(struct controller_ctx *);
-void chassis_run(struct controller_ctx *);
-bool chassis_cleanup(struct controller_ctx *);
+void chassis_run(struct controller_ctx *, const char *chassis_id);
+bool chassis_cleanup(struct controller_ctx *, const char *chassis_id);
#endif /* ovn/chassis.h */
}
void
-encaps_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int)
+encaps_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int,
+ const char *chassis_id)
{
if (!ctx->ovs_idl_txn) {
return;
tc.ovs_txn = ctx->ovs_idl_txn;
ovsdb_idl_txn_add_comment(tc.ovs_txn,
"ovn-controller: modifying OVS tunnels '%s'",
- ctx->chassis_id);
+ chassis_id);
/* Collect all port names into tc.port_names.
*
}
SBREC_CHASSIS_FOR_EACH(chassis_rec, ctx->ovnsb_idl) {
- if (strcmp(chassis_rec->name, ctx->chassis_id)) {
+ if (strcmp(chassis_rec->name, chassis_id)) {
/* Create tunnels to the other chassis. */
const struct sbrec_encap *encap = preferred_encap(chassis_rec);
if (!encap) {
void encaps_init(struct controller_ctx *);
void encaps_run(struct controller_ctx *,
- const struct ovsrec_bridge *br_int);
+ const struct ovsrec_bridge *br_int, const char *chassis_id);
bool encaps_cleanup(struct controller_ctx *,
- const struct ovsrec_bridge *br_int);
+ const struct ovsrec_bridge *br_int);
#endif /* ovn/encaps.h */
* xxx ovn-controller does not support changing any of these mid-run,
* xxx but that should be addressed later. */
static void
-get_core_config(struct controller_ctx *ctx, char **br_int_namep)
+get_core_config(struct controller_ctx *ctx, char **br_int_namep,
+ char **chassis_idp)
{
while (1) {
ovsdb_idl_run(ctx->ovs_idl);
}
ovnsb_remote = xstrdup(remote);
- ctx->chassis_id = xstrdup(system_id);
+ *chassis_idp = xstrdup(system_id);
*br_int_namep = xstrdup(br_int_name);
return;
main(int argc, char *argv[])
{
struct unixctl_server *unixctl;
- struct controller_ctx ctx = { .chassis_id = NULL };
+ struct controller_ctx ctx = { .ovs_idl = NULL };
bool exiting;
int retval;
get_initial_snapshot(ctx.ovs_idl);
- char *br_int_name;
- get_core_config(&ctx, &br_int_name);
+ char *br_int_name, *chassis_id;
+ get_core_config(&ctx, &br_int_name, &chassis_id);
ctx.ovnsb_idl = ovsdb_idl_create(ovnsb_remote, &sbrec_idl_class,
true, true);
goto exit;
}
- chassis_run(&ctx);
- encaps_run(&ctx, br_int);
- binding_run(&ctx, br_int);
+ chassis_run(&ctx, chassis_id);
+ encaps_run(&ctx, br_int, chassis_id);
+ binding_run(&ctx, br_int, chassis_id);
struct hmap flow_table = HMAP_INITIALIZER(&flow_table);
pipeline_run(&ctx, &flow_table);
- physical_run(&ctx, br_int, &flow_table);
+ physical_run(&ctx, br_int, chassis_id, &flow_table);
ofctrl_run(br_int, &flow_table);
hmap_destroy(&flow_table);
/* Run all of the cleanup functions, even if one of them returns false.
* We're done if all of them return true. */
- done = binding_cleanup(&ctx);
- done = chassis_cleanup(&ctx) && done;
+ done = binding_cleanup(&ctx, chassis_id);
+ done = chassis_cleanup(&ctx, chassis_id) && done;
done = encaps_cleanup(&ctx, br_int) && done;
if (done) {
poll_immediate_wake();
idl_loop_destroy(&ovnsb_idl_loop);
free(br_int_name);
- free(ctx.chassis_id);
+ free(chassis_id);
free(ovnsb_remote);
free(ovs_remote);
#include "ovn/lib/ovn-sb-idl.h"
struct controller_ctx {
- char *chassis_id; /* ID for this chassis. */
-
struct ovsdb_idl *ovnsb_idl;
struct ovsdb_idl_txn *ovnsb_idl_txn;
void
physical_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int,
- struct hmap *flow_table)
+ const char *this_chassis_id, struct hmap *flow_table)
{
struct simap lport_to_ofport = SIMAP_INITIALIZER(&lport_to_ofport);
struct simap chassis_to_ofport = SIMAP_INITIALIZER(&chassis_to_ofport);
const char *chassis_id = smap_get(&port_rec->external_ids,
"ovn-chassis-id");
- if (chassis_id && !strcmp(chassis_id, ctx->chassis_id)) {
+ if (chassis_id && !strcmp(chassis_id, this_chassis_id)) {
continue;
}
void physical_init(struct controller_ctx *);
void physical_run(struct controller_ctx *, const struct ovsrec_bridge *br_int,
- struct hmap *flow_table);
+ const char *chassis_id, struct hmap *flow_table);
#endif /* ovn/physical.h */