aboutgitcodebugslistschat
path: root/tcp_splice.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-03-25 11:24:23 +0100
committerStefano Brivio <sbrivio@redhat.com>2022-03-29 15:35:38 +0200
commit415ccf6116c496aab173ee9548089fe69ccf8f5f (patch)
tree1d8a64b7490f06539b2f1f7f55b840568dddfc63 /tcp_splice.c
parentf41f0416b837925bc8612f45ca58432218ce6707 (diff)
downloadpasst-415ccf6116c496aab173ee9548089fe69ccf8f5f.tar
passt-415ccf6116c496aab173ee9548089fe69ccf8f5f.tar.gz
passt-415ccf6116c496aab173ee9548089fe69ccf8f5f.tar.bz2
passt-415ccf6116c496aab173ee9548089fe69ccf8f5f.tar.lz
passt-415ccf6116c496aab173ee9548089fe69ccf8f5f.tar.xz
passt-415ccf6116c496aab173ee9548089fe69ccf8f5f.tar.zst
passt-415ccf6116c496aab173ee9548089fe69ccf8f5f.zip
tcp, tcp_splice: Use less awkward syntax to swap in/out sockets from pools
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'tcp_splice.c')
-rw-r--r--tcp_splice.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/tcp_splice.c b/tcp_splice.c
index b7bdfc2..bcafd33 100644
--- a/tcp_splice.c
+++ b/tcp_splice.c
@@ -501,18 +501,17 @@ static int tcp_splice_new(struct ctx *c, struct tcp_splice_conn *conn,
in_port_t port)
{
struct tcp_splice_connect_ns_arg ns_arg = { c, conn, port, 0 };
- int *sock_pool_p, i, s = -1;
+ int *p, i, s = -1;
if (bitmap_isset(c->tcp.port_to_tap, port))
- sock_pool_p = CONN_V6(conn) ? ns_sock_pool6 : ns_sock_pool4;
+ p = CONN_V6(conn) ? ns_sock_pool6 : ns_sock_pool4;
else
- sock_pool_p = CONN_V6(conn) ? init_sock_pool6 : init_sock_pool4;
+ p = CONN_V6(conn) ? init_sock_pool6 : init_sock_pool4;
- for (i = 0; i < TCP_SOCK_POOL_SIZE; i++, sock_pool_p++) {
- if ((s = *sock_pool_p) >= 0) {
- *sock_pool_p = -1;
+ for (i = 0; i < TCP_SOCK_POOL_SIZE; i++, p++) {
+ SWAP(s, *p);
+ if (s >= 0)
break;
- }
}
if (s < 0 && bitmap_isset(c->tcp.port_to_tap, port)) {