From fb7c00169d49a99ea2d14dae05bf0c8190f0971c Mon Sep 17 00:00:00 2001 From: David Gibson Date: Tue, 16 Jan 2024 11:50:40 +1100 Subject: flow: Move flow_count from context structure to a global In general, the passt code is a bit haphazard about what's a true global variable and what's in the quasi-global 'context structure'. The flow_count field is one such example: it's in the context structure, although it's really part of the same data structure as flowtab[], which is a genuine global. Move flow_count to be a regular global to match. For now it needs to be public, rather than static, but we expect to be able to change that in future. Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- tcp.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tcp.c') diff --git a/tcp.c b/tcp.c index e7d11ee..6b62896 100644 --- a/tcp.c +++ b/tcp.c @@ -1307,7 +1307,7 @@ static struct tcp_tap_conn *tcp_hash_lookup(const struct ctx *c, * @c: Execution context * @flow: Flow table entry for this connection */ -void tcp_flow_defer(struct ctx *c, union flow *flow) +void tcp_flow_defer(const struct ctx *c, union flow *flow) { const struct tcp_tap_conn *conn = &flow->tcp; @@ -1949,7 +1949,7 @@ static void tcp_conn_from_tap(struct ctx *c, (void)saddr; - if (c->flow_count >= FLOW_MAX) + if (flow_count >= FLOW_MAX) return; if ((s = tcp_conn_pool_sock(pool)) < 0) @@ -1975,7 +1975,7 @@ static void tcp_conn_from_tap(struct ctx *c, } } - conn = CONN(c->flow_count++); + conn = CONN(flow_count++); conn->f.type = FLOW_TCP; conn->sock = s; conn->timer = -1; @@ -2724,14 +2724,14 @@ void tcp_listen_handler(struct ctx *c, union epoll_ref ref, union flow *flow; int s; - if (c->no_tcp || c->flow_count >= FLOW_MAX) + if (c->no_tcp || flow_count >= FLOW_MAX) return; s = accept4(ref.fd, (struct sockaddr *)&sa, &sl, SOCK_NONBLOCK); if (s < 0) return; - flow = flowtab + c->flow_count++; + flow = flowtab + flow_count++; if (c->mode == MODE_PASTA && tcp_splice_conn_from_sock(c, ref.tcp_listen, &flow->tcp_splice, -- cgit v1.2.3