[ovs-dev,v2,ovn,2/5] Add support for using OVN specific rundirs
diff mbox series

Message ID 20190819181513.2944-1-nusiddiq@redhat.com
State Superseded
Headers show
Series
  • External OVS source support and separate run dir for OVN
Related show

Commit Message

Numan Siddique Aug. 19, 2019, 6:15 p.m. UTC
From: Numan Siddique <nusiddiq@redhat.com>

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 <dceara@redhat.com>
Signed-off-by: Numan Siddique <nusiddiq@redhat.com>
---
 Documentation/intro/install/general.rst |  30 ++--
 Makefile.am                             |   6 +-
 TODO_SPLIT.rst                          |   2 +
 configure.ac                            |  34 ++--
 controller/ovn-controller.c             |   4 +-
 lib/.gitignore                          |   1 +
 lib/automake.mk                         |  21 ++-
 lib/ovn-dirs.c.in                       | 112 +++++++++++++
 lib/ovn-dirs.h                          |  35 ++++
 lib/ovn-util.c                          |  24 ++-
 lib/ovn-util.h                          |   1 +
 m4/{openvswitch.m4 => ovn.m4}           |  60 +++----
 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 ++++++++++++++++++++++++
 19 files changed, 520 insertions(+), 113 deletions(-)
 create mode 100644 lib/ovn-dirs.c.in
 create mode 100644 lib/ovn-dirs.h
 rename m4/{openvswitch.m4 => ovn.m4} (94%)
 create mode 100644 utilities/ovn-lib.in

Comments

0-day Robot Aug. 19, 2019, 7:06 p.m. UTC | #1
Bleep bloop.  Greetings Numan Siddique, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


checkpatch:
WARNING: Line is 99 characters long (recommended limit is 79)
#2123 FILE: utilities/ovn-ctl:340:
        OVS_RUNDIR=${OVS_RUNDIR} start_ovn_daemon "$OVN_NORTHD_PRIORITY" "$OVN_NORTHD_WRAPPER" "$@"

WARNING: Line is 103 characters long (recommended limit is 79)
#2132 FILE: utilities/ovn-ctl:362:
    OVS_RUNDIR=${OVS_RUNDIR} start_ovn_daemon "$OVN_CONTROLLER_PRIORITY" "$OVN_CONTROLLER_WRAPPER" "$@"

WARNING: Line is 103 characters long (recommended limit is 79)
#2141 FILE: utilities/ovn-ctl:389:
    OVS_RUNDIR=${OVS_RUNDIR} start_ovn_daemon "$OVN_CONTROLLER_PRIORITY" "$OVN_CONTROLLER_WRAPPER" "$@"

Lines checked: 2475, Warnings: 3, Errors: 0


Please check this out.  If you feel there has been an error, please email aconole@redhat.com

Thanks,
0-day Robot

Patch
diff mbox series

diff --git a/Documentation/intro/install/general.rst b/Documentation/intro/install/general.rst
index 226cf3645..a0abfbad8 100644
--- a/Documentation/intro/install/general.rst
+++ b/Documentation/intro/install/general.rst
@@ -159,17 +159,17 @@  For example::
 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 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.
 
@@ -338,9 +338,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
 
@@ -350,7 +354,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.
@@ -360,23 +364,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 9d88eed54..f3df733a1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -179,7 +179,7 @@  SUFFIXES += .in
 	    -e 's,[@]LOGDIR[@],$(LOGDIR),g' \
 	    -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' \
@@ -205,6 +205,7 @@  SUFFIXES += .xml
 	  DBDIR='$(DBDIR)' \
 	  PYTHON='$(PYTHON)' \
 	  RUNDIR='$(RUNDIR)' \
+	  OVN_RUNDIR='$(OVN_RUNDIR)' \
 	  VERSION='$(VERSION)' \
 	  localstatedir='$(localstatedir)' \
 	  pkgdatadir='$(pkgdatadir)' \
@@ -498,6 +499,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/TODO_SPLIT.rst b/TODO_SPLIT.rst
index bda0ff862..bb8657eb1 100644
--- a/TODO_SPLIT.rst
+++ b/TODO_SPLIT.rst
@@ -41,6 +41,8 @@  Immediate tasks
      - ovn-architecture manpage generation.
   This needs to be fixed.
 
