diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2022-11-17 16:58:52 +1100 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2022-11-25 01:35:22 +0100 |
commit | d909fda1e81979da12ed4ab8b2f2a18fba756a07 (patch) | |
tree | 10598d5ebd35e5a454e860ecd66b838c1f7c563c /tcp_splice.h | |
parent | 356c6e0677072f1a6cfe9b5d0648d89ab6fd5523 (diff) | |
download | passt-d909fda1e81979da12ed4ab8b2f2a18fba756a07.tar passt-d909fda1e81979da12ed4ab8b2f2a18fba756a07.tar.gz passt-d909fda1e81979da12ed4ab8b2f2a18fba756a07.tar.bz2 passt-d909fda1e81979da12ed4ab8b2f2a18fba756a07.tar.lz passt-d909fda1e81979da12ed4ab8b2f2a18fba756a07.tar.xz passt-d909fda1e81979da12ed4ab8b2f2a18fba756a07.tar.zst passt-d909fda1e81979da12ed4ab8b2f2a18fba756a07.zip |
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 <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'tcp_splice.h')
-rw-r--r-- | tcp_splice.h | 5 |
1 files changed, 3 insertions, 2 deletions
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 */ |