VLOG_DEFINE_THIS_MODULE(bindings);
-#define DEFAULT_BRIDGE_NAME "br-int"
-
void
bindings_init(struct controller_ctx *ctx)
{
static void
get_local_iface_ids(struct controller_ctx *ctx, struct sset *lports)
{
- const struct ovsrec_open_vswitch *cfg;
- const struct ovsrec_bridge *bridge_rec;
- const char *bridge_name;
int i;
- cfg = ovsrec_open_vswitch_first(ctx->ovs_idl);
- if (!cfg) {
- VLOG_INFO("No Open_vSwitch row defined.");
- return;
- }
-
- bridge_name = smap_get(&cfg->external_ids, "ovn-bridge");
- if (!bridge_name) {
- bridge_name = DEFAULT_BRIDGE_NAME;
- }
-
- OVSREC_BRIDGE_FOR_EACH(bridge_rec, ctx->ovs_idl) {
- if (!strcmp(bridge_rec->name, bridge_name)) {
- break;
- }
- }
-
- if (!bridge_rec) {
- VLOG_INFO("Could not find bridge '%s'", bridge_name);
- return;
- }
-
- for (i = 0; i < bridge_rec->n_ports; i++) {
- const struct ovsrec_port *port_rec = bridge_rec->ports[i];
+ for (i = 0; i < ctx->br_int->n_ports; i++) {
+ const struct ovsrec_port *port_rec = ctx->br_int->ports[i];
const char *iface_id;
int j;
- if (!strcmp(port_rec->name, bridge_rec->name)) {
+ if (!strcmp(port_rec->name, ctx->br_int_name)) {
continue;
}
static unixctl_cb_func ovn_controller_exit;
+#define DEFAULT_BRIDGE_NAME "br-int"
+
static void parse_options(int argc, char *argv[]);
OVS_NO_RETURN static void usage(void);
}
}
-/* Retrieve the OVN remote location from the "external-ids:ovn-remote"
- * key and the chassis name from the "external-ids:system-id" key in the
+static const struct ovsrec_bridge *
+get_bridge(struct controller_ctx *ctx, const char *name)
+{
+ const struct ovsrec_bridge *br;
+
+ OVSREC_BRIDGE_FOR_EACH(br, ctx->ovs_idl) {
+ if (!strcmp(br->name, name)) {
+ return br;
+ }
+ }
+
+ return NULL;
+}
+
+/* Retrieve the OVN integration bridge from the "external-ids:ovn-bridge"
+ * key, the remote location from the "external-ids:ovn-remote" key, and
+ * the chassis name from the "external-ids:system-id" key in the
* Open_vSwitch table of the OVS database instance. */
static void
get_core_config(struct controller_ctx *ctx)
}
while (1) {
+ const struct ovsrec_bridge *br_int;
const char *remote, *system_id;
ovsdb_idl_run(ctx->ovs_idl);
+ ctx->br_int_name = smap_get(&cfg->external_ids, "ovn-bridge");
+ if (!ctx->br_int_name) {
+ ctx->br_int_name = DEFAULT_BRIDGE_NAME;
+ }
+
+ br_int = get_bridge(ctx, ctx->br_int_name);
+ if (!br_int) {
+ VLOG_INFO("Integration bridge '%s' does not exist. Waiting...",
+ ctx->br_int_name);
+ goto try_again;
+ }
+
/* xxx This does not support changing OVN Southbound OVSDB mid-run. */
remote = smap_get(&cfg->external_ids, "ovn-remote");
if (!remote) {
ovsdb_idl_run(ctx.ovs_idl);
ovsdb_idl_run(ctx.ovnsb_idl);
+ /* xxx If run into any surprising changes, we exit. We should
+ * xxx handle this more gracefully. */
+ ctx.br_int = get_bridge(&ctx, ctx.br_int_name);
+ if (!ctx.br_int) {
+ VLOG_ERR("Integration bridge '%s' disappeared",
+ ctx.br_int_name);
+ retval = EXIT_FAILURE;
+ break;
+ }
+
if (!ovsdb_idl_is_alive(ctx.ovnsb_idl)) {
int retval = ovsdb_idl_get_last_error(ctx.ovnsb_idl);
VLOG_ERR("%s: database connection failed (%s)",