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(a)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; -- 2.41.0