From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id 37C305A0278 for ; Thu, 22 Feb 2024 18:18:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708622298; 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=rTrKkfwGZYwAd76mE+Hl2/zsslssm+8zhQaM0qxUaCM=; b=MTMa+Io1138mudV3QnWGUSEEdgfi93Yf/BVXePz8Tafh/+NcCsQXyVsinDxDTChAfGfktW X0EqFUQlxi2Hgas2GO7du04WgXm/1GVPZ3akNcjmdGMvJcvOt36am8wQxcp2ZE2FaT5vXM 92LN9hZJlZVDkicG114jYAhIS/xP7Us= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-562-w6z3NAS9OyqrpaT1mVouiA-1; Thu, 22 Feb 2024 12:18:17 -0500 X-MC-Unique: w6z3NAS9OyqrpaT1mVouiA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id B6A80108C060 for ; Thu, 22 Feb 2024 17:18:16 +0000 (UTC) Received: from pholzing-fedora.redhat.com (unknown [10.39.192.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 343511121337; Thu, 22 Feb 2024 17:18:16 +0000 (UTC) From: Paul Holzinger To: passt-dev@passt.top Subject: [PATCH 2/2] conf: set the log level much earlier Date: Thu, 22 Feb 2024 18:17:41 +0100 Message-ID: <20240222171739.141623-4-pholzing@redhat.com> In-Reply-To: <20240222171739.141623-2-pholzing@redhat.com> References: <20240222171739.141623-2-pholzing@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: DXAVXZQZ3POPMHEDVKFTNKMA2W3KVRY4 X-Message-ID-Hash: DXAVXZQZ3POPMHEDVKFTNKMA2W3KVRY4 X-MailFrom: pholzing@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Paul Holzinger X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --quiet is supposed to silence the "No routable interface" message but it does not work because the log level was set long after conf_ip4/6() was called which means it uses the default level which logs everything. To address this move the log level logic directly after the option parsing in conf(). Signed-off-by: Paul Holzinger --- conf.c | 10 ++++++++++ passt.c | 10 ---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/conf.c b/conf.c index 9c99531..17cf279 100644 --- a/conf.c +++ b/conf.c @@ -1646,6 +1646,16 @@ void conf(struct ctx *c, int argc, char **argv) logfile, logsize); } + /* Once the log mask is not LOG_EARLY, we will no longer log to stderr + * if there was a log file specified. + */ + if (c->debug) + __setlogmask(LOG_UPTO(LOG_DEBUG)); + else if (c->quiet) + __setlogmask(LOG_UPTO(LOG_WARNING)); + else + __setlogmask(LOG_UPTO(LOG_INFO)); + nl_sock_init(c, false); if (!v6_only) c->ifi4 = conf_ip4(ifi4, &c->ip4, c->mac); diff --git a/passt.c b/passt.c index 5d7e7c4..a061f2b 100644 --- a/passt.c +++ b/passt.c @@ -320,16 +320,6 @@ int main(int argc, char **argv) if (isolate_prefork(&c)) die("Failed to sandbox process, exiting"); - /* Once the log mask is not LOG_EARLY, we will no longer log to stderr - * if there was a log file specified. - */ - if (c.debug) - __setlogmask(LOG_UPTO(LOG_DEBUG)); - else if (c.quiet) - __setlogmask(LOG_UPTO(LOG_WARNING)); - else - __setlogmask(LOG_UPTO(LOG_INFO)); - if (!c.foreground) __daemon(pidfile_fd, devnull_fd); else -- 2.43.2