patch 'test/pcapng: fix for Windows' has been queued to stable release 23.11.7
Shani Peretz
shperetz at nvidia.com
Wed Apr 15 11:59:45 CEST 2026
Hi,
FYI, your patch has been queued to stable release 23.11.7
Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 04/19/26. So please
shout if anyone has objections.
Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.
Queued patches are on a temporary branch at:
https://github.com/shanipr/dpdk-stable
This queued commit can be viewed at:
https://github.com/shanipr/dpdk-stable/commit/efd195fc93aae46b5c868d24b47b4428d764e515
Thanks.
Shani
---
>From efd195fc93aae46b5c868d24b47b4428d764e515 Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <stephen at networkplumber.org>
Date: Sat, 28 Feb 2026 09:35:00 -0800
Subject: [PATCH] test/pcapng: fix for Windows
[ upstream commit 93efb28e67f8a39ddf171c43a9b2d079e1f8c30e ]
The pcapng test needs additional wrappers to be able to
build and run on Windows.
This is a pre-existing problem, only exposed when the
test was enabled on Windows builds, and when libpcap
is setup on Windows.
Fixes: 0edc1f408a8b ("test: enable subset of tests on Windows")
Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
app/test/test_pcapng.c | 65 +++++++++++++++++++++++++++++++++++++++---
1 file changed, 61 insertions(+), 4 deletions(-)
diff --git a/app/test/test_pcapng.c b/app/test/test_pcapng.c
index 75ff461e8a..42eb1c44dc 100644
--- a/app/test/test_pcapng.c
+++ b/app/test/test_pcapng.c
@@ -4,7 +4,16 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
+
+#ifdef RTE_EXEC_ENV_WINDOWS
+#include <winsock2.h>
+#include <io.h>
+#include <fcntl.h>
+#include <windows.h>
+#else
#include <unistd.h>
+#endif
#include <rte_bus_vdev.h>
#include <rte_ethdev.h>
@@ -23,6 +32,52 @@
#include "test.h"
+#ifdef RTE_EXEC_ENV_WINDOWS
+static uint64_t
+current_timestamp(void)
+{
+ FILETIME ft;
+ ULARGE_INTEGER ul;
+
+ GetSystemTimeAsFileTime(&ft);
+ ul.LowPart = ft.dwLowDateTime;
+ ul.HighPart = ft.dwHighDateTime;
+ /* FILETIME is 100ns intervals since 1601-01-01, convert to ns since Unix epoch */
+ return (ul.QuadPart - 116444736000000000ULL) * 100;
+}
+
+/*
+ * Create temporary file with suffix for Windows.
+ * Returns file descriptor or -1 on failure.
+ */
+static int
+mkstemps(char *tmpl, int suffixlen)
+{
+ char temp_dir[MAX_PATH];
+ char temp_file[MAX_PATH];
+ DWORD ret;
+
+ ret = GetTempPathA(sizeof(temp_dir), temp_dir);
+ if (ret == 0 || ret > sizeof(temp_dir))
+ return -1;
+
+ if (GetTempFileNameA(temp_dir, "pcap", 0, temp_file) == 0)
+ return -1;
+
+ /*
+ * GetTempFileNameA with uUnique=0 creates the file to reserve the name.
+ * Remove it since we open a different name with the original suffix appended.
+ */
+ DeleteFileA(temp_file);
+
+ /* Append the original suffix (e.g. ".pcapng") to the temp file */
+ strlcat(temp_file, tmpl + strlen(tmpl) - suffixlen, sizeof(temp_file));
+ strlcpy(tmpl, temp_file, PATH_MAX);
+
+ return _open(tmpl, _O_RDWR | _O_BINARY | _O_CREAT | _O_EXCL, 0666);
+}
+#endif /* RTE_EXEC_ENV_WINDOWS */
+
#define PCAPNG_TEST_DEBUG 0
#define TOTAL_PACKETS 4096
@@ -273,6 +328,7 @@ error:
pcap_breakloop(ctx->pcap);
}
+#ifndef RTE_EXEC_ENV_WINDOWS
static uint64_t
current_timestamp(void)
{
@@ -281,6 +337,7 @@ current_timestamp(void)
clock_gettime(CLOCK_REALTIME, &ts);
return rte_timespec_to_ns(&ts);
}
+#endif
/*
* Open the resulting pcapng file with libpcap
@@ -324,7 +381,7 @@ valid_pcapng_file(const char *file_name, uint64_t started, unsigned int expected
static int
test_add_interface(void)
{
- char file_name[] = "/tmp/pcapng_test_XXXXXX.pcapng";
+ char file_name[PATH_MAX] = "/tmp/pcapng_test_XXXXXX.pcapng";
static rte_pcapng_t *pcapng;
int ret, tmp_fd;
uint64_t now = current_timestamp();
@@ -373,7 +430,7 @@ test_add_interface(void)
ret = valid_pcapng_file(file_name, now, 0);
/* if test fails want to investigate the file */
if (ret == 0)
- unlink(file_name);
+ remove(file_name);
return ret;
@@ -385,7 +442,7 @@ fail:
static int
test_write_packets(void)
{
- char file_name[] = "/tmp/pcapng_test_XXXXXX.pcapng";
+ char file_name[PATH_MAX] = "/tmp/pcapng_test_XXXXXX.pcapng";
static rte_pcapng_t *pcapng;
int ret, tmp_fd, count;
uint64_t now = current_timestamp();
@@ -430,7 +487,7 @@ test_write_packets(void)
ret = valid_pcapng_file(file_name, now, count);
/* if test fails want to investigate the file */
if (ret == 0)
- unlink(file_name);
+ remove(file_name);
return ret;
--
2.43.0
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2026-04-14 14:44:33.079459591 +0300
+++ 0044-test-pcapng-fix-for-Windows.patch 2026-04-14 14:44:28.623399000 +0300
@@ -1 +1 @@
-From 93efb28e67f8a39ddf171c43a9b2d079e1f8c30e Mon Sep 17 00:00:00 2001
+From efd195fc93aae46b5c868d24b47b4428d764e515 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 93efb28e67f8a39ddf171c43a9b2d079e1f8c30e ]
+
@@ -14 +15,0 @@
-Cc: stable at dpdk.org
@@ -22 +23 @@
-index ad9ad51f4c..f0faead728 100644
+index 75ff461e8a..42eb1c44dc 100644
@@ -94,2 +95,2 @@
- #define TOTAL_PACKETS 10000
-@@ -344,6 +399,7 @@ error:
+ #define TOTAL_PACKETS 4096
+@@ -273,6 +328,7 @@ error:
@@ -103 +104 @@
-@@ -352,6 +408,7 @@ current_timestamp(void)
+@@ -281,6 +337,7 @@ current_timestamp(void)
@@ -111 +112 @@
-@@ -395,7 +452,7 @@ valid_pcapng_file(const char *file_name, uint64_t started, unsigned int expected
+@@ -324,7 +381,7 @@ valid_pcapng_file(const char *file_name, uint64_t started, unsigned int expected
@@ -120 +121 @@
-@@ -444,7 +501,7 @@ test_add_interface(void)
+@@ -373,7 +430,7 @@ test_add_interface(void)
@@ -129 +130 @@
-@@ -456,7 +513,7 @@ fail:
+@@ -385,7 +442,7 @@ fail:
@@ -135 +136 @@
- rte_pcapng_t *pcapng = NULL;
+ static rte_pcapng_t *pcapng;
@@ -138 +139 @@
-@@ -508,7 +565,7 @@ test_write_packets(void)
+@@ -430,7 +487,7 @@ test_write_packets(void)
More information about the stable
mailing list