diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2024-02-28 22:25:16 +1100 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2024-02-29 09:48:15 +0100 |
commit | dc9a5d71e9d0abbcfb115ca20461a94a981a9344 (patch) | |
tree | 659c2fc996b05185702f1cfa5dc9b82e6d802bfd /tcp.c | |
parent | ee677e0a42c434787bf02cb715d76612a6550c21 (diff) | |
download | passt-dc9a5d71e9d0abbcfb115ca20461a94a981a9344.tar passt-dc9a5d71e9d0abbcfb115ca20461a94a981a9344.tar.gz passt-dc9a5d71e9d0abbcfb115ca20461a94a981a9344.tar.bz2 passt-dc9a5d71e9d0abbcfb115ca20461a94a981a9344.tar.lz passt-dc9a5d71e9d0abbcfb115ca20461a94a981a9344.tar.xz passt-dc9a5d71e9d0abbcfb115ca20461a94a981a9344.tar.zst passt-dc9a5d71e9d0abbcfb115ca20461a94a981a9344.zip |
tcp, tcp_splice: Parse listening socket epoll ref in tcp_listen_handler()
tcp_listen_handler() uses the epoll reference for the listening socket
it handles, and also passes on one variant of it to
tcp_tap_conn_from_sock() and tcp_splice_conn_from_sock(). The latter
two functions only need a couple of specific fields from the
reference.
Pass those specific values instead of the whole reference, which
localises the handling of the listening (as opposed to accepted)
socket and its reference entirely within tcp_listen_handler().
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'tcp.c')
-rw-r--r-- | tcp.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -2679,14 +2679,13 @@ static void tcp_snat_inbound(const struct ctx *c, union inany_addr *addr) /** * tcp_tap_conn_from_sock() - Initialize state for non-spliced connection * @c: Execution context - * @ref: epoll reference of listening socket + * @dstport: Destination port for connection (host side) * @flow: flow to initialise * @s: Accepted socket * @sa: Peer socket address (from accept()) * @now: Current timestamp */ -static void tcp_tap_conn_from_sock(struct ctx *c, - union tcp_listen_epoll_ref ref, +static void tcp_tap_conn_from_sock(struct ctx *c, in_port_t dstport, union flow *flow, int s, const union sockaddr_inany *sa, const struct timespec *now) @@ -2699,7 +2698,7 @@ static void tcp_tap_conn_from_sock(struct ctx *c, conn_event(c, conn, SOCK_ACCEPTED); inany_from_sockaddr(&conn->faddr, &conn->fport, sa); - conn->eport = ref.port + c->tcp.fwd_in.delta[ref.port]; + conn->eport = dstport + c->tcp.fwd_in.delta[dstport]; tcp_snat_inbound(c, &conn->faddr); @@ -2737,10 +2736,11 @@ void tcp_listen_handler(struct ctx *c, union epoll_ref ref, if (s < 0) goto cancel; - if (tcp_splice_conn_from_sock(c, ref.tcp_listen, flow, s, &sa)) + if (tcp_splice_conn_from_sock(c, ref.tcp_listen.pif, + ref.tcp_listen.port, flow, s, &sa)) return; - tcp_tap_conn_from_sock(c, ref.tcp_listen, flow, s, &sa, now); + tcp_tap_conn_from_sock(c, ref.tcp_listen.port, flow, s, &sa, now); return; cancel: |