+* Cleanup the acinclude.m4 and m4 folder
+
 Immediate to Short-term tasks
 -----------------------------
 
diff --git a/configure.ac b/configure.ac
index c68a2a9e8..a6f708812 100644
--- a/configure.ac
+++ b/configure.ac
@@ -86,18 +86,18 @@  OVS_CHECK_ESX
 OVS_CHECK_WIN64
 OVS_CHECK_WIN32
 OVS_CHECK_VISUAL_STUDIO_DDK
-OVS_CHECK_COVERAGE
+OVN_CHECK_COVERAGE
 OVS_CHECK_NDEBUG
 OVS_CHECK_NETLINK
 OVS_CHECK_OPENSSL
-OVS_CHECK_LIBCAPNG
-OVS_CHECK_LOGDIR
-OVS_CHECK_PYTHON2
-OVS_CHECK_PYTHON3
-OVS_CHECK_PYTHON
-OVS_CHECK_FLAKE8
-OVS_CHECK_SPHINX
-OVS_CHECK_DOT
+OVN_CHECK_LIBCAPNG
+OVN_CHECK_LOGDIR
+OVN_CHECK_PYTHON2
+OVN_CHECK_PYTHON3
+OVN_CHECK_PYTHON
+OVN_CHECK_FLAKE8
+OVN_CHECK_SPHINX
+OVN_CHECK_DOT
 OVS_CHECK_IF_DL
 OVS_CHECK_STRTOK_R
 AC_CHECK_DECLS([sys_siglist], [], [], [[#include <signal.h>]])
@@ -116,14 +116,12 @@  AC_CHECK_HEADERS([net/if_mib.h], [], [], [[#include <sys/types.h>
 #include <net/if.h>]])
 
 OVS_CHECK_PKIDIR
-OVS_CHECK_RUNDIR
-OVS_CHECK_DBDIR
-OVS_CHECK_BACKTRACE
-OVS_CHECK_PERF_EVENT
-OVS_CHECK_VALGRIND
-OVS_CHECK_SOCKET_LIBS
-OVS_CHECK_XENSERVER_VERSION
-OVS_CHECK_GROFF
+OVN_CHECK_RUNDIR
+OVN_CHECK_DBDIR
+OVN_CHECK_BACKTRACE
+OVN_CHECK_PERF_EVENT
+OVN_CHECK_VALGRIND
+OVN_CHECK_GROFF
 OVS_CHECK_TLS
 OVS_CHECK_ATOMIC_LIBS
 OVS_CHECK_GCC4_ATOMICS
@@ -137,7 +135,7 @@  OVS_CHECK_LINUX_HOST
 OVS_LIBTOOL_VERSIONS
 OVS_CHECK_CXX
 AX_FUNC_POSIX_MEMALIGN
-OVS_CHECK_UNBOUND
+OVN_CHECK_UNBOUND
 
 OVS_CHECK_INCLUDE_NEXT([stdio.h string.h])
 AC_CONFIG_FILES([lib/libovn.sym])
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..0c8245c9c 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,35 @@  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,[@]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 <config.h>
+#include "ovn-dirs.h"
+#include <stdlib.h>
+#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 <config.h>
+#include <unistd.h>
+
 #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/ovn.m4
similarity index 94%
rename from m4/openvswitch.m4
rename to m4/ovn.m4
index b599f17d7..4d19a8d9e 100644
--- a/m4/openvswitch.m4
+++ b/m4/ovn.m4
@@ -17,7 +17,7 @@ 
 m4_include([m4/compat.m4])
 
 dnl Checks for --enable-coverage and updates CFLAGS and LDFLAGS appropriately.
-AC_DEFUN([OVS_CHECK_COVERAGE],
+AC_DEFUN([OVN_CHECK_COVERAGE],
   [AC_REQUIRE([AC_PROG_CC])
    AC_ARG_ENABLE(
      [coverage],
@@ -203,21 +203,8 @@  AC_ARG_WITH([vstudiotargetver],
   AM_CONDITIONAL([VSTUDIO_DDK], [test -n "$VSTUDIO_CONFIG"])
 ])
 
-dnl Checks for Netlink support.
-AC_DEFUN([OVS_CHECK_NETLINK],
-  [AC_CHECK_HEADER([linux/netlink.h],
-                   [HAVE_NETLINK=yes],
-                   [HAVE_NETLINK=no],
-                   [#include <sys/socket.h>
-   ])
-   AM_CONDITIONAL([HAVE_NETLINK], [test "$HAVE_NETLINK" = yes])
-   if test "$HAVE_NETLINK" = yes; then
-      AC_DEFINE([HAVE_NETLINK], [1],
-                [Define to 1 if Netlink protocol is available.])
-   fi])
-
 dnl Checks for libcap-ng.
-AC_DEFUN([OVS_CHECK_LIBCAPNG],
+AC_DEFUN([OVN_CHECK_LIBCAPNG],
   [AC_ARG_ENABLE(
      [libcapng],
      [AC_HELP_STRING([--disable-libcapng], [Disable Linux capability support])],
@@ -304,11 +291,6 @@  OpenFlow connections over SSL will not be supported.
    AC_SUBST([OPENSSL_SUPPORTS_SNI])
 ])
 
-dnl Checks for libraries needed by lib/socket-util.c.
-AC_DEFUN([OVS_CHECK_SOCKET_LIBS],
-  [AC_CHECK_LIB([socket], [connect])
-   AC_SEARCH_LIBS([gethostbyname], [resolv])])
-
 dnl Checks for the directory in which to store the PKI.
 AC_DEFUN([OVS_CHECK_PKIDIR],
   [AC_ARG_WITH(
@@ -320,18 +302,18 @@  AC_DEFUN([OVS_CHECK_PKIDIR],
    AC_SUBST([PKIDIR])])
 
 dnl Checks for the directory in which to store pidfiles.
-AC_DEFUN([OVS_CHECK_RUNDIR],
+AC_DEFUN([OVN_CHECK_RUNDIR],
   [AC_ARG_WITH(
      [rundir],
      AC_HELP_STRING([--with-rundir=DIR],
                     [directory used for pidfiles
-                    [[LOCALSTATEDIR/run/openvswitch]]]),
-     [RUNDIR=$withval],
-     [RUNDIR='${localstatedir}/run/openvswitch'])
-   AC_SUBST([RUNDIR])])
+                    [[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_DEFUN([OVN_CHECK_LOGDIR],
   [AC_ARG_WITH(
      [logdir],
      AC_HELP_STRING([--with-logdir=DIR],
@@ -340,8 +322,8 @@  AC_DEFUN([OVS_CHECK_LOGDIR],
      [LOGDIR='${localstatedir}/log/${PACKAGE}'])
    AC_SUBST([LOGDIR])])
 
-dnl Checks for the directory in which to store the Open vSwitch database.
-AC_DEFUN([OVS_CHECK_DBDIR],
+dnl Checks for the directory in which to store the OVN database.
+AC_DEFUN([OVN_CHECK_DBDIR],
   [AC_ARG_WITH(
      [dbdir],
      AC_HELP_STRING([--with-dbdir=DIR],
@@ -351,21 +333,21 @@  AC_DEFUN([OVS_CHECK_DBDIR],
    AC_SUBST([DBDIR])])
 
 dnl Defines HAVE_BACKTRACE if backtrace() is found.
-AC_DEFUN([OVS_CHECK_BACKTRACE],
+AC_DEFUN([OVN_CHECK_BACKTRACE],
   [AC_SEARCH_LIBS([backtrace], [execinfo ubacktrace],
                   [AC_DEFINE([HAVE_BACKTRACE], [1],
                              [Define to 1 if you have backtrace(3).])])])
 
 dnl Defines HAVE_PERF_EVENT if linux/perf_event.h is found.
-AC_DEFUN([OVS_CHECK_PERF_EVENT],
+AC_DEFUN([OVN_CHECK_PERF_EVENT],
   [AC_CHECK_HEADERS([linux/perf_event.h])])
 
 dnl Checks for valgrind/valgrind.h.
-AC_DEFUN([OVS_CHECK_VALGRIND],
+AC_DEFUN([OVN_CHECK_VALGRIND],
   [AC_CHECK_HEADERS([valgrind/valgrind.h])])
 
 dnl Checks for Python 2.x, x >= 7.
-AC_DEFUN([OVS_CHECK_PYTHON2],
+AC_DEFUN([OVN_CHECK_PYTHON2],
   [AC_CACHE_CHECK(
      [for Python 2.x for x >= 7],
      [ovs_cv_python2],
@@ -406,7 +388,7 @@  else:
    AM_CONDITIONAL([HAVE_PYTHON2], [test "$HAVE_PYTHON2" = yes])])
 
 dnl Checks for Python 3.x, x >= 4.
-AC_DEFUN([OVS_CHECK_PYTHON3],
+AC_DEFUN([OVN_CHECK_PYTHON3],
   [AC_CACHE_CHECK(
      [for Python 3.x for x >= 4],
      [ovs_cv_python3],
@@ -448,7 +430,7 @@  else:
 
 dnl Checks if you have any compatible Python version installed.
 dnl Python 2.7+ has the preference to 3.4+
-AC_DEFUN([OVS_CHECK_PYTHON],
+AC_DEFUN([OVN_CHECK_PYTHON],
   [AC_CACHE_CHECK(
      [for Python 2 or 3],
      [ovs_cv_python],
@@ -471,7 +453,7 @@  AC_DEFUN([OVS_CHECK_PYTHON],
     AM_CONDITIONAL([HAVE_PYTHON], [test "$HAVE_PYTHON" = yes])])
 
 dnl Checks for flake8.
-AC_DEFUN([OVS_CHECK_FLAKE8],
+AC_DEFUN([OVN_CHECK_FLAKE8],
   [AC_CACHE_CHECK(
     [for flake8],
     [ovs_cv_flake8],
@@ -483,7 +465,7 @@  AC_DEFUN([OVS_CHECK_FLAKE8],
    AM_CONDITIONAL([HAVE_FLAKE8], [test "$ovs_cv_flake8" = yes])])
 
 dnl Checks for sphinx.
-AC_DEFUN([OVS_CHECK_SPHINX],
+AC_DEFUN([OVN_CHECK_SPHINX],
   [AC_CACHE_CHECK(
     [for sphinx],
     [ovs_cv_sphinx],
@@ -495,7 +477,7 @@  AC_DEFUN([OVS_CHECK_SPHINX],
    AM_CONDITIONAL([HAVE_SPHINX], [test "$ovs_cv_sphinx" = yes])])
 
 dnl Checks for dot.
-AC_DEFUN([OVS_CHECK_DOT],
+AC_DEFUN([OVN_CHECK_DOT],
   [AC_CACHE_CHECK(
     [for dot],
     [ovs_cv_dot],
@@ -508,7 +490,7 @@  AC_DEFUN([OVS_CHECK_DOT],
    AM_CONDITIONAL([HAVE_DOT], [test "$ovs_cv_dot" = yes])])
 
 dnl Checks for groff.
-AC_DEFUN([OVS_CHECK_GROFF],
+AC_DEFUN([OVN_CHECK_GROFF],
   [AC_CACHE_CHECK(
     [for groff],
     [ovs_cv_groff],
@@ -707,7 +689,7 @@  AC_DEFUN([OVS_CHECK_CXX],
    AM_CONDITIONAL([HAVE_CXX], [$enable_cxx])])
 
 dnl Checks for unbound library.
-AC_DEFUN([OVS_CHECK_UNBOUND],
+AC_DEFUN([OVN_CHECK_UNBOUND],
   [AC_CHECK_LIB(unbound, ub_ctx_create, [HAVE_UNBOUND=yes], [HAVE_UNBOUND=no])
    if test "$HAVE_UNBOUND" = yes; then
      AC_DEFINE([HAVE_UNBOUND], [1], [Define to 1 if unbound is detected.])
diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c
index e29b0fff4..b54866659 100644
--- a/northd/ovn-northd.c
+++ b/northd/ovn-northd.c
@@ -9600,7 +9600,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 2def6695c..a19dea2f1 100755
--- a/tutorial/ovs-sandbox
+++ b/tutorial/ovs-sandbox
@@ -372,6 +372,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 @@ 
     <h3>Starting standalone ovn db server passing SSL certificates</h3>
     <p>
       <code>
-        # 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
       </code>
     </p>
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