From: Stefano Brivio <sbrivio@redhat.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: passt-dev@passt.top, Laurent Vivier <lvivier@redhat.com>
Subject: Re: [PATCH v2 8/8] flow, tcp: Basic pre-migration source handler to dump sequence numbers
Date: Wed, 29 Jan 2025 09:46:13 +0100 [thread overview]
Message-ID: <20250129094613.30baf0b6@elisabeth> (raw)
In-Reply-To: <Z5nHjbmfbfgcLKc3@zatzit>
On Wed, 29 Jan 2025 17:15:41 +1100
David Gibson <david@gibson.dropbear.id.au> wrote:
> On Wed, Jan 29, 2025 at 12:39:40AM +0100, Stefano Brivio wrote:
> > Very much draft quality, but it works. Ask passt-repair to switch
> > TCP sockets to repair mode and dump their current sequence numbers to
> > the flow table, which will be transferred and used by the target in
> > the next step.
> >
> > Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
> > ---
> > flow.c | 43 +++++++++++++++++++++++++++++++++++++++++
> > flow.h | 1 +
> > migrate.c | 1 +
> > tcp.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > tcp_conn.h | 5 +++++
> > 5 files changed, 106 insertions(+)
> >
> > diff --git a/flow.c b/flow.c
> > index ee1221b..e7148b2 100644
> > --- a/flow.c
> > +++ b/flow.c
> > @@ -19,6 +19,7 @@
> > #include "inany.h"
> > #include "flow.h"
> > #include "flow_table.h"
> > +#include "repair.h"
> >
> > const char *flow_state_str[] = {
> > [FLOW_STATE_FREE] = "FREE",
> > @@ -874,6 +875,48 @@ void flow_defer_handler(const struct ctx *c, const struct timespec *now)
> > *last_next = FLOW_MAX;
> > }
> >
> > +/**
> > + * flow_migrate_source_pre() - Prepare all source flows for migration
> > + * @c: Execution context
> > + * @m: Migration metadata
> > + *
> > + * Return: 0 on success
> > + */
> > +int flow_migrate_source_pre(struct ctx *c, struct migrate_meta *m)
> > +{
> > + unsigned i;
> > + int rc;
> > +
> > + (void)m;
> > +
> > + for (i = 0; i < FLOW_MAX; i++) { /* TODO: iterator with skip */
> > + union flow *flow = &flowtab[i];
> > +
> > + if (flow->f.state == FLOW_STATE_FREE)
> > + i += flow->free.n - 1;
> > + else if (flow->f.state == FLOW_STATE_ACTIVE &&
>
> We should probably just abort any flows that are in pre-ACTIVE state
> at migration time. Wait... IIRC flows have to be in ACTIVE state (or
> already cancelled) once we get to the next epoll cycle. So we can
> possibly just assert that state is either ACTIVE or FREE.
"IIRC" doesn't quite fit with "just assert". Let's not make things
crash here, it's really not the right point to get issues reported. I
can add a print.
> > + flow->f.type == FLOW_TCP)
> > + rc = tcp_flow_repair_on(c, &flow->tcp);
> > +
> > + if (rc)
> > + return rc; /* TODO: rollback */
> > + }
> > +
> > + repair_flush(c); /* TODO: move to TCP logic */
> > +
> > + for (i = 0; i < FLOW_MAX; i++) { /* TODO: iterator with skip */
> > + union flow *flow = &flowtab[i];
> > +
> > + if (flow->f.state == FLOW_STATE_FREE)
> > + i += flow->free.n - 1;
> > + else if (flow->f.state == FLOW_STATE_ACTIVE &&
> > + flow->f.type == FLOW_TCP)
> > + tcp_flow_dump_seq(c, &flow->tcp);
> > + }
> > +
> > + return 0;
> > +}
> > +
> > /**
> > * flow_init() - Initialise flow related data structures
> > */
> > diff --git a/flow.h b/flow.h
> > index 8eb5964..ff390a6 100644
> > --- a/flow.h
> > +++ b/flow.h
> > @@ -255,6 +255,7 @@ union flow;
> >
> > void flow_init(void);
> > void flow_defer_handler(const struct ctx *c, const struct timespec *now);
> > +int flow_migrate_source_pre(struct ctx *c, struct migrate_meta *m);
> >
> > void flow_log_(const struct flow_common *f, int pri, const char *fmt, ...)
> > __attribute__((format(printf, 3, 4)));
> > diff --git a/migrate.c b/migrate.c
> > index b8b79e0..6707c02 100644
> > --- a/migrate.c
> > +++ b/migrate.c
> > @@ -56,6 +56,7 @@ static struct migrate_data data_versions[] = {
> >
> > /* Handlers to call in source before sending data */
> > struct migrate_handler handlers_source_pre[] = {
> > + { flow_migrate_source_pre },
> > { 0 },
> > };
> >
> > diff --git a/tcp.c b/tcp.c
> > index c89f323..3a3038b 100644
> > --- a/tcp.c
> > +++ b/tcp.c
> > @@ -299,6 +299,7 @@
> > #include "log.h"
> > #include "inany.h"
> > #include "flow.h"
> > +#include "repair.h"
> > #include "linux_dep.h"
> >
> > #include "flow_table.h"
> > @@ -868,6 +869,61 @@ void tcp_defer_handler(struct ctx *c)
> > tcp_payload_flush(c);
> > }
> >
> > +/**
> > + * tcp_flow_repair_on() - Enable repair mode for a single TCP flow
> > + * @c: Execution context
> > + * @conn: Pointer to the TCP connection structure
> > + *
> > + * Return: 0 on success, negative error code on failure
> > + */
> > +int tcp_flow_repair_on(struct ctx *c, const struct tcp_tap_conn *conn)
> > +{
> > + int rc = 0;
> > +
> > + if ((rc = repair_set(c, conn->sock, TCP_REPAIR_ON)))
> > + err("Failed to set TCP_REPAIR for socket %i", conn->sock);
>
> Well.. except that the error could just as easily have been on a
> previous socket that wasn't flushed yet.
Right, I should probably just drop the socket number from here.
--
Stefano
prev parent reply other threads:[~2025-01-29 8:46 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-28 23:39 [PATCH v2 0/8] Draft, incomplete series introducing state migration Stefano Brivio
2025-01-28 23:39 ` [PATCH v2 1/8] icmp, udp: Pad time_t timestamp to 64-bit to ease " Stefano Brivio
2025-01-29 1:34 ` David Gibson
2025-01-28 23:39 ` [PATCH v2 2/8] flow, flow_table: Pad flow table entries to 128 bytes, hash entries to 32 bits Stefano Brivio
2025-01-29 1:35 ` David Gibson
2025-01-28 23:39 ` [PATCH v2 3/8] flow_table: Use size in extern declaration for flowtab Stefano Brivio
2025-01-28 23:39 ` [PATCH v2 4/8] util: Add read_remainder() and read_all_buf() Stefano Brivio
2025-01-29 1:37 ` David Gibson
2025-01-28 23:39 ` [PATCH v2 5/8] Introduce facilities for guest migration on top of vhost-user infrastructure Stefano Brivio
2025-01-29 5:41 ` David Gibson
2025-01-29 8:46 ` Stefano Brivio
2025-01-30 1:28 ` David Gibson
2025-01-28 23:39 ` [PATCH v2 6/8] Introduce passt-repair Stefano Brivio
2025-01-28 23:39 ` [PATCH v2 7/8] Add interfaces and configuration bits for passt-repair Stefano Brivio
2025-01-29 6:09 ` David Gibson
2025-01-29 8:46 ` Stefano Brivio
2025-01-30 1:33 ` David Gibson
2025-01-28 23:39 ` [PATCH v2 8/8] flow, tcp: Basic pre-migration source handler to dump sequence numbers Stefano Brivio
2025-01-29 6:15 ` David Gibson
2025-01-29 8:46 ` Stefano Brivio [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250129094613.30baf0b6@elisabeth \
--to=sbrivio@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=lvivier@redhat.com \
--cc=passt-dev@passt.top \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).