Message ID | 20190311183551.17938-1-mmichels@redhat.com |
---|---|
State | Accepted |
Headers | show |
Series | [ovs-dev] Add unixctl option for ovn-northd | expand |
It didn't seem like this is different from the original version, so I just cherry-picked that back to branch-2.9. Let me know if I missed something. --Justin > On Mar 11, 2019, at 11:35 AM, Mark Michelson <mmichels@redhat.com> wrote: > > From: Venkata Anil <vkommadi@redhat.com> > > This is a backport to the 2.9 branch of the feature. > > Openstack is requesting this backport in order to have their functional > suite for OSP13 work properly with OVS 2.9. > > Signed-off-by: Venkata Anil <vkommadi@redhat.com> > Signed-off-by: Ben Pfaff <blp@ovn.org> > --- > lib/automake.mk | 3 ++- > lib/unixctl.xml | 26 ++++++++++++++++++++++++++ > ovn/northd/ovn-northd.8.xml | 7 +++++-- > ovn/northd/ovn-northd.c | 9 ++++++++- > tests/ovn-northd.at | 39 +++++++++++++++++++++++++++++++++++++++ > 5 files changed, 80 insertions(+), 4 deletions(-) > create mode 100644 lib/unixctl.xml > > diff --git a/lib/automake.mk b/lib/automake.mk > index 70461ec8c..73bc4b219 100644 > --- a/lib/automake.mk > +++ b/lib/automake.mk > @@ -459,7 +459,8 @@ EXTRA_DIST += \ > lib/ssl.xml \ > lib/ssl-bootstrap.xml \ > lib/table.xml \ > - lib/vlog.xml > + lib/vlog.xml \ > + lib/unixctl.xml > > MAN_FRAGMENTS += \ > lib/colors.man \ > diff --git a/lib/unixctl.xml b/lib/unixctl.xml > new file mode 100644 > index 000000000..51bfc5faa > --- /dev/null > +++ b/lib/unixctl.xml > @@ -0,0 +1,26 @@ > +<?xml version="1.0" encoding="utf-8"?> > +<dl> > + <dt><code>--unixctl=<var>socket</var></code></dt> > + <dd> > + Sets the name of the control socket on which > + <code><var>program</var></code> listens for runtime management commands > + (see <var>RUNTIME MANAGEMENT COMMANDS,</var> below). If <var>socket</var> > + does not begin with <code>/</code>, it is interpreted as relative to > + <code>@RUNDIR@</code>. If <code>--unixctl</code> is not used at all, > + the default socket is > + <code>@RUNDIR@/<var>program</var>.</code><var>pid</var><code>.ctl</code>, > + where <var>pid</var> is <code><var>program</var></code>'s process ID. > + <p> > + On Windows a local named pipe is used to listen for runtime management > + commands. A file is created in the absolute path as pointed by > + <var>socket</var> or if <code>--unixctl</code> is not used at all, > + a file is created as <code><var>program</var></code> in the configured > + <var>OVS_RUNDIR</var> directory. The file exists just to mimic the > + behavior of a Unix domain socket. > + </p> > + <p> > + Specifying <code>none</code> for <var>socket</var> disables the control > + socket feature. > + </p> > + </dd> > +</dl> > diff --git a/ovn/northd/ovn-northd.8.xml b/ovn/northd/ovn-northd.8.xml > index 78df522c9..10ae42cfa 100644 > --- a/ovn/northd/ovn-northd.8.xml > +++ b/ovn/northd/ovn-northd.8.xml > @@ -54,8 +54,11 @@ > <xi:include href="lib/ssl.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/> > > <h2>Other Options</h2> > - > - <xi:include href="lib/common.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/> > + <xi:include href="lib/unixctl.xml" > + xmlns:xi="http://www.w3.org/2003/XInclude"/> > + <h3></h3> > + <xi:include href="lib/common.xml" > + xmlns:xi="http://www.w3.org/2003/XInclude"/> > > <h1>Runtime Management Commands</h1> > <p> > diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c > index 82a962b5f..0059cef5d 100644 > --- a/ovn/northd/ovn-northd.c > +++ b/ovn/northd/ovn-northd.c > @@ -59,6 +59,7 @@ struct northd_context { > > static const char *ovnnb_db; > static const char *ovnsb_db; > +static const char *unixctl_path; > > #define MAC_ADDR_PREFIX 0x0A0000000000ULL > #define MAC_ADDR_SPACE 0xffffff > @@ -239,6 +240,7 @@ Options:\n\ > (default: %s)\n\ > --ovnsb-db=DATABASE connect to ovn-sb database at DATABASE\n\ > (default: %s)\n\ > + --unixctl=SOCKET override default control socket name\n\ > -h, --help display this help message\n\ > -o, --options list available options\n\ > -V, --version display version information\n\ > @@ -6701,6 +6703,7 @@ parse_options(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) > static const struct option long_options[] = { > {"ovnsb-db", required_argument, NULL, 'd'}, > {"ovnnb-db", required_argument, NULL, 'D'}, > + {"unixctl", required_argument, NULL, 'u'}, > {"help", no_argument, NULL, 'h'}, > {"options", no_argument, NULL, 'o'}, > {"version", no_argument, NULL, 'V'}, > @@ -6732,6 +6735,10 @@ parse_options(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) > ovnnb_db = optarg; > break; > > + case 'u': > + unixctl_path = optarg; > + break; > + > case 'h': > usage(); > exit(EXIT_SUCCESS); > @@ -6784,7 +6791,7 @@ main(int argc, char *argv[]) > > daemonize_start(false); > > - retval = unixctl_server_create(NULL, &unixctl); > + retval = unixctl_server_create(unixctl_path, &unixctl); > if (retval) { > exit(EXIT_FAILURE); > } > diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at > index baa2add41..1878eb2df 100644 > --- a/tests/ovn-northd.at > +++ b/tests/ovn-northd.at > @@ -262,3 +262,42 @@ AT_CHECK_UNQUOTED([ovn-sbctl get Port_Binding ${uuid} options:ipv6_ra_prefixes], > ]) > > AT_CLEANUP > + > +AT_SETUP([ovn -- test unixctl]) > +ovn_init_db ovn-sb; ovn-sbctl init > +ovn_init_db ovn-nb; ovn-nbctl init > + > +# test unixctl option > +mkdir "$ovs_base"/northd > +as northd start_daemon ovn-northd --unixctl="$ovs_base"/northd/ovn-northd.ctl --ovnnb-db=unix:"$ovs_base"/ovn-nb/ovn-nb.sock --ovnsb-db=unix:"$ovs_base"/ovn-sb/ovn-sb.sock > +ovn-nbctl ls-add sw > +ovn-nbctl --wait=sb lsp-add sw p1 > +# northd created with unixctl option successfully created port_binding entry > +AT_CHECK([ovn-sbctl --bare --columns datapath find port_binding logical_port="p1" | wc -l], [0], [1 > +]) > +AT_CHECK([ovn-nbctl --wait=sb lsp-del p1]) > + > +# ovs-appctl exit with unixctl option > +OVS_APP_EXIT_AND_WAIT_BY_TARGET(["$ovs_base"/northd/ovn-northd.ctl], ["$ovs_base"/northd/ovn-northd.pid]) > + > +# Check no port_binding entry for new port as ovn-northd is not running > +ovn-nbctl lsp-add sw p2 > +ovn-nbctl --timeout=10 --wait=sb sync > +AT_CHECK([ovn-sbctl --bare --columns datapath find port_binding logical_port="p2" | wc -l], [0], [0 > +]) > + > +# test default unixctl path > +as northd start_daemon ovn-northd --ovnnb-db=unix:"$ovs_base"/ovn-nb/ovn-nb.sock --ovnsb-db=unix:"$ovs_base"/ovn-sb/ovn-sb.sock > +ovn-nbctl --wait=sb lsp-add sw p3 > +# northd created with default unixctl path successfully created port_binding entry > +AT_CHECK([ovn-sbctl --bare --columns datapath find port_binding logical_port="p3" | wc -l], [0], [1 > +]) > + > +as ovn-sb > +OVS_APP_EXIT_AND_WAIT([ovsdb-server]) > +as ovn-nb > +OVS_APP_EXIT_AND_WAIT([ovsdb-server]) > +as northd > +OVS_APP_EXIT_AND_WAIT([ovn-northd]) > + > +AT_CLEANUP > -- > 2.14.5 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > https://mail.openvswitch.org/mailman/listinfo/ovs-dev
diff --git a/lib/automake.mk b/lib/automake.mk index 70461ec8c..73bc4b219 100644 --- a/lib/automake.mk +++ b/lib/automake.mk @@ -459,7 +459,8 @@ EXTRA_DIST += \ lib/ssl.xml \ lib/ssl-bootstrap.xml \ lib/table.xml \ - lib/vlog.xml + lib/vlog.xml \ + lib/unixctl.xml MAN_FRAGMENTS += \ lib/colors.man \ diff --git a/lib/unixctl.xml b/lib/unixctl.xml new file mode 100644 index 000000000..51bfc5faa --- /dev/null +++ b/lib/unixctl.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<dl> + <dt><code>--unixctl=<var>socket</var></code></dt> + <dd> + Sets the name of the control socket on which + <code><var>program</var></code> listens for runtime management commands + (see <var>RUNTIME MANAGEMENT COMMANDS,</var> below). If <var>socket</var> + does not begin with <code>/</code>, it is interpreted as relative to + <code>@RUNDIR@</code>. If <code>--unixctl</code> is not used at all, + the default socket is + <code>@RUNDIR@/<var>program</var>.</code><var>pid</var><code>.ctl</code>, + where <var>pid</var> is <code><var>program</var></code>'s process ID. + <p> + On Windows a local named pipe is used to listen for runtime management + commands. A file is created in the absolute path as pointed by + <var>socket</var> or if <code>--unixctl</code> is not used at all, + a file is created as <code><var>program</var></code> in the configured + <var>OVS_RUNDIR</var> directory. The file exists just to mimic the + behavior of a Unix domain socket. + </p> + <p> + Specifying <code>none</code> for <var>socket</var> disables the control + socket feature. + </p> + </dd> +</dl> diff --git a/ovn/northd/ovn-northd.8.xml b/ovn/northd/ovn-northd.8.xml index 78df522c9..10ae42cfa 100644 --- a/ovn/northd/ovn-northd.8.xml +++ b/ovn/northd/ovn-northd.8.xml @@ -54,8 +54,11 @@ <xi:include href="lib/ssl.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/> <h2>Other Options</h2> - - <xi:include href="lib/common.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/> + <xi:include href="lib/unixctl.xml" + xmlns:xi="http://www.w3.org/2003/XInclude"/> + <h3></h3> + <xi:include href="lib/common.xml" + xmlns:xi="http://www.w3.org/2003/XInclude"/> <h1>Runtime Management Commands</h1> <p> diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c index 82a962b5f..0059cef5d 100644 --- a/ovn/northd/ovn-northd.c +++ b/ovn/northd/ovn-northd.c @@ -59,6 +59,7 @@ struct northd_context { static const char *ovnnb_db; static const char *ovnsb_db; +static const char *unixctl_path; #define MAC_ADDR_PREFIX 0x0A0000000000ULL #define MAC_ADDR_SPACE 0xffffff @@ -239,6 +240,7 @@ Options:\n\ (default: %s)\n\ --ovnsb-db=DATABASE connect to ovn-sb database at DATABASE\n\ (default: %s)\n\ + --unixctl=SOCKET override default control socket name\n\ -h, --help display this help message\n\ -o, --options list available options\n\ -V, --version display version information\n\ @@ -6701,6 +6703,7 @@ parse_options(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) static const struct option long_options[] = { {"ovnsb-db", required_argument, NULL, 'd'}, {"ovnnb-db", required_argument, NULL, 'D'}, + {"unixctl", required_argument, NULL, 'u'}, {"help", no_argument, NULL, 'h'}, {"options", no_argument, NULL, 'o'}, {"version", no_argument, NULL, 'V'}, @@ -6732,6 +6735,10 @@ parse_options(int argc OVS_UNUSED, char *argv[] OVS_UNUSED) ovnnb_db = optarg; break; + case 'u': + unixctl_path = optarg; + break; + case 'h': usage(); exit(EXIT_SUCCESS); @@ -6784,7 +6791,7 @@ main(int argc, char *argv[]) daemonize_start(false); - retval = unixctl_server_create(NULL, &unixctl); + retval = unixctl_server_create(unixctl_path, &unixctl); if (retval) { exit(EXIT_FAILURE); } diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at index baa2add41..1878eb2df 100644 --- a/tests/ovn-northd.at +++ b/tests/ovn-northd.at @@ -262,3 +262,42 @@ AT_CHECK_UNQUOTED([ovn-sbctl get Port_Binding ${uuid} options:ipv6_ra_prefixes], ]) AT_CLEANUP + +AT_SETUP([ovn -- test unixctl]) +ovn_init_db ovn-sb; ovn-sbctl init +ovn_init_db ovn-nb; ovn-nbctl init + +# test unixctl option +mkdir "$ovs_base"/northd +as northd start_daemon ovn-northd --unixctl="$ovs_base"/northd/ovn-northd.ctl --ovnnb-db=unix:"$ovs_base"/ovn-nb/ovn-nb.sock --ovnsb-db=unix:"$ovs_base"/ovn-sb/ovn-sb.sock +ovn-nbctl ls-add sw +ovn-nbctl --wait=sb lsp-add sw p1 +# northd created with unixctl option successfully created port_binding entry +AT_CHECK([ovn-sbctl --bare --columns datapath find port_binding logical_port="p1" | wc -l], [0], [1 +]) +AT_CHECK([ovn-nbctl --wait=sb lsp-del p1]) + +# ovs-appctl exit with unixctl option +OVS_APP_EXIT_AND_WAIT_BY_TARGET(["$ovs_base"/northd/ovn-northd.ctl], ["$ovs_base"/northd/ovn-northd.pid]) + +# Check no port_binding entry for new port as ovn-northd is not running +ovn-nbctl lsp-add sw p2 +ovn-nbctl --timeout=10 --wait=sb sync +AT_CHECK([ovn-sbctl --bare --columns datapath find port_binding logical_port="p2" | wc -l], [0], [0 +]) + +# test default unixctl path +as northd start_daemon ovn-northd --ovnnb-db=unix:"$ovs_base"/ovn-nb/ovn-nb.sock --ovnsb-db=unix:"$ovs_base"/ovn-sb/ovn-sb.sock +ovn-nbctl --wait=sb lsp-add sw p3 +# northd created with default unixctl path successfully created port_binding entry +AT_CHECK([ovn-sbctl --bare --columns datapath find port_binding logical_port="p3" | wc -l], [0], [1 +]) + +as ovn-sb +OVS_APP_EXIT_AND_WAIT([ovsdb-server]) +as ovn-nb +OVS_APP_EXIT_AND_WAIT([ovsdb-server]) +as northd +OVS_APP_EXIT_AND_WAIT([ovn-northd]) + +AT_CLEANUP