From: Stefano Brivio <sbrivio@redhat.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: passt-dev@passt.top
Subject: Re: [PATCH v3 05/15] flow, tcp, tcp_splice: Uniform debug helpers for new flows
Date: Wed, 17 Jan 2024 20:59:22 +0100 [thread overview]
Message-ID: <20240117205922.7bba3b54@elisabeth> (raw)
In-Reply-To: <20231221070237.1422557-6-david@gibson.dropbear.id.au>
On Thu, 21 Dec 2023 18:02:27 +1100
David Gibson <david@gibson.dropbear.id.au> wrote:
> 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.
>
> 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.
>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> flow.c | 40 ++++++++++++++++++++++++++++++++++++++++
> flow.h | 16 ++++++++++++++++
> tcp.c | 11 +++++++++--
> tcp_splice.c | 3 ++-
> 4 files changed, 67 insertions(+), 3 deletions(-)
>
> diff --git a/flow.c b/flow.c
> index b9c4a18..bc8cfc6 100644
> --- a/flow.c
> +++ b/flow.c
> @@ -9,6 +9,7 @@
> #include <unistd.h>
> #include <string.h>
> #include <errno.h>
> +#include <arpa/inet.h>
>
> #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);
> }
>
> +/**
> + * 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 = &f->side[side];
> +
> + flow_log_(f, LOG_DEBUG, "New %s from %s/%u: [%s]:%hu <-> [%s]:%hu",
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.
It's also useful if anything goes wrong with the flow table itself.
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.
> + 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 = &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 socket
> * @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 */
>
> +/** 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 != FLOW_TYPE_NONE && f->type < FLOW_NUM_TYPES &&
> + flowside_complete(&f->side[0]) &&
> + flowside_complete(&f->side[1]);
Preferably align next lines after "return ".
--
Stefano
next prev parent reply other threads:[~2024-01-17 19:59 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-21 7:02 [PATCH v3 00/15] RFC: Unified flow table David Gibson
2023-12-21 7:02 ` [PATCH v3 01/15] flow: Common data structures for tracking flow addresses David Gibson
2024-01-13 22:50 ` Stefano Brivio
2024-01-16 6:14 ` David Gibson
2023-12-21 7:02 ` [PATCH v3 02/15] tcp, flow: Maintain guest side flow information David Gibson
2024-01-13 22:51 ` Stefano Brivio
2024-01-16 6:23 ` David Gibson
2023-12-21 7:02 ` [PATCH v3 03/15] tcp, flow: Maintain host " David Gibson
2023-12-21 7:02 ` [PATCH v3 04/15] tcp_splice,flow: Maintain flow information for spliced connections David Gibson
2024-01-17 19:59 ` Stefano Brivio
2024-01-18 1:01 ` David Gibson
2023-12-21 7:02 ` [PATCH v3 05/15] flow, tcp, tcp_splice: Uniform debug helpers for new flows David Gibson
2024-01-17 19:59 ` Stefano Brivio [this message]
2024-01-18 1:04 ` David Gibson
2024-01-18 15:40 ` Stefano Brivio
2023-12-21 7:02 ` [PATCH v3 06/15] tcp, flow: Replace TCP specific hash function with general flow hash David Gibson
2024-01-17 19:59 ` Stefano Brivio
2024-01-18 1:15 ` David Gibson
2024-01-18 15:42 ` Stefano Brivio
2024-01-18 23:55 ` David Gibson
2023-12-21 7:02 ` [PATCH v3 07/15] flow: Add helper to determine a flow's protocol David Gibson
2023-12-21 7:02 ` [PATCH v3 08/15] flow, tcp: Generalise TCP hash table to general flow hash table David Gibson
2023-12-21 7:02 ` [PATCH v3 09/15] tcp: Re-use flow hash for initial sequence number generation David Gibson
2023-12-21 7:02 ` [PATCH v3 10/15] icmp: Store ping socket information in the flow table David Gibson
2023-12-21 7:02 ` [PATCH v3 11/15] icmp: Populate guest side information for ping flows David Gibson
2023-12-21 7:02 ` [PATCH v3 12/15] icmp: Populate and use host side flow information David Gibson
2024-01-17 19:59 ` Stefano Brivio
2024-01-18 1:22 ` David Gibson
2024-01-18 15:43 ` Stefano Brivio
2024-01-18 23:58 ` David Gibson
2023-12-21 7:02 ` [PATCH v3 13/15] icmp: Use 'flowside' epoll references for ping sockets David Gibson
2023-12-21 7:02 ` [PATCH v3 14/15] icmp: Merge EPOLL_TYPE_ICMP and EPOLL_TYPE_ICMPV6 David Gibson
2023-12-21 7:02 ` [PATCH v3 15/15] icmp: Eliminate icmp_id_map David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240117205922.7bba3b54@elisabeth \
--to=sbrivio@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=passt-dev@passt.top \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).