mirror of
https://github.com/openvswitch/ovs
synced 2025-09-03 15:55:19 +00:00
ovn: Automatically create br-int in ovn-controller.
ovn-controller previously required the integration bridge to be created before running ovn-controller. This patch makes ovn-controller automatically create it if it doesn't already exist. Signed-off-by: Russell Bryant <rbryant@redhat.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
committed by
Ben Pfaff
parent
18f777b287
commit
e43fc07cd0
@@ -84,7 +84,10 @@
|
||||
<p>
|
||||
<code>external_ids:ovn-bridge</code> specifies the
|
||||
integration bridge to which logical ports are attached.
|
||||
The default is <code>br-int</code>.
|
||||
The default is <code>br-int</code>. If this bridge does
|
||||
not exist when ovn-controller starts, it will be created
|
||||
automatically with the default configuration suggested in
|
||||
<code>ovn-architecture</code>(7).
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
|
@@ -70,9 +70,53 @@ get_bridge(struct ovsdb_idl *ovs_idl, const char *br_name)
|
||||
}
|
||||
|
||||
static const struct ovsrec_bridge *
|
||||
get_br_int(struct ovsdb_idl *ovs_idl)
|
||||
create_br_int(struct controller_ctx *ctx,
|
||||
const struct ovsrec_open_vswitch *cfg,
|
||||
const char *bridge_name)
|
||||
{
|
||||
const struct ovsrec_open_vswitch *cfg = ovsrec_open_vswitch_first(ovs_idl);
|
||||
if (!ctx->ovs_idl_txn) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ovsdb_idl_txn_add_comment(ctx->ovs_idl_txn,
|
||||
"ovn-controller: creating integration bridge '%s'", bridge_name);
|
||||
|
||||
struct ovsrec_interface *iface;
|
||||
iface = ovsrec_interface_insert(ctx->ovs_idl_txn);
|
||||
ovsrec_interface_set_name(iface, bridge_name);
|
||||
ovsrec_interface_set_type(iface, "internal");
|
||||
|
||||
struct ovsrec_port *port;
|
||||
port = ovsrec_port_insert(ctx->ovs_idl_txn);
|
||||
ovsrec_port_set_name(port, bridge_name);
|
||||
ovsrec_port_set_interfaces(port, &iface, 1);
|
||||
|
||||
struct ovsrec_bridge *bridge;
|
||||
bridge = ovsrec_bridge_insert(ctx->ovs_idl_txn);
|
||||
ovsrec_bridge_set_name(bridge, bridge_name);
|
||||
ovsrec_bridge_set_fail_mode(bridge, "secure");
|
||||
struct smap other_config = SMAP_INITIALIZER(&other_config);
|
||||
smap_add(&other_config, "disable-in-band", "true");
|
||||
ovsrec_bridge_set_other_config(bridge, &other_config);
|
||||
smap_destroy(&other_config);
|
||||
ovsrec_bridge_set_ports(bridge, &port, 1);
|
||||
|
||||
struct ovsrec_bridge **bridges;
|
||||
size_t bytes = sizeof *bridges * cfg->n_bridges;
|
||||
bridges = xmalloc(bytes + sizeof *bridges);
|
||||
memcpy(bridges, cfg->bridges, bytes);
|
||||
bridges[cfg->n_bridges] = bridge;
|
||||
ovsrec_open_vswitch_verify_bridges(cfg);
|
||||
ovsrec_open_vswitch_set_bridges(cfg, bridges, cfg->n_bridges + 1);
|
||||
|
||||
return bridge;
|
||||
}
|
||||
|
||||
static const struct ovsrec_bridge *
|
||||
get_br_int(struct controller_ctx *ctx)
|
||||
{
|
||||
const struct ovsrec_open_vswitch *cfg;
|
||||
cfg = ovsrec_open_vswitch_first(ctx->ovs_idl);
|
||||
if (!cfg) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -83,14 +127,11 @@ get_br_int(struct ovsdb_idl *ovs_idl)
|
||||
}
|
||||
|
||||
const struct ovsrec_bridge *br;
|
||||
br = get_bridge(ovs_idl, br_int_name);
|
||||
if (br) {
|
||||
return br;
|
||||
br = get_bridge(ctx->ovs_idl, br_int_name);
|
||||
if (!br) {
|
||||
return create_br_int(ctx, cfg, br_int_name);
|
||||
}
|
||||
|
||||
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1);
|
||||
VLOG_WARN_RL(&rl, "%s: integration bridge does not exist", br_int_name);
|
||||
return NULL;
|
||||
return br;
|
||||
}
|
||||
|
||||
static const char *
|
||||
@@ -374,6 +415,7 @@ main(int argc, char *argv[])
|
||||
ovsdb_idl_add_table(ovs_idl_loop.idl, &ovsrec_table_open_vswitch);
|
||||
ovsdb_idl_add_column(ovs_idl_loop.idl,
|
||||
&ovsrec_open_vswitch_col_external_ids);
|
||||
ovsdb_idl_add_column(ovs_idl_loop.idl, &ovsrec_open_vswitch_col_bridges);
|
||||
ovsdb_idl_add_table(ovs_idl_loop.idl, &ovsrec_table_interface);
|
||||
ovsdb_idl_add_column(ovs_idl_loop.idl, &ovsrec_interface_col_name);
|
||||
ovsdb_idl_add_column(ovs_idl_loop.idl, &ovsrec_interface_col_type);
|
||||
@@ -384,6 +426,9 @@ main(int argc, char *argv[])
|
||||
ovsdb_idl_add_column(ovs_idl_loop.idl, &ovsrec_port_col_external_ids);
|
||||
ovsdb_idl_add_table(ovs_idl_loop.idl, &ovsrec_table_bridge);
|
||||
ovsdb_idl_add_column(ovs_idl_loop.idl, &ovsrec_bridge_col_ports);
|
||||
ovsdb_idl_add_column(ovs_idl_loop.idl, &ovsrec_bridge_col_name);
|
||||
ovsdb_idl_add_column(ovs_idl_loop.idl, &ovsrec_bridge_col_fail_mode);
|
||||
ovsdb_idl_add_column(ovs_idl_loop.idl, &ovsrec_bridge_col_other_config);
|
||||
chassis_register_ovs_idl(ovs_idl_loop.idl);
|
||||
encaps_register_ovs_idl(ovs_idl_loop.idl);
|
||||
binding_register_ovs_idl(ovs_idl_loop.idl);
|
||||
@@ -406,7 +451,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.ovs_idl);
|
||||
const struct ovsrec_bridge *br_int = get_br_int(&ctx);
|
||||
const char *chassis_id = get_chassis_id(ctx.ovs_idl);
|
||||
|
||||
/* Map bridges to local nets from ovn-bridge-mappings */
|
||||
@@ -462,7 +507,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.ovs_idl);
|
||||
const struct ovsrec_bridge *br_int = get_br_int(&ctx);
|
||||
const char *chassis_id = get_chassis_id(ctx.ovs_idl);
|
||||
|
||||
/* Run all of the cleanup functions, even if one of them returns false.
|
||||
|
@@ -205,8 +205,10 @@
|
||||
<p>
|
||||
Each chassis in an OVN deployment must be configured with an Open vSwitch
|
||||
bridge dedicated for OVN's use, called the <dfn>integration bridge</dfn>.
|
||||
System startup scripts create this bridge prior to starting
|
||||
<code>ovn-controller</code>. The ports on the integration bridge include:
|
||||
System startup scripts may create this bridge prior to starting
|
||||
<code>ovn-controller</code> if desired. If this bridge does not exist when
|
||||
ovn-controller starts, it will be created automatically with the default
|
||||
configuration suggested below. The ports on the integration bridge include:
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
@@ -248,6 +250,8 @@
|
||||
<code>ovs-vswitchd.conf.db</code>(5):
|
||||
</p>
|
||||
|
||||
<!-- Keep the following in sync with create_br_int() in
|
||||
ovn/controller/ovn-controller.c. -->
|
||||
<dl>
|
||||
<dt><code>fail-mode=secure</code></dt>
|
||||
<dd>
|
||||
|
@@ -347,8 +347,6 @@ if $ovn; then
|
||||
ovs-vsctl set open . external-ids:ovn-remote=unix:"$sandbox"/db.sock
|
||||
ovs-vsctl set open . external-ids:ovn-encap-type=geneve
|
||||
ovs-vsctl set open . external-ids:ovn-encap-ip=127.0.0.1
|
||||
ovs-vsctl add-br br-int \
|
||||
-- set bridge br-int fail-mode=secure other-config:disable-in-band=true
|
||||
|
||||
rungdb $gdb_ovn_northd $gdb_ovn_northd_ex ovn-northd --detach --no-chdir --pidfile -vconsole:off --log-file
|
||||
rungdb $gdb_ovn_controller $gdb_ovn_controller_ex ovn-controller --detach --no-chdir --pidfile -vconsole:off --log-file
|
||||
|
Reference in New Issue
Block a user