On Thu, Nov 17, 2022 at 01:15:26AM +0100, Stefano Brivio wrote: > On Wed, 16 Nov 2022 15:42:08 +1100 > David Gibson wrote: > > > For non-spliced connections we now treat IPv4-mapped IPv6 addresses the > > same as the corresponding IPv4 addresses. However currently we won't > > splice a connection from ::ffff:127.0.0.1 the way we would one from > > 127.0.0.1. Correct this so that we can splice connections from IPv4 > > localhost that have been received on an IPv6 dual stack socket. > > > > Signed-off-by: David Gibson > > --- > > tcp_splice.c | 20 ++++++++++++-------- > > 1 file changed, 12 insertions(+), 8 deletions(-) > > > > diff --git a/tcp_splice.c b/tcp_splice.c > > index 7c2f667..61c56be 100644 > > --- a/tcp_splice.c > > +++ b/tcp_splice.c > > @@ -514,19 +514,23 @@ bool tcp_splice_conn_from_sock(struct ctx *c, union epoll_ref ref, > > struct tcp_splice_conn *conn, int s, > > const struct sockaddr *sa) > > { > > + union inany_addr aany; > > + const struct in_addr *a4; > > The usual order. Fixed. > > + in_port_t port; > > Is the port actually needed here? I don't see how you use it. Well, inany_from_sockaddr() requires a port parameter. I could make it accept NULL, but then I'd have some noise there instead of here. Since inany_from_sockaddr() is an inline, I'm hoping the compiler will be smart enough to elide it anyway. I don't have a strong preference, I can change it if you'd like. > > > + > > assert(c->mode == MODE_PASTA); > > > > - if (sa->sa_family == AF_INET6) { > > - const struct sockaddr_in6 *sa6 > > - = (const struct sockaddr_in6 *)sa; > > - if (!IN6_IS_ADDR_LOOPBACK(&sa6->sin6_addr)) > > + inany_from_sockaddr(&aany, &port, sa); > > + a4 = inany_v4(&aany); > > + > > + if (a4) { > > + if (!IN4_IS_ADDR_LOOPBACK(a4)) > > return false; > > - conn->flags = SPLICE_V6; > > + conn->flags = 0; > > } else { > > - const struct sockaddr_in *sa4 = (const struct sockaddr_in *)sa; > > - if (!IN4_IS_ADDR_LOOPBACK(&sa4->sin_addr)) > > + if (!IN6_IS_ADDR_LOOPBACK(&aany.a6)) > > return false; > > - conn->flags = 0; > > + conn->flags = SPLICE_V6; > > } > > > > if (setsockopt(s, SOL_TCP, TCP_QUICKACK, &((int){ 1 }), > -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson