@@ -93,9 +93,10 @@ chassis_register_ovs_idl(struct ovsdb_idl *ovs_idl)
}
static const char *
-get_hostname(const struct smap *ext_ids)
+get_hostname(const struct smap *ext_ids, const char *chassis_id)
{
- const char *hostname = smap_get_def(ext_ids, "hostname", "");
+ const char *hostname = get_chassis_external_id_value(ext_ids, chassis_id,
+ "hostname", "");
if (strlen(hostname) == 0) {
static char hostname_[HOST_NAME_MAX + 1];
@@ -111,69 +112,81 @@ get_hostname(const struct smap *ext_ids)
}
static const char *
-get_bridge_mappings(const struct smap *ext_ids)
+get_bridge_mappings(const struct smap *ext_ids, const char *chassis_id)
{
- return smap_get_def(ext_ids, "ovn-bridge-mappings", "");
+ return get_chassis_external_id_value(ext_ids, chassis_id,
+ "ovn-bridge-mappings", "");
}
const char *
-get_chassis_mac_mappings(const struct smap *ext_ids)
+get_chassis_mac_mappings(const struct smap *ext_ids, const char *chassis_id)
{
- return smap_get_def(ext_ids, "ovn-chassis-mac-mappings", "");
+ return get_chassis_external_id_value(ext_ids, chassis_id,
+ "ovn-chassis-mac-mappings", "");
}
static const char *
-get_cms_options(const struct smap *ext_ids)
+get_cms_options(const struct smap *ext_ids, const char *chassis_id)
{
- return smap_get_def(ext_ids, "ovn-cms-options", "");
+ return get_chassis_external_id_value(ext_ids, chassis_id,
+ "ovn-cms-options", "");
}
static const char *
-get_monitor_all(const struct smap *ext_ids)
+get_monitor_all(const struct smap *ext_ids, const char *chassis_id)
{
- return smap_get_def(ext_ids, "ovn-monitor-all", "false");
+ return get_chassis_external_id_value(ext_ids, chassis_id,
+ "ovn-monitor-all", "false");
}
static const char *
-get_enable_lflow_cache(const struct smap *ext_ids)
+get_enable_lflow_cache(const struct smap *ext_ids, const char *chassis_id)
{
- return smap_get_def(ext_ids, "ovn-enable-lflow-cache", "true");
+ return get_chassis_external_id_value(ext_ids, chassis_id,
+ "ovn-enable-lflow-cache", "true");
}
static const char *
-get_limit_lflow_cache(const struct smap *ext_ids)
+get_limit_lflow_cache(const struct smap *ext_ids, const char *chassis_id)
{
- return smap_get_def(ext_ids, "ovn-limit-lflow-cache", "");
+ return get_chassis_external_id_value(ext_ids, chassis_id,
+ "ovn-limit-lflow-cache", "");
}
static const char *
-get_memlimit_lflow_cache(const struct smap *ext_ids)
+get_memlimit_lflow_cache(const struct smap *ext_ids, const char *chassis_id)
{
- return smap_get_def(ext_ids, "ovn-memlimit-lflow-cache-kb", "");
+ return get_chassis_external_id_value(ext_ids, chassis_id,
+ "ovn-memlimit-lflow-cache-kb", "");
}
static const char *
-get_trim_limit_lflow_cache(const struct smap *ext_ids)
+get_trim_limit_lflow_cache(const struct smap *ext_ids, const char *chassis_id)
{
- return smap_get_def(ext_ids, "ovn-trim-limit-lflow-cache", "");
+ return get_chassis_external_id_value(ext_ids, chassis_id,
+ "ovn-trim-limit-lflow-cache", "");
}
static const char *
-get_trim_wmark_perc_lflow_cache(const struct smap *ext_ids)
+get_trim_wmark_perc_lflow_cache(const struct smap *ext_ids,
+ const char *chassis_id)
{
- return smap_get_def(ext_ids, "ovn-trim-wmark-perc-lflow-cache", "");
+ return get_chassis_external_id_value(
+ ext_ids, chassis_id, "ovn-trim-wmark-perc-lflow-cache", "");
}
static const char *
-get_trim_timeout(const struct smap *ext_ids)
+get_trim_timeout(const struct smap *ext_ids, const char *chassis_id)
{
- return smap_get_def(ext_ids, "ovn-trim-timeout-ms", "");
+ return get_chassis_external_id_value(ext_ids, chassis_id,
+ "ovn-trim-timeout-ms", "");
}
static const char *
-get_encap_csum(const struct smap *ext_ids)
+get_encap_csum(const struct smap *ext_ids, const char *chassis_id)
{
- return smap_get_def(ext_ids, "ovn-encap-csum", "true");
+ return get_chassis_external_id_value(ext_ids, chassis_id,
+ "ovn-encap-csum", "true");
}
static const char *
@@ -187,9 +200,10 @@ get_datapath_type(const struct ovsrec_bridge *br_int)
}
static bool
-get_is_interconn(const struct smap *ext_ids)
+get_is_interconn(const struct smap *ext_ids, const char *chassis_id)
{
- return smap_get_bool(ext_ids, "ovn-is-interconn", false);
+ return get_chassis_external_id_value_bool(ext_ids, chassis_id,
+ "ovn-is-interconn", false);
}
static void
@@ -276,30 +290,41 @@ chassis_parse_ovs_config(const struct ovsrec_open_vswitch_table *ovs_table,
return false;
}
- const char *encap_type = smap_get(&cfg->external_ids, "ovn-encap-type");
- const char *encap_ips = smap_get(&cfg->external_ids, "ovn-encap-ip");
+ const char *chassis_id = get_ovs_chassis_id(ovs_table);
+ const char *encap_type =
+ get_chassis_external_id_value(&cfg->external_ids, chassis_id,
+ "ovn-encap-type", NULL);
+
+ const char *encap_ips =
+ get_chassis_external_id_value(&cfg->external_ids, chassis_id,
+ "ovn-encap-ip", NULL);
if (!encap_type || !encap_ips) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
VLOG_INFO_RL(&rl, "Need to specify an encap type and ip");
return false;
}
- ovs_cfg->hostname = get_hostname(&cfg->external_ids);
- ovs_cfg->bridge_mappings = get_bridge_mappings(&cfg->external_ids);
+ ovs_cfg->hostname = get_hostname(&cfg->external_ids, chassis_id);
+ ovs_cfg->bridge_mappings =
+ get_bridge_mappings(&cfg->external_ids, chassis_id);
ovs_cfg->datapath_type = get_datapath_type(br_int);
- ovs_cfg->encap_csum = get_encap_csum(&cfg->external_ids);
- ovs_cfg->cms_options = get_cms_options(&cfg->external_ids);
- ovs_cfg->monitor_all = get_monitor_all(&cfg->external_ids);
- ovs_cfg->chassis_macs = get_chassis_mac_mappings(&cfg->external_ids);
- ovs_cfg->enable_lflow_cache = get_enable_lflow_cache(&cfg->external_ids);
- ovs_cfg->limit_lflow_cache = get_limit_lflow_cache(&cfg->external_ids);
+ ovs_cfg->encap_csum = get_encap_csum(&cfg->external_ids, chassis_id);
+ ovs_cfg->cms_options = get_cms_options(&cfg->external_ids, chassis_id);
+ ovs_cfg->monitor_all = get_monitor_all(&cfg->external_ids, chassis_id);
+ ovs_cfg->chassis_macs =
+ get_chassis_mac_mappings(&cfg->external_ids, chassis_id);
+ ovs_cfg->enable_lflow_cache =
+ get_enable_lflow_cache(&cfg->external_ids, chassis_id);
+ ovs_cfg->limit_lflow_cache =
+ get_limit_lflow_cache(&cfg->external_ids, chassis_id);
ovs_cfg->memlimit_lflow_cache =
- get_memlimit_lflow_cache(&cfg->external_ids);
+ get_memlimit_lflow_cache(&cfg->external_ids, chassis_id);
ovs_cfg->trim_limit_lflow_cache =
- get_trim_limit_lflow_cache(&cfg->external_ids);
+ get_trim_limit_lflow_cache(&cfg->external_ids, chassis_id);
ovs_cfg->trim_wmark_perc_lflow_cache =
- get_trim_wmark_perc_lflow_cache(&cfg->external_ids);
- ovs_cfg->trim_timeout_ms = get_trim_timeout(&cfg->external_ids);
+ get_trim_wmark_perc_lflow_cache(&cfg->external_ids, chassis_id);
+ ovs_cfg->trim_timeout_ms =
+ get_trim_timeout(&cfg->external_ids, chassis_id);
if (!chassis_parse_ovs_encap_type(encap_type, &ovs_cfg->encap_type_set)) {
return false;
@@ -322,7 +347,7 @@ chassis_parse_ovs_config(const struct ovsrec_open_vswitch_table *ovs_table,
sset_destroy(&ovs_cfg->encap_ip_set);
}
- ovs_cfg->is_interconn = get_is_interconn(&cfg->external_ids);
+ ovs_cfg->is_interconn = get_is_interconn(&cfg->external_ids, chassis_id);
return true;
}
@@ -362,7 +387,7 @@ chassis_other_config_changed(const struct ovs_chassis_cfg *ovs_cfg,
const struct sbrec_chassis *chassis_rec)
{
const char *chassis_bridge_mappings =
- get_bridge_mappings(&chassis_rec->other_config);
+ get_bridge_mappings(&chassis_rec->other_config, chassis_rec->name);
if (strcmp(ovs_cfg->bridge_mappings, chassis_bridge_mappings)) {
return true;
@@ -376,42 +401,44 @@ chassis_other_config_changed(const struct ovs_chassis_cfg *ovs_cfg,
}
const char *chassis_cms_options =
- get_cms_options(&chassis_rec->other_config);
+ get_cms_options(&chassis_rec->other_config, chassis_rec->name);
if (strcmp(ovs_cfg->cms_options, chassis_cms_options)) {
return true;
}
const char *chassis_monitor_all =
- get_monitor_all(&chassis_rec->other_config);
+ get_monitor_all(&chassis_rec->other_config, chassis_rec->name);
if (strcmp(ovs_cfg->monitor_all, chassis_monitor_all)) {
return true;
}
const char *chassis_enable_lflow_cache =
- get_enable_lflow_cache(&chassis_rec->other_config);
+ get_enable_lflow_cache(&chassis_rec->other_config, chassis_rec->name);
if (strcmp(ovs_cfg->enable_lflow_cache, chassis_enable_lflow_cache)) {
return true;
}
const char *chassis_limit_lflow_cache =
- get_limit_lflow_cache(&chassis_rec->other_config);
+ get_limit_lflow_cache(&chassis_rec->other_config, chassis_rec->name);
if (strcmp(ovs_cfg->limit_lflow_cache, chassis_limit_lflow_cache)) {
return true;
}
const char *chassis_memlimit_lflow_cache =
- get_memlimit_lflow_cache(&chassis_rec->other_config);
+ get_memlimit_lflow_cache(&chassis_rec->other_config,
+ chassis_rec->name);
if (strcmp(ovs_cfg->memlimit_lflow_cache, chassis_memlimit_lflow_cache)) {
return true;
}
const char *chassis_trim_limit_lflow_cache =
- get_trim_limit_lflow_cache(&chassis_rec->other_config);
+ get_trim_limit_lflow_cache(&chassis_rec->other_config,
+ chassis_rec->name);
if (strcmp(ovs_cfg->trim_limit_lflow_cache,
chassis_trim_limit_lflow_cache)) {
@@ -419,7 +446,8 @@ chassis_other_config_changed(const struct ovs_chassis_cfg *ovs_cfg,
}
const char *chassis_trim_wmark_perc_lflow_cache =
- get_trim_wmark_perc_lflow_cache(&chassis_rec->other_config);
+ get_trim_wmark_perc_lflow_cache(
+ &chassis_rec->other_config, chassis_rec->name);
if (strcmp(ovs_cfg->trim_wmark_perc_lflow_cache,
chassis_trim_wmark_perc_lflow_cache)) {
@@ -427,14 +455,15 @@ chassis_other_config_changed(const struct ovs_chassis_cfg *ovs_cfg,
}
const char *chassis_trim_timeout_ms =
- get_trim_timeout(&chassis_rec->other_config);
+ get_trim_timeout(&chassis_rec->other_config, chassis_rec->name);
if (strcmp(ovs_cfg->trim_timeout_ms, chassis_trim_timeout_ms)) {
return true;
}
const char *chassis_mac_mappings =
- get_chassis_mac_mappings(&chassis_rec->other_config);
+ get_chassis_mac_mappings(&chassis_rec->other_config,
+ chassis_rec->name);
if (strcmp(ovs_cfg->chassis_macs, chassis_mac_mappings)) {
return true;
}
@@ -754,8 +783,9 @@ chassis_get_mac(const struct sbrec_chassis *chassis_rec,
const char *bridge_mapping,
struct eth_addr *chassis_mac)
{
- const char *tokens
- = get_chassis_mac_mappings(&chassis_rec->other_config);
+ const char *tokens =
+ get_chassis_mac_mappings(&chassis_rec->other_config,
+ chassis_rec->name);
if (!tokens[0]) {
return false;
}
@@ -49,7 +49,8 @@ bool chassis_cleanup(struct ovsdb_idl_txn *ovnsb_idl_txn,
bool chassis_get_mac(const struct sbrec_chassis *chassis,
const char *bridge_mapping,
struct eth_addr *chassis_mac);
-const char * get_chassis_mac_mappings(const struct smap *ext_ids);
+const char * get_chassis_mac_mappings(const struct smap *ext_ids,
+ const char *chassis_id);
const char *get_ovs_chassis_id(const struct ovsrec_open_vswitch_table *);
const char *get_chassis_idx(const struct ovsrec_open_vswitch_table *);
void store_chassis_index_if_needed(const struct ovsrec_open_vswitch_table *);
@@ -185,24 +185,29 @@ tunnel_add(struct tunnel_ctx *tc, const struct sbrec_sb_global *sbg,
bool set_local_ip = false;
if (cfg) {
/* If the tos option is configured, get it */
- const char *encap_tos = smap_get_def(&cfg->external_ids,
- "ovn-encap-tos", "none");
+ const char *encap_tos =
+ get_chassis_external_id_value(
+ &cfg->external_ids, tc->this_chassis->name,
+ "ovn-encap-tos", "none");
if (encap_tos && strcmp(encap_tos, "none")) {
smap_add(&options, "tos", encap_tos);
}
/* If the df_default option is configured, get it */
-
- const char *encap_df = smap_get(&cfg->external_ids,
- "ovn-encap-df_default");
+ const char *encap_df =
+ get_chassis_external_id_value(
+ &cfg->external_ids, tc->this_chassis->name,
+ "ovn-encap-df_default", NULL);
if (encap_df) {
smap_add(&options, "df_default", encap_df);
}
/* If ovn-set-local-ip option is configured, get it */
- set_local_ip = smap_get_bool(&cfg->external_ids, "ovn-set-local-ip",
- false);
+ set_local_ip =
+ get_chassis_external_id_value_bool(
+ &cfg->external_ids, tc->this_chassis->name,
+ "ovn-set-local-ip", false);
}
/* Add auth info if ipsec is enabled. */
@@ -84,6 +84,10 @@
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).
+ When more than one controllers are running on the same host,
+ <code>external_ids:ovn-bridge-CHASSIS_NAME</code> should be set for
+ each of them, pointing to a unique bridge. This is required to avoid
+ controllers stepping on each others' feet.
</dd>
<dt><code>external_ids:ovn-bridge-datapath-type</code></dt>
@@ -354,6 +358,18 @@
</dd>
</dl>
+ <p>
+ Most of configuration options listed above can also be set for a
+ particular chassis name (see <code>external_ids:system-id </code>
+ for more information). This can be achieved by setting
+ <code>external_ids:option-[chassis]</code> instead of
+ <code>external_ids:option</code>. For example, set
+ <code>external_ids:ovn-encap-ip-otherhv</code> to use a particular
+ IP address for the controller instance named <code>otherhv</code>.
+ Name specific configuration options always override any global options
+ set in the database.
+ </p>
+
<p>
<code>ovn-controller</code> reads the following values from the
<code>Open_vSwitch</code> database of the local OVS instance:
@@ -311,9 +311,13 @@ out:;
}
static const char *
-br_int_name(const struct ovsrec_open_vswitch *cfg)
+br_int_name(const struct ovsrec_open_vswitch_table *ovs_table)
{
- return smap_get_def(&cfg->external_ids, "ovn-bridge", DEFAULT_BRIDGE_NAME);
+ const struct ovsrec_open_vswitch *cfg =
+ ovsrec_open_vswitch_table_first(ovs_table);
+ const char *chassis_id = get_ovs_chassis_id(ovs_table);
+ return get_chassis_external_id_value(&cfg->external_ids, chassis_id,
+ "ovn-bridge", DEFAULT_BRIDGE_NAME);
}
static const struct ovsrec_bridge *
@@ -325,7 +329,7 @@ create_br_int(struct ovsdb_idl_txn *ovs_idl_txn,
if (!cfg) {
return NULL;
}
- const char *bridge_name = br_int_name(cfg);
+ const char *bridge_name = br_int_name(ovs_table);
ovsdb_idl_txn_add_comment(ovs_idl_txn,
"ovn-controller: creating integration bridge '%s'", bridge_name);
@@ -410,7 +414,7 @@ get_br_int(const struct ovsrec_bridge_table *bridge_table,
return NULL;
}
- return get_bridge(bridge_table, br_int_name(cfg));
+ return get_bridge(bridge_table, br_int_name(ovs_table));
}
static const struct ovsrec_datapath *
@@ -449,8 +453,11 @@ process_br_int(struct ovsdb_idl_txn *ovs_idl_txn,
* Otherwise use the datapath-type set in br-int, if any.
* Finally, assume "system" datapath if none configured.
*/
+ const char *chassis_id = get_ovs_chassis_id(ovs_table);
const char *datapath_type =
- smap_get(&cfg->external_ids, "ovn-bridge-datapath-type");
+ get_chassis_external_id_value(
+ &cfg->external_ids, chassis_id,
+ "ovn-bridge-datapath-type", NULL);
if (!datapath_type) {
if (br_int->datapath_type[0]) {
@@ -501,10 +508,16 @@ static int
get_ofctrl_probe_interval(struct ovsdb_idl *ovs_idl)
{
const struct ovsrec_open_vswitch *cfg = ovsrec_open_vswitch_first(ovs_idl);
- return !cfg ? OFCTRL_DEFAULT_PROBE_INTERVAL_SEC :
- smap_get_int(&cfg->external_ids,
- "ovn-openflow-probe-interval",
- OFCTRL_DEFAULT_PROBE_INTERVAL_SEC);
+ if (!cfg) {
+ return OFCTRL_DEFAULT_PROBE_INTERVAL_SEC;
+ }
+
+ const struct ovsrec_open_vswitch_table *ovs_table =
+ ovsrec_open_vswitch_table_get(ovs_idl);
+ const char *chassis_id = get_ovs_chassis_id(ovs_table);
+ return get_chassis_external_id_value_int(
+ &cfg->external_ids, chassis_id,
+ "ovn-openflow-probe-interval", OFCTRL_DEFAULT_PROBE_INTERVAL_SEC);
}
/* Retrieves the pointer to the OVN Southbound database from 'ovs_idl' and
@@ -521,18 +534,26 @@ update_sb_db(struct ovsdb_idl *ovs_idl, struct ovsdb_idl *ovnsb_idl,
}
/* Set remote based on user configuration. */
- const char *remote = smap_get(&cfg->external_ids, "ovn-remote");
+ const struct ovsrec_open_vswitch_table *ovs_table =
+ ovsrec_open_vswitch_table_get(ovs_idl);
+ const char *chassis_id = get_ovs_chassis_id(ovs_table);
+ const char *remote =
+ get_chassis_external_id_value(
+ &cfg->external_ids, chassis_id, "ovn-remote", NULL);
ovsdb_idl_set_remote(ovnsb_idl, remote, true);
/* Set probe interval, based on user configuration and the remote. */
int default_interval = (remote && !stream_or_pstream_needs_probes(remote)
? 0 : DEFAULT_PROBE_INTERVAL_MSEC);
- int interval = smap_get_int(&cfg->external_ids,
- "ovn-remote-probe-interval", default_interval);
+ int interval =
+ get_chassis_external_id_value_int(
+ &cfg->external_ids, chassis_id,
+ "ovn-remote-probe-interval", default_interval);
ovsdb_idl_set_probe_interval(ovnsb_idl, interval);
- bool monitor_all = smap_get_bool(&cfg->external_ids, "ovn-monitor-all",
- false);
+ bool monitor_all =
+ get_chassis_external_id_value_bool(
+ &cfg->external_ids, chassis_id, "ovn-monitor-all", false);
if (monitor_all) {
/* Always call update_sb_monitors when monitor_all is true.
* Otherwise, don't call it here, because there would be unnecessary
@@ -555,25 +576,31 @@ update_sb_db(struct ovsdb_idl *ovs_idl, struct ovsdb_idl *ovnsb_idl,
}
if (ctx) {
- lflow_cache_enable(ctx->lflow_cache,
- smap_get_bool(&cfg->external_ids,
- "ovn-enable-lflow-cache",
- true),
- smap_get_uint(&cfg->external_ids,
- "ovn-limit-lflow-cache",
- DEFAULT_LFLOW_CACHE_MAX_ENTRIES),
- smap_get_ullong(&cfg->external_ids,
- "ovn-memlimit-lflow-cache-kb",
- DEFAULT_LFLOW_CACHE_MAX_MEM_KB),
- smap_get_uint(&cfg->external_ids,
- "ovn-trim-limit-lflow-cache",
- DEFAULT_LFLOW_CACHE_TRIM_LIMIT),
- smap_get_uint(&cfg->external_ids,
- "ovn-trim-wmark-perc-lflow-cache",
- DEFAULT_LFLOW_CACHE_WMARK_PERC),
- smap_get_uint(&cfg->external_ids,
- "ovn-trim-timeout-ms",
- DEFAULT_LFLOW_CACHE_TRIM_TO_MS));
+ lflow_cache_enable(
+ ctx->lflow_cache,
+ get_chassis_external_id_value_bool(
+ &cfg->external_ids, chassis_id,
+ "ovn-enable-lflow-cache", true),
+ get_chassis_external_id_value_uint(
+ &cfg->external_ids, chassis_id,
+ "ovn-limit-lflow-cache",
+ DEFAULT_LFLOW_CACHE_MAX_ENTRIES),
+ get_chassis_external_id_value_ullong(
+ &cfg->external_ids, chassis_id,
+ "ovn-memlimit-lflow-cache-kb",
+ DEFAULT_LFLOW_CACHE_MAX_MEM_KB),
+ get_chassis_external_id_value_uint(
+ &cfg->external_ids, chassis_id,
+ "ovn-trim-limit-lflow-cache",
+ DEFAULT_LFLOW_CACHE_TRIM_LIMIT),
+ get_chassis_external_id_value_uint(
+ &cfg->external_ids, chassis_id,
+ "ovn-trim-wmark-perc-lflow-cache",
+ DEFAULT_LFLOW_CACHE_WMARK_PERC),
+ get_chassis_external_id_value_uint(
+ &cfg->external_ids, chassis_id,
+ "ovn-trim-timeout-ms",
+ DEFAULT_LFLOW_CACHE_TRIM_TO_MS));
}
}
@@ -816,7 +843,7 @@ restore_ct_zones(const struct ovsrec_bridge_table *bridge_table,
}
const struct ovsrec_bridge *br_int;
- br_int = get_bridge(bridge_table, br_int_name(cfg));
+ br_int = get_bridge(bridge_table, br_int_name(ovs_table));
if (!br_int) {
/* If the integration bridge hasn't been defined, assume that
* any existing ct-zone definitions aren't valid. */
@@ -929,7 +956,9 @@ get_transport_zones(const struct ovsrec_open_vswitch_table *ovs_table)
{
const struct ovsrec_open_vswitch *cfg
= ovsrec_open_vswitch_table_first(ovs_table);
- return smap_get_def(&cfg->external_ids, "ovn-transport-zones", "");
+ const char *chassis_id = get_ovs_chassis_id(ovs_table);
+ return get_chassis_external_id_value(&cfg->external_ids, chassis_id,
+ "ovn-transport-zones", "");
}
static void
@@ -3536,8 +3565,12 @@ check_northd_version(struct ovsdb_idl *ovs_idl, struct ovsdb_idl *ovnsb_idl,
static bool version_mismatch;
const struct ovsrec_open_vswitch *cfg = ovsrec_open_vswitch_first(ovs_idl);
- if (!cfg || !smap_get_bool(&cfg->external_ids, "ovn-match-northd-version",
- false)) {
+ const struct ovsrec_open_vswitch_table *ovs_table =
+ ovsrec_open_vswitch_table_get(ovs_idl);
+ const char *chassis_id = get_ovs_chassis_id(ovs_table);
+ if (!cfg || !get_chassis_external_id_value_bool(
+ &cfg->external_ids, chassis_id,
+ "ovn-match-northd-version", false)) {
version_mismatch = false;
return true;
}
@@ -15,6 +15,7 @@
#include <config.h>
+#include "chassis.h"
#include "patch.h"
#include "ovsport.h"
@@ -131,7 +132,10 @@ add_ovs_bridge_mappings(const struct ovsrec_open_vswitch_table *ovs_table,
const char *mappings_cfg;
char *cur, *next, *start;
- mappings_cfg = smap_get(&cfg->external_ids, "ovn-bridge-mappings");
+ const char *chassis_id = get_ovs_chassis_id(ovs_table);
+ mappings_cfg =
+ get_chassis_external_id_value(
+ &cfg->external_ids, chassis_id, "ovn-bridge-mappings", NULL);
if (!mappings_cfg || !mappings_cfg[0]) {
return;
}
@@ -503,7 +503,7 @@ populate_remote_chassis_macs(const struct sbrec_chassis *my_chassis,
}
const char *tokens
- = get_chassis_mac_mappings(&chassis->other_config);
+ = get_chassis_mac_mappings(&chassis->other_config, chassis->name);
if (!strlen(tokens)) {
continue;
@@ -968,3 +968,82 @@ lr_lb_address_set_ref(uint32_t lr_tunnel_key, int addr_family)
{
return lr_lb_address_set_name_(lr_tunnel_key, "$", addr_family);
}
+
+static char *
+chassis_option_key(const char *option_key, const char *chassis_id)
+{
+ if (!chassis_id) {
+ return xasprintf("%s", option_key);
+ }
+ return xasprintf("%s-%s", option_key, chassis_id);
+}
+
+const char *
+get_chassis_external_id_value(const struct smap *external_ids,
+ const char *chassis_id,
+ const char *option_key,
+ const char *def)
+{
+ char *chassis_key = chassis_option_key(option_key, chassis_id);
+ const char *ret =
+ smap_get_def(external_ids, chassis_key,
+ smap_get_def(external_ids, option_key, def));
+ free(chassis_key);
+ return ret;
+}
+
+int
+get_chassis_external_id_value_int(const struct smap *external_ids,
+ const char *chassis_id,
+ const char *option_key,
+ int def)
+{
+ char *chassis_key = chassis_option_key(option_key, chassis_id);
+ int ret =
+ smap_get_int(external_ids, chassis_key,
+ smap_get_int(external_ids, option_key, def));
+ free(chassis_key);
+ return ret;
+}
+
+unsigned int
+get_chassis_external_id_value_uint(const struct smap *external_ids,
+ const char *chassis_id,
+ const char *option_key,
+ unsigned int def)
+{
+ char *chassis_key = chassis_option_key(option_key, chassis_id);
+ unsigned int ret =
+ smap_get_uint(external_ids, chassis_key,
+ smap_get_uint(external_ids, option_key, def));
+ free(chassis_key);
+ return ret;
+}
+
+unsigned long long int
+get_chassis_external_id_value_ullong(const struct smap *external_ids,
+ const char *chassis_id,
+ const char *option_key,
+ unsigned long long int def)
+{
+ char *chassis_key = chassis_option_key(option_key, chassis_id);
+ unsigned long long int ret =
+ smap_get_ullong(external_ids, chassis_key,
+ smap_get_ullong(external_ids, option_key, def));
+ free(chassis_key);
+ return ret;
+}
+
+bool
+get_chassis_external_id_value_bool(const struct smap *external_ids,
+ const char *chassis_id,
+ const char *option_key,
+ bool def)
+{
+ char *chassis_key = chassis_option_key(option_key, chassis_id);
+ bool ret =
+ smap_get_bool(external_ids, chassis_key,
+ smap_get_bool(external_ids, option_key, def));
+ free(chassis_key);
+ return ret;
+}
@@ -318,4 +318,30 @@ int64_t daemon_startup_ts(void);
char *lr_lb_address_set_name(uint32_t lr_tunnel_key, int addr_family);
char *lr_lb_address_set_ref(uint32_t lr_tunnel_key, int addr_family);
+const char *
+get_chassis_external_id_value(const struct smap *,
+ const char *chassis_id,
+ const char *option_key,
+ const char *def);
+int
+get_chassis_external_id_value_int(const struct smap *,
+ const char *chassis_id,
+ const char *option_key,
+ int def);
+unsigned int
+get_chassis_external_id_value_uint(const struct smap *,
+ const char *chassis_id,
+ const char *option_key,
+ unsigned int def);
+unsigned long long int
+get_chassis_external_id_value_ullong(const struct smap *external_ids,
+ const char *chassis_id,
+ const char *option_key,
+ unsigned long long int def);
+bool
+get_chassis_external_id_value_bool(const struct smap *,
+ const char *chassis_id,
+ const char *option_key,
+ bool def);
+
#endif /* OVN_UTIL_H */
@@ -1080,6 +1080,14 @@
implications because the network used for tunneling must have MTU
larger than <code>localnet</code> for stable connectivity.
</p>
+
+ <p>
+ If the same host co-hosts more than one controller instance
+ (either belonging to the same or separate clusters), special
+ attention should be given to consistently using unique chassis
+ names used in this option. It is advised that chassis names -
+ and not host names - are used for this option.
+ </p>
</column>
<column name="options" key="activation-strategy">
@@ -290,7 +290,7 @@ net_attach () {
# ovn_az_attach AZ NETWORK BRIDGE IP [MASKLEN] [ENCAP]
ovn_az_attach() {
- local az=$1 net=$2 bridge=$3 ip=$4 masklen=${5-24} encap=${6-geneve,vxlan}
+ local az=$1 net=$2 bridge=$3 ip=$4 masklen=${5-24} encap=${6-geneve,vxlan} systemid=${7-$sandbox}
net_attach $net $bridge || return 1
mac=`ovs-vsctl get Interface $bridge mac_in_use | sed s/\"//g`
@@ -315,7 +315,7 @@ ovn_az_attach() {
fi
ovs-vsctl \
-- set Open_vSwitch . external-ids:hostname=$sandbox \
- -- set Open_vSwitch . external-ids:system-id=$sandbox \
+ -- set Open_vSwitch . external-ids:system-id=$systemid \
-- set Open_vSwitch . external-ids:ovn-remote=$ovn_remote \
-- set Open_vSwitch . external-ids:ovn-encap-type=$encap \
-- set Open_vSwitch . external-ids:ovn-encap-ip=$ip \
@@ -33455,3 +33455,38 @@ OVN_CLEANUP
AT_CLEANUP
])
+
+OVN_FOR_EACH_NORTHD([
+AT_SETUP([chassis-specific configuration options])
+ovn_start
+net_add n1
+
+sim_add hv1
+as hv1
+ovs-vsctl add-br br-phys
+
+ovs-vsctl \
+ -- set Open_vSwitch . external-ids:ovn-encap-type-hv3=geneve \
+ -- set Open_vSwitch . external-ids:ovn-encap-ip-hv3=192.168.1.1
+
+as hv1 ovs-vsctl set-ssl \
+ $PKIDIR/testpki-hv3-privkey.pem \
+ $PKIDIR/testpki-hv3-cert.pem \
+ $PKIDIR/testpki-cacert.pem
+
+ovn_attach n1 br-phys 192.168.0.1 24 vxlan hv3
+
+sim_add hv2
+as hv2
+ovs-vsctl add-br br-phys
+ovn_attach n1 br-phys 192.168.0.2 24 geneve
+
+# despite that we configured ovn-encap-ip=192.168.0.1, this setting is
+# overridden by chassis specific ovn-encap-ip-hv3
+wait_column 192.168.1.1 Encap ip chassis_name=hv3 type=geneve
+
+check_column "" Encap ip chassis_name=hv1 type=vxlan
+
+OVN_CLEANUP([hv1],[hv2])
+AT_CLEANUP
+])
Before the patch, all controller instances were reading configuration from the same external-ids:ovn-* options. This patch adds support for distinct config otions for different chassis names stored in the same ovsdb global config object. To configure an option for a distinct chassis name, an admin may add a suffix with the desired chassis name to a config option. For example, if the following is configured in ovsdb, only a controller with the corresponding chassis name (either 'hv1' or 'hv2') would read just one of the following options: ovs-vsctl set open . external-ids:ovn-bridge-mappings-hv1=phys:br-phys-1 ovs-vsctl set open . external-ids:ovn-bridge-mappings-hv2=phys:br-phys-2 Chassis specific config options override any global settings, so for example if the following configuration is used, then controller 'hv1' will use the first setting but not the latter. Any other controllers will use the global setting, which is the second setting.. ovs-vsctl set open . external-ids:ovn-bridge-mappings-hv1=phys:br-phys-1 ovs-vsctl set open . external-ids:ovn-bridge-mappings=phys:br-phys-2 This is supported for other options too. This is in preparation to support running multiple controller instances using the same vswitchd instance. Signed-off-by: Ihar Hrachyshka <ihrachys@redhat.com> --- controller/chassis.c | 136 +++++++++++++++++++------------- controller/chassis.h | 3 +- controller/encaps.c | 19 +++-- controller/ovn-controller.8.xml | 16 ++++ controller/ovn-controller.c | 107 ++++++++++++++++--------- controller/patch.c | 6 +- controller/physical.c | 2 +- lib/ovn-util.c | 79 +++++++++++++++++++ lib/ovn-util.h | 26 ++++++ ovn-nb.xml | 8 ++ tests/ovn-macros.at | 4 +- tests/ovn.at | 35 ++++++++ 12 files changed, 339 insertions(+), 102 deletions(-)