From patchwork Sat Jul 30 10:02:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 654263 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3s1h392dtXz9t0h for ; Sat, 30 Jul 2016 20:02:12 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 1B3AA115A9; Sat, 30 Jul 2016 03:02:11 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v3.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id B2BAB115A3 for ; Sat, 30 Jul 2016 03:02:09 -0700 (PDT) Received: from bar6.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id 12FF016237F for ; Sat, 30 Jul 2016 04:02:09 -0600 (MDT) X-ASG-Debug-ID: 1469872926-0b32374d30d1da0001-byXFYA Received: from mx3-pf3.cudamail.com ([192.168.14.3]) by bar6.cudamail.com with ESMTP id fYJ5kJo9MOmSJm4f (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 30 Jul 2016 04:02:06 -0600 (MDT) X-Barracuda-Envelope-From: nusiddiq@redhat.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.3 Received: from unknown (HELO mx1.redhat.com) (209.132.183.28) by mx3-pf3.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 30 Jul 2016 10:02:06 -0000 Received-SPF: pass (mx3-pf3.cudamail.com: SPF record at _spf1.redhat.com designates 209.132.183.28 as permitted sender) X-Barracuda-Apparent-Source-IP: 209.132.183.28 X-Barracuda-RBL-IP: 209.132.183.28 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7CCA119C315 for ; Sat, 30 Jul 2016 10:02:04 +0000 (UTC) Received: from nusiddiq.blr.redhat.com (ovpn-116-22.phx2.redhat.com [10.3.116.22]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6UA22GI025362 for ; Sat, 30 Jul 2016 06:02:03 -0400 X-CudaMail-Envelope-Sender: nusiddiq@redhat.com From: Numan Siddique X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-V3-729001704 X-CudaMail-DTE: 073016 X-CudaMail-Originating-IP: 209.132.183.28 To: ovs dev X-ASG-Orig-Subj: [##CM-V3-729001704##][PATCH v4] ovn-controller: Add datapath-type and iface-types in chassis:external_ids Organization: Red Hat Message-ID: <2b946d44-2cc7-5f60-7e64-274bdcd64aab@redhat.com> Date: Sat, 30 Jul 2016 15:32:01 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Sat, 30 Jul 2016 10:02:04 +0000 (UTC) X-Barracuda-Connect: UNKNOWN[192.168.14.3] X-Barracuda-Start-Time: 1469872926 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Subject: [ovs-dev] [PATCH v4] ovn-controller: Add datapath-type and iface-types in chassis:external_ids X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@openvswitch.org Sender: "dev" This patch reads the 'Bridge.datapath_type' column value of the integration bridge and 'Open_vSwitch.iface_types' column value and sets these in the external_ids:datapath-type and external_ids:iface-types of Chassis table. This will provide hints to the CMS or clients monitoring OVN SB DB to determine the datapath type (DPDK or non-DPDK) configured and take some actions based on it. One usecase is, OVN neutron plugin can use this information to set the vif_type (ovs or vhostuser) during the port binding. Signed-off-by: Numan Siddique Acked-by: Ryan Moats --- ovn/controller/chassis.c | 63 ++++++++++++++++++++++++++++++++++--- ovn/controller/chassis.h | 3 +- ovn/controller/ovn-controller.8.xml | 24 ++++++++++++++ ovn/controller/ovn-controller.c | 2 +- ovn/ovn-sb.xml | 16 ++++++++++ tests/ovn-controller.at | 60 +++++++++++++++++++++++++++++++++++ 6 files changed, 161 insertions(+), 7 deletions(-) v3 -> v4 -------- * Also storing the supported iface-types in the chassis external_ids. * Updated the documentation. v2 -> v3 -------- * Fixed the compilation error which I accidentally introduced by deleting "<" in the ovn-controller.8.xml in v2. v1 -> v2 -------- * Addressed the review comments. Reading the datapath-type from Bridge.datapath_type column instead of adding a new configuration option. diff --git a/ovn/controller/chassis.c b/ovn/controller/chassis.c index a1545ec..4adf110 100644 --- a/ovn/controller/chassis.c +++ b/ovn/controller/chassis.c @@ -38,6 +38,9 @@ chassis_register_ovs_idl(struct ovsdb_idl *ovs_idl) { ovsdb_idl_add_table(ovs_idl, &ovsrec_table_open_vswitch); ovsdb_idl_add_column(ovs_idl, &ovsrec_open_vswitch_col_external_ids); + ovsdb_idl_add_column(ovs_idl, &ovsrec_open_vswitch_col_iface_types); + ovsdb_idl_add_table(ovs_idl, &ovsrec_table_bridge); + ovsdb_idl_add_column(ovs_idl, &ovsrec_bridge_col_datapath_type); } static const char * @@ -67,7 +70,8 @@ get_bridge_mappings(const struct smap *ext_ids) /* Returns this chassis's Chassis record, if it is available and is currently * amenable to a transaction. */ const struct sbrec_chassis * -chassis_run(struct controller_ctx *ctx, const char *chassis_id) +chassis_run(struct controller_ctx *ctx, const char *chassis_id, + const struct ovsrec_bridge *br_int) { if (!ctx->ovnsb_idl_txn) { return NULL; @@ -114,6 +118,16 @@ chassis_run(struct controller_ctx *ctx, const char *chassis_id) } const char *bridge_mappings = get_bridge_mappings(&cfg->external_ids); + const char *datapath_type = + br_int && br_int->datapath_type ? br_int->datapath_type : ""; + + struct ds iface_types = DS_EMPTY_INITIALIZER; + ds_put_cstr(&iface_types, ""); + for (int j = 0; j < cfg->n_iface_types; j++) { + ds_put_format(&iface_types, "%s,", cfg->iface_types[j]); + } + ds_chomp(&iface_types, ','); + const char *iface_types_str = ds_cstr(&iface_types); const struct sbrec_chassis *chassis_rec = get_chassis(ctx->ovnsb_idl, chassis_id); @@ -125,10 +139,45 @@ chassis_run(struct controller_ctx *ctx, const char *chassis_id) const char *chassis_bridge_mappings = get_bridge_mappings(&chassis_rec->external_ids); - if (strcmp(bridge_mappings, chassis_bridge_mappings)) { + const char *chassis_datapath_type + = smap_get(&chassis_rec->external_ids, "datapath-type"); + const char *chassis_iface_types + = smap_get(&chassis_rec->external_ids, "iface-types"); + + if (!chassis_datapath_type) { + chassis_datapath_type = ""; + } + + if (!chassis_iface_types) { + chassis_iface_types = ""; + } + + if (!strcmp(bridge_mappings, chassis_bridge_mappings)) { + bridge_mappings = NULL; + } + if (!strcmp(datapath_type, chassis_datapath_type)) { + datapath_type = NULL; + } + + if (!strcmp(iface_types_str, chassis_iface_types)) { + iface_types_str = NULL; + } + + if (bridge_mappings || datapath_type || iface_types_str) { struct smap new_ids; smap_clone(&new_ids, &chassis_rec->external_ids); - smap_replace(&new_ids, "ovn-bridge-mappings", bridge_mappings); + if (bridge_mappings) { + smap_replace(&new_ids, "ovn-bridge-mappings", bridge_mappings); + } + + if (datapath_type) { + smap_replace(&new_ids, "datapath-type", datapath_type); + } + + if (iface_types_str) { + smap_replace(&new_ids, "iface-types", iface_types_str); + } + sbrec_chassis_verify_external_ids(chassis_rec); sbrec_chassis_set_external_ids(chassis_rec, &new_ids); smap_destroy(&new_ids); @@ -169,14 +218,18 @@ chassis_run(struct controller_ctx *ctx, const char *chassis_id) chassis_id); if (!chassis_rec) { - struct smap ext_ids = SMAP_CONST1(&ext_ids, "ovn-bridge-mappings", - bridge_mappings); + struct smap ext_ids = SMAP_INITIALIZER(&ext_ids); + smap_add(&ext_ids, "ovn-bridge-mappings", bridge_mappings); + smap_add(&ext_ids, "datapath-type", datapath_type); + smap_add(&ext_ids, "iface-types", iface_types_str); chassis_rec = sbrec_chassis_insert(ctx->ovnsb_idl_txn); sbrec_chassis_set_name(chassis_rec, chassis_id); sbrec_chassis_set_hostname(chassis_rec, hostname); sbrec_chassis_set_external_ids(chassis_rec, &ext_ids); + smap_destroy(&ext_ids); } + ds_destroy(&iface_types); int n_encaps = count_1bits(req_tunnels); struct sbrec_encap **encaps = xmalloc(n_encaps * sizeof *encaps); for (int i = 0; i < n_encaps; i++) { diff --git a/ovn/controller/chassis.h b/ovn/controller/chassis.h index a14da1c..016d71c 100644 --- a/ovn/controller/chassis.h +++ b/ovn/controller/chassis.h @@ -24,7 +24,8 @@ struct ovsrec_bridge; void chassis_register_ovs_idl(struct ovsdb_idl *); const struct sbrec_chassis *chassis_run(struct controller_ctx *, - const char *chassis_id); + const char *chassis_id, + const struct ovsrec_bridge *br_int); bool chassis_cleanup(struct controller_ctx *, const char *chassis_id); #endif /* ovn/chassis.h */ diff --git a/ovn/controller/ovn-controller.8.xml b/ovn/controller/ovn-controller.8.xml index 3fda8e7..75151af 100644 --- a/ovn/controller/ovn-controller.8.xml +++ b/ovn/controller/ovn-controller.8.xml @@ -156,6 +156,30 @@ +

+ ovn-controller reads the following values from the + Open_vSwitch database of the local OVS instance: +

+ +
+
datapath-type from table
+
+ This value is read from local OVS integration bridge row of + table and populated in + of the + table in the OVN_Southbound database. +
+ +
iface-types from table
+
+ This value is populated in of the + table in the OVN_Southbound + database. +
+
+

Open vSwitch Database Usage

diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c index 2ca0295..09a11ab 100644 --- a/ovn/controller/ovn-controller.c +++ b/ovn/controller/ovn-controller.c @@ -435,7 +435,7 @@ main(int argc, char *argv[]) const struct sbrec_chassis *chassis = NULL; if (chassis_id) { - chassis = chassis_run(&ctx, chassis_id); + chassis = chassis_run(&ctx, chassis_id, br_int); encaps_run(&ctx, br_int, chassis_id); binding_run(&ctx, br_int, chassis_id, &local_datapaths, &all_lports); diff --git a/ovn/ovn-sb.xml b/ovn/ovn-sb.xml index c5f236e..96897f7 100644 --- a/ovn/ovn-sb.xml +++ b/ovn/ovn-sb.xml @@ -213,6 +213,22 @@ information. + + ovn-controller populates this key with the datapath type + configured in the of the + Open_vSwitch database's table. + Other applications should treat this key as read-only. See + ovn-controller(8) for more information. + + + + ovn-controller populates this key with the iface-types + configured in the of the + Open_vSwitch database's table. + Other applications should treat this key as read-only. See + ovn-controller(8) for more information. + + The overall purpose of these columns is described under Common Columns at the beginning of this document. diff --git a/tests/ovn-controller.at b/tests/ovn-controller.at index a2349a4..91fb2af 100644 --- a/tests/ovn-controller.at +++ b/tests/ovn-controller.at @@ -151,3 +151,63 @@ OVS_APP_EXIT_AND_WAIT_BY_TARGET([$ovs_base/ovn-sb/ovsdb-server-2.ctl], [$ovs_bas OVS_APP_EXIT_AND_WAIT([ovsdb-server]) AT_CLEANUP + +AT_SETUP([ovn-controller - chassis:external_ids - datapath-type and iface-types]) +AT_KEYWORDS([ovn]) +ovn_init_db ovn-sb + +net_add n1 +sim_add hv +as hv +ovs-vsctl \ + -- add-br br-phys \ + -- add-br br-eth0 \ + -- add-br br-eth1 \ + -- add-br br-eth2 +ovn_attach n1 br-phys 192.168.0.1 + +# Make sure that the datapath_type set in the bridge table +# is mirrored into the Chassis record in the OVN_Southbound db. +check_datapath_type () { + datapath_type=$1 + sysid=$(ovs-vsctl get Open_vSwitch . external_ids:system-id) + chassis_datapath_type=$(ovn-sbctl get Chassis ${sysid} external_ids:datapath-type | sed -e 's/\"//g') + AT_CHECK([test "${datapath_type}" = "${chassis_datapath_type}"]) +} + +check_datapath_type "" + +ovs-vsctl set Bridge br-int datapath-type=foo +check_datapath_type foo + +# Change "ovn-bridge-mappings" value. It should not change the "datapath-type". +ovs-vsctl set Open_vSwitch . external_ids:ovn-bridge-mappings=foo-mapping +check_datapath_type foo + +ovs-vsctl set Bridge br-int datapath-type=bar +check_datapath_type bar + +ovs-vsctl set Bridge br-int datapath-type=\"\" +check_datapath_type "" + +expected_iface_types="dummy,dummy-pmd,geneve,gre,internal,ipsec_gre,lisp,patch,stt,system,tap,vxlan" +sysid=$(ovs-vsctl get Open_vSwitch . external_ids:system-id) +chassis_iface_types=$(ovn-sbctl get Chassis ${sysid} external_ids:iface-types | sed -e 's/\"//g') +echo "chassis_iface_types = ${chassis_iface_types}" +AT_CHECK([test "${expected_iface_types}" = "${chassis_iface_types}"]) + +# Change the value of external_ids:iface-types using ovn-sbctl. +# ovn-controller should again set it back to proper one. +ovn-sbctl set Chassis ${sysid} external_ids:iface-types="foo" +sleep 1 +chassis_iface_types=$(ovn-sbctl get Chassis ${sysid} external_ids:iface-types | sed -e 's/\"//g') +echo "chassis_iface_types = ${chassis_iface_types}" +AT_CHECK([test "${expected_iface_types}" = "${chassis_iface_types}"]) + +# Gracefully terminate daemons +OVN_CLEANUP_SBOX([hv]) +OVN_CLEANUP_VSWITCH([main]) +as ovn-sb +OVS_APP_EXIT_AND_WAIT([ovsdb-server]) + +AT_CLEANUP