diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2022-11-17 16:59:02 +1100 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2022-11-25 01:35:48 +0100 |
commit | 034fa8a58d87ad2ea5f8b56d267d17dbc75798de (patch) | |
tree | f635dc58f88475a526b2229e8ea68ebaa56616ec /tcp_splice.c | |
parent | 7f1f2f3f518eace6ee08a00158189aaf571f3dcb (diff) | |
download | passt-034fa8a58d87ad2ea5f8b56d267d17dbc75798de.tar passt-034fa8a58d87ad2ea5f8b56d267d17dbc75798de.tar.gz passt-034fa8a58d87ad2ea5f8b56d267d17dbc75798de.tar.bz2 passt-034fa8a58d87ad2ea5f8b56d267d17dbc75798de.tar.lz passt-034fa8a58d87ad2ea5f8b56d267d17dbc75798de.tar.xz passt-034fa8a58d87ad2ea5f8b56d267d17dbc75798de.tar.zst passt-034fa8a58d87ad2ea5f8b56d267d17dbc75798de.zip |
tcp: Remove v6 flag from tcp_epoll_ref
This bit in the TCP specific epoll reference indicates whether the
connection is IPv6 or IPv4. However the sites which refer to it are
already calling accept() which (optionally) returns an address for the
remote end of the connection. We can use the sa_family field in that
address to determine the connection type independent of the epoll
reference.
This does have a cost: for the spliced case, it means we now need to get
that address from accept() which introduces an extran copy_to_user().
However, in future we want to allow handling IPv4 connectons through IPv6
sockets, which means we won't be able to determine the IP version at the
time we create the listening socket and epoll reference. So, at some point
we'll have to pay this cost anyway.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'tcp_splice.c')
-rw-r--r-- | tcp_splice.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/tcp_splice.c b/tcp_splice.c index 2be9b77..1bbd085 100644 --- a/tcp_splice.c +++ b/tcp_splice.c @@ -167,11 +167,9 @@ static int tcp_splice_epoll_ctl(const struct ctx *c, { int m = conn->c.in_epoll ? EPOLL_CTL_MOD : EPOLL_CTL_ADD; union epoll_ref ref_a = { .r.proto = IPPROTO_TCP, .r.s = conn->a, - .r.p.tcp.tcp.index = CONN_IDX(conn), - .r.p.tcp.tcp.v6 = CONN_V6(conn) }; + .r.p.tcp.tcp.index = CONN_IDX(conn) }; union epoll_ref ref_b = { .r.proto = IPPROTO_TCP, .r.s = conn->b, - .r.p.tcp.tcp.index = CONN_IDX(conn), - .r.p.tcp.tcp.v6 = CONN_V6(conn) }; + .r.p.tcp.tcp.index = CONN_IDX(conn) }; struct epoll_event ev_a = { .data.u64 = ref_a.u64 }; struct epoll_event ev_b = { .data.u64 = ref_b.u64 }; uint32_t events_a, events_b; @@ -517,7 +515,7 @@ bool tcp_splice_conn_from_sock(struct ctx *c, union epoll_ref ref, { assert(c->mode == MODE_PASTA); - if (ref.r.p.tcp.tcp.v6) { + if (sa->sa_family == AF_INET6) { const struct sockaddr_in6 *sa6; sa6 = (const struct sockaddr_in6 *)sa; |