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 332875A0275 for ; Thu, 18 Jan 2024 02:15:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1705540519; bh=Gfl1RhfkrhfWSiTGNaI7KAuLdVEwRu3JCsA8vtepQD8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rVFq9MEFPo2UqrR+/roy4MioOHgt5ALYLJgN0dfeSx2pOWO9rSdyq/J7GmBQBNX+1 eeR3k5QUclOFgSyRuCrDKFDJhC+jObiac/qRh5fQ1oGi5WF02pkvf3WkmTL/bvTHq8 6riINsaWSneemEO4DgreqU+UbVqeau04JkNq9ufB0JQJFNsfREpzmBfoWsd1v0W9Ia sUZbgCx1ouCUUpDtts1w+qaa1R9WS2ODJhOFK1cfJhD3c5bgoPWq15JzClcakNpx1n fGz/2epSiHqb/FRWorZuRt2OzIu0OvubfKg7BYwnRXT99cXIReIt3Vd2mFL3jetuQ+ 7UOTYRvN0Ma9Q== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4TFlD730Pnz4xPL; Thu, 18 Jan 2024 12:15:19 +1100 (AEDT) Date: Thu, 18 Jan 2024 12:04:15 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH v3 05/15] flow, tcp, tcp_splice: Uniform debug helpers for new flows Message-ID: References: <20231221070237.1422557-1-david@gibson.dropbear.id.au> <20231221070237.1422557-6-david@gibson.dropbear.id.au> <20240117205922.7bba3b54@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="r/mdhlyQ20puCC8L" Content-Disposition: inline In-Reply-To: <20240117205922.7bba3b54@elisabeth> Message-ID-Hash: B6GPNMRKFCIYIWU235YJKIZRLSDXLBZO X-Message-ID-Hash: B6GPNMRKFCIYIWU235YJKIZRLSDXLBZO 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: --r/mdhlyQ20puCC8L Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jan 17, 2024 at 08:59:22PM +0100, Stefano Brivio wrote: > On Thu, 21 Dec 2023 18:02:27 +1100 > David Gibson wrote: >=20 > > When debugging passt/pasta, and the flow table in particular, one of the > > most obvious things to know is when a new flow is initiated, along with= the > > details of its interface, addresses and ports. Once we've determined to > > what interface the flow should be forwarded, it's useful to know the > > details of how it will appear on that other interface. > >=20 > > To help present that information uniformly, introduce FLOW_NEW_DBG() and > > FLOW_FWD_DBG() helpers and use them for TCP connections, both "tap" and > > spliced. > >=20 > > Signed-off-by: David Gibson > > --- > > flow.c | 40 ++++++++++++++++++++++++++++++++++++++++ > > flow.h | 16 ++++++++++++++++ > > tcp.c | 11 +++++++++-- > > tcp_splice.c | 3 ++- > > 4 files changed, 67 insertions(+), 3 deletions(-) > >=20 > > diff --git a/flow.c b/flow.c > > index b9c4a18..bc8cfc6 100644 > > --- a/flow.c > > +++ b/flow.c > > @@ -9,6 +9,7 @@ > > #include > > #include > > #include > > +#include > > =20 > > #include "util.h" > > #include "passt.h" > > @@ -50,6 +51,45 @@ void flow_log_(const struct flow_common *f, int pri,= const char *fmt, ...) > > logmsg(pri, "Flow %u (%s): %s", flow_idx(f), FLOW_TYPE(f), msg); > > } > > =20 > > +/** > > + * flow_new_dbg() - Print debug message for new flow > > + * @f: Common flow structure > > + * @side: Which side initiated the new flow > > + */ > > +void flow_new_dbg(const struct flow_common *f, unsigned side) > > +{ > > + char ebuf[INET6_ADDRSTRLEN], fbuf[INET6_ADDRSTRLEN]; > > + const struct flowside *fside =3D &f->side[side]; > > + > > + flow_log_(f, LOG_DEBUG, "New %s from %s/%u: [%s]:%hu <-> [%s]:%hu", >=20 > I think we should always print the connection index too (passed from > the macro, or passing 'conn' as argument here) -- especially if we want > to correlate this to what flow_fwd_dbg() will print later. Printing the index is built into flow_log_(), so we're already doing that. > It's also useful if anything goes wrong with the flow table itself. >=20 > Sure, address/ports pairs should now be sufficient to uniquely identify > a flow, and the flow table should be otherwise transparent, but the idea > behind debugging is that there's a bug somewhere. >=20 > > + flow_type_str[f->type], pif_name(fside->pif), side, > > + inet_ntop(AF_INET6, &fside->faddr, fbuf, sizeof(fbuf)), > > + fside->fport, > > + inet_ntop(AF_INET6, &fside->eaddr, ebuf, sizeof(ebuf)), > > + fside->eport); > > +} > > + > > +/** > > + * flow_fwd_dbg() - Print debug message for newly forwarded flow > > + * @f: Common flow structure > > + * @side: Which side was the flow forwarded to > > + */ > > +void flow_fwd_dbg(const struct flow_common *f, unsigned side) > > +{ > > + char ebuf[INET6_ADDRSTRLEN], fbuf[INET6_ADDRSTRLEN]; > > + const struct flowside *fside =3D &f->side[side]; > > + > > + inet_ntop(AF_INET6, &fside->eaddr, ebuf, sizeof(ebuf)); > > + inet_ntop(AF_INET6, &fside->faddr, fbuf, sizeof(fbuf)); > > + > > + flow_log_(f, LOG_DEBUG, "Forwarded to %s/%u: [%s]:%hu <-> [%s]:%hu", > > + pif_name(fside->pif), side, > > + inet_ntop(AF_INET6, &fside->faddr, fbuf, sizeof(fbuf)), > > + fside->fport, > > + inet_ntop(AF_INET6, &fside->eaddr, ebuf, sizeof(ebuf)), > > + fside->eport); > > +} > > + > > /** flowside_from_sock - Initialize flowside to match an existing sock= et > > * @fside: flowside to initialize > > * @pif: pif id of this flowside > > diff --git a/flow.h b/flow.h > > index 37885b2..e7c4484 100644 > > --- a/flow.h > > +++ b/flow.h > > @@ -97,6 +97,22 @@ struct flow_common { > > #define FLOW_TABLE_PRESSURE 30 /* % of FLOW_MAX */ > > #define FLOW_FILE_PRESSURE 30 /* % of c->nofile */ > > =20 > > +/** flow_complete - Check if common parts of flow are fully initialized > > + * @flow: flow to check > > + */ > > +static inline bool flow_complete(const struct flow_common *f) > > +{ > > + return f->type !=3D FLOW_TYPE_NONE && f->type < FLOW_NUM_TYPES && > > + flowside_complete(&f->side[0]) && > > + flowside_complete(&f->side[1]); >=20 > Preferably align next lines after "return ". Done. --=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 --r/mdhlyQ20puCC8L Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmWoeQ4ACgkQzQJF27ox 2Gc5DRAAjZw98gqCAL2XtRkyZ6piaQvSPJZPaAeG2ra4Ybkbn7Ol8iTiWD1OyDCz QMn34pWagnmwmXB24R+sHUs2X26SofP3++Kc1DBtSwaj+66QDQN08pcgPOvXl/pM O2CcZBgChqQnuA+sCfkjaXUDk8VH+R65Vsu9SHRroCUtDqkaVLQlodSGa5ov7tF4 ASYHznx/D0e1kDQTNLX0pTeOL6QTUmG3YnD7tVK9JxVuowxoelMXKrR9MZDDDkA1 Z3ulk0OlxzpI+3vSR6xlNgJCReJpMgUuqALXgHKqGHQm2TwnMYSUlXyK7TWueRUT bs95jpHP6Uv0LgmVmqd+IbHF8pjOPw+TY1eoKvlVkMdFTn+yJiUFi8KkOStz9SBv cwx7zIhFZ5ie54hUCqRQuk5rh4I+bOFOb2A8UjEznSAJqyPsEvjtZkY0JhIyOqu8 KcLacGE+NHlFdtXJk1OSdgneopusrTkfAqTCFaOaYf99kEO+zgtTQ6URN0UXKg4F fkVUjQAEZI0qdA6VhsO/CB01wcW2644Ip9YkxreQTJUhmfhBhm90mTW7ut/19Kyh yNS7BEksZpwGZUpMesmf/MQusx3rPqu7ZgbmddNbgDRcvHdRX8CVbOmzTxRqwKK2 hXOUZKTNODKDAT6F7oXFCE3U4A0wbXsAu7AfqlV9MhFlvs3PYEw= =0xlh -----END PGP SIGNATURE----- --r/mdhlyQ20puCC8L--