From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202606 header.b=jcXn1wpr; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 2F2995A0265 for ; Fri, 19 Jun 2026 17:26:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202606; t=1781882789; bh=Z5VsQaqLHpxLOyQAf2admP5PSBzkm2bvijR2uuSqd9E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jcXn1wprXou3OALDVvTkwdl4FN7hwHvoGovjaefXqIBJ18NNSasUR5/faUEoGjCzu sRm7SaCNHOdjdSlLCHFW9mLMT9qpvSEYiWYhz4hAluYgozCikL3J4cWTQ5k6aH4oVH iFp5KrzZkf1Nq+0hpENvPyASeHglQlqs12A02YUJsHMWeMwNuGYNY3Aj6LQ9Xh6tBs sYlHlahVsdDHWhVgr4SH0UxJdSpupVk7dxpzT7M/IIrEXnQUdDjrLoCHFynH+r3vQG g+wjZSfAI9HBvXWn1W+eRHWDhpvn3uypl/MQJhAhs0U4ZKf7RmTFdXaxPC9uxzifdc 1skA5/drDi8vA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4ghhJj59QVz58t5; Sat, 20 Jun 2026 01:26:29 +1000 (AEST) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v3 3/6] flow: Include flow details with higher priority log messages Date: Sat, 20 Jun 2026 01:26:23 +1000 Message-ID: <20260619152626.3033033-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260619152626.3033033-1-david@gibson.dropbear.id.au> References: <20260619152626.3033033-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: LGW5IIQ4TNGLIMUXDB4N56S3ELIGSUC3 X-Message-ID-Hash: LGW5IIQ4TNGLIMUXDB4N56S3ELIGSUC3 X-MailFrom: dgibson@gandalf.ozlabs.org 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: David Gibson 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: Currently flow_log() and related functions / macros have a 'details' parameter which indicates whether to add extra messages with details of the flow's addresses. This is still a bit awkward to invoke, and only used in a few places. Change the logic, to automatically include the details if and only if the log priority is greater than LOG_DEBUG. Rationale: If at debug log level, there are already a bunch of debug messages tracking the flow life cycle, which include those details (we make sure to retain those). It's usually pretty easy to cross reference a specific flow debug message with the flow's history including the details. If at higher log level, and we generate a flow-connected error or warning we don't have those life cycle messages. So, just giving the flow index doesn't really tell you anything about which flow tripped the error. Adding the address details make the error message significantly more useful. Signed-off-by: David Gibson --- flow.c | 2 +- flow.h | 22 +++++++++++----------- tcp.c | 2 +- udp.c | 5 ++--- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/flow.c b/flow.c index 8f8435e6..b2963396 100644 --- a/flow.c +++ b/flow.c @@ -554,7 +554,7 @@ norule: /* This shouldn't happen, because if there's no rule for it we should * have no listening socket that would let us get here */ - flow_log(flow, LOG_DEBUG, false, true, "Missing forward rule"); + flow_dbg(flow, "Missing forward rule"); nofwd: flow_err(flow, "No rules to forward %s %s [%s]:%hu -> [%s]:%hu", diff --git a/flow.h b/flow.h index 2b78067a..61dde6d9 100644 --- a/flow.h +++ b/flow.h @@ -284,19 +284,19 @@ void flow_log__(const struct flow_common *f, int pri, bool perror, bool details, enum flow_state state, const char *fmt, ...) __attribute__((format(printf, 6, 7))); -#define flow_log_(f_, pri_, perror_, details_, ...) \ - flow_log__((f_), (pri_), (perror_), (details_), (f_)->state, \ - __VA_ARGS__) +#define flow_log_(f_, pri_, perror_, ...) \ + flow_log__((f_), (pri_), (perror_), (pri_) > LOG_DEBUG, \ + (f_)->state, __VA_ARGS__) -#define flow_log(flow_, pri_, perror_, details_, ...) \ - flow_log_(&(flow_)->f, (pri_), (perror_), (details_), __VA_ARGS__) +#define flow_log(flow_, pri_, perror_, ...) \ + flow_log_(&(flow_)->f, (pri_), (perror_), __VA_ARGS__) #define flow_dbg(flow_, ...) \ - flow_log((flow_), LOG_DEBUG, false, false, __VA_ARGS__) + flow_log((flow_), LOG_DEBUG, false, __VA_ARGS__) #define flow_warn(flow_, ...) \ - flow_log((flow_), LOG_WARNING, false, false, __VA_ARGS__) + flow_log((flow_), LOG_WARNING, false, __VA_ARGS__) #define flow_err(flow_, ...) \ - flow_log((flow_), LOG_ERR, false, false, __VA_ARGS__) + flow_log((flow_), LOG_ERR, false, __VA_ARGS__) #define flow_trace(flow_, ...) \ do { \ if (log_trace) \ @@ -304,11 +304,11 @@ void flow_log__(const struct flow_common *f, int pri, bool perror, bool details, } while (0) #define flow_dbg_perror(flow_, ...) \ - flow_log((flow_), LOG_DEBUG, true, false, __VA_ARGS__) + flow_log((flow_), LOG_DEBUG, true, __VA_ARGS__) #define flow_warn_perror(flow_, ...) \ - flow_log((flow_), LOG_WARNING, true, false, __VA_ARGS__) + flow_log((flow_), LOG_WARNING, true, __VA_ARGS__) #define flow_perror(flow_, ...) \ - flow_log((flow_), LOG_ERR, true, false, __VA_ARGS__) + flow_log((flow_), LOG_ERR, true, __VA_ARGS__) #define flow_dbg_ratelimit(flow_, now_, ...) \ logmsg_ratelimit(flow_dbg, debug, (now_), (flow_), __VA_ARGS__) diff --git a/tcp.c b/tcp.c index 3538eec2..1c902ac2 100644 --- a/tcp.c +++ b/tcp.c @@ -1404,7 +1404,7 @@ void tcp_linger0_(const struct flow_common *f, int s) */ if (setsockopt(s, SOL_SOCKET, SO_LINGER, &linger0, sizeof(linger0)) < 0) { - flow_log_(f, LOG_DEBUG, true, false, + flow_log_(f, LOG_DEBUG, true, "SO_LINGER failed, may not send RST to peer"); } } diff --git a/udp.c b/udp.c index c95bb200..2d9e2f04 100644 --- a/udp.c +++ b/udp.c @@ -943,8 +943,7 @@ void udp_sock_handler(const struct ctx *c, union epoll_ref ref, if (events & EPOLLERR) { if (udp_sock_errs(c, ref.fd, ref.flowside, PIF_NONE, 0) < 0) { - flow_log(uflow, LOG_ERR, false, true, - "Unrecoverable error on flow socket"); + flow_err(uflow, "Unrecoverable error on flow socket"); goto fail; } } @@ -975,7 +974,7 @@ void udp_sock_handler(const struct ctx *c, union epoll_ref ref, udp_buf_sock_to_tap(c, s, n, tosidx); } } else { - flow_log(uflow, LOG_ERR, false, true, + flow_err(uflow, "No support for forwarding UDP from %s to %s", pif_name(pif_at_sidx(ref.flowside)), pif_name(topif)); -- 2.54.0