From patchwork Tue Aug 13 16:27:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1146490 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 467J6H3qbfz9sDQ for ; Wed, 14 Aug 2019 02:27:51 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id D4699C2C; Tue, 13 Aug 2019 16:27:47 +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 F12BEAF7 for ; Tue, 13 Aug 2019 16:27:46 +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 B7DDF8A7 for ; Tue, 13 Aug 2019 16:27:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5A3A230D00A7 for ; Tue, 13 Aug 2019 16:27:44 +0000 (UTC) Received: from nusiddiq.redhat (ovpn-116-27.sin2.redhat.com [10.67.116.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id B7BB28BE4D; Tue, 13 Aug 2019 16:27:40 +0000 (UTC) From: nusiddiq@redhat.com To: dev@openvswitch.org Date: Tue, 13 Aug 2019 21:57:26 +0530 Message-Id: <20190813162726.16262-1-nusiddiq@redhat.com> In-Reply-To: <20190813162629.15983-1-nusiddiq@redhat.com> References: <20190813162629.15983-1-nusiddiq@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Tue, 13 Aug 2019 16:27:44 +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 ovn 1/4] Add support for using OVN specific rundirs 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: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: Numan Siddique Until now, OVN uses the openvswitch rundirs (rundir, logdir, etcdir). The commit [1] changed the package name from openvswitch to ovn, but it didn't take into the account the effects of it. When "make install" is run ovn-ctl utility is copied to /usr/local/share/ovn/scripts folder. ovn-ctl depends on 'ovs-lib' and it is not present in this scripts foler. Because of which we cannot start OVN services using ovn-ctl. This patch addresses all these issues. It changes the rundir to ovn specific ones. (i.e /usr/local/var/run/ovn, /usr/local/var/log/ovn, /usr/local/etc/ovn with default configuration). [1] - 7795e0e28dce("Change the package name from openvswitch to ovn in AC_INIT()") Tested:by: Dumitru Ceara Signed-off-by: Numan Siddique --- Documentation/intro/install/general.rst | 30 ++-- Makefile.am | 5 + configure.ac | 1 + controller/ovn-controller.c | 4 +- lib/.gitignore | 1 + lib/automake.mk | 22 ++- lib/ovn-dirs.c.in | 112 +++++++++++++ lib/ovn-dirs.h | 35 ++++ lib/ovn-util.c | 24 ++- lib/ovn-util.h | 1 + m4/openvswitch.m4 | 11 ++ northd/ovn-northd.c | 9 +- tests/ovs-macros.at | 1 + tutorial/ovs-sandbox | 1 + utilities/automake.mk | 5 + utilities/ovn-ctl | 71 +++++---- utilities/ovn-ctl.8.xml | 12 +- utilities/ovn-lib.in | 204 ++++++++++++++++++++++++ 18 files changed, 494 insertions(+), 55 deletions(-) create mode 100644 lib/ovn-dirs.c.in create mode 100644 lib/ovn-dirs.h create mode 100644 utilities/ovn-lib.in diff --git a/Documentation/intro/install/general.rst b/Documentation/intro/install/general.rst index 99d8fec04..4cc9c4c3a 100644 --- a/Documentation/intro/install/general.rst +++ b/Documentation/intro/install/general.rst @@ -153,17 +153,17 @@ invoke configure without any arguments. For example:: $ ./configure -By default all files are installed under ``/usr/local``. OVN and Open vSwitch -also expects to find its database in ``/usr/local/etc/openvswitch`` by default. +By default all files are installed under ``/usr/local``. OVN expects to find +its database in ``/usr/local/etc/ovn`` by default. If you want to install all files into, e.g., ``/usr`` and ``/var`` instead of -``/usr/local`` and ``/usr/local/var`` and expect to use ``/etc/openvswitch`` as +``/usr/local`` and ``/usr/local/var`` and expect to use ``/etc/ovn`` as the default database directory, add options as shown here:: $ ./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc .. note:: - Open vSwitch and OVN installed with packages like .rpm (e.g. via + OVN installed with packages like .rpm (e.g. via ``yum install`` or ``rpm -ivh``) and .deb (e.g. via ``apt-get install`` or ``dpkg -i``) use the above configure options. @@ -319,9 +319,13 @@ and stopping ovn-northd, ovn-controller and ovsdb-servers. After installation, the daemons can be started by using the ovn-ctl utility. This will take care to setup initial conditions, and start the daemons in the correct order. The ovn-ctl utility is located in '$(pkgdatadir)/scripts', and defaults to -'/usr/local/share/openvswitch/scripts'. An example after install might be:: +'/usr/local/share/ovn/scripts'. ovn-ctl utility requires the 'ovs-lib' +helper shell script which is present in '/usr/local/share/openvswitch/scripts'. +So invoking ovn-ctl as "./ovn-ctl" will fail. - $ export PATH=$PATH:/usr/local/share/openvswitch/scripts +An example after install might be:: + + $ export PATH=$PATH:/usr/local/share/ovn/scripts $ ovn-ctl start_northd $ ovn-ctl start_controller @@ -331,7 +335,7 @@ Starting OVN Central services OVN central services includes ovn-northd, Northbound and Southbound ovsdb-server. - $ export PATH=$PATH:/usr/local/share/openvswitch/scripts + $ export PATH=$PATH:/usr/local/share/ovn/scripts $ ovn-ctl start_northd Refer to ovn-ctl(8) for more information and the supported options. @@ -341,23 +345,23 @@ Before starting ovn-northd you need to start OVN Northbound and Southbound ovsdb-servers. Before ovsdb-servers can be started, configure the Northbound and Southbound databases:: - $ mkdir -p /usr/local/etc/openvswitch - $ ovsdb-tool create /usr/local/etc/openvswitch/ovnnb_db.db \ + $ mkdir -p /usr/local/etc/ovn + $ ovsdb-tool create /usr/local/etc/ovn/ovnnb_db.db \ ovn-nb.ovsschema - $ ovsdb-tool create /usr/local/etc/openvswitch/ovnsb_db.db \ + $ ovsdb-tool create /usr/local/etc/ovn/ovnsb_db.db \ ovn-sb.ovsschema Configure ovsdb-servers to use databases created above, to listen on a Unix domain socket and to use the SSL configuration in the database:: - $ mkdir -p /usr/local/var/run/openvswitch - $ ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/ovnnb_db.sock \ + $ mkdir -p /usr/local/var/run/ovn + $ ovsdb-server --remote=punix:/usr/local/var/run/ovn/ovnnb_db.sock \ --remote=db:OVN_Northbound,NB_Global,connections \ --private-key=db:OVN_Northbound,SSL,private_key \ --certificate=db:OVN_Northbound,SSL,certificate \ --bootstrap-ca-cert=db:OVN_Northbound,SSL,ca_cert \ --pidfile --detach --log-file - $ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/ovnsb_db.sock \ + $ovsdb-server --remote=punix:/usr/local/var/run/ovn/ovnsb_db.sock \ --remote=db:OVN_Southbound,SB_Global,connections \ --private-key=db:OVN_Southbound,SSL,private_key \ --certificate=db:OVN_Southbound,SSL,certificate \ diff --git a/Makefile.am b/Makefile.am index f886a8e63..6447e348b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -177,6 +177,7 @@ SUFFIXES += .in -e 's,[@]DBDIR[@],$(DBDIR),g' \ -e 's,[@]PYTHON[@],$(PYTHON),g' \ -e 's,[@]RUNDIR[@],$(RUNDIR),g' \ + -e 's,[@]OVN_RUNDIR[@],$(OVN_RUNDIR),g' \ -e 's,[@]VERSION[@],$(VERSION),g' \ -e 's,[@]localstatedir[@],$(localstatedir),g' \ -e 's,[@]pkgdatadir[@],$(pkgdatadir),g' \ @@ -202,6 +203,7 @@ SUFFIXES += .xml DBDIR='$(DBDIR)' \ PYTHON='$(PYTHON)' \ RUNDIR='$(RUNDIR)' \ + OVN_RUNDIR='$(OVN_RUNDIR)' \ VERSION='$(VERSION)' \ localstatedir='$(localstatedir)' \ pkgdatadir='$(pkgdatadir)' \ @@ -502,6 +504,9 @@ ALL_LOCAL += ovn-sb.ovsschema.stamp ovn-sb.ovsschema.stamp: ovn-sb.ovsschema $(srcdir)/build-aux/cksum-schema-check $? $@ +pkgdata_DATA += ovn-nb.ovsschema +pkgdata_DATA += ovn-sb.ovsschema + CLEANFILES += ovn-sb.ovsschema.stamp include Documentation/automake.mk diff --git a/configure.ac b/configure.ac index 8a32d3a18..c74b17a1d 100644 --- a/configure.ac +++ b/configure.ac @@ -123,6 +123,7 @@ AC_CHECK_HEADERS([net/if_mib.h], [], [], [[#include OVS_CHECK_PKIDIR OVS_CHECK_RUNDIR +OVN_CHECK_RUNDIR OVS_CHECK_DBDIR OVS_CHECK_BACKTRACE OVS_CHECK_PERF_EVENT diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 86f29accf..e27b56b2b 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -1715,7 +1715,9 @@ main(int argc, char *argv[]) daemonize_start(false); - retval = unixctl_server_create(NULL, &unixctl); + char *abs_unixctl_path = get_abs_unix_ctl_path(); + retval = unixctl_server_create(abs_unixctl_path, &unixctl); + free(abs_unixctl_path); if (retval) { exit(EXIT_FAILURE); } diff --git a/lib/.gitignore b/lib/.gitignore index a80a1bce1..3eed4588b 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -5,3 +5,4 @@ /ovn-sb-idl.c /ovn-sb-idl.h /ovn-sb-idl.ovsidl +/ovn-dirs.c diff --git a/lib/automake.mk b/lib/automake.mk index 8e7a1a937..2ee14a261 100644 --- a/lib/automake.mk +++ b/lib/automake.mk @@ -9,6 +9,7 @@ lib_libovn_la_SOURCES = \ lib/actions.c \ lib/chassis-index.c \ lib/chassis-index.h \ + lib/ovn-dirs.h \ lib/expr.c \ lib/extend-table.h \ lib/extend-table.c \ @@ -24,17 +25,36 @@ lib_libovn_la_SOURCES = \ lib/inc-proc-eng.c \ lib/inc-proc-eng.h nodist_lib_libovn_la_SOURCES = \ + lib/ovn-dirs.c \ lib/ovn-nb-idl.c \ lib/ovn-nb-idl.h \ lib/ovn-sb-idl.c \ lib/ovn-sb-idl.h +CLEANFILES += $(nodist_lib_libovn_la_SOURCES) + # ovn-sb IDL OVSIDL_BUILT += \ lib/ovn-sb-idl.c \ lib/ovn-sb-idl.h \ lib/ovn-sb-idl.ovsidl -EXTRA_DIST += lib/ovn-sb-idl.ann +EXTRA_DIST += \ + lib/ovn-sb-idl.ann \ + lib/ovn-dirs.c.in + +lib/ovn-dirs.c: lib/ovn-dirs.c.in Makefile + $(AM_V_GEN)($(ro_c) && sed < $(srcdir)/lib/ovn-dirs.c.in \ + -e 's,[@]srcdir[@],$(srcdir),g' \ + -e 's,[@]LOGDIR[@],"$(LOGDIR)",g' \ + -e 's,[@]RUNDIR[@],"$(RUNDIR)",g' \ + -e 's,[@]OVN_RUNDIR[@],"$(OVN_RUNDIR)",g' \ + -e 's,[@]DBDIR[@],"$(DBDIR)",g' \ + -e 's,[@]bindir[@],"$(bindir)",g' \ + -e 's,[@]sysconfdir[@],"$(sysconfdir)",g' \ + -e 's,[@]pkgdatadir[@],"$(pkgdatadir)",g') \ + > lib/ovn-dirs.c.tmp && \ + mv lib/ovn-dirs.c.tmp lib/ovn-dirs.c + OVN_SB_IDL_FILES = \ $(srcdir)/ovn-sb.ovsschema \ $(srcdir)/lib/ovn-sb-idl.ann diff --git a/lib/ovn-dirs.c.in b/lib/ovn-dirs.c.in new file mode 100644 index 000000000..7ed1e3018 --- /dev/null +++ b/lib/ovn-dirs.c.in @@ -0,0 +1,112 @@ +#line 2 "@srcdir@/lib/dirs.c.in" +/* + * Copyright (c) 2019 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "ovn-dirs.h" +#include +#include "lib/ovs-thread.h" +#include "lib/util.h" + +struct directory { + const char *value; /* Actual value; NULL if not yet determined. */ + const char *default_value; /* Default value. */ + const char *var_name; /* Environment variable to override default. */ + struct ovsthread_once once; /* Ensures 'value' gets initialized once. */ +}; + +static const char * +get_dir(struct directory *d) +{ + if (ovsthread_once_start(&d->once)) { + d->value = getenv(d->var_name); + if (!d->value || !d->value[0]) { + d->value = d->default_value; + } + ovsthread_once_done(&d->once); + } + return d->value; +} + +const char * +ovn_sysconfdir(void) +{ + static struct directory d = { + NULL, @sysconfdir@, "OVN_SYSCONFDIR", OVSTHREAD_ONCE_INITIALIZER + }; + + return get_dir(&d); +} + +const char * +ovn_pkgdatadir(void) +{ + static struct directory d = { + NULL, @pkgdatadir@, "OVN_PKGDATADIR", OVSTHREAD_ONCE_INITIALIZER + }; + + return get_dir(&d); +} + +const char * +ovn_rundir(void) +{ + static struct directory d = { + NULL, @OVN_RUNDIR@, "OVN_RUNDIR", OVSTHREAD_ONCE_INITIALIZER + }; + + return get_dir(&d); +} + +const char * +ovn_logdir(void) +{ + static struct directory d = { + NULL, @LOGDIR@, "OVN_LOGDIR", OVSTHREAD_ONCE_INITIALIZER + }; + + return get_dir(&d); +} + +const char * +ovn_dbdir(void) +{ + static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER; + static const char *dbdir; + + if (ovsthread_once_start(&once)) { + dbdir = getenv("OVN_DBDIR"); + if (!dbdir || !dbdir[0]) { + char *sysconfdir = getenv("OVN_SYSCONFDIR"); + + dbdir = (sysconfdir + ? xasprintf("%s/ovn", sysconfdir) + : @DBDIR@); + } + ovsthread_once_done(&once); + } + return dbdir; +} + +const char * +ovn_bindir(void) +{ + static struct directory d = { + NULL, @bindir@, "OVN_BINDIR", OVSTHREAD_ONCE_INITIALIZER + }; + + return get_dir(&d); +} diff --git a/lib/ovn-dirs.h b/lib/ovn-dirs.h new file mode 100644 index 000000000..22ff7a1ee --- /dev/null +++ b/lib/ovn-dirs.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2019. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OVN_DIRS_H +#define OVN_DIRS_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +const char *ovn_sysconfdir(void); /* /usr/local/etc */ +const char *ovn_pkgdatadir(void); /* /usr/local/share/ovn */ +const char *ovn_rundir(void); /* /usr/local/var/run/ovn */ +const char *ovn_logdir(void); /* /usr/local/var/log/ovn */ +const char *ovn_dbdir(void); /* /usr/local/etc/ovn */ +const char *ovn_bindir(void); /* /usr/local/bin */ + +#ifdef __cplusplus +} +#endif + +#endif /* OVN_DIRS_H */ diff --git a/lib/ovn-util.c b/lib/ovn-util.c index 085498fd1..b425f3f2d 100644 --- a/lib/ovn-util.c +++ b/lib/ovn-util.c @@ -13,8 +13,10 @@ */ #include +#include + #include "ovn-util.h" -#include "dirs.h" +#include "ovn-dirs.h" #include "openvswitch/vlog.h" #include "ovn-nb-idl.h" #include "ovn-sb-idl.h" @@ -296,7 +298,7 @@ default_nb_db(void) if (!def) { def = getenv("OVN_NB_DB"); if (!def) { - def = xasprintf("unix:%s/ovnnb_db.sock", ovs_rundir()); + def = xasprintf("unix:%s/ovnnb_db.sock", ovn_rundir()); } } return def; @@ -309,12 +311,28 @@ default_sb_db(void) if (!def) { def = getenv("OVN_SB_DB"); if (!def) { - def = xasprintf("unix:%s/ovnsb_db.sock", ovs_rundir()); + def = xasprintf("unix:%s/ovnsb_db.sock", ovn_rundir()); } } return def; } +char * +get_abs_unix_ctl_path(void) +{ +#ifdef _WIN32 + enum { WINDOWS = 1 }; +#else + enum { WINDOWS = 0 }; +#endif + + long int pid = getpid(); + char *abs_path = + WINDOWS ? xasprintf("%s/%s.ctl", ovn_rundir(), program_name) + : xasprintf("%s/%s.%ld.ctl", ovn_rundir(), program_name, pid); + return abs_path; +} + /* l3gateway, chassisredirect, and patch * are not in this list since they are * only set in the SB DB by northd diff --git a/lib/ovn-util.h b/lib/ovn-util.h index 6d5e1dfb5..fcd93cd82 100644 --- a/lib/ovn-util.h +++ b/lib/ovn-util.h @@ -67,6 +67,7 @@ char *alloc_nat_zone_key(const struct uuid *key, const char *type); const char *default_nb_db(void); const char *default_sb_db(void); +char *get_abs_unix_ctl_path(void); struct ovsdb_idl_table_class; const char *db_table_usage(struct ds *tables, diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4 index b599f17d7..964512795 100644 --- a/m4/openvswitch.m4 +++ b/m4/openvswitch.m4 @@ -330,6 +330,17 @@ AC_DEFUN([OVS_CHECK_RUNDIR], [RUNDIR='${localstatedir}/run/openvswitch']) AC_SUBST([RUNDIR])]) +dnl Checks for the directory in which to store pidfiles. +AC_DEFUN([OVN_CHECK_RUNDIR], + [AC_ARG_WITH( + [rundir], + AC_HELP_STRING([--with-ovn-rundir=DIR], + [directory used for pidfiles + [[LOCALSTATEDIR/run/ovn]]]), + [OVN_RUNDIR=$withval], + [OVN_RUNDIR='${localstatedir}/run/ovn']) + AC_SUBST([OVN_RUNDIR])]) + dnl Checks for the directory in which to store logs. AC_DEFUN([OVS_CHECK_LOGDIR], [AC_ARG_WITH( diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index e86134414..b527f2172 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -9351,7 +9351,14 @@ main(int argc, char *argv[]) daemonize_start(false); - retval = unixctl_server_create(unixctl_path, &unixctl); + if (!unixctl_path) { + char *abs_unixctl_path = get_abs_unix_ctl_path(); + retval = unixctl_server_create(abs_unixctl_path, &unixctl); + free(abs_unixctl_path); + } else { + retval = unixctl_server_create(unixctl_path, &unixctl); + } + if (retval) { exit(EXIT_FAILURE); } diff --git a/tests/ovs-macros.at b/tests/ovs-macros.at index 10593429d..b2e619f76 100644 --- a/tests/ovs-macros.at +++ b/tests/ovs-macros.at @@ -49,6 +49,7 @@ ovs_setenv() { sandbox=$1 ovs_dir=$ovs_base${1:+/$1} OVS_RUNDIR=$ovs_dir; export OVS_RUNDIR + OVN_RUNDIR=$ovs_dir; export OVN_RUNDIR OVS_LOGDIR=$ovs_dir; export OVS_LOGDIR OVS_DBDIR=$ovs_dir; export OVS_DBDIR OVS_SYSCONFDIR=$ovs_dir; export OVS_SYSCONFDIR diff --git a/tutorial/ovs-sandbox b/tutorial/ovs-sandbox index 47032b499..7546d27ca 100755 --- a/tutorial/ovs-sandbox +++ b/tutorial/ovs-sandbox @@ -360,6 +360,7 @@ sandbox=`cd sandbox && pwd` # Set up environment for OVS programs to sandbox themselves. OVS_RUNDIR=$sandbox; export OVS_RUNDIR +OVN_RUNDIR=$sandbox; export OVN_RUNDIR OVS_LOGDIR=$sandbox; export OVS_LOGDIR OVS_DBDIR=$sandbox; export OVS_DBDIR OVS_SYSCONFDIR=$sandbox; export OVS_SYSCONFDIR diff --git a/utilities/automake.mk b/utilities/automake.mk index d666b9661..db0b0e051 100644 --- a/utilities/automake.mk +++ b/utilities/automake.mk @@ -1,6 +1,7 @@ scripts_SCRIPTS += \ utilities/ovn-ctl \ utilities/ovndb-servers.ocf +scripts_DATA += utilities/ovn-lib man_MANS += \ utilities/ovn-ctl.8 \ @@ -21,6 +22,7 @@ bin_SCRIPTS += \ EXTRA_DIST += \ utilities/ovn-ctl \ + utilities/ovn-lib.in \ utilities/ovn-ctl.8.xml \ utilities/ovn-docker-overlay-driver.in \ utilities/ovn-docker-underlay-driver.in \ @@ -31,6 +33,7 @@ EXTRA_DIST += \ CLEANFILES += \ utilities/ovn-ctl.8 \ + utilities/ovn-lib \ utilities/ovn-docker-overlay-driver \ utilities/ovn-docker-underlay-driver \ utilities/ovn-nbctl.8 \ @@ -39,6 +42,8 @@ CLEANFILES += \ utilities/ovn-detrace.1 \ utilities/ovn-detrace +utilities/ovn-lib: $(top_builddir)/config.status + # ovn-nbctl bin_PROGRAMS += utilities/ovn-nbctl utilities_ovn_nbctl_SOURCES = utilities/ovn-nbctl.c diff --git a/utilities/ovn-ctl b/utilities/ovn-ctl index 7e5cd469c..a973b09a2 100755 --- a/utilities/ovn-ctl +++ b/utilities/ovn-ctl @@ -13,12 +13,16 @@ # limitations under the License. case $0 in - */*) dir0=`echo "$0" | sed 's,/[^/]*$,,'` ;; + */*) dir0=`echo "$0" | sed 's,/[^/]*$,,'` + ovsdir=`echo "$dir0" | sed 's,/ovn/scripts,,'` + ovsdir=$ovsdir/openvswitch/scripts + ;; *) dir0=./ ;; esac -. "$dir0/ovs-lib" || exit 1 +. "$dir0/ovn-lib" || exit 1 +. "$ovsdir/ovs-lib" || exit 1 -for dir in "$sbindir" "$bindir" /sbin /bin /usr/sbin /usr/bin; do +for dir in "$sbindir" "$ovn_bindir" "$bindir" /sbin /bin /usr/sbin /usr/bin; do case :$PATH: in *:$dir:*) ;; *) PATH=$PATH:$dir ;; @@ -26,9 +30,9 @@ for dir in "$sbindir" "$bindir" /sbin /bin /usr/sbin /usr/bin; do done -ovnnb_active_conf_file="$etcdir/ovnnb-active.conf" -ovnsb_active_conf_file="$etcdir/ovnsb-active.conf" -ovn_northd_db_conf_file="$etcdir/ovn-northd-db-params.conf" +ovnnb_active_conf_file="$ovn_etcdir/ovnnb-active.conf" +ovnsb_active_conf_file="$ovn_etcdir/ovnsb-active.conf" +ovn_northd_db_conf_file="$ovn_etcdir/ovn-northd-db-params.conf" ## ----- ## ## start ## ## ----- ## @@ -110,6 +114,7 @@ start_ovsdb__() { local logfile local log local sock + local ctrl_sock local detach local create_insecure_remote local port @@ -134,6 +139,7 @@ start_ovsdb__() { eval logfile=\$OVN_${DB}_LOGFILE eval log=\$OVN_${DB}_LOG eval sock=\$DB_${DB}_SOCK + eval ctrl_sock=\$DB_${DB}_CTRL_SOCK eval detach=\$DB_${DB}_DETACH eval create_insecure_remote=\$DB_${DB}_CREATE_INSECURE_REMOTE eval port=\$DB_${DB}_PORT @@ -144,7 +150,10 @@ start_ovsdb__() { eval ovn_db_ssl_cert=\$OVN_${DB}_DB_SSL_CERT eval ovn_db_ssl_cacert=\$OVN_${DB}_DB_SSL_CA_CERT - install_dir "$OVN_RUNDIR" + ovn_install_dir "$OVN_RUNDIR" + ovn_install_dir "$ovn_logdir" + ovn_install_dir "$ovn_dbdir" + # Check and eventually start ovsdb-server for DB if pidfile_is_running $db_pid_file; then return @@ -177,7 +186,7 @@ $cluster_remote_port set ovsdb-server set "$@" $log --log-file=$logfile set "$@" --remote=punix:$sock --pidfile=$db_pid_file - set "$@" --unixctl=ovn${db}_db.ctl + set "$@" --unixctl=$ctrl_sock [ "$OVS_USER" != "" ] && set "$@" --user "$OVS_USER" @@ -328,7 +337,7 @@ start_northd () { set "$@" $OVN_NORTHD_LOG $ovn_northd_params - OVS_RUNDIR=${OVN_RUNDIR} start_daemon "$OVN_NORTHD_PRIORITY" "$OVN_NORTHD_WRAPPER" "$@" + OVS_RUNDIR=${OVS_RUNDIR} start_ovn_daemon "$OVN_NORTHD_PRIORITY" "$OVN_NORTHD_WRAPPER" "$@" fi } @@ -350,7 +359,7 @@ start_controller () { [ "$OVN_USER" != "" ] && set "$@" --user "$OVN_USER" - OVS_RUNDIR=${OVN_RUNDIR} start_daemon "$OVN_CONTROLLER_PRIORITY" "$OVN_CONTROLLER_WRAPPER" "$@" + OVS_RUNDIR=${OVS_RUNDIR} start_ovn_daemon "$OVN_CONTROLLER_PRIORITY" "$OVN_CONTROLLER_WRAPPER" "$@" } start_controller_vtep () { @@ -377,7 +386,7 @@ start_controller_vtep () { [ "$OVN_USER" != "" ] && set "$@" --user "$OVN_USER" - OVS_RUNDIR=${OVN_RUNDIR} start_daemon "$OVN_CONTROLLER_PRIORITY" "$OVN_CONTROLLER_WRAPPER" "$@" + OVS_RUNDIR=${OVS_RUNDIR} start_ovn_daemon "$OVN_CONTROLLER_PRIORITY" "$OVN_CONTROLLER_WRAPPER" "$@" } ## ---- ## @@ -385,7 +394,7 @@ start_controller_vtep () { ## ---- ## stop_northd () { - OVS_RUNDIR=${OVN_RUNDIR} stop_daemon ovn-northd + OVS_RUNDIR=${OVS_RUNDIR} stop_ovn_daemon ovn-northd if [ ! -e $ovn_northd_db_conf_file ]; then if test X"$OVN_MANAGE_OVSDB" = Xyes; then @@ -395,11 +404,11 @@ stop_northd () { } stop_controller () { - OVS_RUNDIR=${OVN_RUNDIR} stop_daemon ovn-controller "$@" + OVS_RUNDIR=${OVS_RUNDIR} stop_ovn_daemon ovn-controller "$@" } stop_controller_vtep () { - OVS_RUNDIR=${OVN_RUNDIR} stop_daemon ovn-controller-vtep + OVS_RUNDIR=${OVS_RUNDIR} stop_ovn_daemon ovn-controller-vtep } ## ------- ## @@ -444,11 +453,12 @@ set_defaults () { OVN_MANAGE_OVSDB=yes OVS_RUNDIR=${OVS_RUNDIR:-${rundir}} - OVN_RUNDIR=${OVN_RUNDIR:-${OVS_RUNDIR}} + OVN_RUNDIR=${OVN_RUNDIR:-${ovn_rundir}} DB_NB_SOCK=$OVN_RUNDIR/ovnnb_db.sock DB_NB_PID=$OVN_RUNDIR/ovnnb_db.pid - DB_NB_FILE=$dbdir/ovnnb_db.db + DB_NB_CTRL_SOCK=$OVN_RUNDIR/ovnnb_db.ctl + DB_NB_FILE=$ovn_dbdir/ovnnb_db.db DB_NB_ADDR=0.0.0.0 DB_NB_PORT=6641 DB_NB_SYNC_FROM_PROTO=tcp @@ -457,17 +467,18 @@ set_defaults () { DB_SB_SOCK=$OVN_RUNDIR/ovnsb_db.sock DB_SB_PID=$OVN_RUNDIR/ovnsb_db.pid - DB_SB_FILE=$dbdir/ovnsb_db.db + DB_SB_CTRL_SOCK=$OVN_RUNDIR/ovnsb_db.ctl + DB_SB_FILE=$ovn_dbdir/ovnsb_db.db DB_SB_ADDR=0.0.0.0 DB_SB_PORT=6642 DB_SB_SYNC_FROM_PROTO=tcp DB_SB_SYNC_FROM_ADDR= DB_SB_SYNC_FROM_PORT=6642 - DB_NB_SCHEMA=$datadir/ovn-nb.ovsschema - DB_SB_SCHEMA=$datadir/ovn-sb.ovsschema + DB_NB_SCHEMA=$ovn_datadir/ovn-nb.ovsschema + DB_SB_SCHEMA=$ovn_datadir/ovn-sb.ovsschema - DB_SOCK=$OVN_RUNDIR/db.sock + DB_SOCK=$OVS_RUNDIR/db.sock DB_CONF_FILE=$dbdir/conf.db OVN_NORTHD_PRIORITY=-10 @@ -483,8 +494,8 @@ set_defaults () { OVN_NORTHD_LOGFILE="" OVN_NB_LOG="-vconsole:off -vfile:info" OVN_SB_LOG="-vconsole:off -vfile:info" - OVN_NB_LOGFILE="$logdir/ovsdb-server-nb.log" - OVN_SB_LOGFILE="$logdir/ovsdb-server-sb.log" + OVN_NB_LOGFILE="$ovn_logdir/ovsdb-server-nb.log" + OVN_SB_LOGFILE="$ovn_logdir/ovsdb-server-sb.log" OVN_CONTROLLER_SSL_KEY="" OVN_CONTROLLER_SSL_CERT="" @@ -662,14 +673,14 @@ File location options: --db-sb-use-remote-in-db=yes|no OVN_Southbound db listen on target connection table (default: $DB_SB_USE_REMOTE_IN_DB) Default directories with "configure" option and environment variable override: - logs: /usr/local/var/log/openvswitch (--with-logdir, OVS_LOGDIR) - pidfiles and sockets: /usr/local/var/run/openvswitch (--with-rundir, OVS_RUNDIR) - ovn-nb.db: /usr/local/etc/openvswitch (--with-dbdir, OVS_DBDIR) - ovn-sb.db: /usr/local/etc/openvswitch (--with-dbdir, OVS_DBDIR) - system configuration: /usr/local/etc (--sysconfdir, OVS_SYSCONFDIR) - data files: /usr/local/share/openvswitch (--pkgdatadir, OVS_PKGDATADIR) - user binaries: /usr/local/bin (--bindir, OVS_BINDIR) - system binaries: /usr/local/sbin (--sbindir, OVS_SBINDIR) + logs: /usr/local/var/log/ovn (--with-logdir, OVN_LOGDIR) + pidfiles and sockets: /usr/local/var/run/ovn (--with-rundir, OVN_RUNDIR) + ovn-nb.db: /usr/local/etc/ovn (--with-dbdir, OVN_DBDIR) + ovn-sb.db: /usr/local/etc/ovn (--with-dbdir, OVN_DBDIR) + system configuration: /usr/local/etc (--sysconfdir, OVN_SYSCONFDIR) + data files: /usr/local/share/ovn (--pkgdatadir, OVN_PKGDATADIR) + user binaries: /usr/local/bin (--bindir, OVN_BINDIR) + system binaries: /usr/local/sbin (--sbindir, OVN_SBINDIR) EOF } diff --git a/utilities/ovn-ctl.8.xml b/utilities/ovn-ctl.8.xml index c5294d794..f70bd6f0f 100644 --- a/utilities/ovn-ctl.8.xml +++ b/utilities/ovn-ctl.8.xml @@ -203,12 +203,12 @@

Starting standalone ovn db server passing SSL certificates

- # ovn-ctl --ovn-nb-db-ssl-key=/etc/openvswitch/ovnnb-privkey.pem - --ovn-nb-db-ssl-cert=/etc/openvswitch/ovnnb-cert.pem - --ovn-nb-db-ssl-ca-cert=/etc/openvswitch/cacert.pem - --ovn-sb-db-ssl-key=/etc/openvswitch/ovnsb-privkey.pem - --ovn-sb-db-ssl-cert=/etc/openvswitch/ovnsb-cert.pem - --ovn-sb-db-ssl-ca-cert=/etc/openvswitch/cacert.pem + # ovn-ctl --ovn-nb-db-ssl-key=/etc/ovn/ovnnb-privkey.pem + --ovn-nb-db-ssl-cert=/etc/ovn/ovnnb-cert.pem + --ovn-nb-db-ssl-ca-cert=/etc/ovn/cacert.pem + --ovn-sb-db-ssl-key=/etc/ovn/ovnsb-privkey.pem + --ovn-sb-db-ssl-cert=/etc/ovn/ovnsb-cert.pem + --ovn-sb-db-ssl-ca-cert=/etc/ovn/cacert.pem start_northd

diff --git a/utilities/ovn-lib.in b/utilities/ovn-lib.in new file mode 100644 index 000000000..50111a76b --- /dev/null +++ b/utilities/ovn-lib.in @@ -0,0 +1,204 @@ +# -*- sh -*- +# vi:syntax=sh +# This is a shell function library sourced by some OVN scripts. +# It is not intended to be invoked on its own. +# The code copied from ovs/utilities/ovs-lib.in + +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +## ----------------- ## +## configure options ## +## ----------------- ## + +# All of these should be substituted by the Makefile at build time. +ovn_logdir=${OVN_LOGDIR-'@LOGDIR@'} # /var/log/ovn +ovn_rundir=${OVN_RUNDIR-'@OVN_RUNDIR@'} # /var/run/ovn +ovn_sysconfdir=${OVN_SYSCONFDIR-'@sysconfdir@'} # /etc +ovn_etcdir=$sysconfdir/ovn # /etc/ovn +ovn_datadir=${OVN_PKGDATADIR-'@pkgdatadir@'} # /usr/share/ovn +ovn_bindir=${OVN_BINDIR-'@bindir@'} # /usr/bin +ovn_sbindir=${OVN_SBINDIR-'@sbindir@'} # /usr/sbin + +# /etc/ovn or /var/lib/ovn +if test X"$OVN_DBDIR" != X; then + ovn_dbdir=$OVN_DBDIR +elif test X"$OVN_SYSCONFDIR" != X; then + ovn_dbdir=$OVN_SYSCONFDIR/ovn +else + ovn_dbdir='@DBDIR@' +fi + +VERSION='@VERSION@' + +DAEMON_CWD=/ + +LC_ALL=C; export LC_ALL + +ovn_install_dir () { + DIR="$1" + INSTALL_MODE="${2:-755}" + INSTALL_USER="root" + INSTALL_GROUP="root" + [ "$OVN_USER" != "" ] && INSTALL_USER="${OVN_USER%:*}" + [ "${OVN_USER##*:}" != "" ] && INSTALL_GROUP="${OVN_USER##*:}" + + if test ! -d "$DIR"; then + install -d -m "$INSTALL_MODE" -o "$INSTALL_USER" -g "$INSTALL_GROUP" "$DIR" + restorecon "$DIR" >/dev/null 2>&1 + fi +} + +start_ovn_daemon () { + priority=$1 + wrapper=$2 + shift; shift + daemon=$1 + strace="" + + # drop core files in a sensible place + ovn_install_dir "$DAEMON_CWD" + set "$@" --no-chdir + cd "$DAEMON_CWD" + + # log file + ovn_install_dir "$ovn_logdir" "750" + set "$@" --log-file="$ovn_logdir/$daemon.log" + + # pidfile and monitoring + ovn_install_dir "$ovn_rundir" + set "$@" --pidfile="$ovn_rundir/$daemon.pid" + set "$@" --detach + test X"$MONITOR" = Xno || set "$@" --monitor + + # wrapper + case $wrapper in + valgrind) + if (valgrind --version) > /dev/null 2>&1; then + set valgrind -q --leak-check=full --time-stamp=yes \ + --log-file="$ovn_logdir/$daemon.valgrind.log.%p" "$@" + else + log_failure_msg "valgrind not installed, running $daemon without it" + fi + ;; + strace) + if (strace -V) > /dev/null 2>&1; then + strace="strace -tt -T -s 256 -ff" + if (strace -DV) > /dev/null 2>&1; then + # Has the -D option. + set $strace -D -o "$ovn_logdir/$daemon.strace.log" "$@" + strace="" + fi + else + log_failure_msg "strace not installed, running $daemon without it" + fi + ;; + glibc) + set env MALLOC_CHECK_=2 MALLOC_PERTURB_=165 "$@" + ;; + '') + ;; + *) + log_failure_msg "unknown wrapper $wrapper, running $daemon without it" + ;; + esac + + # priority + if test X"$priority" != X; then + set nice -n "$priority" "$@" + fi + + action "Starting $daemon" "$@" || return 1 + + if test X"$strace" != X; then + # Strace doesn't have the -D option so we attach after the fact. + setsid $strace -o "$ovn_logdir/$daemon.strace.log" \ + -p `cat $ovn_rundir/$daemon.pid` > /dev/null 2>&1 & + fi +} + +stop_ovn_daemon () { + if test -e "$ovn_rundir/$1.pid"; then + if pid=`cat "$ovn_rundir/$1.pid"`; then + if pid_exists "$pid" >/dev/null 2>&1; then :; else + rm -f $ovn_rundir/$1.$pid.ctl $ovn_rundir/$1.$pid + return 0 + fi + + graceful="EXIT .1 .25 .65 1" + actions="TERM .1 .25 .65 1 1 1 1 \ + KILL 1 1 1 2 10 15 30 \ + FAIL" + version=`ovs-appctl -T 1 -t $ovn_rundir/$1.$pid.ctl version \ + | awk 'NR==1{print $NF}'` + + # Use `ovs-appctl exit` only if the running daemon version + # is >= 2.5.90. This script might be used during upgrade to + # stop older versions of daemons which do not behave correctly + # with `ovs-appctl exit` (e.g. ovs-vswitchd <= 2.5.0 deletes + # internal ports). + if version_geq "$version" "2.5.90"; then + actions="$graceful $actions" + fi + for action in $actions; do + if pid_exists "$pid" >/dev/null 2>&1; then :; else + return 0 + fi + case $action in + EXIT) + action "Exiting $1 ($pid)" \ + ${bindir}/ovs-appctl -T 1 -t $ovn_rundir/$1.$pid.ctl exit $2 + ;; + TERM) + action "Killing $1 ($pid)" kill $pid + ;; + KILL) + action "Killing $1 ($pid) with SIGKILL" kill -9 $pid + ;; + FAIL) + log_failure_msg "Killing $1 ($pid) failed" + return 1 + ;; + *) + sleep $action + ;; + esac + done + fi + fi + log_success_msg "$1 is not running" +} + +ovn_daemon_status () { + pidfile=$ovn_rundir/$1.pid + if test -e "$pidfile"; then + if pid=`cat "$pidfile"`; then + if pid_exists "$pid"; then + echo "$1 is running with pid $pid" + return 0 + else + echo "Pidfile for $1 ($pidfile) is stale" + fi + else + echo "Pidfile for $1 ($pidfile) exists but cannot be read" + fi + else + echo "$1 is not running" + fi + return 1 +} + +daemon_is_running () { + pidfile=$ovn_rundir/$1.pid + test -e "$pidfile" && pid=`cat "$pidfile"` && pid_exists "$pid" && pid_comm_check $1 $pid +} >/dev/null 2>&1 From patchwork Tue Aug 13 16:27:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1146491 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 467J7G5QVWz9sN1 for ; Wed, 14 Aug 2019 02:28:41 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id B5A42CAE; Tue, 13 Aug 2019 16:28:09 +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 336E8AF7 for ; Tue, 13 Aug 2019 16:28:08 +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 140D88AB for ; Tue, 13 Aug 2019 16:28:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A89AA8FAB2; Tue, 13 Aug 2019 16:28:02 +0000 (UTC) Received: from nusiddiq.redhat (ovpn-116-27.sin2.redhat.com [10.67.116.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 480227EED3; Tue, 13 Aug 2019 16:27:54 +0000 (UTC) From: nusiddiq@redhat.com To: dev@openvswitch.org Date: Tue, 13 Aug 2019 21:57:45 +0530 Message-Id: <20190813162745.16349-1-nusiddiq@redhat.com> In-Reply-To: <20190813162629.15983-1-nusiddiq@redhat.com> References: <20190813162629.15983-1-nusiddiq@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 13 Aug 2019 16:28:02 +0000 (UTC) X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,LOTS_OF_MONEY, 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 ovn 2/4] Build OVN using external OVS directory 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: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: Numan Siddique With this patch we have to configure OVN to refer to external OVS source/build directory instead of the ovs subtree. The new configuration options added are: * --with-ovs-source=/path/to/ovs/source/dir * --with-ovs-build=/path/to/ovs/build/dir Before configuring OVN, user should configure and compile OVS. If the user has configured OVS on a different directory than the source dir, then 'with-ovs-build' should be specified. If ovs-build dir is not defined, then ovs-source is used. An upcoming patch will delete the ovs subtree. Example usage: $ # Clone OVS repo $cd /home/foo/ovs $./boot.sh $mkdir _gcc $cd _gcc && ../configure && cd .. $make -C _gcc $ # Clone OVN repo $cd /home/foo/ovn $./boot.sh $./configure --with-ovs-source=/home/foo/ovs/ --with-ovs-build=/home/foo/ovs/_gcc $make The test files ovn-controller-vtep.at, ovn-nbctl.at and ovn-sbctl.at needed to be modified because of this commit [1] in the openvswitch repo. This patch also updates the tutorial/ovs-sandbox to use OVS binaries from the OVS build folder. [1] - https://github.com/openvswitch/ovs/commit/29004db273985088cdb60097bdfd4a6bc6a966d1 Acked-by: Lucas Alvares Gomes Signed-off-by: Numan Siddique Tested-by: Lorenzo Bianconi --- .travis/linux-build.sh | 17 +- .travis/osx-build.sh | 13 +- Documentation/intro/install/general.rst | 31 ++- Makefile.am | 24 +- acinclude.m4 | 35 +++ configure.ac | 29 +-- controller-vtep/automake.mk | 2 +- include/ovn/version.h.in | 28 +++ lib/ovsdb_automake.mk | 7 +- tests/automake.mk | 6 +- tests/ofproto-macros.at | 4 +- tests/ovn-controller-vtep.at | 12 +- tests/ovn-nbctl.at | 6 +- tests/ovn-sbctl.at | 20 +- tests/ovn.at | 158 ++++++------ tests/ovsdb-macros.at | 2 +- tutorial/automake.mk | 2 +- tutorial/ovs-sandbox | 308 ++++++++++++------------ 18 files changed, 403 insertions(+), 301 deletions(-) create mode 100644 include/ovn/version.h.in diff --git a/.travis/linux-build.sh b/.travis/linux-build.sh index a20474345..37a6844ab 100755 --- a/.travis/linux-build.sh +++ b/.travis/linux-build.sh @@ -10,7 +10,18 @@ TARGET="x86_64-native-linuxapp-gcc" function configure_ovs() { + git clone https://github.com/openvswitch/ovs.git ovs_src + pushd ovs_src ./boot.sh && ./configure $* || { cat config.log; exit 1; } + make -j4 + popd +} + +function configure_ovn() +{ + configure_ovs $* + ./boot.sh && ./configure --with-ovs-source=$PWD/ovs_src $* || \ + { cat config.log; exit 1; } } OPTS="$EXTRA_OPTS $*" @@ -28,16 +39,16 @@ fi if [ "$TESTSUITE" ]; then # 'distcheck' will reconfigure with required options. # Now we only need to prepare the Makefile without sparse-wrapped CC. - configure_ovs + configure_ovn - export DISTCHECK_CONFIGURE_FLAGS="$OPTS" + export DISTCHECK_CONFIGURE_FLAGS="$OPTS --with-ovs-source=$PWD/ovs_src" if ! make distcheck -j4 TESTSUITEFLAGS="-j4 -k ovn" RECHECK=yes; then # testsuite.log is necessary for debugging. cat */_build/tests/testsuite.log exit 1 fi else - configure_ovs $OPTS + configure_ovn $OPTS make selinux-policy make -j4 diff --git a/.travis/osx-build.sh b/.travis/osx-build.sh index f11d7b9af..1d6ac54af 100755 --- a/.travis/osx-build.sh +++ b/.travis/osx-build.sh @@ -7,10 +7,20 @@ EXTRA_OPTS="" function configure_ovs() { + git clone https://github.com/openvswitch/ovs.git ovs_src + pushd ovs_src ./boot.sh && ./configure $* + make -j4 + popd } -configure_ovs $EXTRA_OPTS $* +function configure_ovn() +{ + configure_ovs $* + ./boot.sh && ./configure $* --with-ovs-source=$PWD/ovs_src +} + +configure_ovn $EXTRA_OPTS $* if [ "$CC" = "clang" ]; then make CFLAGS="$CFLAGS -Wno-error=unused-command-line-argument" @@ -18,6 +28,7 @@ else make CFLAGS="$CFLAGS $BUILD_ENV" fi if [ "$TESTSUITE" ] && [ "$CC" != "clang" ]; then + export DISTCHECK_CONFIGURE_FLAGS="$EXTRA_OPTS --with-ovs-source=$PWD/ovs_src" if ! make distcheck RECHECK=yes; then # testsuite.log is necessary for debugging. cat */_build/tests/testsuite.log diff --git a/Documentation/intro/install/general.rst b/Documentation/intro/install/general.rst index 4cc9c4c3a..c19b717b2 100644 --- a/Documentation/intro/install/general.rst +++ b/Documentation/intro/install/general.rst @@ -42,9 +42,8 @@ out. This is the right branch for general development. As of now there are no official OVN releases. -Although building OVN, also builds OVS, it is recommended to clone -and build OVS from its own repo. Please see the Open vSwitch -documentation to build and install OVS. +Before building OVN you should configure and build OVS. +Please see the Open vSwitch documentation to build and install OVS. .. _general-build-reqs: @@ -143,18 +142,25 @@ the "configure" script:: $ ./boot.sh +Before configuring OVN, clone, configure and build Open vSwitch. + .. _general-configuring: Configuring ----------- -Configure the package by running the configure script. You can usually -invoke configure without any arguments. For example:: +Configure the package by running the configure script. You need to +invoke configure with atleast the argument --with-ovs-source. +For example:: + + $ ./configure --with-ovs-source=/path/to/ovs/source - $ ./configure +If you have built Open vSwitch in a separate directory, then you +need to provide that path in the option - --with-ovs-build. By default all files are installed under ``/usr/local``. OVN expects to find its database in ``/usr/local/etc/ovn`` by default. + If you want to install all files into, e.g., ``/usr`` and ``/var`` instead of ``/usr/local`` and ``/usr/local/var`` and expect to use ``/etc/ovn`` as the default database directory, add options as shown here:: @@ -272,6 +278,19 @@ you wish to link with jemalloc add it to LIBS:: $ ./configure LIBS=-ljemalloc +Example usage:: + $ # Clone OVS repo + $cd /home/foo/ovs + $./boot.sh + $mkdir _gcc + $cd _gcc && ../configure && cd .. + $make -C _gcc + + $ # Clone OVN repo + $cd /home/foo/ovn + $./boot.sh + $./configure --with-ovs-source=/home/foo/ovs/ --with-ovs-build=/home/foo/ovs/_gcc + .. _general-building: Building diff --git a/Makefile.am b/Makefile.am index 6447e348b..d2dae3948 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,7 +7,7 @@ AUTOMAKE_OPTIONS = foreign subdir-objects ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = ovs +#SUBDIRS = ovs OVS_SRCDIR=@ovs_srcdir@ OVS_BUILDDIR=@ovs_builddir@ @@ -22,9 +22,9 @@ AM_LDFLAGS += $(OVS_LDFLAGS) AM_CPPFLAGS += -I $(top_srcdir)/include if WIN32 -AM_CPPFLAGS += -I $(top_srcdir)/ovs/include -AM_CPPFLAGS += -I $(top_srcdir)/ovs/lib -AM_CPPFLAGS += -I $(top_srcdir)/ovs +AM_CPPFLAGS += -I $(OVS_SRCDIR)/include +AM_CPPFLAGS += -I $(OVS_SRCDIR)/lib +AM_CPPFLAGS += -I $(OVS_SRCDIR) AM_CPPFLAGS += -I $(top_srcdir)/lib AM_CPPFLAGS += $(PTHREAD_INCLUDES) AM_CPPFLAGS += $(MSVC_CFLAGS) @@ -33,6 +33,10 @@ AM_LDFLAGS += $(MSVC64_LDFLAGS) PLATFORM = $(MSVC_PLATFORM) endif +AM_CPPFLAGS += -I $(top_srcdir)/include +AM_CPPFLAGS += -I $(top_srcdir)/ovn +AM_CPPFLAGS += -I $(top_builddir)/include + AM_CPPFLAGS += -I $(OVS_SRCDIR)/include AM_CPPFLAGS += -I $(OVS_BUILDDIR)/include AM_CPPFLAGS += -I $(OVS_SRCDIR)/lib @@ -113,8 +117,7 @@ EXTRA_DIST = \ ovn-nb.ovsschema \ ovn-nb.xml \ ovn-sb.ovsschema \ - ovn-sb.xml \ - ovs/ + ovn-sb.xml bin_PROGRAMS = sbin_PROGRAMS = bin_SCRIPTS = @@ -222,13 +225,6 @@ CLEAN_LOCAL += clean-pycov ALL_LOCAL += dist-hook-git dist-hook-git: distfiles @if test -e $(srcdir)/.git && (git --version) >/dev/null 2>&1; then \ - (cd ovs && $(MAKE) distfiles); \ - (cat distfiles; sed 's|^|ovs/|' ovs/distfiles) | \ - LC_ALL=C sort -u > ovs-distfiles; \ - (cd ovs/datapath && $(MAKE) distfiles); \ - (cat distfiles; sed 's|^|ovs/datapath/|' ovs/datapath/distfiles) | \ - LC_ALL=C sort -u > datapath-distfiles; \ - LC_ALL=C sort -u ovs-distfiles datapath-distfiles > all-distfiles; \ (cd $(srcdir) && git ls-files) | grep -v '\.gitignore$$' | \ grep -v '\.gitattributes$$' | \ LC_ALL=C sort -u > all-gitfiles; \ @@ -244,7 +240,7 @@ dist-hook-git: distfiles exit 1; \ fi \ fi -CLEANFILES += ovs-distfiles datapath-distfiles all-distfiles all-gitfiles missing-distfiles +CLEANFILES += all-distfiles all-gitfiles missing-distfiles # The following is based on commands for the Automake "distdir" target. distfiles: Makefile @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ diff --git a/acinclude.m4 b/acinclude.m4 index 7604c92b8..b0211ed35 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1206,3 +1206,38 @@ AC_DEFUN([OVS_CHECK_LINUX_HOST], [ovs_cv_linux=true], [ovs_cv_linux=false])]) AM_CONDITIONAL([LINUX], [$ovs_cv_linux])]) + +dnl OVN_CHECK_OVS +dnl +dnl Check for OVS sources +AC_DEFUN([OVN_CHECK_OVS], [ + AC_ARG_WITH([ovs-source], + [AC_HELP_STRING([--ovs-source=/path/to/ovs/src/dir], + [Specify the OVS src directory])]) + AC_ARG_WITH([ovs-build], + [AC_HELP_STRING([--ovs-build=/path/to/ovs/build/dir], + [Specify the OVS build directory])]) + + AC_MSG_CHECKING([for OVS source directory]) + if test X"$with_ovs_source" != X; then + OVSDIR=$with_ovs_source + else + AC_ERROR([OVS source dir path needs to be specified]) + fi + + OVSDIR=`eval echo "$OVSDIR"` + AC_MSG_RESULT([$OVSDIR]) + AC_SUBST(OVSDIR) + + AC_MSG_CHECKING([for OVS build directory]) + if test X"$with_ovs_build" != X; then + OVSBUILDDIR=$with_ovs_build + else + # If separate build dir is not specified, use src dir. + OVSBUILDDIR=$OVSDIR + fi + + OVSBUILDDIR=`eval echo "$OVSBUILDDIR"` + AC_MSG_RESULT([$OVSBUILDDIR]) + AC_SUBST(OVSBUILDDIR) +]) diff --git a/configure.ac b/configure.ac index c74b17a1d..4ba092f51 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,7 @@ AC_CONFIG_HEADERS([config.h]) AC_CONFIG_TESTDIR([tests]) AM_INIT_AUTOMAKE([tar-pax]) -AC_CONFIG_SUBDIRS([ovs]) +#AC_CONFIG_SUBDIRS([ovs]) AC_PROG_CC_C99 AM_PROG_CC_C_O @@ -64,23 +64,17 @@ m4_pattern_forbid([LT_INIT]) dnl Make autoconf fail if libtool is missing. # the new version. This is the case when symbols have been modified or # deleted. Bump current, set revision and age to 0. -m4_define([libopenvswitch_lt_current], [0]) -m4_define([libopenvswitch_lt_revision], [0]) -m4_define([libopenvswitch_lt_age], [0]) +m4_define([libovn_lt_current], [0]) +m4_define([libovn_lt_revision], [0]) +m4_define([libovn_lt_age], [0]) -LT_CURRENT=libopenvswitch_lt_current +LT_CURRENT=libovn_lt_current AC_SUBST([LT_CURRENT]) -LT_REVISION=libopenvswitch_lt_revision +LT_REVISION=libovn_lt_revision AC_SUBST([LT_REVISION]) -LT_AGE=libopenvswitch_lt_age +LT_AGE=libovn_lt_age AC_SUBST([LT_AGE]) -AC_SUBST([ovs_srcdir], ['${top_srcdir}/ovs']) -AC_SUBST([ovs_builddir], ['${top_builddir}/ovs']) -AC_SUBST([ovs_libdir], ['${top_builddir}/ovs/lib']) -AC_SUBST([ovsdb_libdir], ['${top_builddir}/ovs/ovsdb']) -AC_SUBST([ovs_mandir], ['${top_srcdir}/ovs/']) - AC_SEARCH_LIBS([pow], [m]) AC_SEARCH_LIBS([clock_gettime], [rt]) AC_SEARCH_LIBS([timer_create], [rt]) @@ -188,12 +182,19 @@ OVS_CHECK_LINUX OVS_CHECK_LINUX_TC OVS_CHECK_DPDK OVS_CHECK_PRAGMA_MESSAGE +OVN_CHECK_OVS AC_SUBST([OVS_CFLAGS]) AC_SUBST([OVS_LDFLAGS]) +AC_SUBST([ovs_srcdir], ['${OVSDIR}']) +AC_SUBST([ovs_builddir], ['${OVSBUILDDIR}']) +AC_SUBST([ovs_libdir], ['${OVSBUILDDIR}/lib']) +AC_SUBST([ovsdb_libdir], ['${OVSBUILDDIR}/ovsdb']) +AC_SUBST([ovs_mandir], ['${OVSDIR}']) + AC_CONFIG_FILES(Makefile) AC_CONFIG_FILES(tests/atlocal) -AC_CONFIG_FILES(ovs/include/openvswitch/version.h) +AC_CONFIG_FILES(include/ovn/version.h) dnl This makes sure that include/openflow gets created in the build directory. AC_CONFIG_COMMANDS([include/openflow/openflow.h.stamp]) diff --git a/controller-vtep/automake.mk b/controller-vtep/automake.mk index a6810969f..a5779eba6 100644 --- a/controller-vtep/automake.mk +++ b/controller-vtep/automake.mk @@ -8,7 +8,7 @@ controller_vtep_ovn_controller_vtep_SOURCES = \ controller-vtep/ovn-controller-vtep.h \ controller-vtep/vtep.c \ controller-vtep/vtep.h -controller_vtep_ovn_controller_vtep_LDADD = lib/libovn.la $(OVS_LIBDIR)/libopenvswitch.la ovs/vtep/libvtep.la +controller_vtep_ovn_controller_vtep_LDADD = lib/libovn.la $(OVS_LIBDIR)/libopenvswitch.la $(OVSBUILDDIR)/vtep/libvtep.la man_MANS += controller-vtep/ovn-controller-vtep.8 EXTRA_DIST += controller-vtep/ovn-controller-vtep.8.xml CLEANFILES += controller-vtep/ovn-controller-vtep.8 diff --git a/include/ovn/version.h.in b/include/ovn/version.h.in new file mode 100644 index 000000000..e27415ba1 --- /dev/null +++ b/include/ovn/version.h.in @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2014 Nicira, Inc. + * Copyright (c) 2014 Cisco Systems, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OVN_VERSION_H +#define OVN_VERSION_H 1 + +#define OVN_PACKAGE_STRING "@PACKAGE_STRING@" +#define OVN_PACKAGE_VERSION "@PACKAGE_VERSION@" + +#define OVN_LIB_VERSION @LT_CURRENT@ +#define OVN_LIB_REVISION @LT_REVISION@ +#define OVN_LIB_AGE @LT_AGE@ + +#endif /* ovn/version.h */ diff --git a/lib/ovsdb_automake.mk b/lib/ovsdb_automake.mk index f6fd5e8b3..32f22b672 100644 --- a/lib/ovsdb_automake.mk +++ b/lib/ovsdb_automake.mk @@ -1,10 +1,6 @@ # ovsdb-idlc -noinst_SCRIPTS += ovs/ovsdb/ovsdb-idlc -EXTRA_DIST += ovs/ovsdb/ovsdb-idlc.in -MAN_ROOTS += ovs/ovsdb/ovsdb-idlc.1 -CLEANFILES += ovs/ovsdb/ovsdb-idlc SUFFIXES += .ovsidl .ovsschema -OVSDB_IDLC = $(run_python) $(srcdir)/ovs/ovsdb/ovsdb-idlc.in +OVSDB_IDLC = $(run_python) ${OVSDIR}/ovsdb/ovsdb-idlc.in .ovsidl.c: $(AM_V_GEN)$(OVSDB_IDLC) c-idl-source $< > $@.tmp && mv $@.tmp $@ .ovsidl.h: @@ -21,5 +17,4 @@ CLEANFILES += $(OVSIDL_BUILT) # However, current versions of Automake seem to output all variable # assignments before any targets, so it doesn't seem to be a problem, # at least for now. -$(OVSIDL_BUILT): ovs/ovsdb/ovsdb-idlc.in diff --git a/tests/automake.mk b/tests/automake.mk index 5411772a4..1fabb5350 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -51,10 +51,10 @@ SYSTEM_KMOD_TESTSUITE = $(srcdir)/tests/system-kmod-testsuite SYSTEM_USERSPACE_TESTSUITE = $(srcdir)/tests/system-userspace-testsuite DISTCLEANFILES += tests/atconfig tests/atlocal -AUTOTEST_PATH = ovs/utilities:ovs/vswitchd:ovs/ovsdb:ovs/vtep:tests:$(PTHREAD_WIN32_DIR_DLL):$(SSL_DIR):controller-vtep:northd:utilities:controller +AUTOTEST_PATH = $(ovs_builddir)/utilities:$(ovs_builddir)/vswitchd:$(ovs_builddir)/ovsdb:$(ovs_builddir)/vtep:tests:$(PTHREAD_WIN32_DIR_DLL):$(SSL_DIR):controller-vtep:northd:utilities:controller check-local: - set $(SHELL) '$(TESTSUITE)' -C tests AUTOTEST_PATH=$(AUTOTEST_PATH); \ + set $(SHELL) '$(TESTSUITE)' -C tests AUTOTEST_PATH=$(AUTOTEST_PATH) ovs_srcdir=$(ovs_srcdir); \ "$$@" $(TESTSUITEFLAGS) || (test X'$(RECHECK)' = Xyes && "$$@" --recheck) # Python Coverage support. @@ -230,7 +230,7 @@ tests/testpki-req2.pem: tests/pki/stamp tests/testpki-privkey2.pem: tests/pki/stamp $(AM_V_GEN)cp tests/pki/test2-privkey.pem $@ -OVS_PKI = $(SHELL) $(srcdir)/ovs/utilities/ovs-pki.in --dir=tests/pki --log=tests/ovs-pki.log +OVS_PKI = $(SHELL) $(ovs_srcdir)/utilities/ovs-pki.in --dir=tests/pki --log=tests/ovs-pki.log tests/pki/stamp: $(AM_V_at)rm -f tests/pki/stamp $(AM_V_at)rm -rf tests/pki diff --git a/tests/ofproto-macros.at b/tests/ofproto-macros.at index 4d4683775..536da8dd7 100644 --- a/tests/ofproto-macros.at +++ b/tests/ofproto-macros.at @@ -91,7 +91,7 @@ sim_add () { # Create database and start ovsdb-server. : > "$d"/.conf.db.~lock~ - as $1 ovsdb-tool create "$d"/conf.db "$abs_top_srcdir"/ovs/vswitchd/vswitch.ovsschema || return 1 + as $1 ovsdb-tool create "$d"/conf.db "$ovs_srcdir"/vswitchd/vswitch.ovsschema || return 1 as $1 start_daemon ovsdb-server --remote=punix:"$d"/db.sock || return 1 # Initialize database. @@ -322,7 +322,7 @@ m4_define([TESTABLE_LOG], [-vPATTERN:ANY:'%c|%p|%m']) m4_define([_OVS_VSWITCHD_START], [dnl Create database. touch .conf.db.~lock~ - AT_CHECK([ovsdb-tool create conf.db $abs_top_srcdir/ovs/vswitchd/vswitch.ovsschema]) + AT_CHECK([ovsdb-tool create conf.db $ovs_srcdir/vswitchd/vswitch.ovsschema]) dnl Start ovsdb-server. AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:$OVS_RUNDIR/db.sock], [0], [], [stderr]) diff --git a/tests/ovn-controller-vtep.at b/tests/ovn-controller-vtep.at index 187235138..e8c731fca 100644 --- a/tests/ovn-controller-vtep.at +++ b/tests/ovn-controller-vtep.at @@ -18,11 +18,11 @@ m4_define([OVN_CONTROLLER_VTEP_START], AT_SKIP_IF([test $HAVE_PYTHON = no]) dnl Create databases (ovn-nb, ovn-sb, vtep). - AT_CHECK([ovsdb-tool create vswitchd.db $abs_top_srcdir/ovs/vswitchd/vswitch.ovsschema]) + AT_CHECK([ovsdb-tool create vswitchd.db $ovs_srcdir/vswitchd/vswitch.ovsschema]) for daemon in ovn-nb ovn-sb; do AT_CHECK([ovsdb-tool create $daemon.db $abs_top_srcdir/${daemon}.ovsschema]) done - AT_CHECK([ovsdb-tool create vtep.db $abs_top_srcdir/ovs/vtep/vtep.ovsschema]) + AT_CHECK([ovsdb-tool create vtep.db $ovs_srcdir/vtep/vtep.ovsschema]) dnl Start ovsdb-server. AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --log-file --remote=punix:$OVS_RUNDIR/db.sock vswitchd.db vtep.db], [0], [], [stderr]) @@ -137,28 +137,28 @@ AT_CHECK([ovn-sbctl --columns=ip list Encap | cut -d ':' -f2 | tr -d ' '], [0], AT_CHECK([vtep-ctl add-ls lswitch0 -- bind-ls br-vtep p0 100 lswitch0 -- bind-ls br-vtep p0 200 lswitch0 -- bind-ls br-vtep p1 300 lswitch0]) OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Chassis | grep -- lswitch0`"]) AT_CHECK([ovn-sbctl --columns=vtep_logical_switches list Chassis | cut -d ':' -f2 | tr -d ' ' ], [0], [dnl -[["lswitch0"]] +[[lswitch0]] ]) # adds another logical switch and new vlan_bindings. AT_CHECK([vtep-ctl add-ls lswitch1 -- bind-ls br-vtep p0 300 lswitch1]) OVS_WAIT_UNTIL([test -n "`ovn-sbctl list Chassis | grep -- lswitch1`"]) AT_CHECK([ovn-sbctl --columns=vtep_logical_switches list Chassis | cut -d ':' -f2 | tr -d ' '], [0], [dnl -[["lswitch0","lswitch1"]] +[[lswitch0,lswitch1]] ]) # unbinds one port from lswitch0, nothing should change. AT_CHECK([vtep-ctl unbind-ls br-vtep p0 200]) OVS_WAIT_UNTIL([test -z "`vtep-ctl --columns=vlan_bindings list physical_port p0 | grep -- '200='`"]) AT_CHECK([ovn-sbctl --columns=vtep_logical_switches list Chassis | cut -d ':' -f2 | tr -d ' ' ], [0], [dnl -[["lswitch0","lswitch1"]] +[[lswitch0,lswitch1]] ]) # unbinds all ports from lswitch0. AT_CHECK([vtep-ctl unbind-ls br-vtep p0 100 -- unbind-ls br-vtep p1 300]) OVS_WAIT_UNTIL([test -z "`ovn-sbctl list Chassis | grep -- br-vtep_lswitch0`"]) AT_CHECK([ovn-sbctl --columns=vtep_logical_switches list Chassis | cut -d ':' -f2 | tr -d ' ' ], [0], [dnl -[["lswitch1"]] +[[lswitch1]] ]) # unbinds all ports from lswitch1. diff --git a/tests/ovn-nbctl.at b/tests/ovn-nbctl.at index cf06966ed..a46174c72 100644 --- a/tests/ovn-nbctl.at +++ b/tests/ovn-nbctl.at @@ -1594,7 +1594,7 @@ OVN_NBCTL_TEST([ovn_nbctl_port_groups], [port groups], [ dnl Check that port group can be looked up by name AT_CHECK([ovn-nbctl create Port_Group name=pg0], [0], [ignore]) AT_CHECK([ovn-nbctl get Port_Group pg0 name], [0], [dnl -"pg0" +pg0 ])]) OVN_NBCTL_TEST([ovn_nbctl_extra_newlines], [extra newlines], [ @@ -1603,10 +1603,10 @@ dnl daemon mode. All we have to do is ensure that each time we list database dnl information, there is not an extra newline at the beginning of the output. AT_CHECK([ovn-nbctl ls-add sw1], [0], [ignore]) AT_CHECK([ovn-nbctl --columns=name list logical_switch sw1], [0], [dnl -name : "sw1" +name : sw1 ]) AT_CHECK([ovn-nbctl --columns=name list logical_switch sw1], [0], [dnl -name : "sw1" +name : sw1 ])]) OVN_NBCTL_TEST([ovn_nbctl_table_formatting], [table formatting], [ diff --git a/tests/ovn-sbctl.at b/tests/ovn-sbctl.at index a679f40a8..c25d4d372 100644 --- a/tests/ovn-sbctl.at +++ b/tests/ovn-sbctl.at @@ -79,11 +79,11 @@ AT_CHECK([ovn-nbctl --wait=sb sync]) AT_CHECK([ovn-sbctl lsp-bind vif0 ch0]) AT_CHECK([ovn-sbctl show], [0], [dnl -Chassis "ch0" +Chassis ch0 Encap stt ip: "1.2.3.5" options: {csum="true"} - Port_Binding "vif0" + Port_Binding vif0 ]) # adds another 'vif1' @@ -92,12 +92,12 @@ AT_CHECK([ovn-nbctl lsp-set-addresses vif1 f0:ab:cd:ef:01:03]) AT_CHECK([ovn-sbctl lsp-bind vif1 ch0]) AT_CHECK([ovn-sbctl show | sed 's/vif[[0-9]]/vif/'], [0], [dnl -Chassis "ch0" +Chassis ch0 Encap stt ip: "1.2.3.5" options: {csum="true"} - Port_Binding "vif" - Port_Binding "vif" + Port_Binding vif + Port_Binding vif ]) # deletes 'vif1' @@ -105,16 +105,16 @@ AT_CHECK([ovn-nbctl lsp-del vif1]) AT_CHECK([ovn-nbctl --wait=sb sync]) AT_CHECK([ovn-sbctl show], [0], [dnl -Chassis "ch0" +Chassis ch0 Encap stt ip: "1.2.3.5" options: {csum="true"} - Port_Binding "vif0" + Port_Binding vif0 ]) uuid=$(ovn-sbctl --columns=_uuid list Chassis ch0 | cut -d ':' -f2 | tr -d ' ') AT_CHECK_UNQUOTED([ovn-sbctl --columns=logical_port,mac,chassis list Port_Binding], [0], [dnl -logical_port : "vif0" +logical_port : vif0 mac : [["f0:ab:cd:ef:01:02"]] chassis : ${uuid} ]) @@ -126,10 +126,10 @@ AT_CHECK([ovn-nbctl lsp-set-options vtep0 vtep_physical_switch=p0 vtep_logical_s AT_CHECK([ovn-sbctl --timeout=10 wait-until Port_Binding vtep0 options!={}]) AT_CHECK([ovn-sbctl --columns=logical_port,mac,type,options list Port_Binding vtep0], [0], [dnl -logical_port : "vtep0" +logical_port : vtep0 mac : [[]] type : vtep -options : {vtep_logical_switch="l0", vtep_physical_switch="p0"} +options : {vtep_logical_switch=l0, vtep_physical_switch=p0} ]) OVN_SBCTL_TEST_STOP diff --git a/tests/ovn.at b/tests/ovn.at index 71eb39079..a54a8ca59 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -18,7 +18,7 @@ m4_divert_text([PREPARE_TESTS], exp_text=$2 exp_n=`wc -l < "$exp_text"` OVS_WAIT_UNTIL( - [$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" $rcv_pcap > $rcv_text + [$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" $rcv_pcap > $rcv_text rcv_n=`wc -l < "$rcv_text"` echo "rcv_n=$rcv_n exp_n=$exp_n" test $rcv_n -ge $exp_n]) @@ -4607,7 +4607,7 @@ test_dhcp 1 f00000000001 01 $ciaddr $offer_ip $request_ip 0 ff1000000001 $server # NXT_RESUMEs should be 1. OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets cat 1.expected | cut -c -48 > expout AT_CHECK([cat 1.packets | cut -c -48], [0], [expout]) # Skipping the IPv4 checksum. @@ -4633,7 +4633,7 @@ test_dhcp 2 f00000000002 03 $ciaddr $offer_ip $request_ip 0 ff1000000001 $server # NXT_RESUMEs should be 2. OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets cat 2.expected | cut -c -48 > expout AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) # Skipping the IPv4 checksum. @@ -4657,7 +4657,7 @@ test_dhcp 2 f00000000002 03 $ciaddr $offer_ip $request_ip 0 ff1000000001 $server # NXT_RESUMEs should be 3. OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets cat 2.expected | cut -c -48 > expout AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) # Skipping the IPv4 checksum. @@ -4720,7 +4720,7 @@ test_dhcp 2 f00000000002 03 $ciaddr $offer_ip $request_ip 1 $src_ip $dst_ip ff10 # NXT_RESUMEs should be 5. OVS_WAIT_UNTIL([test 5 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets cat 2.expected | cut -c -48 > expout AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) # Skipping the IPv4 checksum. @@ -4746,7 +4746,7 @@ test_dhcp 2 f00000000002 03 $ciaddr $offer_ip $request_ip 1 $src_ip $dst_ip ff10 # NXT_RESUMEs should be 6. OVS_WAIT_UNTIL([test 6 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets cat 2.expected | cut -c -48 > expout AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) # Skipping the IPv4 checksum. @@ -4772,7 +4772,7 @@ test_dhcp 2 f00000000002 03 $ciaddr $offer_ip $request_ip 1 $src_ip $dst_ip ff10 # NXT_RESUMEs should be 7. OVS_WAIT_UNTIL([test 7 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets cat 2.expected | cut -c -48 > expout AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) # Skipping the IPv4 checksum. @@ -4798,7 +4798,7 @@ test_dhcp 2 f00000000002 03 $ciaddr $offer_ip $request_ip 1 $src_ip $dst_ip ff10 # NXT_RESUMEs should be 8. OVS_WAIT_UNTIL([test 8 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets cat 2.expected | cut -c -48 > expout AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) # Skipping the IPv4 checksum. @@ -5005,7 +5005,7 @@ test_dhcpv6 1 $src_mac $src_lla 01 $offer_ip # NXT_RESUMEs should be 1. OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif1-tx.pcap | trim_zeros > 1.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap | trim_zeros > 1.packets # cat 1.expected | trim_zeros > expout cat 1.expected | cut -c -120 > expout AT_CHECK([cat 1.packets | cut -c -120], [0], [expout]) @@ -5035,11 +5035,11 @@ OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) # vif2-tx.pcap should not have received the DHCPv6 reply packet rm 2.packets -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif2-tx.pcap | trim_zeros > 2.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap | trim_zeros > 2.packets AT_CHECK([cat 2.packets], [0], []) # vif1-tx.pcap should have received the DHCPv6 (invalid) request packet -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif1-tx.pcap | trim_zeros > 1.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap | trim_zeros > 1.packets cat 1.expected > expout AT_CHECK([cat 1.packets], [0], [expout]) @@ -5055,11 +5055,11 @@ test_dhcpv6 3 $src_mac $src_lla 01 0 4 OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) # vif3-tx.pcap should not have received the DHCPv6 reply packet -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif3-tx.pcap | trim_zeros > 3.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif3-tx.pcap | trim_zeros > 3.packets AT_CHECK([cat 3.packets], [0], []) # vif4-tx.pcap should have received the DHCPv6 request packet -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif4-tx.pcap | trim_zeros > 4.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif4-tx.pcap | trim_zeros > 4.packets cat 4.expected > expout AT_CHECK([cat 4.packets], [0], [expout]) @@ -5073,7 +5073,7 @@ test_dhcpv6 5 $src_mac $src_lla 01 1 5 # NXT_RESUMEs should be 3. OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif5-tx.pcap | trim_zeros > 5.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif5-tx.pcap | trim_zeros > 5.packets # Skipping the UDP checksum cat 5.expected | cut -c 1-120,125- > expout AT_CHECK([cat 5.packets | cut -c 1-120,125- ], [0], [expout]) @@ -5089,7 +5089,7 @@ test_dhcpv6 5 $src_mac $src_lla 0b 1 5 # NXT_RESUMEs should be 4. OVS_WAIT_UNTIL([test 4 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif5-tx.pcap | +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif5-tx.pcap | trim_zeros > 5.packets # Skipping the UDP checksum cat 5.expected | cut -c 1-120,125- > expout @@ -5533,7 +5533,7 @@ AT_CHECK([ovs-ofctl dump-flows br-int | \ ]) # Expected to drop the packet. -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" pbr-hv/vif2-tx.pcap > vif2.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" pbr-hv/vif2-tx.pcap > vif2.packets rcvd_packet=`cat vif2.packets` AT_FAIL_IF([rcvd_packet = ""]) @@ -5719,7 +5719,7 @@ AT_CHECK([ovs-ofctl dump-flows br-int | \ ]) # Expected to drop the packet. -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" pbr-hv/vif2-tx.pcap > vif2.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" pbr-hv/vif2-tx.pcap > vif2.packets rcvd_packet=`cat vif2.packets` AT_FAIL_IF([rcvd_packet = ""]) @@ -6506,7 +6506,7 @@ src_ip=`ip_to_hex 192 168 1 2` dst_ip=`ip_to_hex 192 168 1 3` expected=${dst_mac}${src_mac}08004500001c0000000040110000${src_ip}${dst_ip}0035111100080000 -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > received1.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > received1.packets echo $expected > expout AT_CHECK([cat received1.packets], [0], [expout]) @@ -6517,7 +6517,7 @@ src_ip=`ip_to_hex 192 168 1 2` dst_ip=`ip_to_hex 192 168 2 2` expected=${dst_mac}${src_mac}08004500001c000000003f110100${src_ip}${dst_ip}0035111100080000 -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif3-tx.pcap > received2.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif3-tx.pcap > received2.packets echo $expected > expout AT_CHECK([cat received2.packets], [0], [expout]) @@ -6720,7 +6720,7 @@ trim_zeros() { # ARP packet should be received with Target IP Address set to 192.168.1.254 and # not 8.8.8.8 -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/ls2lp2-tx.pcap | trim_zeros > packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/ls2lp2-tx.pcap | trim_zeros > packets expected="fffffffffffff0000000000208060001080006040001f00000000002c0a80101000000000000c0a801fe" echo $expected > expout AT_CHECK([cat packets], [0], [expout]) @@ -6771,7 +6771,7 @@ OVS_WAIT_UNTIL([test `wc -c < "hv1/snoopvif-tx.pcap"` -ge 50]) trim_zeros() { sed 's/\(00\)\{1,\}$//' } -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros > packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros > packets expected="fffffffffffff0000000000108060001080006040001f00000000001c0a80001000000000000c0a80001" echo $expected > expout expected="fffffffffffff0000000000108060001080006040001f00000000001c0a80002000000000000c0a80002" @@ -6836,7 +6836,7 @@ OVS_WAIT_UNTIL([test `wc -c < "hv1/snoopvif-tx.pcap"` -ge 50]) trim_zeros() { sed 's/\(00\)\{1,\}$//' } -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros > packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros > packets expected="fffffffffffff0000000000108060001080006040001f00000000001c0a80001000000000000c0a80001" echo $expected > expout expected="fffffffffffff0000000000108060001080006040001f00000000001c0a80002000000000000c0a80002" @@ -8245,7 +8245,7 @@ test_dns 1 f00000000001 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data $d # NXT_RESUMEs should be 1. OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets cat 1.expected | cut -c -48 > expout AT_CHECK([cat 1.packets | cut -c -48], [0], [expout]) # Skipping the IPv4 checksum. @@ -8266,7 +8266,7 @@ test_dns 2 f00000000002 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data $d # NXT_RESUMEs should be 2. OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets cat 2.expected | cut -c -48 > expout AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) # Skipping the IPv4 checksum. @@ -8290,7 +8290,7 @@ test_dns 1 f00000000001 f00000000002 $src_ip $dst_ip $dns_reply $dns_req_data # NXT_RESUMEs should be 3. OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets AT_CHECK([cat 1.packets], [0], []) reset_pcap_file hv1-vif1 hv1/vif1 @@ -8312,7 +8312,7 @@ test_dns 2 f00000000002 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data # NXT_RESUMEs should be 3 only. OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets AT_CHECK([cat 2.packets], [0], []) reset_pcap_file hv1-vif1 hv1/vif1 @@ -8333,7 +8333,7 @@ test_dns 2 f00000000002 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data $d # NXT_RESUMEs should be 4. OVS_WAIT_UNTIL([test 4 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets cat 2.expected | cut -c -48 > expout AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) # Skipping the IPv4 checksum. @@ -8355,7 +8355,7 @@ test_dns 2 f00000000002 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data $d # NXT_RESUMEs should be 5. OVS_WAIT_UNTIL([test 5 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets cat 2.expected | cut -c -48 > expout AT_CHECK([cat 2.packets | cut -c -48], [0], [expout]) # Skipping the IPv4 checksum. @@ -8377,7 +8377,7 @@ test_dns 2 f00000000002 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data # NXT_RESUMEs should be 6. OVS_WAIT_UNTIL([test 6 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets AT_CHECK([cat 2.packets], [0], []) reset_pcap_file hv1-vif1 hv1/vif1 @@ -8395,7 +8395,7 @@ test_dns 2 f00000000002 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data # NXT_RESUMEs should be 7. OVS_WAIT_UNTIL([test 7 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets AT_CHECK([cat 2.packets], [0], []) reset_pcap_file hv1-vif1 hv1/vif1 @@ -8415,7 +8415,7 @@ test_dns 1 f00000000001 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data $d # NXT_RESUMEs should be 8. OVS_WAIT_UNTIL([test 8 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets cat 1.expected | cut -c -48 > expout AT_CHECK([cat 1.packets | cut -c -48], [0], [expout]) # Skipping the IPv4 checksum. @@ -8437,7 +8437,7 @@ test_dns6 1 f00000000001 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data $ # NXT_RESUMEs should be 9. OVS_WAIT_UNTIL([test 9 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets # Skipping the UDP checksum. cat 1.expected | cut -c 1-120,125- > expout AT_CHECK([cat 1.packets | cut -c 1-120,125-], [0], [expout]) @@ -8623,7 +8623,7 @@ grep actions=mod_dl_dst:f0:00:00:01:02:04 | wc -l` -eq 1 sleep 1 OVN_CHECK_PACKETS([ext1/vif1-tx.pcap], [ext1-vif1.expected]) - $PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" $active_gw/br-phys_n1-tx.pcap > packets + $PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" $active_gw/br-phys_n1-tx.pcap > packets cat packets | grep $expected > exp # Its possible that $active_gw/br-phys_n1-tx.pcap may have received multiple # garp packets. So consider only the first packet. @@ -8632,7 +8632,7 @@ grep actions=mod_dl_dst:f0:00:00:01:02:04 | wc -l` -eq 1 rm -f expout if test $backup_vswitchd_dead != 1; then # Check for backup gw only if vswitchd is alive - $PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" $backup_gw/br-phys_n1-tx.pcap > packets + $PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" $backup_gw/br-phys_n1-tx.pcap > packets AT_CHECK([grep $expected packets | sort], [0], []) fi } @@ -8872,12 +8872,12 @@ grep actions=mod_dl_dst:f0:00:00:01:02:04 | wc -l` -eq 1 as hv1 ovs-appctl netdev-dummy/receive hv1-vif1 $packet OVN_CHECK_PACKETS([ext1/vif1-tx.pcap], [ext1-vif1.expected]) - $PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" $active_gw/br-phys_n1-tx.pcap > packets + $PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" $active_gw/br-phys_n1-tx.pcap > packets cat packets | grep $expected > exp cat packets | grep $exp_gw_ip_garp | head -1 >> exp AT_CHECK([cat exp], [0], [expout]) - $PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" $backup_gw/br-phys_n1-tx.pcap > packets + $PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" $backup_gw/br-phys_n1-tx.pcap > packets AT_CHECK([grep $expected packets | sort], [0], []) } @@ -9302,7 +9302,7 @@ OVS_WAIT_UNTIL([test `wc -c < "hv1/snoopvif-tx.pcap"` -ge 100]) trim_zeros() { sed 's/\(00\)\{1,\}$//' } -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros > packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros > packets expected="fffffffffffff0000000000108060001080006040001f00000000001c0a80001000000000000c0a80001" echo $expected > expout expected="fffffffffffff0000000000108060001080006040001f00000000001c0a80002000000000000c0a80002" @@ -9350,7 +9350,7 @@ trim_zeros() { sed 's/\(00\)\{1,\}$//' } -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros > packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros > packets garp_1="fffffffffffff0000000000308060001080006040001f00000000003c0a80003000000000000c0a80003" echo $garp_1 > expout garp_2="fffffffffffff0000000000408060001080006040001f00000000004c0a80004000000000000c0a80004" @@ -9615,12 +9615,12 @@ ip_packet() { # Check vlan tagged packet on the bridge connecting hv1 and hv2 with the # foo1's mac. -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/br-ex_n2-tx.pcap | ip_packet | uniq > hv1-br-ex_n2 +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/br-ex_n2-tx.pcap | ip_packet | uniq > hv1-br-ex_n2 cat hv1-br-ex_n2.expected > expout AT_CHECK([sort hv1-br-ex_n2], [0], [expout]) # Check expected packet on nexthop interface -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv3/vif1-tx.pcap | grep ${foo1_ip}${dst_ip} | uniq > hv3-vif1 +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv3/vif1-tx.pcap | grep ${foo1_ip}${dst_ip} | uniq > hv3-vif1 cat hv3-vif1.expected > expout AT_CHECK([sort hv3-vif1], [0], [expout]) @@ -9650,11 +9650,11 @@ sent_garp="ffffffffffff0000010102038100000208060001080006040001000001010203c0a80 OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [foo1.expout]) # Wait until we receive atleast 1 packet -OVS_WAIT_UNTIL([test 1=`$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv2/br-ex_n2-tx.pcap | wc -l`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv2/br-ex_n2-tx.pcap | head -1 > packets +OVS_WAIT_UNTIL([test 1=`$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv2/br-ex_n2-tx.pcap | wc -l`]) +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv2/br-ex_n2-tx.pcap | head -1 > packets echo $sent_garp > expout AT_CHECK([cat packets], [0], [expout]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv4/br-ex_n2-tx.pcap > empty +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv4/br-ex_n2-tx.pcap > empty AT_CHECK([cat empty], [0], []) # Make hv4 master @@ -9679,7 +9679,7 @@ OVN_CHECK_PACKETS([hv4/br-ex_n2-tx.pcap], [br-ex_n2.expout]) sleep 2 -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv2/br-ex_n2-tx.pcap > empty +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv2/br-ex_n2-tx.pcap > empty AT_CHECK([cat empty], [0], []) OVN_CLEANUP([hv1],[hv2],[hv3], [hv4]) @@ -9807,7 +9807,7 @@ test_ipv6_ra 1 $src_mac $src_lla $addr_mode 0 $default_prefix_option_config # NXT_RESUME should be 1. OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets cat 1.expected | cut -c -112 > expout AT_CHECK([cat 1.packets | cut -c -112], [0], [expout]) @@ -9838,7 +9838,7 @@ test_ipv6_ra 2 $src_mac $src_lla $addr_mode $mtu $default_prefix_option_config # NXT_RESUME should be 2. OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets cat 2.expected | cut -c -112 > expout AT_CHECK([cat 2.packets | cut -c -112], [0], [expout]) @@ -9868,7 +9868,7 @@ test_ipv6_ra 3 $src_mac $src_lla $addr_mode $mtu $default_prefix_option_config # NXT_RESUME should be 3. OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif3-tx.pcap > 3.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif3-tx.pcap > 3.packets cat 3.expected | cut -c -112 > expout AT_CHECK([cat 3.packets | cut -c -112], [0], [expout]) @@ -9898,7 +9898,7 @@ test_ipv6_ra 1 $src_mac $src_lla $addr_mode $mtu $default_prefix_option_config # NXT_RESUME should be 4. OVS_WAIT_UNTIL([test 4 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets cat 1.expected | cut -c -112 > expout AT_CHECK([cat 1.packets | cut -c -112], [0], [expout]) @@ -9928,7 +9928,7 @@ test_ipv6_ra 1 $src_mac $src_lla $addr_mode $mtu $default_prefix_option_config # NXT_RESUME should be 4 only. OVS_WAIT_UNTIL([test 4 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets AT_CHECK([cat 1.packets], [0], []) OVN_CLEANUP([hv1]) @@ -10790,15 +10790,15 @@ only_broadcast_from_lrp1() { garp="fffffffffffff0000000000108060001080006040001f00000000001c0a80064000000000000c0a80064" echo $garp > expout -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv1_snoop_tx +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv1_snoop_tx echo "packets on hv1-snoopvif:" cat hv1_snoop_tx AT_CHECK([sort hv1_snoop_tx], [0], [expout]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv2/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv2_br_phys_tx +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv2/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv2_br_phys_tx echo "packets on hv2 br-phys tx" cat hv2_br_phys_tx AT_CHECK([grep $garp hv2_br_phys_tx | sort], [0], [expout]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv3/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv3_br_phys_tx +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv3/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv3_br_phys_tx echo "packets on hv3 br-phys tx" cat hv3_br_phys_tx AT_CHECK([grep $garp hv3_br_phys_tx | sort], [0], []) @@ -10824,11 +10824,11 @@ trim_zeros() { sed 's/\(00\)\{1,\}$//' } -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv1_snoopvif_tx +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv1_snoopvif_tx AT_CHECK([sort hv1_snoopvif_tx], [0], [expout]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv3/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv3_br_phys_tx +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv3/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv3_br_phys_tx AT_CHECK([grep $garp hv3_br_phys_tx | sort], [0], [expout]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv2/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv2_br_phys_tx +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv2/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv2_br_phys_tx AT_CHECK([grep $garp hv2_br_phys_tx | sort], [0], []) # change localnet port tag. @@ -10869,11 +10869,11 @@ trim_zeros() { garp="fffffffffffff00000000001810007de08060001080006040001f00000000001c0a80064000000000000c0a80064" echo $garp > expout -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv1_snoopvif_tx +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/snoopvif-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv1_snoopvif_tx AT_CHECK([sort hv1_snoopvif_tx], [0], [expout]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv3/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv3_br_phys_tx +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv3/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv3_br_phys_tx AT_CHECK([grep $garp hv3_br_phys_tx | sort], [0], [expout]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv2/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv2_br_phys_tx +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv2/br-phys_n1-tx.pcap | trim_zeros | only_broadcast_from_lrp1 | uniq > hv2_br_phys_tx AT_CHECK([grep $garp hv2_br_phys_tx | sort], [0], []) OVN_CLEANUP([hv1],[hv2],[hv3]) @@ -11086,9 +11086,9 @@ $mcast_node_ip $nd_target OVS_WAIT_WHILE([test 24 = $(wc -c hv1/br-phys_n1-tx.pcap | cut -d " " -f1)]) OVS_WAIT_WHILE([test 24 = $(wc -c hv1/br-phys-tx.pcap | cut -d " " -f1)]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/br-phys_n1-tx.pcap | \ +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/br-phys_n1-tx.pcap | \ trim_zeros > 1.packets -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/br-phys-tx.pcap | \ +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/br-phys-tx.pcap | \ trim_zeros > 2.packets cat ipv6_ns.expected | cut -c -112 > expout @@ -11119,9 +11119,9 @@ $mcast_node_ip $nd_target OVS_WAIT_WHILE([test 24 = $(wc -c hv1/br-phys_n1-tx.pcap | cut -d " " -f1)]) OVS_WAIT_WHILE([test 24 = $(wc -c hv1/br-phys-tx.pcap | cut -d " " -f1)]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/br-phys_n1-tx.pcap | \ +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/br-phys_n1-tx.pcap | \ trim_zeros > 1.packets -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/br-phys-tx.pcap | \ +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/br-phys-tx.pcap | \ trim_zeros > 2.packets cat ipv6_ns.expected | cut -c -112 > expout @@ -11366,7 +11366,7 @@ ra_test() { for i in hv1 hv2 ; do OVS_WAIT_WHILE([test 24 = $(wc -c $i/vif1-tx.pcap | cut -d " " -f1)]) - $PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" $i/vif1-tx.pcap > packets + $PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" $i/vif1-tx.pcap > packets cat expected | cut -c -112 > expout AT_CHECK([cat packets | cut -c -112], [0], [expout]) @@ -12217,7 +12217,7 @@ dip=`ip_to_hex 10 0 0 6` test_ip 1 f00000000001 f00000000002 $sip $dip 2 cat 2.expected > expout -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets AT_CHECK([cat 2.packets], [0], [expout]) # There should be total of 12 flows present with conjunction action and 2 flows @@ -12256,7 +12256,7 @@ sip=`ip_to_hex 10 0 0 4` dip=`ip_to_hex 10 0 0 7` test_ip 1 f00000000001 f00000000002 $sip $dip -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif2-tx.pcap > 2.packets AT_CHECK([cat 2.packets], [0], []) AT_CLEANUP @@ -12973,7 +12973,7 @@ OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor0_hv1.log | grep -c NXT_RESUME`]) # NXT_RESUMEs should be 0 in hv2. OVS_WAIT_UNTIL([test 0 = `cat ofctl_monitor0_hv2.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/ext1-tx.pcap > ext1_v4.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/ext1-tx.pcap > ext1_v4.packets cat ext1_v4.expected | cut -c -48 > expout AT_CHECK([cat ext1_v4.packets | cut -c -48], [0], [expout]) # Skipping the IPv4 checksum. @@ -13000,7 +13000,7 @@ OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor0_hv1.log | grep -c NXT_RESUME`]) # NXT_RESUMEs should be 0 in hv2. OVS_WAIT_UNTIL([test 0 = `cat ofctl_monitor0_hv2.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/ext1-tx.pcap | \ +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/ext1-tx.pcap | \ sort > ext1_v6.packets cat ext1_v6.expected | cut -c -120 > expout AT_CHECK([cat ext1_v6.packets | cut -c -120], [0], [expout]) @@ -13071,7 +13071,7 @@ OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor0_hv1.log | grep -c NXT_RESUME`]) # NXT_RESUMEs should be 1 in hv2. OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor0_hv2.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/ext1-tx.pcap > ext1_v4.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/ext1-tx.pcap > ext1_v4.packets cat ext1_v4.expected | cut -c -48 > expout AT_CHECK([cat ext1_v4.packets | cut -c -48], [0], [expout]) # Skipping the IPv4 checksum. @@ -13097,7 +13097,7 @@ OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor0_hv1.log | grep -c NXT_RESUME`]) # NXT_RESUMEs should be 2 in hv2. OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor0_hv2.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/ext1-tx.pcap | \ +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/ext1-tx.pcap | \ sort > ext1_v6.packets cat ext1_v6.expected | cut -c -120 > expout AT_CHECK([cat ext1_v6.packets | cut -c -120], [0], [expout]) @@ -13131,11 +13131,11 @@ arp_request=ffffffffffff${ext1_mac}08060001080006040001${ext1_mac}${ext1_ip}0000 as hv1 ovs-appctl netdev-dummy/receive hv1-ext1 $arp_request expected_response=${src_mac}${router_mac}08060001080006040002${router_mac}${router_ip}${ext1_mac}${ext1_ip} echo $expected_response > expout -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/ext1-tx.pcap > ext1_arp_resp +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/ext1-tx.pcap > ext1_arp_resp AT_CHECK([cat ext1_arp_resp], [0], [expout]) # Verify that the response came from hv2 -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv2/br-phys_n1-tx.pcap > ext1_arp_resp +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv2/br-phys_n1-tx.pcap > ext1_arp_resp AT_CHECK([cat ext1_arp_resp], [0], [expout]) # Now add 3 ha chassis to the ha chassis group @@ -13181,7 +13181,7 @@ OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor0_hv1.log | grep -c NXT_RESUME`]) # NXT_RESUMEs should be 2 in hv2. OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor0_hv2.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/ext1-tx.pcap > ext1_v4.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/ext1-tx.pcap > ext1_v4.packets cat ext1_v4.expected | cut -c -48 > expout AT_CHECK([cat ext1_v4.packets | cut -c -48], [0], [expout]) # Skipping the IPv4 checksum. @@ -13208,7 +13208,7 @@ OVS_WAIT_UNTIL([test 4 = `cat ofctl_monitor0_hv1.log | grep -c NXT_RESUME`]) # NXT_RESUMEs should be 2 in hv2. OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor0_hv2.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/ext1-tx.pcap | \ +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/ext1-tx.pcap | \ sort > ext1_v6.packets cat ext1_v6.expected | cut -c -120 > expout AT_CHECK([cat ext1_v6.packets | cut -c -120], [0], [expout]) @@ -13264,7 +13264,7 @@ OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor0_hv2.log | grep -c NXT_RESUME`]) # NXT_RESUMEs should be 1 in hv3. OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor0_hv3.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/ext1-tx.pcap > ext1_v4.packets +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/ext1-tx.pcap > ext1_v4.packets cat ext1_v4.expected | cut -c -48 > expout AT_CHECK([cat ext1_v4.packets | cut -c -48], [0], [expout]) # Skipping the IPv4 checksum. @@ -13294,7 +13294,7 @@ OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor0_hv2.log | grep -c NXT_RESUME`]) # NXT_RESUMEs should be 2 in hv3. OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor0_hv3.log | grep -c NXT_RESUME`]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/ext1-tx.pcap | \ +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/ext1-tx.pcap | \ sort > ext1_v6.packets cat ext1_v6.expected | cut -c -120 > expout AT_CHECK([cat ext1_v6.packets | cut -c -120], [0], [expout]) @@ -13665,14 +13665,14 @@ test_ip_packet_larger() { if test $icmp_pmtu_reply_expected = 0; then OVN_CHECK_PACKETS([hv1/br-phys_n1-tx.pcap], [br_phys_n1.expected]) - $PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > pkts + $PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > pkts # hv1/vif1-tx.pcap can receive the GARP packet generated by ovn-controller # for the gateway router port. So ignore this packet. cat pkts | grep -v $gw_ip_garp > packets AT_CHECK([cat packets], [0], []) else OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [hv1-vif1.expected]) - $PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/br-phys_n1-tx.pcap > \ + $PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/br-phys_n1-tx.pcap > \ pkts # hv1/br-phys_n1-tx.pcap can receive the GARP packet generated by ovn-controller # for the gateway router port. So ignore this packet. @@ -13947,8 +13947,8 @@ OVS_WAIT_UNTIL([test `ovn-sbctl find mac_binding logical_port="lr1-pub" ip="172. # Check that the GARPs went also to the external physical network # Wait until at least 4 packets have arrived and copy them to a separate file as # more GARPs are expected in the capture in order to avoid race conditions. -OVS_WAIT_UNTIL([test `$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/br-phys-tx.pcap | wc -l` -gt 4]) -$PYTHON "$top_srcdir/ovs/utilities/ovs-pcap.in" hv1/br-phys-tx.pcap | head -n4 > hv1/br-phys-tx4.pcap +OVS_WAIT_UNTIL([test `$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/br-phys-tx.pcap | wc -l` -gt 4]) +$PYTHON "$ovs_srcdir/utilities/ovs-pcap.in" hv1/br-phys-tx.pcap | head -n4 > hv1/br-phys-tx4.pcap # GARP for lp0 172.24.4.100 on lr0-pub MAC (f0:00:00:00:00:01) echo "fffffffffffff0000000000108060001080006040001f00000000001ac180464000000000000ac180464" > expout diff --git a/tests/ovsdb-macros.at b/tests/ovsdb-macros.at index 638894794..83e3df750 100644 --- a/tests/ovsdb-macros.at +++ b/tests/ovsdb-macros.at @@ -3,7 +3,7 @@ dnl dnl Creates an empty database named $1. m4_define([OVSDB_INIT], [AT_CHECK( - [ovsdb-tool create $1 $abs_top_srcdir/vswitchd/vswitch.ovsschema], + [ovsdb-tool create $1 $ovs_srcdir/vswitchd/vswitch.ovsschema], [0], [stdout], [ignore]) AT_CHECK( [[ovsdb-tool transact $1 \ diff --git a/tutorial/automake.mk b/tutorial/automake.mk index b7ea10c98..13b3bee05 100644 --- a/tutorial/automake.mk +++ b/tutorial/automake.mk @@ -9,4 +9,4 @@ EXTRA_DIST += \ tutorial/ovn-setup.sh sandbox: all cd $(srcdir)/tutorial && MAKE=$(MAKE) HAVE_OPENSSL=$(HAVE_OPENSSL) \ - ./ovs-sandbox -b $(abs_builddir) $(SANDBOXFLAGS) + ./ovs-sandbox -b $(abs_builddir) --ovs-src $(ovs_srcdir) --ovs-build $(ovs_builddir) $(SANDBOXFLAGS) diff --git a/tutorial/ovs-sandbox b/tutorial/ovs-sandbox index 7546d27ca..a19dea2f1 100755 --- a/tutorial/ovs-sandbox +++ b/tutorial/ovs-sandbox @@ -63,7 +63,9 @@ gdb_ovn_controller_ex=false gdb_ovn_controller_vtep=false gdb_ovn_controller_vtep_ex=false builddir= +ovsbuilddir= srcdir= +ovssrcdir= schema= installed=false built=false @@ -111,9 +113,11 @@ If you run ovs-sandbox from an OVS build directory, it uses the OVS that you built. Otherwise, if you have an installed Open vSwitch, it uses the installed version. -These options force ovs-sandbox to use a particular OVS build: - -b, --builddir=DIR specify Open vSwitch build directory - -s, --srcdir=DIR specify Open vSwitch source directory +These options force ovs-sandbox to use a particular OVN and OVS build: + -b, --builddir=DIR specify OVN build directory + -s, --srcdir=DIR specify OVN source directory + --ovs-build, --ovsbuilddir=DIR specify Open vSwitch build directory + --ovs-src, --ovssrcdir=DIR specify Open vSwitch source directory These options force ovs-sandbox to use an installed Open vSwitch: -i, --installed use installed Open vSwitch @@ -150,6 +154,18 @@ EOF prev=builddir built=: ;; + --ovs-build*=*) + ovsbuilddir=$optarg + ;; + --ovs-build*) + prev=ovsbuilddir + ;; + --ovs-src*=*) + ovssrcdir=$optarg + ;; + --ovs-src*) + prev=ovssrcdir + ;; --sr*=*) srcdir=$optarg built=false @@ -278,8 +294,8 @@ else fi if $built; then - if test ! -e "$builddir"/ovs/vswitchd/ovs-vswitchd; then - echo "$builddir does not appear to be an OVS build directory" >&2 + if test ! -e "$builddir"/controller/ovn-controller; then + echo "$builddir does not appear to be an OVN build directory" >&2 exit 1 fi builddir=`cd $builddir && pwd` @@ -295,7 +311,7 @@ if $built; then /*) ;; *) srcdir=`pwd`/$srcdir ;; esac - schema=$srcdir/ovs/vswitchd/vswitch.ovsschema + schema=$ovssrcdir/vswitchd/vswitch.ovsschema if test ! -e "$schema"; then echo >&2 'source directory not found, please use --srcdir' exit 1 @@ -311,7 +327,7 @@ if $built; then echo >&2 'source directory not found, please use --srcdir' exit 1 fi - vtep_schema=$srcdir/ovs/vtep/vtep.ovsschema + vtep_schema=$ovssrcdir/vtep/vtep.ovsschema if test ! -e "$vtep_schema"; then echo >&2 'source directory not found, please use --srcdir' exit 1 @@ -319,14 +335,12 @@ if $built; then fi # Put built tools early in $PATH. - if test ! -e $builddir/ovs/vswitchd/ovs-vswitchd; then + if test ! -e $ovsbuilddir/vswitchd/ovs-vswitchd; then echo >&2 'build not found, please change set $builddir or change directory' exit 1 fi - PATH=$builddir/ovs/ovsdb:$builddir/ovs/vswitchd:$builddir/ovs/utilities:$builddir/ovs/vtep:$PATH - if $ovn; then - PATH=$builddir/controller:$builddir/controller-vtep:$builddir/northd:$builddir/utilities:$PATH - fi + PATH=$ovsbuilddir/ovsdb:$ovsbuilddir/vswitchd:$ovsbuilddir/utilities:$ovsbuilddir/vtep:$PATH + PATH=$builddir/controller:$builddir/controller-vtep:$builddir/northd:$builddir/utilities:$PATH export PATH else case $schema in @@ -347,10 +361,8 @@ else echo "can't find vswitch.ovsschema, please specify --schema" >&2 exit 1 fi - if $ovn; then - echo "running with ovn is only supported from the build dir." >&2 - exit 1 - fi + echo "running with ovn is only supported from the build dir." >&2 + exit 1 fi # Create sandbox. @@ -378,109 +390,108 @@ trap 'kill `cat "$sandbox"/*.pid`' 0 1 2 3 13 14 15 touch "$sandbox"/.conf.db.~lock~ run ovsdb-tool create conf.db "$schema" ovsdb_server_args= -if $ovn; then - touch "$sandbox"/.ovnnb.db.~lock~ - run ovsdb-tool create ovnnb.db "$ovnnb_schema" - run ovsdb-tool create vtep.db "$vtep_schema" - ovsdb_server_args="vtep.db conf.db" - ovsdb_nb_server_args="ovnnb.db" - - if [ "$HAVE_OPENSSL" = yes ]; then - OVS_PKI="run ovs-pki --dir=$sandbox/pki --log=$sandbox/ovs-pki.log" - $OVS_PKI init - $OVS_PKI req+sign ovnsb switch - $OVS_PKI req+sign ovnnb switch - for i in $(seq $n_controllers); do - $OVS_PKI -u req+sign chassis-$i switch - done - fi + +touch "$sandbox"/.ovnnb.db.~lock~ +run ovsdb-tool create ovnnb.db "$ovnnb_schema" +run ovsdb-tool create vtep.db "$vtep_schema" +ovsdb_server_args="vtep.db conf.db" +ovsdb_nb_server_args="ovnnb.db" + +if [ "$HAVE_OPENSSL" = yes ]; then + OVS_PKI="run ovs-pki --dir=$sandbox/pki --log=$sandbox/ovs-pki.log" + $OVS_PKI init + $OVS_PKI req+sign ovnsb switch + $OVS_PKI req+sign ovnnb switch + for i in $(seq $n_controllers); do + $OVS_PKI -u req+sign chassis-$i switch + done fi + rungdb $gdb_ovsdb $gdb_ovsdb_ex ovsdb-server --detach --no-chdir --pidfile -vconsole:off --log-file -vsyslog:off \ --remote=punix:"$sandbox"/db.sock \ --remote=db:Open_vSwitch,Open_vSwitch,manager_options \ $ovsdb_server_args -if $ovn; then - ovn_start_db() { - local db=$1 model=$2 servers=$3 schema=$4 - local DB=$(echo $db | tr a-z A-Z) - local schema_name=$(ovsdb-tool schema-name $schema) - - case $model in - standalone | backup) ;; - clustered) - case $servers in - [1-9] | [1-9][0-9]) ;; - *) echo "${db}db servers must be between 1 and 99" >&2 - exit 1 - ;; - esac - ;; - *) - echo "unknown ${db}db model \"$model\"" >&2 - exit 1 - ;; - esac - - ovn_start_ovsdb_server() { - local i=$1; shift - rungdb $gdb_ovsdb $gdb_ovsdb_ex ovsdb-server --detach --no-chdir \ - --pidfile=$db$i.pid -vconsole:off --log-file=$db$i.log \ - -vsyslog:off \ - --remote=db:$schema_name,${DB}_Global,connections \ - --private-key=db:$schema_name,SSL,private_key \ - --certificate=db:$schema_name,SSL,certificate \ - --ca-cert=db:$schema_name,SSL,ca_cert \ - --ssl-protocols=db:$schema_name,SSL,ssl_protocols \ - --ssl-ciphers=db:$schema_name,SSL,ssl_ciphers \ - --unixctl=${db}$i --remote=punix:$db$i.ovsdb ${db}$i.db "$@" - } - - case $model in - standalone) - run ovsdb-tool create ${db}1.db "$schema" - ovn_start_ovsdb_server 1 - remote=unix:${db}1.ovsdb - ;; - backup) - for i in 1 2; do - run ovsdb-tool create $db$i.db "$schema" - done - ovn_start_ovsdb_server 1 - ovn_start_ovsdb_server 2 --sync-from=unix:${db}1.ovsdb - remote=unix:${db}1.ovsdb - backup_note="$backup_note + +ovn_start_db() { + local db=$1 model=$2 servers=$3 schema=$4 + local DB=$(echo $db | tr a-z A-Z) + local schema_name=$(ovsdb-tool schema-name $schema) + + case $model in + standalone | backup) ;; + clustered) + case $servers in + [1-9] | [1-9][0-9]) ;; + *) echo "${db}db servers must be between 1 and 99" >&2 + exit 1 + ;; + esac + ;; + *) + echo "unknown ${db}db model \"$model\"" >&2 + exit 1 + ;; + esac + + ovn_start_ovsdb_server() { + local i=$1; shift + rungdb $gdb_ovsdb $gdb_ovsdb_ex ovsdb-server --detach --no-chdir \ + --pidfile=$db$i.pid -vconsole:off --log-file=$db$i.log \ + -vsyslog:off \ + --remote=db:$schema_name,${DB}_Global,connections \ + --private-key=db:$schema_name,SSL,private_key \ + --certificate=db:$schema_name,SSL,certificate \ + --ca-cert=db:$schema_name,SSL,ca_cert \ + --ssl-protocols=db:$schema_name,SSL,ssl_protocols \ + --ssl-ciphers=db:$schema_name,SSL,ssl_ciphers \ + --unixctl=${db}$i --remote=punix:$db$i.ovsdb ${db}$i.db "$@" + } + + case $model in + standalone) + run ovsdb-tool create ${db}1.db "$schema" + ovn_start_ovsdb_server 1 + remote=unix:${db}1.ovsdb + ;; + backup) + for i in 1 2; do + run ovsdb-tool create $db$i.db "$schema" + done + ovn_start_ovsdb_server 1 + ovn_start_ovsdb_server 2 --sync-from=unix:${db}1.ovsdb + remote=unix:${db}1.ovsdb + backup_note="$backup_note The backup server of OVN $DB can be accessed by: * ovn-${db}ctl --db=unix:`pwd`/sandbox/${db}2.ovsdb * ovs-appctl -t `pwd`/sandbox/${db}2 The backup database file is sandbox/${db}2.db " - ;; - clustered) - for i in $(seq $servers); do - if test $i = 1; then - run ovsdb-tool create-cluster ${db}1.db "$schema" unix:${db}1.raft; - else - run ovsdb-tool join-cluster $db$i.db $schema_name unix:$db$i.raft unix:${db}1.raft - fi - ovn_start_ovsdb_server $i - done - remote=unix:${db}1.ovsdb - for i in `seq 2 $servers`; do - remote=$remote,unix:$db$i.ovsdb - done - for i in $(seq $servers); do - run ovsdb-client wait unix:$db$i.ovsdb $schema_name connected - done - ;; - esac - eval OVN_${DB}_DB=\$remote - eval export OVN_${DB}_DB - } + ;; + clustered) + for i in $(seq $servers); do + if test $i = 1; then + run ovsdb-tool create-cluster ${db}1.db "$schema" unix:${db}1.raft; + else + run ovsdb-tool join-cluster $db$i.db $schema_name unix:$db$i.raft unix:${db}1.raft + fi + ovn_start_ovsdb_server $i + done + remote=unix:${db}1.ovsdb + for i in `seq 2 $servers`; do + remote=$remote,unix:$db$i.ovsdb + done + for i in $(seq $servers); do + run ovsdb-client wait unix:$db$i.ovsdb $schema_name connected + done + ;; + esac + eval OVN_${DB}_DB=\$remote + eval export OVN_${DB}_DB +} - backup_note= - ovn_start_db nb "$nbdb_model" "$nbdb_servers" "$ovnnb_schema" - ovn_start_db sb "$sbdb_model" "$sbdb_servers" "$ovnsb_schema" -fi +backup_note= +ovn_start_db nb "$nbdb_model" "$nbdb_servers" "$ovnnb_schema" +ovn_start_db sb "$sbdb_model" "$sbdb_servers" "$ovnsb_schema" #Add a small delay to allow ovsdb-server to launch. sleep 0.1 @@ -501,49 +512,47 @@ run ovs-vsctl --no-wait -- init rungdb $gdb_vswitchd $gdb_vswitchd_ex ovs-vswitchd --detach --no-chdir --pidfile -vconsole:off --log-file -vsyslog:off \ --enable-dummy=$dummy -vvconn -vnetdev_dummy -if $ovn; then - ovn-nbctl init - ovn-sbctl init - - ovs-vsctl set open . external-ids:system-id=chassis-1 - ovs-vsctl set open . external-ids:hostname=sandbox - ovs-vsctl set open . external-ids:ovn-encap-type=geneve - ovs-vsctl set open . external-ids:ovn-encap-ip=127.0.0.1 - - if [ "$HAVE_OPENSSL" = yes ]; then - ovn-nbctl set-ssl $sandbox/ovnnb-privkey.pem $sandbox/ovnnb-cert.pem $sandbox/pki/switchca/cacert.pem - ovn-nbctl set-connection pssl:6641 - ovn-sbctl set-ssl $sandbox/ovnsb-privkey.pem $sandbox/ovnsb-cert.pem $sandbox/pki/switchca/cacert.pem - if $ovn_rbac; then - ovn-sbctl set-connection role=ovn-controller pssl:6642 - else - ovn-sbctl set-connection pssl:6642 - fi - ovs-vsctl set open . external-ids:ovn-remote=ssl:127.0.0.1:6642 - OVN_CTRLR_PKI="-p $sandbox/chassis-1-privkey.pem -c $sandbox/chassis-1-cert.pem -C $sandbox/pki/switchca/cacert.pem" +ovn-nbctl init +ovn-sbctl init + +ovs-vsctl set open . external-ids:system-id=chassis-1 +ovs-vsctl set open . external-ids:hostname=sandbox +ovs-vsctl set open . external-ids:ovn-encap-type=geneve +ovs-vsctl set open . external-ids:ovn-encap-ip=127.0.0.1 + +if [ "$HAVE_OPENSSL" = yes ]; then + ovn-nbctl set-ssl $sandbox/ovnnb-privkey.pem $sandbox/ovnnb-cert.pem $sandbox/pki/switchca/cacert.pem + ovn-nbctl set-connection pssl:6641 + ovn-sbctl set-ssl $sandbox/ovnsb-privkey.pem $sandbox/ovnsb-cert.pem $sandbox/pki/switchca/cacert.pem + if $ovn_rbac; then + ovn-sbctl set-connection role=ovn-controller pssl:6642 else - ovs-vsctl set open . external-ids:ovn-remote=$OVN_SB_DB - OVN_CTRLR_PKI="" + ovn-sbctl set-connection pssl:6642 fi - for i in $(seq $n_northds); do - if [ $i -eq 1 ]; then inst=""; else inst=$i; fi - rungdb $gdb_ovn_northd $gdb_ovn_northd_ex ovn-northd --detach \ - --no-chdir --pidfile=ovn-northd${inst}.pid -vconsole:off \ - --log-file=ovn-northd${inst}.log -vsyslog:off \ - --ovnsb-db="$OVN_SB_DB" --ovnnb-db="$OVN_NB_DB" - done - for i in $(seq $n_controllers); do - if [ $i -eq 1 ]; then inst=""; else inst=$i; fi - rungdb $gdb_ovn_controller $gdb_ovn_controller_ex ovn-controller \ - $OVN_CTRLR_PKI --detach --no-chdir -vsyslog:off \ - --log-file=ovn-controller${inst}.log \ - --pidfile=ovn-controller${inst}.pid -vconsole:off - done - rungdb $gdb_ovn_controller_vtep $gdb_ovn_controller_vtep_ex \ - ovn-controller-vtep --detach --no-chdir --pidfile -vconsole:off \ - $OVN_CTRLR_PKI --log-file -vsyslog:off \ - --ovnsb-db=unix:"$sandbox"/ovnsb_db.sock + ovs-vsctl set open . external-ids:ovn-remote=ssl:127.0.0.1:6642 + OVN_CTRLR_PKI="-p $sandbox/chassis-1-privkey.pem -c $sandbox/chassis-1-cert.pem -C $sandbox/pki/switchca/cacert.pem" +else + ovs-vsctl set open . external-ids:ovn-remote=$OVN_SB_DB + OVN_CTRLR_PKI="" fi +for i in $(seq $n_northds); do + if [ $i -eq 1 ]; then inst=""; else inst=$i; fi + rungdb $gdb_ovn_northd $gdb_ovn_northd_ex ovn-northd --detach \ + --no-chdir --pidfile=ovn-northd${inst}.pid -vconsole:off \ + --log-file=ovn-northd${inst}.log -vsyslog:off \ + --ovnsb-db="$OVN_SB_DB" --ovnnb-db="$OVN_NB_DB" +done +for i in $(seq $n_controllers); do + if [ $i -eq 1 ]; then inst=""; else inst=$i; fi + rungdb $gdb_ovn_controller $gdb_ovn_controller_ex ovn-controller \ + $OVN_CTRLR_PKI --detach --no-chdir -vsyslog:off \ + --log-file=ovn-controller${inst}.log \ + --pidfile=ovn-controller${inst}.pid -vconsole:off +done +rungdb $gdb_ovn_controller_vtep $gdb_ovn_controller_vtep_ex \ + ovn-controller-vtep --detach --no-chdir --pidfile -vconsole:off \ + $OVN_CTRLR_PKI --log-file -vsyslog:off \ + --ovnsb-db=unix:"$sandbox"/ovnsb_db.sock cat < X-Patchwork-Id: 1146492 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 467J8S0rtVz9sDQ for ; Wed, 14 Aug 2019 02:29:44 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 936F3D9E; Tue, 13 Aug 2019 16:28:25 +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 76EC7D9B for ; Tue, 13 Aug 2019 16:28:24 +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 E68678A3 for ; Tue, 13 Aug 2019 16:28:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 88D9030C1F93 for ; Tue, 13 Aug 2019 16:28:21 +0000 (UTC) Received: from nusiddiq.redhat (ovpn-116-27.sin2.redhat.com [10.67.116.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3671282E24; Tue, 13 Aug 2019 16:28:18 +0000 (UTC) From: nusiddiq@redhat.com To: dev@openvswitch.org Date: Tue, 13 Aug 2019 21:58:03 +0530 Message-Id: <20190813162803.16427-1-nusiddiq@redhat.com> In-Reply-To: <20190813162629.15983-1-nusiddiq@redhat.com> References: <20190813162629.15983-1-nusiddiq@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 13 Aug 2019 16:28:21 +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 ovn 3/4] Fix "make rpm-fedora" 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: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: Numan Siddique "make rpm-fedora" is broken and this patch fixes it. Previous patch in this series supported building OVN from external OVS sources. Before running "make rpm-fedora", it is expected that the developer has run "make dist" in the OVS source folder to generate the openvswitch-%{version}.tar.gz. This tar file is copied to rpmbuild/SOURCES. The rpm spec file extracts this tar file (using %autosetup in prep step) and compiles it before compiling OVN. Signed-off-by: Numan Siddique --- Documentation/intro/install/fedora.rst | 13 +++- rhel/automake.mk | 2 + rhel/etc_logrotate.d_ovn | 22 ++++++ rhel/ovn-fedora.spec.in | 78 +++++++++++++------ ...systemd_system_ovn-controller-vtep.service | 13 ++-- ..._lib_systemd_system_ovn-controller.service | 7 +- .../usr_lib_systemd_system_ovn-northd.service | 12 ++- utilities/ovn-ctl | 3 +- 8 files changed, 105 insertions(+), 45 deletions(-) create mode 100644 rhel/etc_logrotate.d_ovn diff --git a/Documentation/intro/install/fedora.rst b/Documentation/intro/install/fedora.rst index c8ea6ec01..4cf9fbdb6 100644 --- a/Documentation/intro/install/fedora.rst +++ b/Documentation/intro/install/fedora.rst @@ -96,8 +96,15 @@ Building OVN RPMs ~~~~~~~~~~~~~~~ -To build OVN RPMs, execute the following from the directory -in which `./configure` was executed: +To build OVN RPMs, first generate openvswitch source tar bar in +your openvwitch source directory by running + +:: + + $make dist + +And then execute the following in the OVN source directory +(in which `./configure` was executed): :: @@ -108,7 +115,7 @@ This will create the RPMs `ovn`, `ovn-central`, `ovn-host`, `ovn-vtep`, ``ovn-host-debuginfo`` and ```ovn-vtep-debuginfo```. -You can also have the above commands automatically run the Open vSwitch unit +You can also have the above commands automatically run the OVN unit tests. This can take several minutes. :: diff --git a/rhel/automake.mk b/rhel/automake.mk index be7c275a7..39e216b01 100644 --- a/rhel/automake.mk +++ b/rhel/automake.mk @@ -8,6 +8,7 @@ EXTRA_DIST += \ rhel/README.RHEL.rst \ rhel/automake.mk \ + rhel/etc_logrotate.d_ovn \ rhel/ovn-fedora.spec \ rhel/ovn-fedora.spec.in \ rhel/usr_lib_systemd_system_ovn-controller.service \ @@ -27,6 +28,7 @@ RPMBUILD_OPT ?= --without check rpm-fedora: dist $(srcdir)/rhel/ovn-fedora.spec ${MKDIR_P} ${RPMBUILD_TOP}/SOURCES cp ${DIST_ARCHIVES} ${RPMBUILD_TOP}/SOURCES + cp $(ovs_builddir)/openvswitch-$(VERSION).tar.gz ${RPMBUILD_TOP}/SOURCES rpmbuild ${RPMBUILD_OPT} \ -D "_topdir ${RPMBUILD_TOP}" \ -ba $(srcdir)/rhel/ovn-fedora.spec diff --git a/rhel/etc_logrotate.d_ovn b/rhel/etc_logrotate.d_ovn new file mode 100644 index 000000000..a351ec303 --- /dev/null +++ b/rhel/etc_logrotate.d_ovn @@ -0,0 +1,22 @@ +# Copyright (C) 2019 Red Hat, Inc. +# +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. This file is offered as-is, +# without warranty of any kind. + +/var/log/ovn/*.log { + su root root + daily + compress + sharedscripts + missingok + postrotate + # Tell OVN daemons to reopen their log files + if [ -d /var/run/ovn ]; then + for ctl in /var/run/ovn/*.ctl; do + ovs-appctl -t "$ctl" vlog/reopen 2>/dev/null || : + done + fi + endscript +} diff --git a/rhel/ovn-fedora.spec.in b/rhel/ovn-fedora.spec.in index 2234e949f..cbca87511 100644 --- a/rhel/ovn-fedora.spec.in +++ b/rhel/ovn-fedora.spec.in @@ -1,6 +1,6 @@ # Spec file for Open Virtual Network (OVN). -# Copyright (C) 2018 Red Hat, Inc. +# Copyright (C) 2018,2019 Red Hat, Inc. # # Copying and distribution of this file, with or without modification, # are permitted in any medium without royalty provided the copyright @@ -48,11 +48,15 @@ Version: @VERSION@ Obsoletes: openvswitch-ovn-common < %{?epoch:%{epoch}:}%{version}-%{release} Provides: openvswitch-ovn-common = %{?epoch:%{epoch}:}%{version}-%{release} +%define ovsver %{version} +%define ovsdir openvswitch-%{ovsver} + # Nearly all of openvswitch is ASL 2.0. The bugtool is LGPLv2+, and the # lib/sflow*.[ch] files are SISSL License: ASL 2.0 and LGPLv2+ and SISSL Release: 1%{?dist} -Source: http://openvswitch.org/releases/openvswitch-%{version}.tar.gz +Source: http://openvswitch.org/releases/ovn-%{version}.tar.gz +Source10: http://openvswitch.org/releases/openvswitch-%{ovsver}.tar.gz BuildRequires: gcc gcc-c++ BuildRequires: autoconf automake libtool @@ -131,10 +135,37 @@ Provides: openvswitch-ovn-docker = %{?epoch:%{epoch}:}%{version}-%{release} Docker network plugins for OVN. %prep -%setup -n openvswitch-%{version} +%autosetup -n ovn-%{version} -a 10 -p 1 + %build +./boot.sh + +# Build openvswitch first +cd openvswitch-%{ovsver} +./boot.sh %configure \ + --with-ovs-source=ovs \ +%if %{with libcapng} + --enable-libcapng \ +%else + --disable-libcapng \ +%endif + --enable-ssl \ + --with-pkidir=%{_sharedstatedir}/openvswitch/pki \ +%if 0%{?fedora} > 22 || %{with build_python3} + PYTHON3=%{__python3} \ + PYTHON=%{__python2} +%else + PYTHON=%{__python} +%endif + +make %{?_smp_mflags} +cd - + +# Build OVN. +%configure \ + --with-ovs-source=$PWD/openvswitch-%{ovsver} \ %if %{with libcapng} --enable-libcapng \ %else @@ -163,7 +194,7 @@ done rm -rf $RPM_BUILD_ROOT/%{_datadir}/openvswitch/python/ -install -d -m 0755 $RPM_BUILD_ROOT/%{_sharedstatedir}/openvswitch +install -d -m 0755 $RPM_BUILD_ROOT/%{_sharedstatedir}/ovn install -d $RPM_BUILD_ROOT%{_prefix}/lib/firewalld/services/ install -p -m 0644 rhel/usr_lib_firewalld_services_ovn-central-firewall-service.xml \ @@ -172,9 +203,12 @@ install -p -m 0644 rhel/usr_lib_firewalld_services_ovn-host-firewall-service.xml $RPM_BUILD_ROOT%{_prefix}/lib/firewalld/services/ovn-host-firewall-service.xml install -d -m 0755 $RPM_BUILD_ROOT%{_prefix}/lib/ocf/resource.d/ovn -ln -s %{_datadir}/openvswitch/scripts/ovndb-servers.ocf \ +ln -s %{_datadir}/ovn/scripts/ovndb-servers.ocf \ $RPM_BUILD_ROOT%{_prefix}/lib/ocf/resource.d/ovn/ovndb-servers +install -p -D -m 0644 rhel/etc_logrotate.d_ovn \ + $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d/ovn + # remove OVS unpackages files rm -f $RPM_BUILD_ROOT%{_bindir}/ovs* rm -f $RPM_BUILD_ROOT%{_bindir}/vtep-ctl @@ -185,18 +219,12 @@ rm -f $RPM_BUILD_ROOT%{_mandir}/man5/vtep* rm -f $RPM_BUILD_ROOT%{_mandir}/man7/ovs* rm -f $RPM_BUILD_ROOT%{_mandir}/man8/ovs* rm -f $RPM_BUILD_ROOT%{_mandir}/man8/vtep* -rm -f $RPM_BUILD_ROOT%{_datadir}/openvswitch/ovs* -rm -f $RPM_BUILD_ROOT%{_datadir}/openvswitch/vswitch.ovsschema -rm -f $RPM_BUILD_ROOT%{_datadir}/openvswitch/vtep.ovsschema -rm -f $RPM_BUILD_ROOT%{_datadir}/openvswitch/scripts/ovs* -rm -rf $RPM_BUILD_ROOT%{_datadir}/openvswitch/bugtool-plugins -rm -f $RPM_BUILD_ROOT%{_includedir}/openvswitch/* -rm -f $RPM_BUILD_ROOT%{_includedir}/openflow/* +rm -rf $RPM_BUILD_ROOT%{_datadir}/ovn/python +rm -f $RPM_BUILD_ROOT%{_datadir}/ovn/scripts/ovs* +rm -rf $RPM_BUILD_ROOT%{_datadir}/ovn/bugtool-plugins rm -f $RPM_BUILD_ROOT%{_libdir}/*.a rm -f $RPM_BUILD_ROOT%{_libdir}/*.la rm -f $RPM_BUILD_ROOT%{_libdir}/pkgconfig/*.pc -rm -f $RPM_BUILD_ROOT%{_includedir}/openvswitch/* -rm -f $RPM_BUILD_ROOT%{_includedir}/openflow/* rm -f $RPM_BUILD_ROOT%{_includedir}/ovn/* rm -f $RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d/ovs-appctl-bashcomp.bash rm -f $RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d/ovs-vsctl-bashcomp.bash @@ -389,20 +417,22 @@ fi %{_bindir}/ovn-sbctl %{_bindir}/ovn-trace %{_bindir}/ovn-detrace -%{_datadir}/openvswitch/scripts/ovn-ctl -%{_datadir}/openvswitch/scripts/ovndb-servers.ocf -%{_datadir}/openvswitch/scripts/ovn-bugtool-nbctl-show -%{_datadir}/openvswitch/scripts/ovn-bugtool-sbctl-lflow-list -%{_datadir}/openvswitch/scripts/ovn-bugtool-sbctl-show +%{_datadir}/ovn/scripts/ovn-ctl +%{_datadir}/ovn/scripts/ovn-lib +%{_datadir}/ovn/scripts/ovndb-servers.ocf +%{_datadir}/ovn/scripts/ovn-bugtool-nbctl-show +%{_datadir}/ovn/scripts/ovn-bugtool-sbctl-lflow-list +%{_datadir}/ovn/scripts/ovn-bugtool-sbctl-show %{_mandir}/man8/ovn-ctl.8* %{_mandir}/man8/ovn-nbctl.8* %{_mandir}/man8/ovn-trace.8* %{_mandir}/man1/ovn-detrace.1* -%{_mandir}/man7/ovn-architecture.7* +#%{_mandir}/man7/ovn-architecture.7* - Uncomment this once the manpage is fixed %{_mandir}/man8/ovn-sbctl.8* -%{_mandir}/man5/ovn-nb.5* -%{_mandir}/man5/ovn-sb.5* +#%{_mandir}/man5/ovn-nb.5* - Uncomment this once the manpage is fixed +#%{_mandir}/man5/ovn-sb.5* - Uncomment this once the manpage is fixed %{_prefix}/lib/ocf/resource.d/ovn/ovndb-servers +%config(noreplace) %{_sysconfdir}/logrotate.d/ovn %files docker %{_bindir}/ovn-docker-overlay-driver @@ -411,8 +441,8 @@ fi %files central %{_bindir}/ovn-northd %{_mandir}/man8/ovn-northd.8* -%config %{_datadir}/openvswitch/ovn-nb.ovsschema -%config %{_datadir}/openvswitch/ovn-sb.ovsschema +%config %{_datadir}/ovn/ovn-nb.ovsschema +%config %{_datadir}/ovn/ovn-sb.ovsschema %{_unitdir}/ovn-northd.service %{_prefix}/lib/firewalld/services/ovn-central-firewall-service.xml diff --git a/rhel/usr_lib_systemd_system_ovn-controller-vtep.service b/rhel/usr_lib_systemd_system_ovn-controller-vtep.service index 4ca684ac0..832849488 100644 --- a/rhel/usr_lib_systemd_system_ovn-controller-vtep.service +++ b/rhel/usr_lib_systemd_system_ovn-controller-vtep.service @@ -19,12 +19,12 @@ # /etc/systemd/system/ovn-controller-vtep.d/local.conf: # # [System] -# Environment="OVN_DB=unix:/usr/local/var/run/openvswitch/db.sock" "VTEP_DB=unix:/usr/local/var/run/openvswitch/vtep.sock" +# Environment="OVN_DB=unix:/usr/local/var/run/ovn/db.sock" "VTEP_DB=unix:/usr/local/var/run/ovn/vtep.sock" # # Alternatively, you may specify environment variables in the file /etc/sysconfig/ovn-controller-vtep: # -# OVN_DB="unix:/usr/local/var/run/openvswitch/db.sock" -# VTEP_DB="unix:/usr/local/var/run/openvswitch/vtep.sock" +# OVN_DB="unix:/usr/local/var/run/ovn/db.sock" +# VTEP_DB="unix:/usr/local/var/run/ovn/vtep.sock" [Unit] Description=OVN VTEP gateway controller daemon @@ -36,12 +36,13 @@ After=openvswitch.service Type=simple Restart=on-failure Environment=OVS_RUNDIR=%t/openvswitch -Environment=OVN_DB=unix:%t/openvswitch/db.sock +Environment=OVN_RUNDIR=%t/ovn +Environment=OVN_DB=unix:%t/ovn/ovnsb_db.sock Environment=VTEP_DB=unix:%t/openvswitch/db.sock EnvironmentFile=-/etc/sysconfig/ovn-controller-vtep ExecStart=/usr/bin/ovn-controller-vtep -vconsole:emer -vsyslog:err -vfile:info \ - --log-file=/var/log/openvswitch/ovn-controller-vtep.log \ - --no-chdir --pidfile=${OVS_RUNDIR}/ovn-controller-vtep.pid \ + --log-file=/var/log/ovn/ovn-controller-vtep.log \ + --no-chdir --pidfile=${OVN_RUNDIR}/ovn-controller-vtep.pid \ --ovnsb-db=${OVN_DB} --vtep-db=${VTEP_DB} [Install] diff --git a/rhel/usr_lib_systemd_system_ovn-controller.service b/rhel/usr_lib_systemd_system_ovn-controller.service index cf65988fe..6c8f33a27 100644 --- a/rhel/usr_lib_systemd_system_ovn-controller.service +++ b/rhel/usr_lib_systemd_system_ovn-controller.service @@ -21,12 +21,13 @@ After=openvswitch.service [Service] Type=forking -PIDFile=/var/run/openvswitch/ovn-controller.pid +PIDFile=/var/run/ovn/ovn-controller.pid Restart=on-failure +Environment=OVN_RUNDIR=%t/ovn OVS_RUNDIR=%t/openvswitch EnvironmentFile=-/etc/sysconfig/ovn-controller -ExecStart=/usr/share/openvswitch/scripts/ovn-ctl --no-monitor \ +ExecStart=/usr/share/ovn/scripts/ovn-ctl --no-monitor \ start_controller $OVN_CONTROLLER_OPTS -ExecStop=/usr/share/openvswitch/scripts/ovn-ctl stop_controller +ExecStop=/usr/share/ovn/scripts/ovn-ctl stop_controller [Install] WantedBy=multi-user.target diff --git a/rhel/usr_lib_systemd_system_ovn-northd.service b/rhel/usr_lib_systemd_system_ovn-northd.service index 3c44600a0..82c23cee4 100644 --- a/rhel/usr_lib_systemd_system_ovn-northd.service +++ b/rhel/usr_lib_systemd_system_ovn-northd.service @@ -7,25 +7,23 @@ # /etc/systemd/system/ovn-northd.d/local.conf: # # [System] -# Environment="OVN_NORTHD_OPTS=--db-nb-sock=/usr/local/var/run/openvswitch/ovnnb_db.sock --db-sb-sock=/usr/local/var/run/openvswitch/ovnsb_db.sock" +# Environment="OVN_NORTHD_OPTS=--db-nb-sock=/usr/local/var/run/ovn/ovnnb_db.sock --db-sb-sock=/usr/local/var/run/ovn/ovnsb_db.sock" # # Alternatively, you may specify environment variables in the file /etc/sysconfig/ovn-northd: # -# OVN_NORTHD_OPTS="--db-nb-sock=/usr/local/var/run/openvswitch/ovnnb_db.sock --db-sb-sock=/usr/local/var/run/openvswitch/ovnsb_db.sock" +# OVN_NORTHD_OPTS="--db-nb-sock=/usr/local/var/run/ovn/ovnnb_db.sock --db-sb-sock=/usr/local/var/run/ovn/ovnsb_db.sock" [Unit] Description=OVN northd management daemon After=syslog.target -Requires=openvswitch.service -After=openvswitch.service [Service] Type=oneshot RemainAfterExit=yes -Environment=OVS_RUNDIR=%t/openvswitch OVS_DBDIR=/var/lib/openvswitch +Environment=OVN_RUNDIR=%t/ovn OVN_DBDIR=/var/lib/ovn EnvironmentFile=-/etc/sysconfig/ovn-northd -ExecStart=/usr/share/openvswitch/scripts/ovn-ctl start_northd $OVN_NORTHD_OPTS -ExecStop=/usr/share/openvswitch/scripts/ovn-ctl stop_northd +ExecStart=/usr/share/ovn/scripts/ovn-ctl start_northd $OVN_NORTHD_OPTS +ExecStop=/usr/share/ovn/scripts/ovn-ctl stop_northd [Install] WantedBy=multi-user.target diff --git a/utilities/ovn-ctl b/utilities/ovn-ctl index a973b09a2..39e03b189 100755 --- a/utilities/ovn-ctl +++ b/utilities/ovn-ctl @@ -188,7 +188,7 @@ $cluster_remote_port set "$@" --remote=punix:$sock --pidfile=$db_pid_file set "$@" --unixctl=$ctrl_sock - [ "$OVS_USER" != "" ] && set "$@" --user "$OVS_USER" + [ "$OVN_USER" != "" ] && set "$@" --user "$OVN_USER" if test X"$detach" != Xno; then set "$@" --detach --monitor @@ -487,7 +487,6 @@ set_defaults () { OVN_CONTROLLER_WRAPPER= OVN_USER= - OVS_USER= OVN_CONTROLLER_LOG="-vconsole:emer -vsyslog:err -vfile:info" OVN_NORTHD_LOG="-vconsole:emer -vsyslog:err -vfile:info" From patchwork Tue Aug 13 16:28:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1146493 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 467J9G1sRrz9sDQ for ; Wed, 14 Aug 2019 02:30:26 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 457B4DB4; Tue, 13 Aug 2019 16:28:41 +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 4CDE7CC0 for ; Tue, 13 Aug 2019 16:28:40 +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 9A0A78A3 for ; Tue, 13 Aug 2019 16:28:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2CD7C3C917; Tue, 13 Aug 2019 16:28:39 +0000 (UTC) Received: from nusiddiq.redhat (ovpn-116-27.sin2.redhat.com [10.67.116.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA1493469F; Tue, 13 Aug 2019 16:28:36 +0000 (UTC) From: nusiddiq@redhat.com To: dev@openvswitch.org Date: Tue, 13 Aug 2019 21:58:22 +0530 Message-Id: <20190813162822.16517-1-nusiddiq@redhat.com> In-Reply-To: <20190813162629.15983-1-nusiddiq@redhat.com> References: <20190813162629.15983-1-nusiddiq@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 13 Aug 2019 16:28:39 +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 Cc: =?utf-8?q?Jaime_Caama=C3=B1o_Ruiz?= Subject: [ovs-dev] [PATCH ovn 4/4] rhel: Run ovn services with the 'openvswitch' user 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: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: Numan Siddique This patch could have created a new user 'ovn' for ovn services instead of using 'openvswitch' user. But this would require some amount of work and proper testing since the new user 'ovn' should be part of 'openvswitch' group (to access /var/run/openvswitch/db.sock.). If ovs is compiled with dpdk, then it may get tricky (as ovs-vswitchd is run as user - openvswitch:hugetlbfs). We can support a new user for 'ovn' services in the future. Recently the commit [1] in ovs repo added support to run ovn services with the 'openvswitch' user, but this commit was not applied to ovn repo as we had already created a new OVN repo. During the OVS/OVN formal split, we missed out on applying the patch [1]. This patch takes some code from [1]. [1] - 94e1e8be3187 ("rhel: run ovn with the same user as ovs"). CC: Jaime CaamaƱo Ruiz Signed-off-by: Numan Siddique Signed-off-by: Numan Siddique --- rhel/automake.mk | 3 ++- rhel/ovn-fedora.spec.in | 13 +++++++++++++ ...r_lib_systemd_system_ovn-controller-vtep.service | 2 ++ rhel/usr_lib_systemd_system_ovn-controller.service | 2 ++ rhel/usr_lib_systemd_system_ovn-northd.service | 5 ++++- ...usr_share_ovn_scripts_systemd_sysconfig.template | 13 +++++++++++++ utilities/ovn-ctl | 12 ++++++++++++ 7 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 rhel/usr_share_ovn_scripts_systemd_sysconfig.template diff --git a/rhel/automake.mk b/rhel/automake.mk index 39e216b01..a46e6579b 100644 --- a/rhel/automake.mk +++ b/rhel/automake.mk @@ -15,7 +15,8 @@ EXTRA_DIST += \ rhel/usr_lib_systemd_system_ovn-controller-vtep.service \ rhel/usr_lib_systemd_system_ovn-northd.service \ rhel/usr_lib_firewalld_services_ovn-central-firewall-service.xml \ - rhel/usr_lib_firewalld_services_ovn-host-firewall-service.xml + rhel/usr_lib_firewalld_services_ovn-host-firewall-service.xml \ + rhel/usr_share_ovn_scripts_systemd_sysconfig.template update_rhel_spec = \ $(AM_V_GEN)($(ro_shell) && sed -e 's,[@]VERSION[@],$(VERSION),g') \ diff --git a/rhel/ovn-fedora.spec.in b/rhel/ovn-fedora.spec.in index cbca87511..14035de9a 100644 --- a/rhel/ovn-fedora.spec.in +++ b/rhel/ovn-fedora.spec.in @@ -186,6 +186,10 @@ make %{?_smp_mflags} rm -rf $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT +install -p -D -m 0644 \ + rhel/usr_share_ovn_scripts_systemd_sysconfig.template \ + $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/ovn + for service in ovn-controller ovn-controller-vtep ovn-northd; do install -p -D -m 0644 \ rhel/usr_lib_systemd_system_${service}.service \ @@ -319,6 +323,14 @@ fi fi %endif +%post +%if %{with libcapng} +if [ $1 -eq 1 ]; then + sed -i 's:^#OVN_USER_ID=:OVN_USER_ID=:' %{_sysconfdir}/sysconfig/ovn + sed -i 's:\(.*su\).*:\1 ovn ovn:' %{_sysconfdir}/logrotate.d/ovn +fi +%endif + %post central %if 0%{?systemd_post:1} %systemd_post ovn-northd.service @@ -413,6 +425,7 @@ if [ $1 -eq 1 ]; then fi %files +%config(noreplace) %{_sysconfdir}/sysconfig/ovn %{_bindir}/ovn-nbctl %{_bindir}/ovn-sbctl %{_bindir}/ovn-trace diff --git a/rhel/usr_lib_systemd_system_ovn-controller-vtep.service b/rhel/usr_lib_systemd_system_ovn-controller-vtep.service index 832849488..09ad0612c 100644 --- a/rhel/usr_lib_systemd_system_ovn-controller-vtep.service +++ b/rhel/usr_lib_systemd_system_ovn-controller-vtep.service @@ -38,10 +38,12 @@ Restart=on-failure Environment=OVS_RUNDIR=%t/openvswitch Environment=OVN_RUNDIR=%t/ovn Environment=OVN_DB=unix:%t/ovn/ovnsb_db.sock +EnvironmentFile=-/etc/sysconfig/ovn Environment=VTEP_DB=unix:%t/openvswitch/db.sock EnvironmentFile=-/etc/sysconfig/ovn-controller-vtep ExecStart=/usr/bin/ovn-controller-vtep -vconsole:emer -vsyslog:err -vfile:info \ --log-file=/var/log/ovn/ovn-controller-vtep.log \ + --ovn-user=${OVN_USER_ID} \ --no-chdir --pidfile=${OVN_RUNDIR}/ovn-controller-vtep.pid \ --ovnsb-db=${OVN_DB} --vtep-db=${VTEP_DB} diff --git a/rhel/usr_lib_systemd_system_ovn-controller.service b/rhel/usr_lib_systemd_system_ovn-controller.service index 6c8f33a27..15d0ac853 100644 --- a/rhel/usr_lib_systemd_system_ovn-controller.service +++ b/rhel/usr_lib_systemd_system_ovn-controller.service @@ -24,8 +24,10 @@ Type=forking PIDFile=/var/run/ovn/ovn-controller.pid Restart=on-failure Environment=OVN_RUNDIR=%t/ovn OVS_RUNDIR=%t/openvswitch +EnvironmentFile=-/etc/sysconfig/ovn EnvironmentFile=-/etc/sysconfig/ovn-controller ExecStart=/usr/share/ovn/scripts/ovn-ctl --no-monitor \ + --ovn-user=${OVN_USER_ID} \ start_controller $OVN_CONTROLLER_OPTS ExecStop=/usr/share/ovn/scripts/ovn-ctl stop_controller diff --git a/rhel/usr_lib_systemd_system_ovn-northd.service b/rhel/usr_lib_systemd_system_ovn-northd.service index 82c23cee4..d281f861c 100644 --- a/rhel/usr_lib_systemd_system_ovn-northd.service +++ b/rhel/usr_lib_systemd_system_ovn-northd.service @@ -21,8 +21,11 @@ After=syslog.target Type=oneshot RemainAfterExit=yes Environment=OVN_RUNDIR=%t/ovn OVN_DBDIR=/var/lib/ovn +EnvironmentFile=-/etc/sysconfig/ovn EnvironmentFile=-/etc/sysconfig/ovn-northd -ExecStart=/usr/share/ovn/scripts/ovn-ctl start_northd $OVN_NORTHD_OPTS +ExecStartPre=-/usr/bin/chown -R ${OVN_USER_ID} ${OVN_DBDIR} +ExecStart=/usr/share/ovn/scripts/ovn-ctl \ + --ovn-user=${OVN_USER_ID} start_northd $OVN_NORTHD_OPTS ExecStop=/usr/share/ovn/scripts/ovn-ctl stop_northd [Install] diff --git a/rhel/usr_share_ovn_scripts_systemd_sysconfig.template b/rhel/usr_share_ovn_scripts_systemd_sysconfig.template new file mode 100644 index 000000000..4543d1bc9 --- /dev/null +++ b/rhel/usr_share_ovn_scripts_systemd_sysconfig.template @@ -0,0 +1,13 @@ +### Configuration options for OVN +# +# Set "nice" priority at which to run ovn-northd: +# --ovn-northd-priority=-10 +# +# Set "nice" priority at which to run ovn-controller: +# --ovn-controller-priority=-10 +# +# +OPTIONS="" + +# Uncomment and set the OVN User/Group value +#OVN_USER_ID="openvswitch:openvswitch" diff --git a/utilities/ovn-ctl b/utilities/ovn-ctl index 39e03b189..f4ed8f5a8 100755 --- a/utilities/ovn-ctl +++ b/utilities/ovn-ctl @@ -183,6 +183,18 @@ $cluster_remote_port upgrade_db "$file" "$schema" fi + # Set the owner of the ovn_dbdir (with -R option) to OVN_USER if set. + # This is required because the ovndbs are created with root permission + # if not present when create_cluster/upgrade_db is called. + INSTALL_USER="root" + INSTALL_GROUP="root" + [ "$OVN_USER" != "" ] && INSTALL_USER="${OVN_USER%:*}" + [ "${OVN_USER##*:}" != "" ] && INSTALL_GROUP="${OVN_USER##*:}" + + chown -R $INSTALL_USER:$INSTALL_GROUP $ovn_dbdir + chown -R $INSTALL_USER:$INSTALL_GROUP $OVN_RUNDIR + chown -R $INSTALL_USER:$INSTALL_GROUP $ovn_logdir + set ovsdb-server set "$@" $log --log-file=$logfile set "$@" --remote=punix:$sock --pidfile=$db_pid_file