From 163a339214dd34696ce485930f35ed21c86057f0 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Thu, 18 Jul 2024 15:26:34 +1000 Subject: tcp, flow: Replace TCP specific hash function with general flow hash Currently we match TCP packets received on the tap connection to a TCP connection via a hash table based on the forwarding address and both ports. We hope in future to allow for multiple guest side addresses, or for multiple interfaces which means we may need to distinguish based on the endpoint address and pif as well. We also want a unified hash table to cover multiple protocols, not just TCP. Replace the TCP specific hash function with one suitable for general flows, or rather for one side of a general flow. This includes all the information from struct flowside, plus the pif and the L4 protocol number. Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- flow.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'flow.h') diff --git a/flow.h b/flow.h index 8c6ba60..a0550dc 100644 --- a/flow.h +++ b/flow.h @@ -149,6 +149,25 @@ struct flowside { in_port_t eport; }; +/** + * flowside_eq() - Check if two flowsides are equal + * @left, @right: Flowsides to compare + * + * Return: true if equal, false otherwise + */ +static inline bool flowside_eq(const struct flowside *left, + const struct flowside *right) +{ + return inany_equals(&left->eaddr, &right->eaddr) && + left->eport == right->eport && + inany_equals(&left->faddr, &right->faddr) && + left->fport == right->fport; +} + +void flowside_from_af(struct flowside *side, sa_family_t af, + const void *eaddr, in_port_t eport, + const void *faddr, in_port_t fport); + /** * struct flow_common - Common fields for packet flows * @state: State of the flow table entry -- cgit v1.2.3