From dc9a5d71e9d0abbcfb115ca20461a94a981a9344 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Wed, 28 Feb 2024 22:25:16 +1100 Subject: 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 Signed-off-by: Stefano Brivio --- tcp_splice.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'tcp_splice.c') diff --git a/tcp_splice.c b/tcp_splice.c index 45b9b29..4957abb 100644 --- a/tcp_splice.c +++ b/tcp_splice.c @@ -413,7 +413,8 @@ static int tcp_conn_sock_ns(const struct ctx *c, sa_family_t af) /** * tcp_splice_conn_from_sock() - Attempt to init state for a spliced connection * @c: Execution context - * @ref: epoll reference of listening socket + * @pif0: pif id of side 0 + * @dstport: Side 0 destination port of connection * @flow: flow to initialise * @s0: Accepted (side 0) socket * @sa: Peer address of connection @@ -422,12 +423,13 @@ static int tcp_conn_sock_ns(const struct ctx *c, sa_family_t af) * #syscalls:pasta setsockopt */ bool tcp_splice_conn_from_sock(const struct ctx *c, - union tcp_listen_epoll_ref ref, union flow *flow, - int s0, const union sockaddr_inany *sa) + uint8_t pif0, in_port_t dstport, + union flow *flow, int s0, + const union sockaddr_inany *sa) { - in_port_t srcport, dstport = ref.port; struct tcp_splice_conn *conn; union inany_addr src; + in_port_t srcport; sa_family_t af; uint8_t pif1; @@ -437,7 +439,7 @@ bool tcp_splice_conn_from_sock(const struct ctx *c, inany_from_sockaddr(&src, &srcport, sa); af = inany_v4(&src) ? AF_INET : AF_INET6; - switch (ref.pif) { + switch (pif0) { case PIF_SPLICE: if (!inany_is_loopback(&src)) { char str[INANY_ADDRSTRLEN]; -- cgit v1.2.3