From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202502 header.b=EgkOiqnG; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 700705A0623 for ; Tue, 18 Feb 2025 12:04:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202502; t=1739876654; bh=WmZdXh+ppL93Cn1aksthLloUWt87zVUB9xS0NCFHLus=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EgkOiqnGSqDQy/Xo+r9Yt12EJ70uS4FMapnk5MI6h6LX9QMEsAYuLXx7KhBjw/Rk4 H0C+EQ46f3CWed4y7VVv1FVm3q4FmO031149DYCh4SZ/yvGchdeLO2mFtaTfp07fZW apfpP3UbbWpLVVYWWtB0VV6VKrNYM5azNhDK6IkLYPhcuGw6PvgL3qUJZi1nt/p0Xu eg0hZf2l2MpNDvrGEFl4SBNBvygZloX/odz89dlr1qmI6LbL1OnsvJf7tptwlkmnPZ /zAx+vlGN7GT+fiYv6P5KindQAIBiz5REFyT3vcVkLAr+qU7RaqRyCZETjseCI7o6D d0zGTOLcFsxpQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4YxxVQ1rNNz4x87; Tue, 18 Feb 2025 22:04:14 +1100 (AEDT) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH 3/4] tcp: Don't pass both flow pointer and flow index Date: Tue, 18 Feb 2025 19:59:23 +1100 Message-ID: <20250218085924.2627517-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250218085924.2627517-1-david@gibson.dropbear.id.au> References: <20250218085924.2627517-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: LUQKXMGHIZZFNJ2N6PEBDPHMT5ZBY63V X-Message-ID-Hash: LUQKXMGHIZZFNJ2N6PEBDPHMT5ZBY63V 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_flow_migrate_source_ext() is passed both the index of the flow it operates on and the pointer to the connection structure. However, the former is trivially derived from the latter. Simplify the interface. Signed-off-by: David Gibson --- flow.c | 2 +- tcp.c | 6 ++---- tcp_conn.h | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/flow.c b/flow.c index abe95b25..cc393e06 100644 --- a/flow.c +++ b/flow.c @@ -1053,7 +1053,7 @@ int flow_migrate_source(struct ctx *c, const struct migrate_stage *stage, * as EIO). */ foreach_established_tcp_flow(i, flow, FLOW_MAX) { - rc = tcp_flow_migrate_source_ext(fd, i, &flow->tcp); + rc = tcp_flow_migrate_source_ext(fd, &flow->tcp); if (rc) { err("Extended data for flow %u: %s", i, strerror_(-rc)); diff --git a/tcp.c b/tcp.c index 272e4cd5..21b6c6c5 100644 --- a/tcp.c +++ b/tcp.c @@ -3141,16 +3141,14 @@ int tcp_flow_migrate_source(int fd, struct tcp_tap_conn *conn) /** * tcp_flow_migrate_source_ext() - Dump queues, close sockets, send final data * @fd: Descriptor for state migration - * @fidx: Flow index * @conn: Pointer to the TCP connection structure * * Return: 0 on success, negative (not -EIO) on failure, -EIO on sending failure */ -int tcp_flow_migrate_source_ext(int fd, int fidx, - const struct tcp_tap_conn *conn) +int tcp_flow_migrate_source_ext(int fd, const struct tcp_tap_conn *conn) { uint32_t peek_offset = conn->seq_to_tap - conn->seq_ack_from_tap; - struct tcp_tap_transfer_ext *t = &migrate_ext[fidx]; + struct tcp_tap_transfer_ext *t = &migrate_ext[FLOW_IDX(conn)]; int s = conn->sock; int rc; diff --git a/tcp_conn.h b/tcp_conn.h index 8a15b08d..9126a36f 100644 --- a/tcp_conn.h +++ b/tcp_conn.h @@ -234,8 +234,7 @@ int tcp_flow_repair_on(struct ctx *c, const struct tcp_tap_conn *conn); int tcp_flow_repair_off(struct ctx *c, const struct tcp_tap_conn *conn); int tcp_flow_migrate_source(int fd, struct tcp_tap_conn *conn); -int tcp_flow_migrate_source_ext(int fd, int fidx, - const struct tcp_tap_conn *conn); +int tcp_flow_migrate_source_ext(int fd, const struct tcp_tap_conn *conn); int tcp_flow_migrate_target(struct ctx *c, int fd); int tcp_flow_migrate_target_ext(struct ctx *c, struct tcp_tap_conn *conn, int fd); -- 2.48.1