On 30/04/2026 12:49, Eelco Chaudron wrote:
External email: Use caution opening links or attachments
On 1 Apr 2026, at 11:13, Eli Britstein wrote:
A utility function for mem-stream is introduced. It replaces the usage
in dpdk and later for doca.
Thanks for the patch, see some comment below. In general it looks fine to me.
//Eelco
Signed-off-by: Eli Britstein <[email protected]>
---
configure.ac | 2 +-
lib/dpdk.c | 32 ++++----------------------------
lib/unixctl.c | 44 +++++++++++++++++++++++++++++++++++++++-----
lib/unixctl.h | 3 +++
4 files changed, 47 insertions(+), 34 deletions(-)
diff --git a/configure.ac b/configure.ac
index 56eacbbc7..cd063f811 100644
--- a/configure.ac
+++ b/configure.ac
@@ -115,7 +115,7 @@ AC_CHECK_MEMBERS([struct sockaddr_in6.sin6_scope_id], [],
[],
[[#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>]])
-AC_CHECK_FUNCS([mlockall strnlen getloadavg statvfs getmntent_r sendmmsg
clock_gettime])
+AC_CHECK_FUNCS([mlockall strnlen getloadavg statvfs getmntent_r sendmmsg
clock_gettime open_memstream])
AC_CHECK_HEADERS([mntent.h sys/statvfs.h linux/types.h linux/if_ether.h])
AC_CHECK_HEADERS([linux/net_namespace.h stdatomic.h bits/floatn-common.h])
AC_CHECK_HEADERS([net/if_mib.h], [], [], [[#include <sys/types.h>
diff --git a/lib/dpdk.c b/lib/dpdk.c
index d27b95cd9..edd07e3ac 100644
--- a/lib/dpdk.c
+++ b/lib/dpdk.c
@@ -273,30 +273,6 @@ static cookie_io_functions_t dpdk_log_func = {
.write = dpdk_log_write,
};
-static void
-dpdk_unixctl_mem_stream(struct unixctl_conn *conn, int argc OVS_UNUSED,
- const char *argv[] OVS_UNUSED, void *aux)
-{
- void (*callback)(FILE *) = aux;
- char *response = NULL;
- FILE *stream;
- size_t size;
-
- stream = open_memstream(&response, &size);
- if (!stream) {
- response = xasprintf("Unable to open memstream: %s.",
- ovs_strerror(errno));
- unixctl_command_reply_error(conn, response);
- goto out;
- }
-
- callback(stream);
- fclose(stream);
- unixctl_command_reply(conn, response);
-out:
- free(response);
-}
-
Does the build system need to enforce that open_memstream is available
when DPDK is enabled? Without it, the link will fail since
unixctl_mem_stream() is guarded by HAVE_OPEN_MEMSTREAM but the call
sites in dpdk.c are not. Something like the following in acinclude.m4
would catch this at configure time:
AS_IF([test "$DPDKLIB_FOUND" = true],
[AS_IF([test "$ac_cv_func_open_memstream" != yes],
[AC_MSG_ERROR([open_memstream is required when
building with DPDK])])])
Did not test it, and automake is not my thing ;)
I don't think it's mandatory, as it would fail otherwise. I'll add it
though
static int
dpdk_parse_log_level(const char *s)
{
@@ -491,16 +467,16 @@ dpdk_init__(const struct smap *ovs_other_config)
}
unixctl_command_register("dpdk/lcore-list", "", 0, 0,
- dpdk_unixctl_mem_stream, rte_lcore_dump);
+ unixctl_mem_stream, rte_lcore_dump);
unixctl_command_register("dpdk/log-list", "", 0, 0,
- dpdk_unixctl_mem_stream, rte_log_dump);
+ unixctl_mem_stream, rte_log_dump);
unixctl_command_register("dpdk/log-set", "{level | pattern:level}", 0,
INT_MAX, dpdk_unixctl_log_set, NULL);
unixctl_command_register("dpdk/get-malloc-stats", "", 0, 0,
- dpdk_unixctl_mem_stream,
+ unixctl_mem_stream,
malloc_dump_stats_wrapper);
unixctl_command_register("dpdk/get-memzone-stats", "", 0, 0,
- dpdk_unixctl_mem_stream, rte_memzone_dump);
+ unixctl_mem_stream, rte_memzone_dump);
/* We are called from the main thread here */
RTE_PER_LCORE(_lcore_id) = NON_PMD_CORE_ID;
diff --git a/lib/unixctl.c b/lib/unixctl.c
index 4fd150959..b8499394f 100644
--- a/lib/unixctl.c
+++ b/lib/unixctl.c
@@ -15,22 +15,26 @@
*/
#include <config.h>
-#include "unixctl.h"
+
The module's own header should appear second, immediately after
<config.h>, per the OVS coding style guide. So this need to be
restored to:
#include <config.h>
#include "unixctl.h"
#include <errno.h>
#include <getopt.h>
...
Ack
#include <errno.h>
#include <getopt.h>
+#include <stdio.h>
#include <unistd.h>
[...]
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev