From patchwork Fri Jul 29 13:02:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 654108 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 3s186B4jkZz9t25 for ; Fri, 29 Jul 2016 23:02:58 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id B99DC114A8; Fri, 29 Jul 2016 06:02:55 -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 553101149B for ; Fri, 29 Jul 2016 06:02:54 -0700 (PDT) Received: from bar6.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id C819D1614BC for ; Fri, 29 Jul 2016 07:02:53 -0600 (MDT) X-ASG-Debug-ID: 1469797366-0b323747743d15c0001-byXFYA Received: from mx1-pf1.cudamail.com ([192.168.24.1]) by bar6.cudamail.com with ESMTP id MVZvVtyzEGNFc5ZO (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Fri, 29 Jul 2016 07:02:46 -0600 (MDT) X-Barracuda-Envelope-From: nusiddiq@redhat.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.1 Received: from unknown (HELO mx1.redhat.com) (209.132.183.28) by mx1-pf1.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 29 Jul 2016 13:02:46 -0000 Received-SPF: pass (mx1-pf1.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-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (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 EACA13F725 for ; Fri, 29 Jul 2016 13:02:44 +0000 (UTC) Received: from nusiddiq.blr.redhat.com (dhcp-0-114.blr.redhat.com [10.70.1.114]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6TD2hSw016152 for ; Fri, 29 Jul 2016 09:02:44 -0400 X-CudaMail-Envelope-Sender: nusiddiq@redhat.com From: Numan Siddique X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-E1-728012640 X-CudaMail-DTE: 072916 X-CudaMail-Originating-IP: 209.132.183.28 To: ovs dev X-ASG-Orig-Subj: [##CM-E1-728012640##][PATCH v2] ovn-controller: Add datapath-type in chassis:external_ids Organization: Red Hat Message-ID: <10abdd8c-9ca3-2608-1f90-91e9d7fb5048@redhat.com> Date: Fri, 29 Jul 2016 18:32:42 +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.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 29 Jul 2016 13:02:44 +0000 (UTC) X-Barracuda-Connect: UNKNOWN[192.168.24.1] X-Barracuda-Start-Time: 1469797366 X-Barracuda-Encrypted: ECDHE-RSA-AES256-GCM-SHA384 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 v2] ovn-controller: Add datapath-type 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 sets it in the external_ids:datapath-type 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 --- ovn/controller/chassis.c | 38 ++++++++++++++++++++++++++---- ovn/controller/chassis.h | 3 ++- ovn/controller/ovn-controller.8.xml | 17 +++++++++++++- ovn/controller/ovn-controller.c | 2 +- ovn/ovn-sb.xml | 8 +++++++ tests/ovn-controller.at | 46 +++++++++++++++++++++++++++++++++++++ 6 files changed, 106 insertions(+), 8 deletions(-) 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..86f3ef5 100644 --- a/ovn/controller/chassis.c +++ b/ovn/controller/chassis.c @@ -38,6 +38,8 @@ 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_table(ovs_idl, &ovsrec_table_bridge); + ovsdb_idl_add_column(ovs_idl, &ovsrec_bridge_col_datapath_type); } static const char * @@ -67,7 +69,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 +117,8 @@ 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 : ""; const struct sbrec_chassis *chassis_rec = get_chassis(ctx->ovnsb_idl, chassis_id); @@ -125,10 +130,30 @@ 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"); + if (!chassis_datapath_type) { + chassis_datapath_type = ""; + } + + if (!strcmp(bridge_mappings, chassis_bridge_mappings)) { + bridge_mappings = NULL; + } + if (!strcmp(datapath_type, chassis_datapath_type)) { + datapath_type = NULL; + } + + if (bridge_mappings || datapath_type) { 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); + } + sbrec_chassis_verify_external_ids(chassis_rec); sbrec_chassis_set_external_ids(chassis_rec, &new_ids); smap_destroy(&new_ids); @@ -169,12 +194,15 @@ 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); + 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); } int n_encaps = count_1bits(req_tunnels); 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..d2fd9b4 100644 --- a/ovn/controller/ovn-controller.8.xml +++ b/ovn/controller/ovn-controller.8.xml @@ -156,6 +156,21 @@ +

+ ovn-controller reads the following values from the + table of the local OVS integration + bridge. +

+ +
+
datapath-type
+
+ This value is populated in in the OVN_Southbound + database's table. +
+
+

Open vSwitch Database Usage

@@ -173,7 +188,7 @@ integration bridge as one created by ovn-controller to reach a remote chassis. Its value is the chassis ID of the remote chassis. - + /dd>

external-ids:ovn-localnet-port in the Port diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c index 5c74186..971735a 100644 --- a/ovn/controller/ovn-controller.c +++ b/ovn/controller/ovn-controller.c @@ -432,7 +432,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); } diff --git a/ovn/ovn-sb.xml b/ovn/ovn-sb.xml index c5f236e..2512754 100644 --- a/ovn/ovn-sb.xml +++ b/ovn/ovn-sb.xml @@ -213,6 +213,14 @@ 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. + + 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..e1e47a6 100644 --- a/tests/ovn-controller.at +++ b/tests/ovn-controller.at @@ -151,3 +151,49 @@ 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 - datapath-type]) +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 "" + +# Gracefully terminate daemons +OVN_CLEANUP_SBOX([hv]) +OVN_CLEANUP_VSWITCH([main]) +as ovn-sb +OVS_APP_EXIT_AND_WAIT([ovsdb-server]) + +AT_CLEANUP