flow: Clarify flow entry life cycle, introduce uniform logging
Our allocation scheme for flow entries means there are some non-obvious constraints on when what things can be done with an entry. Add a big doc comment explaining the life cycle. In addition, make a FLOW_START() macro to mark one of the important transitions. This encourages correct usage, by making it natural to only access the flow type specific structure after calling it. It also logs that a new flow has been created, which is useful for debugging. We also add logging when a flow's lifecycle ends. This doesn't need a new helper, because it can only happen either from flow_alloc_cancel() or from the flow deferred handler. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:

committed by
Stefano Brivio

parent
d0550f97cd
commit
0f938c3b9a
11
tcp_splice.c
11
tcp_splice.c
@@ -432,7 +432,7 @@ static int tcp_splice_new(const struct ctx *c, struct tcp_splice_conn *conn,
|
||||
* tcp_splice_conn_from_sock() - Attempt to init state for a spliced connection
|
||||
* @c: Execution context
|
||||
* @ref: epoll reference of listening socket
|
||||
* @conn: connection structure to initialize
|
||||
* @flow: flow to initialise
|
||||
* @s: Accepted socket
|
||||
* @sa: Peer address of connection
|
||||
*
|
||||
@@ -440,10 +440,10 @@ static int tcp_splice_new(const struct ctx *c, struct tcp_splice_conn *conn,
|
||||
* #syscalls:pasta setsockopt
|
||||
*/
|
||||
bool tcp_splice_conn_from_sock(const struct ctx *c,
|
||||
union tcp_listen_epoll_ref ref,
|
||||
struct tcp_splice_conn *conn, int s,
|
||||
const union sockaddr_inany *sa)
|
||||
union tcp_listen_epoll_ref ref, union flow *flow,
|
||||
int s, const union sockaddr_inany *sa)
|
||||
{
|
||||
struct tcp_splice_conn *conn;
|
||||
union inany_addr aany;
|
||||
in_port_t port;
|
||||
|
||||
@@ -453,7 +453,8 @@ bool tcp_splice_conn_from_sock(const struct ctx *c,
|
||||
if (!inany_is_loopback(&aany))
|
||||
return false;
|
||||
|
||||
conn->f.type = FLOW_TCP_SPLICE;
|
||||
conn = FLOW_START(flow, FLOW_TCP_SPLICE, tcp_splice, 0);
|
||||
|
||||
conn->flags = inany_v4(&aany) ? 0 : SPLICE_V6;
|
||||
conn->s[0] = s;
|
||||
conn->s[1] = -1;
|
||||
|
Reference in New Issue
Block a user