From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 13DE85A026D for ; Thu, 23 Nov 2023 23:19:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1700777944; bh=v/gVlPQvOa2PKpmax2I6k8eJNp2+m03smM0BsHw+gGA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Yy/51w4Ayulfyy3O44uYsj5PYRDboE6xv7V44M2vGYyN3/Ec6Ngej/dOG/zLnRL1y f/bliYI7r92sgGMIjcz0T1ivpDF6oh7vZLudfs22ZsglnpGC7C/XMCxt4i4CrmtDAS pIMyNFDQJfW83LlxY/x61aoZGvndacX9HkUDnLXs= Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Sbsw84Nt3z4x7q; Fri, 24 Nov 2023 09:19:04 +1100 (AEDT) Date: Fri, 24 Nov 2023 09:14:52 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 6/6] flow, tcp: Add logging helpers for connection related messages Message-ID: References: <20231123023629.2024938-1-david@gibson.dropbear.id.au> <20231123023629.2024938-7-david@gibson.dropbear.id.au> <20231123075845.6dfd16fa@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="t+yPs/dNo5Fzm821" Content-Disposition: inline In-Reply-To: <20231123075845.6dfd16fa@elisabeth> Message-ID-Hash: WLD65DULXBDUOZM7AJBWDJ53NFNX6T7H X-Message-ID-Hash: WLD65DULXBDUOZM7AJBWDJ53NFNX6T7H 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: passt-dev@passt.top 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: --t+yPs/dNo5Fzm821 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Nov 23, 2023 at 07:58:45AM +0100, Stefano Brivio wrote: > On Thu, 23 Nov 2023 13:36:29 +1100 > David Gibson wrote: >=20 > > Most of the messages logged by the TCP code (be they errors, debug or > > trace messages) are related to a specific connection / flow. We're fai= rly > > consistent about prefixing these with the type of connection and the > > connection / flow index. However there are a few places where we put t= he > > index later in the message or omit it entirely. The template with the > > prefix is also a little bulky to carry around for every message, > > particularly for spliced connections. > >=20 > > To help keep this consistent, introduce some helpers to log messages > > linked to a specific flow. It takes the flow as a parameter and adds a > > uniform prefix to each message. This makes things slightly neater now,= but > > more importantly will help keep formatting consistent as we add more th= ings > > to the flow table. > >=20 > > Signed-off-by: David Gibson > > --- > > flow.c | 21 ++++++++++++++ > > flow.h | 14 +++++++++ > > tcp.c | 81 ++++++++++++++++++++++++---------------------------- > > tcp_splice.c | 61 +++++++++++++++++---------------------- > > 4 files changed, 99 insertions(+), 78 deletions(-) > >=20 > > diff --git a/flow.c b/flow.c > > index 0fff119..cb2cf62 100644 > > --- a/flow.c > > +++ b/flow.c > > @@ -64,3 +64,24 @@ void flow_table_compact(struct ctx *c, union flow *h= ole) > > =20 > > memset(from, 0, sizeof(*from)); > > } > > + > > +/** flow_log_ - Log flow-related message > > + * @f: flow the message is related to > > + * @pri: Log priority > > + * @fmt: Format string > > + * @...: printf-arguments > > + * > > + * @fmt must include an initial "%s" to expand to the prefix we genera= te > > + * (typically added by the flow_log() macro). >=20 > I don't understand how it does that -- flow_log() seems to just pass > __VA_ARGS__ through? Oops, that's a leftover from an earlier version. I formatting the prefix first, then adding it to the message, rather than the message first and adding it to the prefix. I was attempting to avoid a fixed size buffer for the message, but it just turned out weird and troublesome. Plus vlogmsg() has a fixed sized buffer anyway, so why bother. Anyway, I've removed the stale comment. --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --t+yPs/dNo5Fzm821 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmVfzsoACgkQzQJF27ox 2GeRzA//SSxa1/7Wnavw89onIGyHhRZX0SaJcTul4a74loMxWLiWmJYON8PWhowA W0MYw8KnhjYVqUaccfVQhMeK5hJ3QOux9oHbcf4RFeh9FZrfVbm+tQsdWl6d+lqp VvAfbHen8clW5rHyw2opSHZs23Rzo5lHPgCMyFMf33oPZ5G3nDkKtLzuJL2JiBPl DaPuRdygAIPIGeWMYHzNVNbW2dVFcvWKft3cWplAIsgPLK9ZcpOu6oBvxHAcdXiM pf+ZGCp3mvCEmX3LUlz9L/YBmVrcYNMKeCQg6uDdl5y57dKxo1NENDoSbW00c/Qz TWo1Ys1YDZePvGE9zr4fI4jDT/ps6WV+tnUEWFoXQ1QQvDOYY/HDxpbBYgLCQ3s4 DghkPCbf6VtdJzgfGGqI3IMk6hjo/9reMuc+Mv8+Ft4+bZvlNDHVm6V/0hKl2jJt fxqEK3b2sE0UzK6Pi1yxv5luZIXu+xbOsaZ7K6CKps3KeTIi2AHKTlBL0E3M++i6 On6vU1PiAATvie4GCuWSALFMrR9HCqspoqLE5z0fMb1T9KWFYC7KaucUG/Nwhzex qFQ102FnbFo7OGoTNj0cqDFBauzvOPJ2bhZmXE0eFGOe3EKSR32gY2iT0p2dkiSG 1HywDNKkM9sl7TQ89pYI/VgI2HfdKtSeosoImEwSYnZOrkSdobE= =K7jh -----END PGP SIGNATURE----- --t+yPs/dNo5Fzm821--