From patchwork Mon Aug 7 15:18:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Singh Rana X-Patchwork-Id: 798718 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="cNQlWjeK"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xR1QV71nQz9s1h for ; Tue, 8 Aug 2017 01:18:58 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id DE39F98A; Mon, 7 Aug 2017 15:18:54 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 3E969900 for ; Mon, 7 Aug 2017 15:18:53 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id D9A1B133 for ; Mon, 7 Aug 2017 15:18:31 +0000 (UTC) Received: by mail-pf0-f193.google.com with SMTP id t83so674673pfj.3 for ; Mon, 07 Aug 2017 08:18:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jGgXQIH76oP4GaddElKnEnzA0Fs5XhtbWgBmtUW2ReI=; b=cNQlWjeKxKrSTvO29yLiHFkwbVzdjnmN9nX3x8MA16kQ6K3kPKW7Vh2vclyLsQx/gw yb4k7OwxvZ2qwn44GBM5VUD+tbVywGcE3r0HPID2G3nORmOSe0J8oi5lE4fn/v+nNcuH tVNenC/wByMElf3FEaoKjevODHiaC0KUPC1gHcZADgbFON0xXMxZHAWMK6W35Mq71URX Rhv9G62HYvT19J4jqNnt7RmJ9rWZZyY6YdZ1PGCYd8qm09ZaMtINnj7ezkrmjVrWA1na Ck2jd3ZdihHDCRZv+S13n4m1uxT7J3unRWTq43o8dDHlnoY3LzafwMGkh/mgXI83aI6f l4Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jGgXQIH76oP4GaddElKnEnzA0Fs5XhtbWgBmtUW2ReI=; b=f8Iu1W5cf25SCw98GnykJpZt2acQwgmlBz0Ak2TU3sZoRhQtP7dax+uxoRkYzT9Lpa to3GjjjE6LD9cVhYjUXCBoynHRwwLQbXgBZhObzSjUzrqwL3DZJLvBh/vx4QExBWS7FZ gnFYmUdf/g+/gUjarWl3PRLZVQ5OfwxS7C3mYdfzubn/Ka1MHMWiCCNPPWaGSK8nSAp5 4KcNexE4vKsLkxkWD0RJX4v0DbdKVTOXuZ0K3VrqcvTnCCy328DDCnUPFV73QIrhCUsh FPS5ojjEaErzhMoW/dlPUNndJt452Qcv5idYu0fBb3MO6yYXT6T0BSRImvcqc44PGgK1 cWtQ== X-Gm-Message-State: AHYfb5gmbUrZFVCt+eR0qGvM3G4HB4byRUk6lttFr2Zu0idYQOk/TKqx /Dj+NJWkNLw1xBxPlWM= X-Received: by 10.101.88.67 with SMTP id s3mr876930pgr.224.1502119111199; Mon, 07 Aug 2017 08:18:31 -0700 (PDT) Received: from localhost.localdomain.in.caveonetworks.com ([14.140.2.178]) by smtp.googlemail.com with ESMTPSA id p5sm13778533pgf.50.2017.08.07.08.18.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Aug 2017 08:18:30 -0700 (PDT) From: Jai Singh Rana X-Google-Original-From: Jai Singh Rana To: dev@openvswitch.org Date: Mon, 7 Aug 2017 20:48:07 +0530 Message-Id: <1502119087-8419-1-git-send-email-JaiSingh.Rana@caviumnetworks.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1501498883-5180-1-git-send-email-JaiSingh.Rana@caviumnetworks.com> References: <1501498883-5180-1-git-send-email-JaiSingh.Rana@caviumnetworks.com> X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: jai.rana@gmail.com, Jai Singh Rana Subject: [ovs-dev] [PATCH] controller: Remote connection option to OpenFlow switch. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Currently ovn-controller uses default unix domain socket in Open vSwitch's "run" directory to connect to OpenFlow switch. If ovn-controller/ovsdb-server and vswitchd are running on different systems, remote connection method needs to be provided. Added configuration option to override default connection by using OVSDB external-ids "ovn-ofswitch-remote". Using this external-id, desired tcp or unix connection to OpenFlow switch can be specified. Tested this by using tcp/unix method configured through external-id "ovn-ofswitch-remote" and confirmed connection as flows getting updated in Open vSwitch. Signed-off-by: Jai Singh Rana --- ovn/controller/ofctrl.c | 13 +++++++------ ovn/controller/ofctrl.h | 4 ++-- ovn/controller/ovn-controller.8.xml | 9 +++++++++ ovn/controller/ovn-controller.c | 37 ++++++++++++++++++++++++++++++++++--- ovn/controller/pinctrl.c | 5 +++-- ovn/controller/pinctrl.h | 3 ++- 6 files changed, 57 insertions(+), 14 deletions(-) diff --git a/ovn/controller/ofctrl.c b/ovn/controller/ofctrl.c index fc88a41..c2ea1a5 100644 --- a/ovn/controller/ofctrl.c +++ b/ovn/controller/ofctrl.c @@ -451,14 +451,15 @@ recv_S_UPDATE_FLOWS(const struct ofp_header *oh, enum ofptype type, } } -/* Runs the OpenFlow state machine against 'br_int', which is local to the - * hypervisor on which we are running. Attempts to negotiate a Geneve option - * field for class OVN_GENEVE_CLASS, type OVN_GENEVE_TYPE. If successful, - * returns the MFF_* field ID for the option, otherwise returns 0. */ +/* Runs the OpenFlow state machine against 'ovn_ofswitch_remote', which can + * be local or remote to hypervisor on which we are running. Attempts to + * negotiate a Geneve option field for class OVN_GENEVE_CLASS, + * type OVN_GENEVE_TYPE. If successful, returns the MFF_* field ID for the + * option, otherwise returns 0. */ enum mf_field_id -ofctrl_run(const struct ovsrec_bridge *br_int, struct shash *pending_ct_zones) +ofctrl_run(struct shash *pending_ct_zones, char *ovn_ofswitch_remote) { - char *target = xasprintf("unix:%s/%s.mgmt", ovs_rundir(), br_int->name); + char *target = xstrdup(ovn_ofswitch_remote); if (strcmp(target, rconn_get_target(swconn))) { VLOG_INFO("%s: connecting to switch", target); rconn_connect(swconn, target, target); diff --git a/ovn/controller/ofctrl.h b/ovn/controller/ofctrl.h index d83f6ae..a23ed4c 100644 --- a/ovn/controller/ofctrl.h +++ b/ovn/controller/ofctrl.h @@ -32,8 +32,8 @@ struct shash; /* Interface for OVN main loop. */ void ofctrl_init(struct group_table *group_table); -enum mf_field_id ofctrl_run(const struct ovsrec_bridge *br_int, - struct shash *pending_ct_zones); +enum mf_field_id ofctrl_run(struct shash *pending_ct_zones, + char *ovn_ofswitch_remote); bool ofctrl_can_put(void); void ofctrl_put(struct hmap *flow_table, struct shash *pending_ct_zones, int64_t nb_cfg); diff --git a/ovn/controller/ovn-controller.8.xml b/ovn/controller/ovn-controller.8.xml index 5641abc..4cd68c4 100644 --- a/ovn/controller/ovn-controller.8.xml +++ b/ovn/controller/ovn-controller.8.xml @@ -151,6 +151,15 @@ network interface card, enabling encapsulation checksum may incur performance loss. In such cases, encapsulation checksums can be disabled. + +
external_ids:ovn-ofswitch-remote
+
+ The OpenFlow connection method that this system can connect to reach + Open vSwitch using the unix or tcp forms + documented above for the ovs-database. If not configured, + default local unix domain socket file in the local Open vSwitch's + "run" directory is used. +

diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c index e2c9652..358b98b 100644 --- a/ovn/controller/ovn-controller.c +++ b/ovn/controller/ovn-controller.c @@ -328,6 +328,30 @@ get_ovnsb_remote(struct ovsdb_idl *ovs_idl) } } +/* Retrieves the OVN OpenFlow switch remote location from the + * "external-ids:ovn-ofswitch-remote" key in 'ovs_idl' and returns + * a copy of it. + */ +static char * +get_ovn_ofswitch_remote(struct ovsdb_idl *ovs_idl, + const struct ovsrec_bridge *br_int) +{ + const struct ovsrec_open_vswitch *cfg + = ovsrec_open_vswitch_first(ovs_idl); + if (cfg) { + const char *remote = + smap_get(&cfg->external_ids, "ovn-ofswitch-remote"); + if (remote) { + return xstrdup(remote); + } + } + + char *target = xasprintf("unix:%s/%s.mgmt", ovs_rundir(), br_int->name); + VLOG_INFO("OVN OVSDB OpenFlow switch remote not specified." + "Using default %s", target); + return target; +} + static void update_ct_zones(struct sset *lports, const struct hmap *local_datapaths, struct simap *ct_zones, unsigned long *ct_zone_bitmap, @@ -690,15 +714,21 @@ main(int argc, char *argv[]) } if (br_int && chassis) { struct shash addr_sets = SHASH_INITIALIZER(&addr_sets); + + /* Get ovn connection method to OpenFlow switch. */ + char *ovn_ofswitch_remote = get_ovn_ofswitch_remote(ctx.ovs_idl, + br_int); + addr_sets_init(&ctx, &addr_sets); patch_run(&ctx, br_int, chassis); - enum mf_field_id mff_ovn_geneve = ofctrl_run(br_int, - &pending_ct_zones); + enum mf_field_id mff_ovn_geneve = ofctrl_run(&pending_ct_zones, + ovn_ofswitch_remote); pinctrl_run(&ctx, br_int, chassis, &chassis_index, - &local_datapaths, &active_tunnels); + &local_datapaths, &active_tunnels, + ovn_ofswitch_remote); update_ct_zones(&local_lports, &local_datapaths, &ct_zones, ct_zone_bitmap, &pending_ct_zones); if (ctx.ovs_idl_txn) { @@ -750,6 +780,7 @@ main(int argc, char *argv[]) expr_addr_sets_destroy(&addr_sets); shash_destroy(&addr_sets); + free(ovn_ofswitch_remote); } /* If we haven't handled the pending packet insertion diff --git a/ovn/controller/pinctrl.c b/ovn/controller/pinctrl.c index 469a355..eda8d76 100644 --- a/ovn/controller/pinctrl.c +++ b/ovn/controller/pinctrl.c @@ -1025,9 +1025,10 @@ pinctrl_run(struct controller_ctx *ctx, const struct sbrec_chassis *chassis, const struct chassis_index *chassis_index, struct hmap *local_datapaths, - struct sset *active_tunnels) + struct sset *active_tunnels, + char *ovn_ofswitch_remote) { - char *target = xasprintf("unix:%s/%s.mgmt", ovs_rundir(), br_int->name); + char *target = xstrdup(ovn_ofswitch_remote); if (strcmp(target, rconn_get_target(swconn))) { VLOG_INFO("%s: connecting to switch", target); rconn_connect(swconn, target, target); diff --git a/ovn/controller/pinctrl.h b/ovn/controller/pinctrl.h index fc9cca8..6abf0f8 100644 --- a/ovn/controller/pinctrl.h +++ b/ovn/controller/pinctrl.h @@ -33,7 +33,8 @@ void pinctrl_init(void); void pinctrl_run(struct controller_ctx *, const struct ovsrec_bridge *, const struct sbrec_chassis *, const struct chassis_index *, struct hmap *local_datapaths, - struct sset *active_tunnels); + struct sset *active_tunnels, + char *ovn_ofswitch_remote); void pinctrl_wait(struct controller_ctx *); void pinctrl_destroy(void);