From patchwork Thu Sep 3 16:45:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell Bryant X-Patchwork-Id: 514208 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (unknown [IPv6:2600:3c00::f03c:91ff:fe6e:bdf7]) by ozlabs.org (Postfix) with ESMTP id 9F2C11402A9 for ; Fri, 4 Sep 2015 02:45:16 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 8114810B62; Thu, 3 Sep 2015 09:45:09 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e4.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id CB95310B59 for ; Thu, 3 Sep 2015 09:45:08 -0700 (PDT) Received: from bar5.cudamail.com (unknown [192.168.21.12]) by mx1e4.cudamail.com (Postfix) with ESMTPS id 4711D1E0455 for ; Thu, 3 Sep 2015 10:45:08 -0600 (MDT) X-ASG-Debug-ID: 1441298707-09eadd603072730001-byXFYA Received: from mx1-pf2.cudamail.com ([192.168.24.2]) by bar5.cudamail.com with ESMTP id J7IJOH7sWPj0CHhA (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 03 Sep 2015 10:45:07 -0600 (MDT) X-Barracuda-Envelope-From: rbryant@redhat.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.2 Received: from unknown (HELO mx1.redhat.com) (209.132.183.28) by mx1-pf2.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 3 Sep 2015 16:45:07 -0000 Received-SPF: error (mx1-pf2.cudamail.com: error in processing during lookup of redhat.com: DNS problem) 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]) by mx1.redhat.com (Postfix) with ESMTPS id 1803E8CF55 for ; Thu, 3 Sep 2015 16:45:06 +0000 (UTC) Received: from x1c.redhat.com (ovpn-112-103.phx2.redhat.com [10.3.112.103]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t83Gj3aA011620; Thu, 3 Sep 2015 12:45:05 -0400 X-CudaMail-Envelope-Sender: rbryant@redhat.com From: Russell Bryant To: dev@openvswitch.org X-CudaMail-MID: CM-E2-902045470 X-CudaMail-DTE: 090315 X-CudaMail-Originating-IP: 209.132.183.28 Date: Thu, 3 Sep 2015 12:45:00 -0400 X-ASG-Orig-Subj: [##CM-E2-902045470##][PATCH v8 1/2] ovn: Automatically create br-int in ovn-controller. Message-Id: <1441298701-32163-2-git-send-email-rbryant@redhat.com> In-Reply-To: <1441298701-32163-1-git-send-email-rbryant@redhat.com> References: <1440601674-27185-1-git-send-email-rbryant@redhat.com> <1441298701-32163-1-git-send-email-rbryant@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-GBUdb-Analysis: 0, 209.132.183.28, Ugly c=0.237282 p=-0.2 Source Normal X-MessageSniffer-Rules: 0-0-0-15929-c X-Barracuda-Connect: UNKNOWN[192.168.24.2] X-Barracuda-Start-Time: 1441298707 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.60 X-Barracuda-Spam-Status: No, SCORE=0.60 using per-user scores of TAG_LEVEL=3.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=3.0 tests=BSF_SC5_MJ1963, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.22193 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS 0.50 BSF_SC5_MJ1963 Custom Rule MJ1963 Subject: [ovs-dev] [PATCH v8 1/2] ovn: Automatically create br-int in ovn-controller. 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: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" 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 --- ovn/controller/ovn-controller.8.xml | 5 ++- ovn/controller/ovn-controller.c | 67 +++++++++++++++++++++++++++++++------ ovn/ovn-architecture.7.xml | 8 +++-- tutorial/ovs-sandbox | 2 -- 4 files changed, 66 insertions(+), 16 deletions(-) diff --git a/ovn/controller/ovn-controller.8.xml b/ovn/controller/ovn-controller.8.xml index c5d9dce..92cd669 100644 --- a/ovn/controller/ovn-controller.8.xml +++ b/ovn/controller/ovn-controller.8.xml @@ -84,7 +84,10 @@

external_ids:ovn-bridge specifies the integration bridge to which logical ports are attached. - The default is br-int. + The default is br-int. If this bridge does + not exist when ovn-controller starts, it will be created + automatically with the default configuration suggested in + ovn-architecture(7).

  • diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c index 1608cc4..d705a16 100644 --- a/ovn/controller/ovn-controller.c +++ b/ovn/controller/ovn-controller.c @@ -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. diff --git a/ovn/ovn-architecture.7.xml b/ovn/ovn-architecture.7.xml index 85a74a9..31488bd 100644 --- a/ovn/ovn-architecture.7.xml +++ b/ovn/ovn-architecture.7.xml @@ -205,8 +205,10 @@

    Each chassis in an OVN deployment must be configured with an Open vSwitch bridge dedicated for OVN's use, called the integration bridge. - System startup scripts create this bridge prior to starting - ovn-controller. The ports on the integration bridge include: + System startup scripts may create this bridge prior to starting + ovn-controller 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:

      @@ -248,6 +250,8 @@ ovs-vswitchd.conf.db(5):

      +
      fail-mode=secure
      diff --git a/tutorial/ovs-sandbox b/tutorial/ovs-sandbox index c8fc32f..b9997e5 100755 --- a/tutorial/ovs-sandbox +++ b/tutorial/ovs-sandbox @@ -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