From patchwork Tue Apr 7 11:14:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1267367 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48xPvn4FFpz9sSq for ; Tue, 7 Apr 2020 21:15:17 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id C91F887F12; Tue, 7 Apr 2020 11:15:14 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XEqC3qDb0gKq; Tue, 7 Apr 2020 11:15:12 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id D929587EA4; Tue, 7 Apr 2020 11:15:12 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id C8B51C1AE2; Tue, 7 Apr 2020 11:15:12 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 01C8AC0177 for ; Tue, 7 Apr 2020 11:15:10 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id E040786930 for ; Tue, 7 Apr 2020 11:15:10 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DDI8qcUUp_Sm for ; Tue, 7 Apr 2020 11:15:09 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 6BB6986920 for ; Tue, 7 Apr 2020 11:15:09 +0000 (UTC) X-Originating-IP: 115.99.219.216 Received: from nummac.local (unknown [115.99.219.216]) (Authenticated sender: numans@ovn.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 2F99660017; Tue, 7 Apr 2020 11:15:04 +0000 (UTC) From: numans@ovn.org To: dev@openvswitch.org Date: Tue, 7 Apr 2020 16:44:53 +0530 Message-Id: <20200407111453.1156652-1-numans@ovn.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Cc: Dan Williams Subject: [ovs-dev] [PATCH ovn v2] ovn-nbctl: Create daemon control socket in ovn run dir X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Numan Siddique 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. When an ovn service is run with -u option (which specifies the ctl socket path) and if this path is not absolute, the ovn ctl socket path is created in the ovs run dir. This patch also fixes this issue by creating it in the ovn run dir. Reported-by: Dan Williams Signed-off-by: Numan Siddique --- v1 -> v2 ------ * Addressed the review comments from Ilya. If the ctl socket path is specified and if it is not absolute path it is now created in the ovn run dir. controller/ovn-controller.c | 2 +- ic/ovn-ic.c | 10 +++------- lib/ovn-util.c | 9 +++++---- lib/ovn-util.h | 2 +- northd/ovn-northd.c | 10 +++------- utilities/ovn-nbctl.c | 6 +++++- 6 files changed, 18 insertions(+), 21 deletions(-) diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 2893eaac1..4d21ba0fd 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -1729,7 +1729,7 @@ main(int argc, char *argv[]) daemonize_start(true); - char *abs_unixctl_path = get_abs_unix_ctl_path(); + char *abs_unixctl_path = get_abs_unix_ctl_path(NULL); retval = unixctl_server_create(abs_unixctl_path, &unixctl); free(abs_unixctl_path); if (retval) { diff --git a/ic/ovn-ic.c b/ic/ovn-ic.c index bf8205de2..d931ca50f 100644 --- a/ic/ovn-ic.c +++ b/ic/ovn-ic.c @@ -1575,13 +1575,9 @@ main(int argc, char *argv[]) daemonize_start(false); - 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); - } + char *abs_unixctl_path = get_abs_unix_ctl_path(unixctl_path); + retval = unixctl_server_create(abs_unixctl_path, &unixctl); + free(abs_unixctl_path); if (retval) { exit(EXIT_FAILURE); diff --git a/lib/ovn-util.c b/lib/ovn-util.c index df18fda89..514e2489f 100644 --- a/lib/ovn-util.c +++ b/lib/ovn-util.c @@ -377,7 +377,7 @@ default_ic_sb_db(void) } char * -get_abs_unix_ctl_path(void) +get_abs_unix_ctl_path(const char *path) { #ifdef _WIN32 enum { WINDOWS = 1 }; @@ -386,9 +386,10 @@ get_abs_unix_ctl_path(void) #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); + char *abs_path + = (path ? abs_file_name(ovn_rundir(), path) + : WINDOWS ? xasprintf("%s/%s.ctl", ovn_rundir(), program_name) + : xasprintf("%s/%s.%ld.ctl", ovn_rundir(), program_name, pid)); return abs_path; } diff --git a/lib/ovn-util.h b/lib/ovn-util.h index 32c8334b0..11238f61c 100644 --- a/lib/ovn-util.h +++ b/lib/ovn-util.h @@ -82,7 +82,7 @@ const char *default_nb_db(void); const char *default_sb_db(void); const char *default_ic_nb_db(void); const char *default_ic_sb_db(void); -char *get_abs_unix_ctl_path(void); +char *get_abs_unix_ctl_path(const char *path); struct ovsdb_idl_table_class; const char *db_table_usage(struct ds *tables, diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index 076278197..29e1fd450 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -11600,13 +11600,9 @@ main(int argc, char *argv[]) daemonize_start(false); - 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); - } + char *abs_unixctl_path = get_abs_unix_ctl_path(unixctl_path); + retval = unixctl_server_create(abs_unixctl_path, &unixctl); + free(abs_unixctl_path); if (retval) { exit(EXIT_FAILURE); diff --git a/utilities/ovn-nbctl.c b/utilities/ovn-nbctl.c index 59abe0051..a88c1ddc2 100644 --- a/utilities/ovn-nbctl.c +++ b/utilities/ovn-nbctl.c @@ -6436,7 +6436,11 @@ 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 = get_abs_unix_ctl_path(unixctl_path); + int error = unixctl_server_create(abs_unixctl_path, &server); + free(abs_unixctl_path); + if (error) { ctl_fatal("failed to create unixctl server (%s)", ovs_retval_to_string(error));