From patchwork Thu Jun 2 14:34:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Wilson X-Patchwork-Id: 1638385 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=gOK24NRd; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LDT791gfNz9sFr for ; Fri, 3 Jun 2022 00:34:45 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 5DFCD40B62; Thu, 2 Jun 2022 14:34:43 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id E1o-Oy9WWTh2; Thu, 2 Jun 2022 14:34:42 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id 8EA5B40B5A; Thu, 2 Jun 2022 14:34:41 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 68030C0039; Thu, 2 Jun 2022 14:34:41 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4412BC007B for ; Thu, 2 Jun 2022 14:34:40 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 3249B40B5E for ; Thu, 2 Jun 2022 14:34:40 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9TIN6Z3z1t5l for ; Thu, 2 Jun 2022 14:34:39 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id 919EF40B5A for ; Thu, 2 Jun 2022 14:34:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654180478; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iC0FrGW0CsIzOYgg0yRRaAC33B+fwy82KMktfLJqAOM=; b=gOK24NRdv8fNAIlNxARYaaA7QejDoWJ9LUeOg85neds3OpDk2TgYC56fnGWqoxd+r6VioQ cpSrfPIYjSdYi5qK8wOHPTDe14Qeti+aUMIHXlalnzXGCK/qVHAcNo7uW6VC1gqU+3gUT9 rPPD01QITf89LzWSiCgLVCyGqXUEGMo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-36-zo8X_-kfOcC_dmbrmXWUEA-1; Thu, 02 Jun 2022 10:34:26 -0400 X-MC-Unique: zo8X_-kfOcC_dmbrmXWUEA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5783E1801389 for ; Thu, 2 Jun 2022 14:34:13 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.33.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2AE8440CF8E5; Thu, 2 Jun 2022 14:34:13 +0000 (UTC) From: Terry Wilson To: dev@openvswitch.org Date: Thu, 2 Jun 2022 09:34:09 -0500 Message-Id: <20220602143410.1986117-1-twilson@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=twilson@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH v2 ovn 1/2] Handle re-used pids in pidfile_is_running 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" Since pids can be re-used, it is necessary to check that the process that is running with a pid matches the one that we expect. This adds the ability to optionally pass a 'binary' argument to pidfile_is_running, and if it is passed to match the binary against /proc/$pid/exe. Signed-off-by: Terry Wilson Acked-by: Ihar Hrachyshka --- utilities/ovn-ctl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/utilities/ovn-ctl b/utilities/ovn-ctl index d733aa42d..41fa89770 100755 --- a/utilities/ovn-ctl +++ b/utilities/ovn-ctl @@ -40,9 +40,16 @@ ovn_ic_db_conf_file="$ovn_etcdir/ovn-ic-db-params.conf" ## start ## ## ----- ## +pid_exe_matches () { + pid=$1 + binary=$2 + [ -z "$binary" -o `readlink /proc/$pid/exe` = "$binary" ] +} + pidfile_is_running () { pidfile=$1 - test -e "$pidfile" && [ -s "$pidfile" ] && pid=`cat "$pidfile"` && pid_exists "$pid" + binary=$2 + test -e "$pidfile" && [ -s "$pidfile" ] && pid=`cat "$pidfile"` && pid_exists "$pid" && pid_exe_matches "$pid" "$binary" } >/dev/null 2>&1 stop_nb_ovsdb() { From patchwork Thu Jun 2 14:34:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Wilson X-Patchwork-Id: 1638384 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Pu8l1v6S; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LDT734zwLz9sFr for ; Fri, 3 Jun 2022 00:34:39 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 0F07F415D7; Thu, 2 Jun 2022 14:34:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id p_-d7TizBZqq; Thu, 2 Jun 2022 14:34:37 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id EA8AE415B8; Thu, 2 Jun 2022 14:34:35 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id BFA0EC0039; Thu, 2 Jun 2022 14:34:35 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id AC384C002D for ; Thu, 2 Jun 2022 14:34:34 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 9B87D415BA for ; Thu, 2 Jun 2022 14:34:34 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QjnOfAEQRMUg for ; Thu, 2 Jun 2022 14:34:33 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id ABD7C415B8 for ; Thu, 2 Jun 2022 14:34:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654180472; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JmKfg4Pc5foX3LK6jMUjvWQsUlQgWk0TR0z02wigXMo=; b=Pu8l1v6S3YJP2NY4uxeV8T3U1AYpNtMbYFoP+QuvVbaKa99/LKrcLjCGAjyvxhylvbyKhf VI7hATFv8JTH+PUskYE7jIqBCzHqKc8SCu4LAuRMXbV6S9/iHYnRiCIeG3O/I35vB2eiMm lyqeMYN0U5bkULREIOv1bi3o5402mvA= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-548-oS7ixHwcPLChnIEYLp4o-g-1; Thu, 02 Jun 2022 10:34:31 -0400 X-MC-Unique: oS7ixHwcPLChnIEYLp4o-g-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7B7103C1730D for ; Thu, 2 Jun 2022 14:34:15 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.33.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E6AA40CF8E5; Thu, 2 Jun 2022 14:34:15 +0000 (UTC) From: Terry Wilson To: dev@openvswitch.org Date: Thu, 2 Jun 2022 09:34:10 -0500 Message-Id: <20220602143410.1986117-2-twilson@redhat.com> In-Reply-To: <20220602143410.1986117-1-twilson@redhat.com> References: <20220602143410.1986117-1-twilson@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=twilson@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH v2 ovn 2/2] Ensure pid belongs to ovsdb-server in ovn-ctl 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" When checking if ovsdb-server is running, ensure that the binary we are going to run matches the one actually running with the the pid that was in our pidfile. Signed-off-by: Terry Wilson Acked-by: Ihar Hrachyshka --- utilities/ovn-ctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/ovn-ctl b/utilities/ovn-ctl index 41fa89770..48ad42780 100755 --- a/utilities/ovn-ctl +++ b/utilities/ovn-ctl @@ -206,7 +206,7 @@ start_ovsdb__() { ovn_install_dir "$ovn_etcdir" # Check and eventually start ovsdb-server for DB - if pidfile_is_running $db_pid_file; then + if pidfile_is_running $db_pid_file `which ovsdb-server`; then return fi