From d909fda1e81979da12ed4ab8b2f2a18fba756a07 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Thu, 17 Nov 2022 16:58:52 +1100 Subject: tcp: Use the same sockets to listen for spliced and non-spliced connections In pasta mode, tcp_sock_init[46]() create separate sockets to listen for spliced connections (these are bound to localhost) and non-spliced connections (these are bound to the host address). This introduces a subtle behavioural difference between pasta and passt: by default, pasta will listen only on a single host address, whereas passt will listen on all addresses (0.0.0.0 or ::). This also prevents us using some additional optimizations that only work with the unspecified (0.0.0.0 or ::) address. However, it turns out we don't need to do this. We can splice a connection if and only if it originates from the loopback address. Currently we ensure this by having the "spliced" listening sockets listening only on loopback. Instead, defer the decision about whether to splice a connection until after accept(), by checking if the connection was made from the loopback address. Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- tcp_splice.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tcp_splice.h') diff --git a/tcp_splice.h b/tcp_splice.h index f9462ae..1a915dd 100644 --- a/tcp_splice.h +++ b/tcp_splice.h @@ -10,8 +10,9 @@ struct tcp_splice_conn; void tcp_sock_handler_splice(struct ctx *c, union epoll_ref ref, uint32_t events); -void tcp_splice_conn_from_sock(struct ctx *c, union epoll_ref ref, - struct tcp_splice_conn *conn, int s); +bool tcp_splice_conn_from_sock(struct ctx *c, union epoll_ref ref, + struct tcp_splice_conn *conn, int s, + const struct sockaddr *sa); void tcp_splice_init(struct ctx *c); #endif /* TCP_SPLICE_H */ -- cgit v1.2.3