From 508adde342f65efc3d58c51beaabb9ae8ecd8137 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Thu, 18 Jul 2024 15:26:36 +1000 Subject: tcp: Re-use flow hash for initial sequence number generation We generate TCP initial sequence numbers, when we need them, from a hash of the source and destination addresses and ports, plus a timestamp. Moments later, we generate another hash of the same information plus some more to insert the connection into the flow hash table. With some tweaks to the flow_hash_insert() interface and changing the order we can re-use that hash table hash for the initial sequence number, rather than calculating another one. It won't generate identical results, but that doesn't matter as long as the sequence numbers are well scattered. Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- flow.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'flow.h') diff --git a/flow.h b/flow.h index fcb4121..e3a778a 100644 --- a/flow.h +++ b/flow.h @@ -229,7 +229,7 @@ static inline bool flow_sidx_eq(flow_sidx_t a, flow_sidx_t b) return (a.flowi == b.flowi) && (a.sidei == b.sidei); } -void flow_hash_insert(const struct ctx *c, flow_sidx_t sidx); +uint64_t flow_hash_insert(const struct ctx *c, flow_sidx_t sidx); void flow_hash_remove(const struct ctx *c, flow_sidx_t sidx); flow_sidx_t flow_lookup_af(const struct ctx *c, uint8_t proto, uint8_t pif, sa_family_t af, -- cgit v1.2.3