Support the new keys in external_ids column of Chassis table for OVN interconnection. Also, populate the is_interconn key according to external_ids:ovn-is-interconn key of Open_vSwitch table on the chassis.
This patch also avoids creating tunnel or bfd sessions with remote chassis. Signed-off-by: Han Zhou <[email protected]> --- controller/bfd.c | 6 +++++- controller/chassis.c | 25 +++++++++++++++++++++++-- controller/encaps.c | 15 ++++++++++++--- controller/encaps.h | 3 ++- controller/ovn-controller.8.xml | 6 ++++++ controller/ovn-controller.c | 2 +- northd/ovn-northd.c | 4 +++- ovn-sb.xml | 15 +++++++++++++++ 8 files changed, 67 insertions(+), 9 deletions(-) diff --git a/controller/bfd.c b/controller/bfd.c index 10cd5fc..2b1e87f 100644 --- a/controller/bfd.c +++ b/controller/bfd.c @@ -151,7 +151,11 @@ bfd_calculate_chassis( if (is_ha_chassis) { /* It's an HA chassis. So add the ref_chassis to the bfd set. */ for (size_t i = 0; i < ha_chassis_grp->n_ref_chassis; i++) { - sset_add(&grp_chassis, ha_chassis_grp->ref_chassis[i]->name); + struct sbrec_chassis *ref_ch = ha_chassis_grp->ref_chassis[i]; + if (smap_get_bool(&ref_ch->external_ids, "is-remote", false)) { + continue; + } + sset_add(&grp_chassis, ref_ch->name); } } else { /* This is not an HA chassis. Check if this chassis is present diff --git a/controller/chassis.c b/controller/chassis.c index 978273e..522893e 100644 --- a/controller/chassis.c +++ b/controller/chassis.c @@ -92,6 +92,8 @@ struct ovs_chassis_cfg { struct sset encap_ip_set; /* Interface type list formatted in the OVN-SB Chassis required format. */ struct ds iface_types; + /* Is this chassis an interconnection gateway. */ + bool is_interconn; }; static void @@ -172,6 +174,12 @@ get_datapath_type(const struct ovsrec_bridge *br_int) return ""; } +static bool +get_is_interconn(const struct smap *ext_ids) +{ + return smap_get_bool(ext_ids, "ovn-is-interconn", false); +} + static void update_chassis_transport_zones(const struct sset *transport_zones, const struct sbrec_chassis *chassis_rec) @@ -285,19 +293,23 @@ 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); + return true; } static void chassis_build_external_ids(struct smap *ext_ids, const char *bridge_mappings, const char *datapath_type, const char *cms_options, - const char *chassis_macs, const char *iface_types) + const char *chassis_macs, const char *iface_types, + bool is_interconn) { smap_replace(ext_ids, "ovn-bridge-mappings", bridge_mappings); smap_replace(ext_ids, "datapath-type", datapath_type); smap_replace(ext_ids, "ovn-cms-options", cms_options); smap_replace(ext_ids, "iface-types", iface_types); smap_replace(ext_ids, "ovn-chassis-mac-mappings", chassis_macs); + smap_replace(ext_ids, "is-interconn", is_interconn ? "true" : "false"); } /* @@ -309,6 +321,7 @@ chassis_external_ids_changed(const char *bridge_mappings, const char *cms_options, const char *chassis_macs, const struct ds *iface_types, + bool is_interconn, const struct sbrec_chassis *chassis_rec) { const char *chassis_bridge_mappings = @@ -345,6 +358,12 @@ chassis_external_ids_changed(const char *bridge_mappings, return true; } + bool chassis_is_interconn = + smap_get_bool(&chassis_rec->external_ids, "is-interconn", false); + if (chassis_is_interconn != is_interconn) { + return true; + } + return false; } @@ -524,6 +543,7 @@ chassis_update(const struct sbrec_chassis *chassis_rec, ovs_cfg->cms_options, ovs_cfg->chassis_macs, &ovs_cfg->iface_types, + ovs_cfg->is_interconn, chassis_rec)) { struct smap ext_ids; @@ -532,7 +552,8 @@ chassis_update(const struct sbrec_chassis *chassis_rec, ovs_cfg->datapath_type, ovs_cfg->cms_options, ovs_cfg->chassis_macs, - ds_cstr_ro(&ovs_cfg->iface_types)); + ds_cstr_ro(&ovs_cfg->iface_types), + ovs_cfg->is_interconn); sbrec_chassis_verify_external_ids(chassis_rec); sbrec_chassis_set_external_ids(chassis_rec, &ext_ids); smap_destroy(&ext_ids); diff --git a/controller/encaps.c b/controller/encaps.c index db48b70..846628a 100644 --- a/controller/encaps.c +++ b/controller/encaps.c @@ -296,7 +296,7 @@ encaps_run(struct ovsdb_idl_txn *ovs_idl_txn, const struct ovsrec_bridge_table *bridge_table, const struct ovsrec_bridge *br_int, const struct sbrec_chassis_table *chassis_table, - const char *chassis_id, + const struct sbrec_chassis *this_chassis, const struct sbrec_sb_global *sbg, const struct sset *transport_zones) { @@ -316,7 +316,7 @@ encaps_run(struct ovsdb_idl_txn *ovs_idl_txn, tc.ovs_txn = ovs_idl_txn; ovsdb_idl_txn_add_comment(tc.ovs_txn, "ovn-controller: modifying OVS tunnels '%s'", - chassis_id); + this_chassis->name); /* Collect all port names into tc.port_names. * @@ -347,7 +347,7 @@ encaps_run(struct ovsdb_idl_txn *ovs_idl_txn, } SBREC_CHASSIS_TABLE_FOR_EACH (chassis_rec, chassis_table) { - if (strcmp(chassis_rec->name, chassis_id)) { + if (strcmp(chassis_rec->name, this_chassis->name)) { /* Create tunnels to the other Chassis belonging to the * same transport zone */ if (!chassis_tzones_overlap(transport_zones, chassis_rec)) { @@ -357,6 +357,15 @@ encaps_run(struct ovsdb_idl_txn *ovs_idl_txn, continue; } + if (smap_get_bool(&chassis_rec->external_ids, "is-remote", false) + && !smap_get_bool(&this_chassis->external_ids, "is-interconn", + false)) { + VLOG_DBG("Skipping encap creation for Chassis '%s' because " + "it is remote but this chassis is not interconn.", + chassis_rec->name); + continue; + } + if (chassis_tunnel_add(chassis_rec, sbg, &tc) == 0) { VLOG_INFO("Creating encap for '%s' failed", chassis_rec->name); continue; diff --git a/controller/encaps.h b/controller/encaps.h index c919d18..f488393 100644 --- a/controller/encaps.h +++ b/controller/encaps.h @@ -23,6 +23,7 @@ struct ovsdb_idl_txn; struct ovsrec_bridge; struct ovsrec_bridge_table; struct sbrec_chassis_table; +struct sbrec_chassis; struct sbrec_sb_global; struct ovsrec_open_vswitch_table; struct sset; @@ -32,7 +33,7 @@ void encaps_run(struct ovsdb_idl_txn *ovs_idl_txn, const struct ovsrec_bridge_table *, const struct ovsrec_bridge *br_int, const struct sbrec_chassis_table *, - const char *chassis_id, + const struct sbrec_chassis *, const struct sbrec_sb_global *, const struct sset *transport_zones); diff --git a/controller/ovn-controller.8.xml b/controller/ovn-controller.8.xml index a163ff5..76bbbdc 100644 --- a/controller/ovn-controller.8.xml +++ b/controller/ovn-controller.8.xml @@ -227,6 +227,12 @@ mac with, if packet is going from a distributed router port on vlan type logical switch. </dd> + + <dt><code>external_ids:ovn-is-interconn</code></dt> + <dd> + The boolean flag indicates if the chassis is used as an + interconnection gateway. + </dd> </dl> <p> diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 29a3792..caef80b 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -2020,7 +2020,7 @@ main(int argc, char *argv[]) encaps_run(ovs_idl_txn, bridge_table, br_int, sbrec_chassis_table_get(ovnsb_idl_loop.idl), - chassis_id, + chassis, sbrec_sb_global_first(ovnsb_idl_loop.idl), &transport_zones); diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index 4b58bea..a3f96b0 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -11178,7 +11178,8 @@ update_northbound_cfg(struct northd_context *ctx, const struct sbrec_chassis *chassis; int64_t hv_cfg = nbg->nb_cfg; SBREC_CHASSIS_FOR_EACH (chassis, ctx->ovnsb_idl) { - if (chassis->nb_cfg < hv_cfg) { + if (!smap_get_bool(&chassis->external_ids, "is-remote", false) && + chassis->nb_cfg < hv_cfg) { hv_cfg = chassis->nb_cfg; } } @@ -11466,6 +11467,7 @@ main(int argc, char *argv[]) ovsdb_idl_add_table(ovnsb_idl_loop.idl, &sbrec_table_chassis); ovsdb_idl_add_column(ovnsb_idl_loop.idl, &sbrec_chassis_col_nb_cfg); ovsdb_idl_add_column(ovnsb_idl_loop.idl, &sbrec_chassis_col_name); + ovsdb_idl_add_column(ovnsb_idl_loop.idl, &sbrec_chassis_col_external_ids); ovsdb_idl_add_table(ovnsb_idl_loop.idl, &sbrec_table_ha_chassis); add_column_noalert(ovnsb_idl_loop.idl, diff --git a/ovn-sb.xml b/ovn-sb.xml index c08ceda..3ae9d4f 100644 --- a/ovn-sb.xml +++ b/ovn-sb.xml @@ -293,6 +293,21 @@ See <code>ovn-controller</code>(8) for more information. </column> + <column name="external_ids" key="is-interconn"> + <code>ovn-controller</code> populates this key with the setting + configured in the <ref table="Open_vSwitch" + column="external_ids:ovn-is-interconn"/> column of the Open_vSwitch + database's <ref table="Open_vSwitch" db="Open_vSwitch"/> table. + If set to true, the chassis is used as an interconnection gateway. + See <code>ovn-controller</code>(8) for more information. + </column> + + <column name="external_ids" key="is-remote"> + <code>ovn-ic</code> set this key to true for remote interconnection + gateway chassises learned from the interconnection southbound database. + See <code>ovn-ic</code>(8) for more information. + </column> + <column name="transport_zones"> <code>ovn-controller</code> populates this key with the transport zones configured in the <ref table="Open_vSwitch" -- 2.1.0 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
