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=kxfZvIj0; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 7E5EC5A0276 for ; Fri, 07 Feb 2025 06:50:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202502; t=1738907437; bh=OCtNho/p5uURn7lxCObPP7IXzc1Jq8BVgR/KSjME8Pc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kxfZvIj0FznCRmG7wPNBs+AFOrB2qbSjqbjkbgA9EcOVGLVGBb8MaQCIKLmj0PlDb vQCrJQJVUdxkB16GJWq9vpOWgAP6mDVPDnxyb2z8aXk4YR48mixlUhWJGXIeWTjlp8 DgpELTkddkTZEGuz0EjPEVQckX8ZW68F/rnIPA0Yj1W8/nZ6g1zrSHYoLhqnVxDikC RsIc/6EjCZQaCK0XNmEdEN1bKuAQdfbZmtRs1LoCzxDVTdZVOlR9EqfRaWA5gTpMt2 JewY2kyzqAP0j1VSQ2CXlRgQix5OPduo65oxHqOgksRk/MaMtrumbVBl/eSq95RlT5 yN2m4vjuX1z9w== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Yq33d5mN0z4wcT; Fri, 7 Feb 2025 16:50:37 +1100 (AEDT) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH 1/2] pcap comment hacks Date: Fri, 7 Feb 2025 16:50:44 +1100 Message-ID: <20250207055045.1753013-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250207055045.1753013-1-david@gibson.dropbear.id.au> References: <20250207055045.1753013-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: U6MDD5WK4DI27VXXGWQQPQDZ57BGKFZE X-Message-ID-Hash: U6MDD5WK4DI27VXXGWQQPQDZ57BGKFZE 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: --- 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)); } -- 2.48.1