1
0
mirror of https://passt.top/passt synced 2024-12-22 21:55:22 +00:00

tcp, tcp_splice: Remove redundant handling from tcp_timer()

tcp_timer() scans the connection table, expiring "tap" connections and
calling tcp_splice_timer() for "splice" connections.  tcp_splice_timer()
expires spliced connections and then does some other processing.

However, tcp_timer() is always called shortly after tcp_defer_handler()
(from post_handler()), which also scans the flow table expiring both tap
and spliced connections.  So remove the redundant handling, and only do
the extra tcp_splice_timer() work from tcp_timer().

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-01-16 11:50:33 +11:00 committed by Stefano Brivio
parent 8563e7c870
commit eebca1115f
3 changed files with 5 additions and 19 deletions

15
tcp.c
View File

@ -3201,20 +3201,9 @@ void tcp_timer(struct ctx *c, const struct timespec *now)
}
}
for (flow = flowtab + c->flow_count - 1; flow >= flowtab; flow--) {
switch (flow->f.type) {
case FLOW_TCP:
if (flow->tcp.events == CLOSED)
tcp_conn_destroy(c, flow);
break;
case FLOW_TCP_SPLICE:
for (flow = flowtab + c->flow_count - 1; flow >= flowtab; flow--)
if (flow->f.type == FLOW_TCP_SPLICE)
tcp_splice_timer(c, flow);
break;
default:
die("Unexpected %s in tcp_timer()",
FLOW_TYPE(&flow->f));
}
}
tcp_sock_refill_init(c);
if (c->mode == MODE_PASTA)

View File

@ -159,7 +159,7 @@ void tcp_tap_conn_update(const struct ctx *c, struct tcp_tap_conn *old,
struct tcp_tap_conn *new);
void tcp_splice_conn_update(const struct ctx *c, struct tcp_splice_conn *new);
void tcp_splice_destroy(struct ctx *c, union flow *flow);
void tcp_splice_timer(struct ctx *c, union flow *flow);
void tcp_splice_timer(const struct ctx *c, union flow *flow);
int tcp_conn_pool_sock(int pool[]);
int tcp_conn_new_sock(const struct ctx *c, sa_family_t af);
void tcp_sock_refill_pool(const struct ctx *c, int pool[], int af);

View File

@ -755,15 +755,12 @@ void tcp_splice_init(struct ctx *c)
* @c: Execution context
* @flow: Flow table entry
*/
void tcp_splice_timer(struct ctx *c, union flow *flow)
void tcp_splice_timer(const struct ctx *c, union flow *flow)
{
struct tcp_splice_conn *conn = &flow->tcp_splice;
int side;
if (conn->flags & CLOSING) {
tcp_splice_destroy(c, flow);
return;
}
ASSERT(!(conn->flags & CLOSING));
for (side = 0; side < SIDES; side++) {
uint8_t set = side == 0 ? RCVLOWAT_SET_0 : RCVLOWAT_SET_1;