diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2023-11-07 12:40:15 +1100 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2023-11-07 09:53:41 +0100 |
commit | 732e24937618f5848e182dc8a38eb170cf079394 (patch) | |
tree | f9748dad8026c85506fad12fd8bb400782635be9 /tcp_splice.c | |
parent | 125c5e52a5c963ead98b175c440314b4c9071143 (diff) | |
download | passt-732e24937618f5848e182dc8a38eb170cf079394.tar passt-732e24937618f5848e182dc8a38eb170cf079394.tar.gz passt-732e24937618f5848e182dc8a38eb170cf079394.tar.bz2 passt-732e24937618f5848e182dc8a38eb170cf079394.tar.lz passt-732e24937618f5848e182dc8a38eb170cf079394.tar.xz passt-732e24937618f5848e182dc8a38eb170cf079394.tar.zst passt-732e24937618f5848e182dc8a38eb170cf079394.zip |
pif: Record originating pif in listening socket refs
For certain socket types, we record in the epoll ref whether they're
sockets in the namespace, or on the host. We now have the notion of "pif"
to indicate what "place" a socket is associated with, so generalise the
simple one-bit 'ns' to a pif id.
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 | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/tcp_splice.c b/tcp_splice.c index 54fc317..133e825 100644 --- a/tcp_splice.c +++ b/tcp_splice.c @@ -411,12 +411,12 @@ static int tcp_splice_connect(const struct ctx *c, struct tcp_splice_conn *conn, * @c: Execution context * @conn: Connection pointer * @port: Destination port, host order - * @outbound: Connection request coming from namespace + * @pif: Originating pif of the splice * * Return: return code from connect() */ static int tcp_splice_new(const struct ctx *c, struct tcp_splice_conn *conn, - in_port_t port, int outbound) + in_port_t port, uint8_t pif) { int s = -1; @@ -427,7 +427,7 @@ static int tcp_splice_new(const struct ctx *c, struct tcp_splice_conn *conn, * entering the ns anyway, so we might as well refill the * pool. */ - if (outbound) { + if (pif == PIF_SPLICE) { int *p = CONN_V6(conn) ? init_sock_pool6 : init_sock_pool4; int af = CONN_V6(conn) ? AF_INET6 : AF_INET; @@ -437,6 +437,8 @@ static int tcp_splice_new(const struct ctx *c, struct tcp_splice_conn *conn, } else { int *p = CONN_V6(conn) ? ns_sock_pool6 : ns_sock_pool4; + ASSERT(pif == PIF_HOST); + /* If pool is empty, refill it first */ if (p[TCP_SOCK_POOL_SIZE-1] < 0) NS_CALL(tcp_sock_refill_ns, c); @@ -516,7 +518,7 @@ bool tcp_splice_conn_from_sock(const struct ctx *c, conn->c.spliced = true; conn->a = s; - if (tcp_splice_new(c, conn, ref.port, ref.ns)) + if (tcp_splice_new(c, conn, ref.port, ref.pif)) conn_flag(c, conn, CLOSING); return true; |