mirror of
https://passt.top/passt
synced 2025-06-07 16:35:33 +02:00
tcp, tcp_splice: Avoid double layered dispatch for connected TCP sockets
Currently connected TCP sockets have the same epoll type, whether they're for a "tap" connection or a spliced connection. This means that tcp_sock_handler() has to do a secondary check on the type of the connection to call the right function. We can avoid this by adding a new epoll type and dispatching directly to the right thing. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
70121ca1ec
commit
02e092b4fe
5 changed files with 27 additions and 39 deletions
36
tcp.c
36
tcp.c
|
@ -2804,14 +2804,18 @@ void tcp_timer_handler(struct ctx *c, union epoll_ref ref)
|
|||
}
|
||||
|
||||
/**
|
||||
* tcp_tap_sock_handler() - Handle new data from non-spliced socket
|
||||
* tcp_sock_handler() - Handle new data from non-spliced socket
|
||||
* @c: Execution context
|
||||
* @conn: Connection state
|
||||
* @ref: epoll reference
|
||||
* @events: epoll events bitmap
|
||||
*/
|
||||
static void tcp_tap_sock_handler(struct ctx *c, struct tcp_tap_conn *conn,
|
||||
uint32_t events)
|
||||
void tcp_sock_handler(struct ctx *c, union epoll_ref ref, uint32_t events)
|
||||
{
|
||||
struct tcp_tap_conn *conn = CONN(ref.flowside.flow);
|
||||
|
||||
ASSERT(conn->f.type == FLOW_TCP);
|
||||
ASSERT(ref.flowside.side == SOCKSIDE);
|
||||
|
||||
if (conn->events == CLOSED)
|
||||
return;
|
||||
|
||||
|
@ -2858,30 +2862,6 @@ static void tcp_tap_sock_handler(struct ctx *c, struct tcp_tap_conn *conn,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* tcp_sock_handler() - Handle new data from socket, or timerfd event
|
||||
* @c: Execution context
|
||||
* @ref: epoll reference
|
||||
* @events: epoll events bitmap
|
||||
*/
|
||||
void tcp_sock_handler(struct ctx *c, union epoll_ref ref, uint32_t events)
|
||||
{
|
||||
union flow *flow = FLOW(ref.flowside.flow);
|
||||
|
||||
switch (flow->f.type) {
|
||||
case FLOW_TCP:
|
||||
tcp_tap_sock_handler(c, &flow->tcp, events);
|
||||
break;
|
||||
case FLOW_TCP_SPLICE:
|
||||
tcp_splice_sock_handler(c, &flow->tcp_splice, ref.flowside.side,
|
||||
events);
|
||||
break;
|
||||
default:
|
||||
die("Unexpected %s in tcp_sock_handler_compact()",
|
||||
FLOW_TYPE(&flow->f));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* tcp_sock_init_af() - Initialise listening socket for a given af and port
|
||||
* @c: Execution context
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue