public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH 0/2] Migration debugging hacks
@ 2025-02-07  5:50 David Gibson
  2025-02-07  5:50 ` [PATCH 1/2] pcap comment hacks David Gibson
  2025-02-07  5:50 ` [PATCH 2/2] debug David Gibson
  0 siblings, 2 replies; 3+ messages in thread
From: David Gibson @ 2025-02-07  5:50 UTC (permalink / raw)
  To: passt-dev, Stefano Brivio; +Cc: David Gibson

Here are a couple of hacky patches I was using for debugging the
failures in the migrate/bidirectional test.  Further details on where
I'm at coming in another email.

David Gibson (2):
  pcap comment hacks
  debug

 pcap.c                     | 20 ++++++++++++++++++++
 pcap.h                     |  2 ++
 tap.c                      |  1 +
 tcp_vu.c                   |  6 ++++++
 test/lib/setup             |  8 +++++---
 test/migrate/bidirectional | 15 ++++++++++++++-
 vu_common.c                |  1 +
 7 files changed, 49 insertions(+), 4 deletions(-)

-- 
2.48.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] pcap comment hacks
  2025-02-07  5:50 [PATCH 0/2] Migration debugging hacks David Gibson
@ 2025-02-07  5:50 ` David Gibson
  2025-02-07  5:50 ` [PATCH 2/2] debug David Gibson
  1 sibling, 0 replies; 3+ messages in thread
From: David Gibson @ 2025-02-07  5:50 UTC (permalink / raw)
  To: passt-dev, Stefano Brivio; +Cc: David Gibson

---
 pcap.c      | 20 ++++++++++++++++++++
 pcap.h      |  2 ++
 tap.c       |  1 +
 tcp_vu.c    |  6 ++++++
 vu_common.c |  1 +
 5 files changed, 30 insertions(+)

diff --git a/pcap.c b/pcap.c
index 3d623cfe..cb843033 100644
--- a/pcap.c
+++ b/pcap.c
@@ -92,6 +92,26 @@ static void pcap_frame(const struct iovec *iov, size_t iovcnt,
 		debug_perror("Cannot log packet, length %zu", l2len);
 }
 
+void pcap_comment(const char *fmt, ...)
+{
+	struct ethhdr eh = {
+		.h_proto = htons(0xffff),
+	};
+	struct timespec ts = { 0 };
+	char payload[1024];
+	struct iovec iov[] = {
+		{ &eh, sizeof(eh) },
+		{ payload, sizeof(payload) },
+	};
+	va_list ap;
+
+	va_start(ap, fmt);
+	iov[1].iov_len = vsnprintf(payload, sizeof(payload), fmt, ap);
+	va_end(ap);
+
+	pcap_frame(iov, ARRAY_SIZE(iov), 0, &ts);
+}
+
 /**
  * pcap() - Capture a single frame to pcap file
  * @pkt:	Pointer to data buffer, including L2 headers
diff --git a/pcap.h b/pcap.h
index 9795f2e8..963a4172 100644
--- a/pcap.h
+++ b/pcap.h
@@ -12,4 +12,6 @@ void pcap_multiple(const struct iovec *iov, size_t frame_parts, unsigned int n,
 void pcap_iov(const struct iovec *iov, size_t iovcnt, size_t offset);
 void pcap_init(struct ctx *c);
 
+void pcap_comment(const char *fmt, ...);
+
 #endif /* PCAP_H */
diff --git a/tap.c b/tap.c
index d0673e58..e2100878 100644
--- a/tap.c
+++ b/tap.c
@@ -972,6 +972,7 @@ void tap_add_packet(struct ctx *c, ssize_t l2len, char *p)
 {
 	const struct ethhdr *eh;
 
+	pcap_comment("tap_add_packet()");
 	pcap(p, l2len);
 
 	eh = (struct ethhdr *)p;
diff --git a/tcp_vu.c b/tcp_vu.c
index fad7065e..6f00770b 100644
--- a/tcp_vu.c
+++ b/tcp_vu.c
@@ -140,6 +140,7 @@ int tcp_vu_send_flag(const struct ctx *c, struct tcp_tap_conn *conn, int flags)
 			 NULL, seq, !*c->pcap);
 
 	if (*c->pcap) {
+		pcap_comment("tcp_vu_send_flag()");
 		pcap_iov(&flags_elem[0].in_sg[0], 1,
 			 sizeof(struct virtio_net_hdr_mrg_rxbuf));
 	}
@@ -159,6 +160,7 @@ int tcp_vu_send_flag(const struct ctx *c, struct tcp_tap_conn *conn, int flags)
 			nb_ack++;
 
 			if (*c->pcap) {
+				pcap_comment("tcp_vu_send_flag() dup_ack");
 				pcap_iov(&flags_elem[1].in_sg[0], 1,
 					 sizeof(struct virtio_net_hdr_mrg_rxbuf));
 			}
@@ -247,6 +249,8 @@ static ssize_t tcp_vu_sock_recv(const struct ctx *c,
 		return -errno;
 	}
 
+	pcap_comment("received %zd", ret);
+
 	if (!peek_offset_cap)
 		ret -= already_sent;
 
@@ -457,6 +461,8 @@ int tcp_vu_data_from_sock(const struct ctx *c, struct tcp_tap_conn *conn)
 		tcp_vu_prepare(c, conn, iov, buf_cnt, &check, !*c->pcap, push);
 
 		if (*c->pcap) {
+			pcap_comment("tcp_vu_data_from_sock() i=%d, head_cnt=%d, len=%zd, iov_cnt=%d",
+				     i, head_cnt, len, iov_cnt);
 			pcap_iov(iov, buf_cnt,
 				 sizeof(struct virtio_net_hdr_mrg_rxbuf));
 		}
diff --git a/vu_common.c b/vu_common.c
index 48826b13..5ad619e8 100644
--- a/vu_common.c
+++ b/vu_common.c
@@ -290,6 +290,7 @@ int vu_send_single(const struct ctx *c, const void *buf, size_t size)
 		     buf, total);
 
 	if (*c->pcap) {
+		pcap_comment("vu_send_single()");
 		pcap_iov(in_sg, elem_cnt,
 			 sizeof(struct virtio_net_hdr_mrg_rxbuf));
 	}
-- 
@@ -290,6 +290,7 @@ int vu_send_single(const struct ctx *c, const void *buf, size_t size)
 		     buf, total);
 
 	if (*c->pcap) {
+		pcap_comment("vu_send_single()");
 		pcap_iov(in_sg, elem_cnt,
 			 sizeof(struct virtio_net_hdr_mrg_rxbuf));
 	}
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] debug
  2025-02-07  5:50 [PATCH 0/2] Migration debugging hacks David Gibson
  2025-02-07  5:50 ` [PATCH 1/2] pcap comment hacks David Gibson
@ 2025-02-07  5:50 ` David Gibson
  1 sibling, 0 replies; 3+ messages in thread
From: David Gibson @ 2025-02-07  5:50 UTC (permalink / raw)
  To: passt-dev, Stefano Brivio; +Cc: David Gibson

---
 test/lib/setup             |  8 +++++---
 test/migrate/bidirectional | 15 ++++++++++++++-
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/test/lib/setup b/test/lib/setup
index 97b4487a..933b81e3 100755
--- a/test/lib/setup
+++ b/test/lib/setup
@@ -308,7 +308,6 @@ setup_two_guests() {
 # setup_migrate() - Set up two namespace, run qemu, passt/passt-repair in both
 setup_migrate() {
 	context_setup_host host
-	context_setup_host mon
 	context_setup_host pasta_1
 	context_setup_host pasta_2
 
@@ -330,8 +329,11 @@ setup_migrate() {
 	# Option 1: send stuff via spliced path in pasta
 	# context_run_bg pasta_1 "./pasta ${__opts} --trace -l /tmp/pasta1.log -P ${STATESETUP}/pasta_1.pid -t 10001,10002 -T 10003 -u 10001,10002 -U 10003 --config-net ${NSTOOL} hold ${STATESETUP}/ns1.hold"
 	# Option 2: send stuff via tap (--map-guest-addr) instead (useful to see capture of full migration)
-	context_run_bg pasta_1 "./pasta ${__opts} --trace -l /tmp/pasta1.log -P ${STATESETUP}/pasta_1.pid -t 10001,10002,10004 -T 10003 -u 10001,10002,10004 -U 10003 --map-guest-addr 169.254.1.1 --config-net ${NSTOOL} hold ${STATESETUP}/ns1.hold"
-	context_setup_nstool passt_1 ${STATESETUP}/ns1.hold
+	context_run_bg pasta_1 "strace -o ${LOGDIR}/pasta_1.strace ./pasta ${__opts} --trace -l /tmp/pasta1.log -P ${STATESETUP}/pasta_1.pid -t 10001,10002,10004 -T 10003 -u 10001,10002,10004 -U 10003 --map-guest-addr 169.254.1.1 --config-net ${NSTOOL} hold ${STATESETUP}/ns1.hold"
+
+	context_setup_nstool mon ${STATESETUP}/ns1.hold
+
+        context_setup_nstool passt_1 ${STATESETUP}/ns1.hold
 	context_setup_nstool passt_repair_1 ${STATESETUP}/ns1.hold
 
 	context_setup_nstool passt_2 ${STATESETUP}/ns1.hold
diff --git a/test/migrate/bidirectional b/test/migrate/bidirectional
index cd686e0c..47af2dcd 100644
--- a/test/migrate/bidirectional
+++ b/test/migrate/bidirectional
@@ -14,6 +14,9 @@
 g1tools	ip jq dhclient socat cat
 htools	ip jq
 
+mon	echo "Before everything"
+mon	ss --tcp -a -n
+
 test	Interface name
 g1out	IFNAME1 ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'
 hout	HOST_IFNAME ip -j -4 route show|jq -rM '[.[] | select(.dst == "default").dev] | .[0]'
@@ -34,6 +37,9 @@ hostb	socat -u TCP4-LISTEN:10006 OPEN:msg,create,trunc
 guest1b	socat -u TCP4-LISTEN:10001 OPEN:msg,create,trunc
 sleep	1
 
+mon	echo "Servers active"
+mon	ss --tcp -a -n
+
 guest1b	socat -u UNIX-RECV:proxy.sock,null-eof TCP4:169.254.1.1:10006
 hostb	socat -u UNIX-RECV:__STATESETUP__/proxy.sock,null-eof TCP4:__ADDR1__:10001
 sleep	1
@@ -41,9 +47,16 @@ guest1	printf "Hello from guest 1" | socat -u STDIN UNIX:proxy.sock
 host	printf "Dear guest 1," | socat -u STDIN UNIX:__STATESETUP__/proxy.sock
 sleep	1
 
+mon	echo "pre-migrate"
+mon	ss --tcp -a -n
+
 mon	echo "migrate tcp:0:20005" | socat -u STDIN UNIX:__STATESETUP__/qemu_1_mon.sock
 
-sleep	1
+sleep	5
+
+mon	echo "post-migrate"
+mon	ss --tcp -a -n
+
 guest2	printf " and from guest 2" | socat -u STDIN UNIX:proxy.sock,shut-null
 host	printf " you are now guest 2" | socat -u STDIN UNIX:__STATESETUP__/proxy.sock,shut-null
 
-- 
@@ -14,6 +14,9 @@
 g1tools	ip jq dhclient socat cat
 htools	ip jq
 
+mon	echo "Before everything"
+mon	ss --tcp -a -n
+
 test	Interface name
 g1out	IFNAME1 ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'
 hout	HOST_IFNAME ip -j -4 route show|jq -rM '[.[] | select(.dst == "default").dev] | .[0]'
@@ -34,6 +37,9 @@ hostb	socat -u TCP4-LISTEN:10006 OPEN:msg,create,trunc
 guest1b	socat -u TCP4-LISTEN:10001 OPEN:msg,create,trunc
 sleep	1
 
+mon	echo "Servers active"
+mon	ss --tcp -a -n
+
 guest1b	socat -u UNIX-RECV:proxy.sock,null-eof TCP4:169.254.1.1:10006
 hostb	socat -u UNIX-RECV:__STATESETUP__/proxy.sock,null-eof TCP4:__ADDR1__:10001
 sleep	1
@@ -41,9 +47,16 @@ guest1	printf "Hello from guest 1" | socat -u STDIN UNIX:proxy.sock
 host	printf "Dear guest 1," | socat -u STDIN UNIX:__STATESETUP__/proxy.sock
 sleep	1
 
+mon	echo "pre-migrate"
+mon	ss --tcp -a -n
+
 mon	echo "migrate tcp:0:20005" | socat -u STDIN UNIX:__STATESETUP__/qemu_1_mon.sock
 
-sleep	1
+sleep	5
+
+mon	echo "post-migrate"
+mon	ss --tcp -a -n
+
 guest2	printf " and from guest 2" | socat -u STDIN UNIX:proxy.sock,shut-null
 host	printf " you are now guest 2" | socat -u STDIN UNIX:__STATESETUP__/proxy.sock,shut-null
 
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-02-07  5:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-07  5:50 [PATCH 0/2] Migration debugging hacks David Gibson
2025-02-07  5:50 ` [PATCH 1/2] pcap comment hacks David Gibson
2025-02-07  5:50 ` [PATCH 2/2] debug David Gibson

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).