[ovs-dev] [PATCH ovn] ovn-nbctl: Create daemon socket in ovn run dir

Ilya Maximets i.maximets at ovn.org
Tue Apr 7 09:24:35 UTC 2020


On 4/7/20 10:26 AM, numans at ovn.org wrote:
> From: Numan Siddique <numans at ovn.org>
> 
> ovn-nbctl when run as a daemon is creating the ctl socket in
> the ovs rundir. This patch fixes this issue by creating it in
> the ovn rundir.
> 
> Reported-by: Dan Williams <dcbw at redhat.com>
> Signed-off-by: Numan Siddique <numans at ovn.org>
> ---
>  utilities/ovn-nbctl.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/utilities/ovn-nbctl.c b/utilities/ovn-nbctl.c
> index 59abe0051..412796e83 100644
> --- a/utilities/ovn-nbctl.c
> +++ b/utilities/ovn-nbctl.c
> @@ -6436,7 +6436,19 @@ server_loop(struct ovsdb_idl *idl, int argc, char *argv[])
>  
>      service_start(&argc, &argv);
>      daemonize_start(false);
> -    int error = unixctl_server_create(unixctl_path, &server);
> +
> +    char *abs_unixctl_path = NULL;
> +    if (!unixctl_path) {
> +        abs_unixctl_path = get_abs_unix_ctl_path();
> +    } else {
> +        abs_unixctl_path = unixctl_path;

But 'unixctl_path' might be not an absolute path.  In this case
unixctl_server_create() will still place it into ovs_rundir().
So, you need to have:
 
       abs_unixctl_path = unixctl_path ? abs_file_name(ovn_rundir(), unixctl_path)
                                       : get_abs_unix_ctl_path();

Another and, probably, better approach is to add an optional 'path' argument to
get_abs_unix_ctl_path() so it might call abs_file_name() for us.
so it will look like:

       abs_unixctl_path = get_abs_unix_ctl_path(unixctl_path);


However, this seems like existing issue for all the OVN processes.
None of the ovn applications checks if 'unixctl_path' is an absolute path or not.

> +    }
> +
> +    int error = unixctl_server_create(abs_unixctl_path, &server);
> +    if (!unixctl_path) {
> +        free(abs_unixctl_path);
> +    }
> +
>      if (error) {
>          ctl_fatal("failed to create unixctl server (%s)",
>                    ovs_retval_to_string(error));
>


More information about the dev mailing list