From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 5EF815A0274 for ; Thu, 14 Dec 2023 03:15:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1702520145; bh=l/pOpc4jqS7vKojMztYenPCQS0cCKfVYyi9WUVjZtAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mRMBmD8YVxJD/HNaIVk5cA+OOfVxohCeXMwYyuOa/XhX3+I/O4S+cfBSwJgd0BQx9 zGJqjNSrrEUwirDwVxGjvjTrJWs/QdwCFiIKhqHo7MaH0IeGh41ydUj3VnZU+hB+JB yXCeheTCNOtU+c8bZVy0kvD/gpwJk6f+R9vlElqSIv2LS7ifqrctHPkQESUJaKUywY JZpLKcEf8kDoP9Im1IcXdOPgveLMYpun4pgtt9wgpxJGXOqFvGEgAUZWwxM/jbL8eT HMdiDsrNW4Hgcl80Ld4/33+bSV6zdzOF/SLk3rUvn7QSCAf8THHA8Vb5J1k2Ouqgyb X5sK0ipg04sJQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4SrGD11QtZz4wdF; Thu, 14 Dec 2023 13:15:45 +1100 (AEDT) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH 3/8] tcp, tcp_splice: Remove redundant handling from tcp_timer() Date: Thu, 14 Dec 2023 13:15:36 +1100 Message-ID: <20231214021541.3925825-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231214021541.3925825-1-david@gibson.dropbear.id.au> References: <20231214021541.3925825-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: N3ZCPIOLBXDYD7HZKFIKMWDRWS6CU7DE X-Message-ID-Hash: N3ZCPIOLBXDYD7HZKFIKMWDRWS6CU7DE X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: tcp_timer() scans the connection table, expiring "tap" connections and calling tcp_splice_timer() for "splice" connections. tcp_splice_timer() expires spliced connections and then does some other processing. However, tcp_timer() is always called shortly after tcp_defer_handler() (from post_handler()), which also scans the flow table expiring both tap and spliced connections. So remove the redundant handling, and only do the extra tcp_splice_timer() work from tcp_timer(). Signed-off-by: David Gibson --- tcp.c | 15 ++------------- tcp_conn.h | 2 +- tcp_splice.c | 7 ++----- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/tcp.c b/tcp.c index a72a580..084100d 100644 --- a/tcp.c +++ b/tcp.c @@ -3193,20 +3193,9 @@ void tcp_timer(struct ctx *c, const struct timespec *now) } } - for (flow = flowtab + c->flow_count - 1; flow >= flowtab; flow--) { - switch (flow->f.type) { - case FLOW_TCP: - if (flow->tcp.events == CLOSED) - tcp_conn_destroy(c, flow); - break; - case FLOW_TCP_SPLICE: + for (flow = flowtab + c->flow_count - 1; flow >= flowtab; flow--) + if (flow->f.type == FLOW_TCP_SPLICE) tcp_splice_timer(c, flow); - break; - default: - die("Unexpected %s in tcp_timer()", - FLOW_TYPE(&flow->f)); - } - } tcp_sock_refill_init(c); if (c->mode == MODE_PASTA) diff --git a/tcp_conn.h b/tcp_conn.h index 3900305..07efe62 100644 --- a/tcp_conn.h +++ b/tcp_conn.h @@ -161,7 +161,7 @@ void tcp_tap_conn_update(const struct ctx *c, struct tcp_tap_conn *old, struct tcp_tap_conn *new); void tcp_splice_conn_update(const struct ctx *c, struct tcp_splice_conn *new); void tcp_splice_destroy(struct ctx *c, union flow *flow); -void tcp_splice_timer(struct ctx *c, union flow *flow); +void tcp_splice_timer(const struct ctx *c, union flow *flow); int tcp_conn_pool_sock(int pool[]); int tcp_conn_new_sock(const struct ctx *c, sa_family_t af); void tcp_sock_refill_pool(const struct ctx *c, int pool[], int af); diff --git a/tcp_splice.c b/tcp_splice.c index 052f989..cf9b4e8 100644 --- a/tcp_splice.c +++ b/tcp_splice.c @@ -755,15 +755,12 @@ void tcp_splice_init(struct ctx *c) * @c: Execution context * @flow: Flow table entry */ -void tcp_splice_timer(struct ctx *c, union flow *flow) +void tcp_splice_timer(const struct ctx *c, union flow *flow) { struct tcp_splice_conn *conn = &flow->tcp_splice; int side; - if (conn->flags & CLOSING) { - tcp_splice_destroy(c, flow); - return; - } + ASSERT(!(conn->flags & CLOSING)); for (side = 0; side < SIDES; side++) { uint8_t set = side == 0 ? RCVLOWAT_SET_0 : RCVLOWAT_SET_1; -- 2.43.0