From patchwork Mon Mar 11 18:35:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Michelson X-Patchwork-Id: 1054669 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; dmarc=fail (p=none dis=none) header.from=redhat.com 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 44J6Hh74Bbz9s55 for ; Tue, 12 Mar 2019 05:35:59 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 50966E32; Mon, 11 Mar 2019 18:35:55 +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 B7CEBE27 for ; Mon, 11 Mar 2019 18:35:54 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 1BDAC827 for ; Mon, 11 Mar 2019 18:35:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9CD0130832EB for ; Mon, 11 Mar 2019 18:35:53 +0000 (UTC) Received: from monae.redhat.com (ovpn-122-84.rdu2.redhat.com [10.10.122.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4ECC60C55 for ; Mon, 11 Mar 2019 18:35:52 +0000 (UTC) From: Mark Michelson To: dev@openvswitch.org Date: Mon, 11 Mar 2019 14:35:51 -0400 Message-Id: <20190311183551.17938-1-mmichels@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Mon, 11 Mar 2019 18:35:53 +0000 (UTC) X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH] Add unixctl option for ovn-northd 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 From: Venkata Anil This is a backport to the 2.9 branch of the feature. Openstack is requesting this backport in order to have their functional suite for OSP13 work properly with OVS 2.9. Signed-off-by: Venkata Anil Signed-off-by: Ben Pfaff --- lib/automake.mk | 3 ++- lib/unixctl.xml | 26 ++++++++++++++++++++++++++ ovn/northd/ovn-northd.8.xml | 7 +++++-- ovn/northd/ovn-northd.c | 9 ++++++++- tests/ovn-northd.at | 39 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 lib/unixctl.xml diff --git a/lib/automake.mk b/lib/automake.mk index 70461ec8c..73bc4b219 100644 --- a/lib/automake.mk +++ b/lib/automake.mk @@ -459,7 +459,8 @@ EXTRA_DIST += \ lib/ssl.xml \ lib/ssl-bootstrap.xml \ lib/table.xml \ - lib/vlog.xml + lib/vlog.xml \ + lib/unixctl.xml MAN_FRAGMENTS += \ lib/colors.man \ diff --git a/lib/unixctl.xml b/lib/unixctl.xml new file mode 100644 index 000000000..51bfc5faa --- /dev/null +++ b/lib/unixctl.xml @@ -0,0 +1,26 @@ + +
+
--unixctl=socket
+
+ Sets the name of the control socket on which + program listens for runtime management commands + (see RUNTIME MANAGEMENT COMMANDS, below). If socket + does not begin with /, it is interpreted as relative to + @RUNDIR@. If --unixctl is not used at all, + the default socket is + @RUNDIR@/program.pid.ctl, + where pid is program's process ID. +

+ On Windows a local named pipe is used to listen for runtime management + commands. A file is created in the absolute path as pointed by + socket or if --unixctl is not used at all, + a file is created as program in the configured + OVS_RUNDIR directory. The file exists just to mimic the + behavior of a Unix domain socket. +

+

+ Specifying none for socket disables the control + socket feature. +

+
+
diff --git a/ovn/northd/ovn-northd.8.xml b/ovn/northd/ovn-northd.8.xml index 78df522c9..10ae42cfa 100644 --- a/ovn/northd/ovn-northd.8.xml +++ b/ovn/northd/ovn-northd.8.xml @@ -54,8 +54,11 @@

Other Options

- - + +

+

Runtime Management Commands

diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c index 82a962b5f..0059cef5d 100644 --- a/ovn/northd/ovn-northd.c +++ b/ovn/northd/ovn-northd.c @@ -59,6 +59,7 @@ struct northd_context { static const char *ovnnb_db; static const char *ovnsb_db; +static const char *unixctl_path; #define MAC_ADDR_PREFIX 0x0A0000000000ULL #define MAC_ADDR_SPACE 0xffffff @@ -239,6 +240,7 @@ Options:\n\ (default: %s)\n\ --ovnsb-db=DATABASE connect to ovn-sb database at DATABASE\n\ (default: %s)\n\ + --unixctl=SOCKET override default control socket name\n\ -h, --help display this help message\n\ -o, --options list available options\n\ -V, --version display version information\n\ @@ -6701,6 +6703,7 @@ parse_options(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) static const struct option long_options[] = { {"ovnsb-db", required_argument, NULL, 'd'}, {"ovnnb-db", required_argument, NULL, 'D'}, + {"unixctl", required_argument, NULL, 'u'}, {"help", no_argument, NULL, 'h'}, {"options", no_argument, NULL, 'o'}, {"version", no_argument, NULL, 'V'}, @@ -6732,6 +6735,10 @@ parse_options(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) ovnnb_db = optarg; break; + case 'u': + unixctl_path = optarg; + break; + case 'h': usage(); exit(EXIT_SUCCESS); @@ -6784,7 +6791,7 @@ main(int argc, char *argv[]) daemonize_start(false); - retval = unixctl_server_create(NULL, &unixctl); + retval = unixctl_server_create(unixctl_path, &unixctl); if (retval) { exit(EXIT_FAILURE); } diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at index baa2add41..1878eb2df 100644 --- a/tests/ovn-northd.at +++ b/tests/ovn-northd.at @@ -262,3 +262,42 @@ AT_CHECK_UNQUOTED([ovn-sbctl get Port_Binding ${uuid} options:ipv6_ra_prefixes], ]) AT_CLEANUP + +AT_SETUP([ovn -- test unixctl]) +ovn_init_db ovn-sb; ovn-sbctl init +ovn_init_db ovn-nb; ovn-nbctl init + +# test unixctl option +mkdir "$ovs_base"/northd +as northd start_daemon ovn-northd --unixctl="$ovs_base"/northd/ovn-northd.ctl --ovnnb-db=unix:"$ovs_base"/ovn-nb/ovn-nb.sock --ovnsb-db=unix:"$ovs_base"/ovn-sb/ovn-sb.sock +ovn-nbctl ls-add sw +ovn-nbctl --wait=sb lsp-add sw p1 +# northd created with unixctl option successfully created port_binding entry +AT_CHECK([ovn-sbctl --bare --columns datapath find port_binding logical_port="p1" | wc -l], [0], [1 +]) +AT_CHECK([ovn-nbctl --wait=sb lsp-del p1]) + +# ovs-appctl exit with unixctl option +OVS_APP_EXIT_AND_WAIT_BY_TARGET(["$ovs_base"/northd/ovn-northd.ctl], ["$ovs_base"/northd/ovn-northd.pid]) + +# Check no port_binding entry for new port as ovn-northd is not running +ovn-nbctl lsp-add sw p2 +ovn-nbctl --timeout=10 --wait=sb sync +AT_CHECK([ovn-sbctl --bare --columns datapath find port_binding logical_port="p2" | wc -l], [0], [0 +]) + +# test default unixctl path +as northd start_daemon ovn-northd --ovnnb-db=unix:"$ovs_base"/ovn-nb/ovn-nb.sock --ovnsb-db=unix:"$ovs_base"/ovn-sb/ovn-sb.sock +ovn-nbctl --wait=sb lsp-add sw p3 +# northd created with default unixctl path successfully created port_binding entry +AT_CHECK([ovn-sbctl --bare --columns datapath find port_binding logical_port="p3" | wc -l], [0], [1 +]) + +as ovn-sb +OVS_APP_EXIT_AND_WAIT([ovsdb-server]) +as ovn-nb +OVS_APP_EXIT_AND_WAIT([ovsdb-server]) +as northd +OVS_APP_EXIT_AND_WAIT([ovn-northd]) + +AT_CLEANUP