Thread (14 messages) 14 messages, 2 authors, 2025-06-11

Re: [PATCH RFC net-next v2 2/3] vsock/test: Introduce get_transports()

From: Michal Luczaj <hidden>
Date: 2025-06-04 19:10:47
Also in: lkml, virtualization

On 6/4/25 11:07, Stefano Garzarella wrote:
On Wed, May 28, 2025 at 10:44:42PM +0200, Michal Luczaj wrote:
quoted
+static int __get_transports(void)
+{
+	/* Order must match transports defined in util.h.
+	 * man nm: "d" The symbol is in the initialized data section.
+	 */
+	const char * const syms[] = {
+		"d loopback_transport",
+		"d virtio_transport",
+		"d vhost_transport",
+		"d vmci_transport",
+		"d hvs_transport",
+	};
I would move this array (or a macro that define it), near the transport 
defined in util.h, so they are near and we can easily update/review 
changes.

BTW what about adding static asserts to check we are aligned?
Something like

#define KNOWN_TRANSPORTS	\
	_(LOOPBACK, "loopback")	\
	_(VIRTIO, "virtio")	\
	_(VHOST, "vhost")	\
	_(VMCI, "vmci")		\
	_(HYPERV, "hvs")

enum transport {
	TRANSPORT_COUNTER_BASE = __COUNTER__ + 1,
	#define _(name, symbol)	\
		TRANSPORT_##name = _BITUL(__COUNTER__ - TRANSPORT_COUNTER_BASE),
	KNOWN_TRANSPORTS
	TRANSPORT_NUM = __COUNTER__ - TRANSPORT_COUNTER_BASE,
	#undef _
};

static char * const transport_ksyms[] = {
	#define _(name, symbol) "d " symbol "_transport",
	KNOWN_TRANSPORTS
	#undef _
};

static_assert(ARRAY_SIZE(transport_ksyms) == TRANSPORT_NUM);

?

Note that I keep pushing for naming HVS a TRANSPORT_HYPERV. Perhaps it's
better to stick to TRANSPORT_HVS after all?
quoted
diff --git a/tools/testing/vsock/util.h b/tools/testing/vsock/util.h
index 0afe7cbae12e5194172c639ccfbeb8b81f7c25ac..63953e32c3e18e1aa5c2addcf6f09f433660fa84 100644
--- a/tools/testing/vsock/util.h
+++ b/tools/testing/vsock/util.h
@@ -3,8 +3,19 @@
#define UTIL_H

#include <sys/socket.h>
+#include <linux/bitops.h>
#include <linux/vm_sockets.h>

+#define KALLSYMS_PATH		"/proc/kallsyms"
+#define KALLSYMS_LINE_LEN	512
We don't need to expose them in util.h IMO, we can keep in util.c
OK, sure.

Thanks,
Michal
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help