On Wed, Oct 12, 2011 at 12:12:59AM -0700, Justin Pettit wrote:
> ---
>  utilities/ovs-vsctl.c |   15 +++++++++++++++
>  1 files changed, 15 insertions(+), 0 deletions(-)
> 
> diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c
> index df5150f..bcb104a 100644
> --- a/utilities/ovs-vsctl.c
> +++ b/utilities/ovs-vsctl.c
> @@ -2010,6 +2010,12 @@ insert_controllers(struct ovsdb_idl_txn *txn, char 
> *targets[], size_t n)
>  
>      controllers = xmalloc(n * sizeof *controllers);
>      for (i = 0; i < n; i++) {
> +        if (strncmp(targets[i], "ssl:", 4)
> +                && strncmp(targets[i], "tcp:", 4)
> +                && strncmp(targets[i], "unix:", 5)) {
> +            vsctl_fatal("target must begin with \"ssl:\", \"tcp:\", or "
> +                        "\"unix:\"");
> +        }

If we add a new way to connect to a controller, then we have to add it
here too or no one can (easily) use that new way.  The list of
possibilities is not complete, since you can also use pssl, ptcp, and
punix.  You can fix that by using vconn_verify_name() and
pvconn_verify_name().

I'd like ovs-vsctl to be able to control somewhat different versions of
OVS (certainly this goal is not fully achieved), so that one could add,
for example, an SCTP controller to a (hypothetical) newer version of OVS
that supports it with an older version of ovs-vsctl.  So I'd also reduce
the fatal error to a warning.

I bet the next question is going to be "how do I get the list of valid
possibilities for the log message" so I'll note that I don't think we
have to list all of them but just say that the syntax is incorrect and
suggest a few likely possibilities.

> @@ -2168,6 +2174,15 @@ insert_managers(struct vsctl_context *ctx, char 
> *targets[], size_t n)
>      /* Insert each manager in a new row in Manager table. */
>      managers = xmalloc(n * sizeof *managers);
>      for (i = 0; i < n; i++) {
> +        if (strncmp(targets[i], "ssl:", 4)
> +                && strncmp(targets[i], "tcp:", 4)
> +                && strncmp(targets[i], "unix:", 5)
> +                && strncmp(targets[i], "pssl:", 5)
> +                && strncmp(targets[i], "ptcp:", 5)
> +                && strncmp(targets[i], "punix:", 6)) {
> +            vsctl_fatal("target must begin with \"[p]ssl:\", \"[p]tcp:\", "
> +                        "or \"[p]unix:\"");
> +        }

Similar comments here, except that stream_verify_name() and
pstream_verify_name() are the right functions to call.
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

Reply via email to