flow: Properly type callbacks to protocol specific handlers

The flow dispatches deferred and timer handling for flows centrally, but
needs to call into protocol specific code for the handling of individual
flows.  Currently this passes a general union flow *.  It makes more sense
to pass the specific relevant flow type structure.  That brings the check
on the flow type adjacent to casting to the union variant which it tags.

Arguably, this is a slight abstraction violation since it involves the
generic flow code using protocol specific types.  It's already calling into
protocol specific functions, so I don't think this really makes any
difference.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
David Gibson
2024-05-21 15:57:03 +10:00
committed by Stefano Brivio
parent 1a20370b36
commit 7a832a8a0e
6 changed files with 19 additions and 25 deletions

10
tcp.c
View File

@@ -1221,15 +1221,13 @@ static struct tcp_tap_conn *tcp_hash_lookup(const struct ctx *c,
/**
* tcp_flow_defer() - Deferred per-flow handling (clean up closed connections)
* @flow: Flow table entry for this connection
* @conn: Connection to handle
*
* Return: true if the flow is ready to free, false otherwise
* Return: true if the connection is ready to free, false otherwise
*/
bool tcp_flow_defer(union flow *flow)
bool tcp_flow_defer(const struct tcp_tap_conn *conn)
{
const struct tcp_tap_conn *conn = &flow->tcp;
if (flow->tcp.events != CLOSED)
if (conn->events != CLOSED)
return false;
close(conn->sock);