From: David Gibson <david@gibson.dropbear.id.au>
To: passt-dev@passt.top, Stefano Brivio <sbrivio@redhat.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH v2 08/10] tcp: Re-use flowside_hash for initial sequence number generation
Date: Mon, 28 Aug 2023 15:41:44 +1000 [thread overview]
Message-ID: <20230828054146.48673-9-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20230828054146.48673-1-david@gibson.dropbear.id.au>
We generate TCP initial sequence numbers, when we need them, from a hash
of the source and destination addresses and ports, plus a timestamp.
The contents of that hash are now exactly the same as the flowside_hash()
we use elsewhere. The values won't be identical because we order the
fields in the hash differently, but that doesn't matter for our purposes.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
tcp.c | 15 +--------------
1 file changed, 1 insertion(+), 14 deletions(-)
diff --git a/tcp.c b/tcp.c
index 27cdd15..a9ddce6 100644
--- a/tcp.c
+++ b/tcp.c
@@ -1754,20 +1754,7 @@ static void tcp_clamp_window(const struct ctx *c, struct tcp_tap_conn *conn,
static void tcp_seq_init(const struct ctx *c, struct tcp_tap_conn *conn,
const struct timespec *now)
{
- struct {
- union inany_addr src;
- in_port_t srcport;
- union inany_addr dst;
- in_port_t dstport;
- } __attribute__((__packed__)) in = {
- .src = TAPSIDE(conn)->faddr,
- .srcport = TAPSIDE(conn)->fport,
- .dst = TAPSIDE(conn)->eaddr,
- .dstport = TAPSIDE(conn)->eport,
- };
- uint32_t ns, seq = 0;
-
- seq = siphash_36b((uint8_t *)&in, c->tcp.hash_secret);
+ uint32_t ns, seq = flowside_hash(TAPSIDE(conn), c->tcp.hash_secret);
/* 32ns ticks, overflows 32 bits every 137s */
ns = (now->tv_sec * 1000000000 + now->tv_nsec) >> 5;
--
@@ -1754,20 +1754,7 @@ static void tcp_clamp_window(const struct ctx *c, struct tcp_tap_conn *conn,
static void tcp_seq_init(const struct ctx *c, struct tcp_tap_conn *conn,
const struct timespec *now)
{
- struct {
- union inany_addr src;
- in_port_t srcport;
- union inany_addr dst;
- in_port_t dstport;
- } __attribute__((__packed__)) in = {
- .src = TAPSIDE(conn)->faddr,
- .srcport = TAPSIDE(conn)->fport,
- .dst = TAPSIDE(conn)->eaddr,
- .dstport = TAPSIDE(conn)->eport,
- };
- uint32_t ns, seq = 0;
-
- seq = siphash_36b((uint8_t *)&in, c->tcp.hash_secret);
+ uint32_t ns, seq = flowside_hash(TAPSIDE(conn), c->tcp.hash_secret);
/* 32ns ticks, overflows 32 bits every 137s */
ns = (now->tv_sec * 1000000000 + now->tv_nsec) >> 5;
--
2.41.0
next prev parent reply other threads:[~2023-08-28 5:42 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
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 ` David Gibson [this message]
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=20230828054146.48673-9-david@gibson.dropbear.id.au \
--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).