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=QIAOeXBI; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 8947E5A004E for ; Mon, 03 Feb 2025 10:26:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202502; t=1738574768; bh=b3lJte4FQnYi+45c7m2C+O4EdQCT9Ou5ldJH9fZ6WGM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QIAOeXBITsfwMyn50cy57YSNkmpJb8XYSoroCov6OSHC6uNlGn94b/Sc30DSo5Ge7 D+aSvGVCI0j9BinFFq5dZDwnCEsJb9G8ctVNn8YDCaA6u94xIagV0tPssKcykAvMqj ev4xgDYZsjI3iQzK2k6FM8OIWOGw8zMEHVq8Ej4P05Nr6BT6bSVkfRtlM1MosBZ1pq KEVSV0emEXeeWWMpsh/zP9PfceQmBo00tyhwLfTO26CmGEXEz/Dx9M1mkiS1RQiGsx 2ZTNny4qZ1+Dn50XQlRJonKc2D5LPDsPro57tSfClHG9RPpqnt1oPf+E6am0SbPFQL tVYsC8DXdUs8A== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Ymh282Yd8z4wyh; Mon, 3 Feb 2025 20:26:08 +1100 (AEDT) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH 4/6] migrate: Handle sending header section from data sections Date: Mon, 3 Feb 2025 20:26:13 +1100 Message-ID: <20250203092615.500163-5-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250203092615.500163-1-david@gibson.dropbear.id.au> References: <20250203092615.500163-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: GKBRD6MUX5SIDAYSTKFHLTQHODLHDWPN X-Message-ID-Hash: GKBRD6MUX5SIDAYSTKFHLTQHODLHDWPN 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: Currently the global state header is included in the list of data sections to send for migration. This makes for an asymmetry between the source and target sides: for the source, the header is sent after the 'pre' handlers along with all the rest of the data. For the target side, the header must be read first (before the 'pre' handlers), so that we know the version which determines what all the rest of the data will be. Change this so that the header is handled explicitly on both the source and target side. This will make some future changes simpler as well. Signed-off-by: David Gibson --- migrate.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/migrate.c b/migrate.c index 2d9f77ef..025f3b71 100644 --- a/migrate.c +++ b/migrate.c @@ -50,7 +50,6 @@ static union migrate_header header = { /* Data sections for version 1 */ static struct iovec sections_v1[] = { - { &header, sizeof(header) }, { &flow_first_free, sizeof(flow_first_free) }, { flowtab, sizeof(flowtab) }, { flow_hashtab, sizeof(flow_hashtab) }, @@ -172,6 +171,12 @@ static int migrate_source(struct ctx *c, int fd) struct migrate_meta m; int rc; + rc = write_all_buf(fd, &header, sizeof(header)); + if (rc) { + err("Failed to send migration header: %s, abort", strerror_(rc)); + return rc; + } + if ((rc = migrate_source_pre(c, &m))) { err("Source pre-migration failed: %s, abort", strerror_(rc)); return rc; @@ -279,10 +284,10 @@ static int migrate_target_state(int fd, const struct migrate_meta *m) for (d = data_versions; d->v != m->v && d->v; d++); - for (cnt = 0; d->sections[cnt + 1 /* skip header */].iov_len; cnt++); + for (cnt = 0; d->sections[cnt].iov_len; cnt++); debug("Reading %u migration sections", cnt); - rc = read_remainder(fd, d->sections + 1, cnt, 0); + rc = read_remainder(fd, d->sections, cnt, 0); if (rc < 0) return errno; -- 2.48.1