From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>
Cc: passt-dev@passt.top
Subject: Re: [PATCH v2 03/10] flow, tcp: Consolidate flow pointer<->index helpers
Date: Thu, 7 Sep 2023 13:48:03 +1000 [thread overview]
Message-ID: <ZPlH8+Ab88138810@zatzit> (raw)
In-Reply-To: <20230907030121.52763165@elisabeth>
[-- Attachment #1: Type: text/plain, Size: 2699 bytes --]
On Thu, Sep 07, 2023 at 03:01:21AM +0200, Stefano Brivio wrote:
> On Mon, 28 Aug 2023 15:41:39 +1000
> David Gibson <david@gibson.dropbear.id.au> wrote:
>
> > Both tcp.c and tcp_splice.c define CONN_IDX() variants to find the index
> > of their connection structures in the connection table, now become the
> > unified flow table. We can easily combine these into a common helper.
> > While we're there, add some trickery for some additional type safety.
> >
> > They also define their own CONN() versions, which aren't so easily combined
> > since they need to return different types, but we can have them use a
> > common helper.
> >
> > Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> > ---
> > flow_table.h | 20 ++++++++++++++++++++
> > tcp.c | 49 ++++++++++++++++++++++++-------------------------
> > tcp_conn.h | 2 +-
> > tcp_splice.c | 17 ++++++++---------
> > 4 files changed, 53 insertions(+), 35 deletions(-)
> >
> > diff --git a/flow_table.h b/flow_table.h
> > index c4c646b..dd4875e 100644
> > --- a/flow_table.h
> > +++ b/flow_table.h
> > @@ -22,4 +22,24 @@ union flow {
> > /* Global Flow Table */
> > extern union flow flowtab[];
> >
> > +
> > +/** flowk_idx - Index of flow from common structure
>
> "flowk"
Oops, fixed.
> > + * @f: Common flow fields pointer
> > + *
> > + * Return: index of @f in the flow table
> > + */
> > +static inline unsigned flow_idx(const struct flow_common *f)
> > +{
> > + return (union flow *)f - flowtab;
> > +}
> > +
> > +/** FLOW_IDX - Find the index of a flow
> > + * @f_: Flow pointer, either union flow * or protocol specific
> > + *
> > + * Return: index of @f in the flow table
> > + */
> > +#define FLOW_IDX(f_) (flow_idx(&(f_)->f))
> > +
> > +#define FLOW(index) (&flowtab[(index)])
> > +
> > #endif /* FLOW_TABLE_H */
> > diff --git a/tcp.c b/tcp.c
> > index 7994197..7d2e89d 100644
> > --- a/tcp.c
> > +++ b/tcp.c
> > @@ -561,8 +561,7 @@ tcp6_l2_flags_buf[TCP_FRAMES_MEM];
> >
> > static unsigned int tcp6_l2_flags_buf_used;
> >
> > -#define CONN(index) (&flowtab[(index)].tcp)
> > -#define CONN_IDX(conn) ((union flow *)(conn) - flowtab)
> > +#define CONN(index) (&FLOW(index)->tcp)
>
> Extra parentheses are not needed, but I've been wondering for a bit why
> you would use "&FLOW" here, as FLOW(x) already resolves to &flowtab[x]...
> perhaps (&(FLOW(index)->tcp)) is actually easier to read?
Makes sense to me, done.
--
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2023-09-07 4:14 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-28 5:41 [PATCH v2 00/10] RFC: Convert TCP connection table to generalisable flow table David Gibson
2023-08-28 5:41 ` [PATCH v2 01/10] flow, tcp: Generalise connection types David Gibson
2023-08-28 5:41 ` [PATCH v2 02/10] flow, tcp: Move TCP connection table to unified flow table David Gibson
2023-08-28 5:41 ` [PATCH v2 03/10] flow, tcp: Consolidate flow pointer<->index helpers David Gibson
2023-09-07 1:01 ` Stefano Brivio
2023-09-07 3:48 ` David Gibson [this message]
2023-08-28 5:41 ` [PATCH v2 04/10] flow: Make unified version of flow table compaction David Gibson
2023-08-28 5:41 ` [PATCH v2 05/10] flow: Introduce struct flowside, space for uniform tracking of addresses David Gibson
2023-09-07 1:01 ` Stefano Brivio
2023-09-07 4:05 ` David Gibson
2023-09-07 7:55 ` Stefano Brivio
2023-08-28 5:41 ` [PATCH v2 06/10] tcp: Move guest side address tracking to flow/flowside David Gibson
2023-08-28 5:41 ` [PATCH v2 07/10] tcp, flow: Perform TCP hash calculations based on flowside David Gibson
2023-08-28 5:41 ` [PATCH v2 08/10] tcp: Re-use flowside_hash for initial sequence number generation David Gibson
2023-08-28 5:41 ` [PATCH v2 09/10] tcp: Maintain host flowside for connections David Gibson
2023-08-28 5:41 ` [PATCH v2 10/10] tcp_splice: Fill out flowside information for spliced connections David Gibson
2023-09-07 1:02 ` Stefano Brivio
2023-09-07 4:14 ` David Gibson
2023-09-07 7:55 ` Stefano Brivio
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=ZPlH8+Ab88138810@zatzit \
--to=david@gibson.dropbear.id.au \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/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).