diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2022-11-17 16:58:48 +1100 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2022-11-25 01:34:58 +0100 |
commit | 34476511f724d52ef4d944627ee741e33c1ba3d7 (patch) | |
tree | 800d82e777d723b3c3aca5b9f47069efa029bdea /tcp_splice.c | |
parent | 0eef48c4be5ae8d9de5fed4daaa1954323e08b96 (diff) | |
download | passt-34476511f724d52ef4d944627ee741e33c1ba3d7.tar passt-34476511f724d52ef4d944627ee741e33c1ba3d7.tar.gz passt-34476511f724d52ef4d944627ee741e33c1ba3d7.tar.bz2 passt-34476511f724d52ef4d944627ee741e33c1ba3d7.tar.lz passt-34476511f724d52ef4d944627ee741e33c1ba3d7.tar.xz passt-34476511f724d52ef4d944627ee741e33c1ba3d7.tar.zst passt-34476511f724d52ef4d944627ee741e33c1ba3d7.zip |
tcp: Partially unify tcp_timer() and tcp_splice_timer()
These two functions scan all the non-splced and spliced connections
respectively and perform timed updates on them. Avoid scanning the now
unified table twice, by having tcp_timer scan it once calling the
relevant per-connection function for each one.
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 | 57 |
1 files changed, 25 insertions, 32 deletions
diff --git a/tcp_splice.c b/tcp_splice.c index ad2b216..0ac316d 100644 --- a/tcp_splice.c +++ b/tcp_splice.c @@ -766,7 +766,7 @@ smaller: * tcp_splice_pipe_refill() - Refill pool of pre-opened pipes * @c: Execution context */ -static void tcp_splice_pipe_refill(const struct ctx *c) +void tcp_splice_pipe_refill(const struct ctx *c) { int i; @@ -803,48 +803,41 @@ void tcp_splice_init(struct ctx *c) { memset(splice_pipe_pool, 0xff, sizeof(splice_pipe_pool)); tcp_set_pipe_size(c); + tcp_splice_pipe_refill(c); } /** * tcp_splice_timer() - Timer for spliced connections * @c: Execution context + * @conn: Spliced connection */ -void tcp_splice_timer(struct ctx *c) +void tcp_splice_timer(struct ctx *c, struct tcp_splice_conn *conn) { - struct tcp_splice_conn *conn; - - for (conn = CONN(c->tcp.conn_count - 1); conn >= CONN(0); conn--) { - if (!conn->c.spliced) - continue; - - if (conn->flags & CLOSING) { - tcp_splice_destroy(c, conn); - return; - } + if (conn->flags & CLOSING) { + tcp_splice_destroy(c, conn); + return; + } - if ( (conn->flags & RCVLOWAT_SET_A) && - !(conn->flags & RCVLOWAT_ACT_A)) { - if (setsockopt(conn->a, SOL_SOCKET, SO_RCVLOWAT, - &((int){ 1 }), sizeof(int))) { - trace("TCP (spliced): can't set SO_RCVLOWAT on " - "%i", conn->a); - } - conn_flag(c, conn, ~RCVLOWAT_SET_A); + if ( (conn->flags & RCVLOWAT_SET_A) && + !(conn->flags & RCVLOWAT_ACT_A)) { + if (setsockopt(conn->a, SOL_SOCKET, SO_RCVLOWAT, + &((int){ 1 }), sizeof(int))) { + trace("TCP (spliced): can't set SO_RCVLOWAT on " + "%i", conn->a); } + conn_flag(c, conn, ~RCVLOWAT_SET_A); + } - if ( (conn->flags & RCVLOWAT_SET_B) && - !(conn->flags & RCVLOWAT_ACT_B)) { - if (setsockopt(conn->b, SOL_SOCKET, SO_RCVLOWAT, - &((int){ 1 }), sizeof(int))) { - trace("TCP (spliced): can't set SO_RCVLOWAT on " - "%i", conn->b); - } - conn_flag(c, conn, ~RCVLOWAT_SET_B); + if ( (conn->flags & RCVLOWAT_SET_B) && + !(conn->flags & RCVLOWAT_ACT_B)) { + if (setsockopt(conn->b, SOL_SOCKET, SO_RCVLOWAT, + &((int){ 1 }), sizeof(int))) { + trace("TCP (spliced): can't set SO_RCVLOWAT on " + "%i", conn->b); } - - conn_flag(c, conn, ~RCVLOWAT_ACT_A); - conn_flag(c, conn, ~RCVLOWAT_ACT_B); + conn_flag(c, conn, ~RCVLOWAT_SET_B); } - tcp_splice_pipe_refill(c); + conn_flag(c, conn, ~RCVLOWAT_ACT_A); + conn_flag(c, conn, ~RCVLOWAT_ACT_B); } |