Skip to contentSkip to conversation

Client UDP not receiving data

EVL Hannes Diethelm 2 participants 8 messages May 20 – May 23

lore
Share & tools
lore
#0 lore raw

Hello

I have issue porting an application that runs as an UDP client to OOB networking.

The standard client pattern:
-connect
-oob_sendmsg
-oob_recvmsg
does not work.

In Wireshark, i see the packages going out and returning with the correct ip/port but oob_recvmsg() doesn't return.

To debug, I modified the oob-net-udp example, attached. Additionally, I ported it back to posix networking where it works as expected.

Send only mode / receive with bind works well.

Config:
Debian Trixie
linux-evl v6.12.y-cip-evl-rebase 569beef0
libevl r57 877d5ca

Regards
Hannes

/*
* SPDX-License-Identifier: MIT
*
* This tidbit demonstrates out-of-band networking, by
* sending[-S]/receiving[-R] UDP packets to/from a particular IP
* address[-a] and port[-p].
*
* See https://v4.xenomai.org/core/net/ for details. */

#include <pthread.h>
#include <error.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <memory.h>
#include <getopt.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <arpa/inet.h>
#include <evl/thread.h>
#include <evl/clock.h>
#include <evl/proxy.h>
#include <evl/net/net.h>

static int verbosity = 1;

static void usage(void)

{
	fprintf(stderr, "oob-net-udp -a <IP-address> [-p <port>]"
		"[-m <text>][-n <msgcount>][-I <iterations>][-i <interface>]"
		"[-d][-s][-R|-S][-b]\n");
}
static void print_addr(char* desc, struct sockaddr_in *addr){
    char ip_str[INET_ADDRSTRLEN+1]; // Puffer für die IP-Adresse
    inet_ntop(AF_INET, &(addr->sin_addr), ip_str, sizeof(ip_str));
    evl_printf("--------%s--------\n", desc);
    evl_printf("IP-Adresse: %s\n", ip_str);
    evl_printf("Port:       %d\n", ntohs(addr->sin_port));
    evl_printf("Family:     %d\n", ntohs(addr->sin_family));
}

static void sender(int s, const char *text, int mcount,
struct sockaddr_in *addr, int iter)

{
	struct oob_msghdr msghdr;
	struct iovec iov;
	int n, tlen;
	ssize_t ret;
	char *tbuf;

	tlen = (strlen(text) + 1) * mcount;
	tbuf = malloc(tlen);
	if (!tbuf)
		error(1, ENOMEM, "cannot create message");

	*tbuf = '\0';
	for (n = 0; n < mcount; n++)
		strcat(tbuf, text); /* yep, lazy.. */

	for (n = 0; !iter || n < iter; n++) {
		iov.iov_base = tbuf;
		iov.iov_len = tlen;
		msghdr.msg_iov = &iov;
		msghdr.msg_iovlen = 1;
		msghdr.msg_control = NULL;
		msghdr.msg_controllen = 0;
		msghdr.msg_name = addr;
		msghdr.msg_namelen = sizeof(*addr);
		msghdr.msg_flags = 0;
		ret = oob_sendmsg(s, &msghdr, NULL, 0);
		if (ret < 0)
			error(1, errno, "oob_sendmsg() failed");

		evl_usleep(1000000);
	}
}

static void client(int s, const char *text, int mcount,
struct sockaddr_in *addr, int iter)

{
	struct sockaddr_in _addr;
	socklen_t len = sizeof(_addr);
	struct oob_msghdr msghdr;
	struct iovec iov;
	int n, tlen;
	ssize_t ret;
	char *tbuf;
	char rbuf[16384];

	tlen = (strlen(text) + 1) * mcount;
	tbuf = malloc(tlen);
	if (!tbuf)
		error(1, ENOMEM, "cannot create message");

	*tbuf = '\0';
	for (n = 0; n < mcount; n++)
		strcat(tbuf, text); /* yep, lazy.. */

	ret = connect(s, (struct sockaddr *)addr, sizeof(*addr));
	if (ret < 0)
		error(1, errno, "connect() failed");

	print_addr("tx", addr);

	ret = getsockname(s, (struct sockaddr *)&_addr, &len);
	if (ret < 0)
		error(1, errno, "getsockname() failed");

	print_addr("rx", &_addr);

	for (n = 0; !iter || n < iter; n++) {
		iov.iov_base = tbuf;
		iov.iov_len = tlen;
		msghdr.msg_iov = &iov;
		msghdr.msg_iovlen = 1;
		msghdr.msg_control = NULL;
		msghdr.msg_controllen = 0;
		msghdr.msg_name = addr;
		msghdr.msg_namelen = sizeof(*addr);
		msghdr.msg_flags = 0;
		ret = oob_sendmsg(s, &msghdr, NULL, 0);
		if (ret < 0)
			error(1, errno, "oob_sendmsg() failed");

		memset(rbuf, 0, sizeof(rbuf));
		iov.iov_base = rbuf;
		iov.iov_len = sizeof(rbuf);
		msghdr.msg_iov = &iov;
		msghdr.msg_iovlen = 1;
		msghdr.msg_control = NULL;
		msghdr.msg_controllen = 0;
		msghdr.msg_name = &_addr;
		msghdr.msg_namelen = sizeof(_addr);
		msghdr.msg_flags = 0;
		ret = oob_recvmsg(s, &msghdr, NULL, 0);
		if (ret < 0)
			error(1, errno, "oob_recvmsg() failed");
		evl_printf("= %zd bytes received", ret);
		if (msghdr.msg_flags & MSG_TRUNC)
			evl_printf(" (TRUNCATED)");
		evl_printf(": %.*s\n", (int)ret, rbuf);
	}
}

static void receiver(int s, struct sockaddr_in *addr, int iter)

{
	struct sockaddr_in _addr;
	socklen_t len = sizeof(_addr);
	struct oob_msghdr msghdr;
	struct iovec iov;
	char rbuf[16384];
	ssize_t ret;
	int n;

	ret = bind(s, (struct sockaddr *)addr, sizeof(*addr));
	if (ret < 0)
		error(1, errno, "bind() failed");

	ret = getsockname(s, (struct sockaddr *)&_addr, &len);
	if (ret < 0)
		error(1, errno, "getsockname() failed");

	if (verbosity)
		printf("== bound to port %d\n", ntohs(_addr.sin_port));

	for (n = 0; !iter || n < iter; n++) {
		memset(rbuf, 0, sizeof(rbuf));
		iov.iov_base = rbuf;
		iov.iov_len = sizeof(rbuf);
		msghdr.msg_iov = &iov;
		msghdr.msg_iovlen = 1;
		msghdr.msg_control = NULL;
		msghdr.msg_controllen = 0;
		msghdr.msg_name = &_addr;
		msghdr.msg_namelen = sizeof(_addr);
		msghdr.msg_flags = 0;
		ret = oob_recvmsg(s, &msghdr, NULL, 0);
		if (ret < 0)
			error(1, errno, "oob_recvmsg() failed");
		evl_printf("= %zd bytes received", ret);
		if (msghdr.msg_flags & MSG_TRUNC)
			evl_printf(" (TRUNCATED)");
		evl_printf(": %.*s\n", (int)ret, rbuf);
	}
}

int main(int argc, char *argv[])

{
	int tfd, s, c, mcount = 1, iter = 0, port = 42042, on = 1;
	const char *text = "Mellow sword!\n", *iface = NULL;
	bool send = false, bcast = false;
	struct sched_param param;
	struct sockaddr_in addr;
	const char *ip = NULL;
	ssize_t ret;

	while ((c = getopt(argc, argv, "a:m:n:i:I:p:dsRSb")) != EOF) {
		switch (c) {
		case 'a':
			ip = optarg;
			break;
		case 'd':
			verbosity = 2;
			break;
		case 's':
			verbosity = 0;
			break;
		case 'm':
			text = optarg;
			break;
		case 'n':
			mcount = atoi(optarg);
			break;
		case 'i':
			iface = optarg;
			break;
		case 'I':
			iter = atoi(optarg);
			break;
		case 'p':
			port = atoi(optarg);
			break;
		case 'b':
			bcast = true; /* Force mode, e.g. for directed broadcast */
			break;
		case 'R':
			send = false;
			break;
		case 'S':
			send = true;
			break;
		default:
			usage();
			exit(1);
		}
	}

	if (ip == NULL) {
		usage();
		exit(2);
	}

	memset(&addr, 0, sizeof(addr));
	addr.sin_family = AF_INET;
	addr.sin_port = htons(port);
	if (!strcmp(ip, "broadcast")) {
		addr.sin_addr.s_addr = INADDR_BROADCAST;
		bcast = true;
	} else if (!inet_pton(AF_INET, ip, &addr.sin_addr)) {
		error(1, EINVAL, "invalid IP address");
	} else if (addr.sin_addr.s_addr == INADDR_BROADCAST) {
		bcast = true;
	}

	param.sched_priority = 1;
	ret = pthread_setschedparam(pthread_self(), SCHED_FIFO, &param);
	if (ret)
		error(1, ret, "pthread_setschedparam()");

	tfd = evl_attach_self("oob-net-udp:%d", getpid());
	if (tfd < 0)
		error(1, -tfd, "cannot attach to the EVL core");

	/*
	 * Get an UDP socket with out-of-band capabilities.
	 */
	s = socket(AF_INET, SOCK_DGRAM | SOCK_OOB, 0);
	if (s < 0)
		error(1, errno, "cannot create out-of-band UDP socket");

	if (iface) {
		if (setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE, iface, strlen(iface)))
			error(1, errno, "setsockopt(SO_BINDTODEVICE)");
		if (verbosity)
			printf("== bound to %s\n", iface);
	}

	if (send) {
		if (bcast) {
			ret = setsockopt(s, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on));
			if (ret)
				error(1, errno, "cannot enable broadcast for UDP socket");
		}

		/*
		 * Guarantee a mere oob path from the first packet
		 * onward by pre-caching the route and link-layer
		 * address via an explicit neighbour solicitation
		 * before we start sending data.
		 */
		ret = evl_net_solicit(s, (const struct sockaddr *)&addr,
				EVL_NEIGH_PERMANENT);
		if (ret)
			error(1, -ret, "evl_net_solicit()");

		if (verbosity)
			printf("== sender mode (=> %s:%d)\n", bcast ? "[broadcast]" : ip, port);

		//sender(s, text, mcount, &addr, iter);
		client(s, text, mcount, &addr, iter);
	} else {
		if (verbosity)
			printf("== receiver mode (<= %s:%d)\n", ip, port);

		receiver(s, &addr, iter);
	}

	return 0;
}

/*
* SPDX-License-Identifier: MIT
*
* This tidbit demonstrates out-of-band networking, by
* sending[-S]/receiving[-R] UDP packets to/from a particular IP
* address[-a] and port[-p].
*
* See https://v4.xenomai.org/core/net/ for details. */

#include <pthread.h>
#include <error.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <memory.h>
#include <getopt.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <arpa/inet.h>
#include <evl/thread.h>
#include <evl/clock.h>
#include <evl/proxy.h>
#include <evl/net/net.h>

static int verbosity = 1;

static void usage(void)

{
	fprintf(stderr, "oob-net-udp -a <IP-address> [-p <port>]"
		"[-m <text>][-n <msgcount>][-I <iterations>][-i <interface>]"
		"[-d][-s][-R|-S][-b]\n");
}
static void print_addr(char* desc, struct sockaddr_in *addr){
    char ip_str[INET_ADDRSTRLEN+1]; // Puffer für die IP-Adresse
    inet_ntop(AF_INET, &(addr->sin_addr), ip_str, sizeof(ip_str));
    printf("--------%s--------\n", desc);
    printf("IP-Adresse: %s\n", ip_str);
    printf("Port:       %d\n", ntohs(addr->sin_port));
    printf("Family:     %d\n", ntohs(addr->sin_family));
}

static void sender(int s, const char *text, int mcount,
struct sockaddr_in *addr, int iter)

{
	struct msghdr msghdr;
	struct iovec iov;
	int n, tlen;
	ssize_t ret;
	char *tbuf;

	tlen = (strlen(text) + 1) * mcount;
	tbuf = malloc(tlen);
	if (!tbuf)
		error(1, ENOMEM, "cannot create message");

	*tbuf = '\0';
	for (n = 0; n < mcount; n++)
		strcat(tbuf, text); /* yep, lazy.. */

	for (n = 0; !iter || n < iter; n++) {
		iov.iov_base = tbuf;
		iov.iov_len = tlen;
		msghdr.msg_iov = &iov;
		msghdr.msg_iovlen = 1;
		msghdr.msg_control = NULL;
		msghdr.msg_controllen = 0;
		msghdr.msg_name = addr;
		msghdr.msg_namelen = sizeof(*addr);
		msghdr.msg_flags = 0;
		ret = sendmsg(s, &msghdr, 0);
		if (ret < 0)
			error(1, errno, "sendmsg() failed");

		usleep(1000000);
	}
}

static void client_msg(int s, const char *text, int mcount,
struct sockaddr_in *addr, int iter)

{
	struct sockaddr_in _addr;
	socklen_t len = sizeof(_addr);
	struct msghdr msghdr;
	struct iovec iov;
	int n, tlen;
	ssize_t ret;
	char *tbuf;
	char rbuf[16384];

	tlen = (strlen(text) + 1) * mcount;
	tbuf = malloc(tlen);
	if (!tbuf)
		error(1, ENOMEM, "cannot create message");

	*tbuf = '\0';
	for (n = 0; n < mcount; n++)
		strcat(tbuf, text); /* yep, lazy.. */

	ret = connect(s, (struct sockaddr *)addr, sizeof(*addr));
	if (ret < 0)
		error(1, errno, "connect() failed");

	print_addr("tx", addr);

	ret = getsockname(s, (struct sockaddr *)&_addr, &len);
	if (ret < 0)
		error(1, errno, "getsockname() failed");

	print_addr("rx", &_addr);

	for (n = 0; !iter || n < iter; n++) {
		iov.iov_base = tbuf;
		iov.iov_len = tlen;
		msghdr.msg_iov = &iov;
		msghdr.msg_iovlen = 1;
		msghdr.msg_control = NULL;
		msghdr.msg_controllen = 0;
		msghdr.msg_name = addr;
		msghdr.msg_namelen = sizeof(*addr);
		msghdr.msg_flags = 0;
		ret = sendmsg(s, &msghdr, 0);
		if (ret < 0)
			error(1, errno, "sendmsg() failed");

		memset(rbuf, 0, sizeof(rbuf));
		iov.iov_base = rbuf;
		iov.iov_len = sizeof(rbuf);
		msghdr.msg_iov = &iov;
		msghdr.msg_iovlen = 1;
		msghdr.msg_control = NULL;
		msghdr.msg_controllen = 0;
		msghdr.msg_name = &_addr;
		msghdr.msg_namelen = sizeof(_addr);
		msghdr.msg_flags = 0;
		ret = recvmsg(s, &msghdr, 0);
		if (ret < 0)
			error(1, errno, "recvmsg() failed");
		printf("= %zd bytes received", ret);
		if (msghdr.msg_flags & MSG_TRUNC)
			printf(" (TRUNCATED)");
		printf(": %.*s\n", (int)ret, rbuf);
	}
}

static void client_sr(int s, const char *text, int mcount,
struct sockaddr_in *addr, int iter)

{
	struct sockaddr_in _addr;
	socklen_t len = sizeof(_addr);
	int n, tlen;
	ssize_t ret;
	char *tbuf;
	char rbuf[16384];

	tlen = (strlen(text) + 1) * mcount;
	tbuf = malloc(tlen);
	if (!tbuf)
		error(1, ENOMEM, "cannot create message");

	*tbuf = '\0';
	for (n = 0; n < mcount; n++)
		strcat(tbuf, text); /* yep, lazy.. */

	ret = connect(s, (struct sockaddr *)addr, sizeof(*addr));
	if (ret < 0)
		error(1, errno, "connect() failed");

	print_addr("tx", addr);

	for (n = 0; !iter || n < iter; n++) {
		ret = send(s, tbuf, tlen, 0);
		if (ret < 0)
			error(1, errno, "sendmsg() failed");

		memset(rbuf, 0, sizeof(rbuf));
		ret = recv(s, rbuf, sizeof(rbuf), 0);
		if (ret < 0)
			error(1, errno, "recvmsg() failed");
		printf("= %zd bytes received", ret);
		printf(": %.*s\n", (int)ret, rbuf);
	}
}

static void receiver(int s, struct sockaddr_in *addr, int iter)

{
	struct sockaddr_in _addr;
	socklen_t len = sizeof(_addr);
	struct msghdr msghdr;
	struct iovec iov;
	char rbuf[16384];
	ssize_t ret;
	int n;

	ret = bind(s, (struct sockaddr *)addr, sizeof(*addr));
	if (ret < 0)
		error(1, errno, "bind() failed");

	ret = getsockname(s, (struct sockaddr *)&_addr, &len);
	if (ret < 0)
		error(1, errno, "getsockname() failed");

	if (verbosity)
		printf("== bound to port %d\n", ntohs(_addr.sin_port));

	for (n = 0; !iter || n < iter; n++) {
		memset(rbuf, 0, sizeof(rbuf));
		iov.iov_base = rbuf;
		iov.iov_len = sizeof(rbuf);
		msghdr.msg_iov = &iov;
		msghdr.msg_iovlen = 1;
		msghdr.msg_control = NULL;
		msghdr.msg_controllen = 0;
		msghdr.msg_name = &_addr;
		msghdr.msg_namelen = sizeof(_addr);
		msghdr.msg_flags = 0;
		ret = recvmsg(s, &msghdr, 0);
		if (ret < 0)
			error(1, errno, "recvmsg() failed");
		printf("= %zd bytes received", ret);
		if (msghdr.msg_flags & MSG_TRUNC)
			printf(" (TRUNCATED)");
		printf(": %.*s\n", (int)ret, rbuf);
	}
}

int main(int argc, char *argv[])

{
	int s, c, mcount = 1, iter = 0, port = 42042, on = 1;
	const char *text = "Mellow sword!\n", *iface = NULL;
	bool send = false, bcast = false;
	struct sockaddr_in addr;
	const char *ip = NULL;
	ssize_t ret;

	while ((c = getopt(argc, argv, "a:m:n:i:I:p:dsRSb")) != EOF) {
		switch (c) {
		case 'a':
			ip = optarg;
			break;
		case 'd':
			verbosity = 2;
			break;
		case 's':
			verbosity = 0;
			break;
		case 'm':
			text = optarg;
			break;
		case 'n':
			mcount = atoi(optarg);
			break;
		case 'i':
			iface = optarg;
			break;
		case 'I':
			iter = atoi(optarg);
			break;
		case 'p':
			port = atoi(optarg);
			break;
		case 'b':
			bcast = true; /* Force mode, e.g. for directed broadcast */
			break;
		case 'R':
			send = false;
			break;
		case 'S':
			send = true;
			break;
		default:
			usage();
			exit(1);
		}
	}

	if (ip == NULL) {
		usage();
		exit(2);
	}

	memset(&addr, 0, sizeof(addr));
	addr.sin_family = AF_INET;
	addr.sin_port = htons(port);
	if (!strcmp(ip, "broadcast")) {
		addr.sin_addr.s_addr = INADDR_BROADCAST;
		bcast = true;
	} else if (!inet_pton(AF_INET, ip, &addr.sin_addr)) {
		error(1, EINVAL, "invalid IP address");
	} else if (addr.sin_addr.s_addr == INADDR_BROADCAST) {
		bcast = true;
	}

	/*
	 * Get an UDP socket with out-of-band capabilities.
	 */
	s = socket(AF_INET, SOCK_DGRAM | SOCK_OOB, 0);
	if (s < 0)
		error(1, errno, "cannot create out-of-band UDP socket");

	if (iface) {
		if (setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE, iface, strlen(iface)))
			error(1, errno, "setsockopt(SO_BINDTODEVICE)");
		if (verbosity)
			printf("== bound to %s\n", iface);
	}

	if (send) {
		if (bcast) {
			ret = setsockopt(s, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on));
			if (ret)
				error(1, errno, "cannot enable broadcast for UDP socket");
		}

		if (ret)
			error(1, -ret, "net_solicit()");

		if (verbosity)
			printf("== client mode (=> %s:%d)\n", bcast ? "[broadcast]" : ip, port);

		//sender(s, text, mcount, &addr, iter);
		client_msg(s, text, mcount, &addr, iter);
		//client_sr(s, text, mcount, &addr, iter);
	} else {
		if (verbosity)
			printf("== receiver mode (<= %s:%d)\n", ip, port);

		receiver(s, &addr, iter);
	}

	return 0;
}
#1 lore raw
Quoted 16 lines · Hannes Diethelm

Hello

I have issue porting an application that runs as an UDP client to OOB networking.

The standard client pattern:

(quoted diff) +0 -3
-connect
-oob_sendmsg
-oob_recvmsg

does not work.

In Wireshark, i see the packages going out and returning with the correct ip/port but oob_recvmsg() doesn't return.

To debug, I modified the oob-net-udp example, attached. Additionally, I ported it back to posix networking where it works as expected.

Quoted 7 lines

Send only mode / receive with bind works well.

Config:
Debian Trixie
linux-evl v6.12.y-cip-evl-rebase 569beef0
libevl r57 877d5ca

I believe oob-net-udp does work as is, but not the way you seem to expect it, which led your to change the original logic so that two instances of this program always run head to tail, each one running a sender+receiver loop.

The original intent was to implement half-duplex roles instead, starting each instance either with the -S (send mode) or -R (receive mode, default) option switch, in order to explicitly select a role.

This allows for more configurations, like mixing the network stacks to use for testing. For instance, we are currently able to broadcast packets to listeners on port #42042 over the wire from a vanilla linux system (no evl) to an evl-enabled one, using VLAN-based selection of packets:

/*
* From the vanilla system, through VLAN device eno2.1 */

$ echo -n "Hello world" | sudo socat - udp-datagram:255.255.255.255:42042,broadcast,so-bindtodevice=eno2.1

/*
* From the evl system, listening to all oob interfaces using VLAN-based
* packet selection.
*/

~# oob-net-udp -R -a broadcast
== receiver mode (<= broadcast:42042)
== bound to port 42042
= 11 bytes received: Hello world

With a different setup, we could connect two evl-enabled systems, like:

/*
* From the first evl-enabled system, sending through eth1
* to 10.10.10.11:42042
*/

~# oob-net-udp -S -a 10.10.10.11
== sender mode (=> 10.10.10.11:42042)

/*
* From the second evl-enabled system, receiving from eth0,
* bound to 10.10.10.11 on port #42042
*/

~# oob-net-udp -R -a 10.10.10.11
== receiver mode (<= 10.10.10.11:42042)
== bound to port 42042

This said, if you believe that a dual role setup like the one you suggested would be nice to have to users as well, we could add it to oob-net-udp alongside the existing half-duplex modes. For instance, omitting the -R and -S keys on the command line currently defaults to -R. Instead, we could select the new "dual role" mode.

PS: please send (diff context, -u or git-diff) formatted patches instead of entire modified files, so that we can immediately grasp the essence of the proposed changes. Also, please make sure to separate unrelated changes sets in distinct patches (e.g. those changing a particular aspect of the logic from others which may be coding style fixups). Generally speaking, we follow the linux kernel coding style and process when it comes to submitting patches [1].

[1] https://docs.kernel.org/process/submitting-patches.html

Signature · 1 line
Philippe.
#2 lore raw

Am 21.05.26 um 11:49 schrieb Philippe Gerum:

Quoted 90 lines
Quoted 16 lines · Hannes Diethelm

Hello

I have issue porting an application that runs as an UDP client to OOB networking.

The standard client pattern:

(quoted diff) +0 -3
-connect
-oob_sendmsg
-oob_recvmsg

does not work.

In Wireshark, i see the packages going out and returning with the correct ip/port but oob_recvmsg() doesn't return.

To debug, I modified the oob-net-udp example, attached. Additionally, I ported it back to posix networking where it works as expected.

Quoted 7 lines

Send only mode / receive with bind works well.

Config:
Debian Trixie
linux-evl v6.12.y-cip-evl-rebase 569beef0
libevl r57 877d5ca

I believe oob-net-udp does work as is, but not the way you seem to expect it, which led your to change the original logic so that two instances of this program always run head to tail, each one running a sender+receiver loop.

The original intent was to implement half-duplex roles instead, starting each instance either with the -S (send mode) or -R (receive mode, default) option switch, in order to explicitly select a role.

This allows for more configurations, like mixing the network stacks to use for testing. For instance, we are currently able to broadcast packets to listeners on port #42042 over the wire from a vanilla linux system (no evl) to an evl-enabled one, using VLAN-based selection of packets:

/*
* From the vanilla system, through VLAN device eno2.1 */

$ echo -n "Hello world" | sudo socat - udp-datagram:255.255.255.255:42042,broadcast,so-bindtodevice=eno2.1

/*
* From the evl system, listening to all oob interfaces using VLAN-based
* packet selection.
*/

~# oob-net-udp -R -a broadcast
== receiver mode (<= broadcast:42042)
== bound to port 42042
= 11 bytes received: Hello world

With a different setup, we could connect two evl-enabled systems, like:

/*
* From the first evl-enabled system, sending through eth1
* to 10.10.10.11:42042
*/

~# oob-net-udp -S -a 10.10.10.11
== sender mode (=> 10.10.10.11:42042)

/*
* From the second evl-enabled system, receiving from eth0,
* bound to 10.10.10.11 on port #42042
*/

~# oob-net-udp -R -a 10.10.10.11
== receiver mode (<= 10.10.10.11:42042)
== bound to port 42042

This said, if you believe that a dual role setup like the one you suggested would be nice to have to users as well, we could add it to oob-net-udp alongside the existing half-duplex modes. For instance, omitting the -R and -S keys on the command line currently defaults to -R. Instead, we could select the new "dual role" mode.

PS: please send (diff context, -u or git-diff) formatted patches instead of entire modified files, so that we can immediately grasp the essence of the proposed changes. Also, please make sure to separate unrelated changes sets in distinct patches (e.g. those changing a particular aspect of the logic from others which may be coding style fixups). Generally speaking, we follow the linux kernel coding style and process when it comes to submitting patches [1].

Quoted 2 lines

[1] https://docs.kernel.org/process/submitting-patches.html

Thanks for the detailed answer. I might have been not precise enough.

The -S and the -R mode work as designed. To show the issue with connect() in evl, I changed the -S mode to:
connect()
while{
oob_sendmsg()
oob_recvmsg()
}

This is the classical UDP client pattern. It works with vanilla linux (net-udp.c) but not with evl (oob-net-udp.c), I do not receive any data.

By just sending the modified code, it is easy to explain and hopefully for you to reproduce. This is also why I attached the files instead of sending a patch. Be aware that this is just to demonstrate what is not working, not intended as a patch.

I run Xenomai4 in a VM and communicate with the host for debugging but I have also a real PC as the final target where I have the same issues.

First start on the host:
echo Hello | nc -u -l 5201

Then in the VM:
sudo evl net -ei enp7s0
sudo oob-net-udp -d -i enp7s0 -a 192.168.122.1 -p 5201 -S

On the host:
Mellow sword!

In the VM:
== bound to enp7s0
== sender mode (=> 192.168.122.1:5201)
--------tx--------

IP-Adresse: 192.168.122.1
Port:       5201
Family:     512
--------rx--------
IP-Adresse: 192.168.122.155
Port:       58422
Family:     512

The package is visible in wireshark but oob_recvmsg does not return:
No "= 6 bytes received: Hello" and no second transmit.

It looks like the auto assigned and bound port from connect() is not forwarded to the oob stage, so no data is received in oob_recvmsg().

In wireshark in the VM, I see the outgoing package 41626->5201 and the incoming 5201->41626 where 41626 is an auto assigned port by connect.

With the code ported to vanilla linux:
connect()
while{
sendmsg()
recvmsg()
}
it works as expected:

Host:
echo Hello | nc -u -l 5201

VM:
sudo evl net -di enp7s0
net-udp -d -i enp7s0 -a 192.168.122.1 -p 5201 -S

Host:
Mellow sword!
Mellow sword!

VM:
== bound to enp7s0
== client mode (=> 192.168.122.1:5201)
--------tx--------

IP-Adresse: 192.168.122.1
Port:       5201
Family:     512
--------rx--------
IP-Adresse: 192.168.122.155
Port:       43042
Family:     512

= 6 bytes received: Hello

But might be evl was never intended to work using connect() in classical UDP client style?

Meanwhile, I found a workaround. Instead of connect() I just use bind(). The only disadvantage is, that I have to manually assign a port:

bind()
while{
oob_sendmsg()
oob_recvmsg()
}

Normally, bind() is only used for servers and point-to-point connections but you can (miss-) use it also for clients. A server would be:
bind()
while{
oob_recvmsg() -> Receives a message from any client
oob_sendmsg() -> Sends the answer back to the ip/port from the address from recvmsg
}

If you think this this example is useful, I can finalize it (for now with the bind() workaround) and also add a server mode. So there would be 4 modes in total. With a server mode, you can run the server on one host, the client on the other and continuously send data forward / backward and measure delays. I would use:
-T send (previously it was -S but then I have nothing for server)
-R receive
-S server: Waits for data and sends a response for each received package.
-C client: Sends data and measures how long it takes for the server to response.

As an alternative, I could just create a second example oob-net-udp-server-client.c. This would result in a bit of duplicated code but not to much.

What do you prefer?

I also created oob-net-ping in the same style as oob-net-icmp but this sends out a ping, receives the response and measures the delay, similar as the ping command:
./oob-net-ping -i enp7s0 -a 192.168.122.1
[0] count=98, proto=0x800, ifindex=3, type=0, halen=6, mac=52:54:00:6b:05:f1 rtt=317.1us
[1] count=98, proto=0x800, ifindex=3, type=0, halen=6, mac=52:54:00:6b:05:f1 rtt=218.5us
[2] count=98, proto=0x800, ifindex=3, type=0, halen=6, mac=52:54:00:6b:05:f1 rtt=252.5us
[3] count=98, proto=0x800, ifindex=3, type=0, halen=6, mac=52:54:00:6b:05:f1 rtt=320.1us
It has to be cleaned it up a bit and integrated it into the libevl repo but then I will also send a patch.

Regards
Hannes

#3 lore raw
Quoted 43 lines · Hannes Diethelm

Thanks for the detailed answer. I might have been not precise enough.

The -S and the -R mode work as designed. To show the issue with connect() in evl, I changed the -S mode to:
connect()
while{
oob_sendmsg()
oob_recvmsg()
}

This is the classical UDP client pattern. It works with vanilla linux (net-udp.c) but not with evl (oob-net-udp.c), I do not receive any data.

By just sending the modified code, it is easy to explain and hopefully for you to reproduce. This is also why I attached the files instead of sending a patch. Be aware that this is just to demonstrate what is not working, not intended as a patch.

I run Xenomai4 in a VM and communicate with the host for debugging but I have also a real PC as the final target where I have the same issues.

First start on the host:
echo Hello | nc -u -l 5201

Then in the VM:
sudo evl net -ei enp7s0
sudo oob-net-udp -d -i enp7s0 -a 192.168.122.1 -p 5201 -S

On the host:
Mellow sword!

In the VM:
== bound to enp7s0
== sender mode (=> 192.168.122.1:5201)
--------tx--------

IP-Adresse: 192.168.122.1
Port:       5201
Family:     512
--------rx--------
IP-Adresse: 192.168.122.155
Port:       58422
Family:     512
Quoted 2 lines

The package is visible in wireshark but oob_recvmsg does not return:
No "= 6 bytes received: Hello" and no second transmit.

Ok, I totally misinterpreted your previous post, sorry for that. Brain received -ENOCOFFEE.

Quoted 4 lines

It looks like the auto assigned and bound port from connect() is not forwarded to the oob stage, so no data is received in oob_recvmsg().

This is exactly the point, indeed. Could you please try this branch [1]? The two commits on top improve the situation with your test code here.

Quoted 3 lines

But might be evl was never intended to work using connect() in classical UDP client style?

IMO, the evl netstack (and evl in general) should follow the POLA principle as closely as possible, and any UDP user can reasonably expect auto-binding to be handled. So this needs fixing.

Quoted 9 lines

If you think this this example is useful, I can finalize it (for now with the bind() workaround) and also add a server mode. So there would be 4 modes in total. With a server mode, you can run the server on one host, the client on the other and continuously send data forward / backward and measure delays. I would use:

(quoted diff) +0 -4
-T send (previously it was -S but then I have nothing for server)
-R receive
-S server: Waits for data and sends a response for each received package.
-C client: Sends data and measures how long it takes for the server to response.
Quoted 3 lines

As an alternative, I could just create a second example oob-net-udp-server-client.c. This would result in a bit of duplicated code but not to much.

What do you prefer?

It is definitely useful. I would go for option #1, i.e. integrated send/recv/server/client example. First because all the boilerplate and ancillary support for parsing options and setting up connections is already there and the code running the client scenario to be added is likely small enough.

Next because the I'd rather have a 'client' mode measuring round-trip times explicitly in the context of some example code, rather than letting people think that we would actually provide a 'ping' command that way. Reason is about performance: the standard in-band ICMP server is operated from kernel context; although the latency would bite compared to any oob-based server under high load, on average the figures obtained on an idle system would be somewhat misleading compared to the oob server in application space, because reinstating a userland context for handling ICMP requests may be more time-consuming than handling it directly as close as possible from the packet delivery point in kernel space, i.e. without entailing any context switching to userland (even to an oob thread).

Quoted 10 lines

I also created oob-net-ping in the same style as oob-net-icmp but this sends out a ping, receives the response and measures the delay, similar as the ping command:
./oob-net-ping -i enp7s0 -a 192.168.122.1
[0] count=98, proto=0x800, ifindex=3, type=0, halen=6, mac=52:54:00:6b:05:f1 rtt=317.1us
[1] count=98, proto=0x800, ifindex=3, type=0, halen=6, mac=52:54:00:6b:05:f1 rtt=218.5us
[2] count=98, proto=0x800, ifindex=3, type=0, halen=6, mac=52:54:00:6b:05:f1 rtt=252.5us
[3] count=98, proto=0x800, ifindex=3, type=0, halen=6, mac=52:54:00:6b:05:f1 rtt=320.1us
It has to be cleaned it up a bit and integrated it into the libevl repo but then I will also send a patch.

I think we need a simple agent somewhere in the evl netstack in kernel space answering ICMP_ECHO requests flowing in oob channels directly, just like the in-band stack does for in-band traffic. I can look into this.

PS: thanks for the test code you provided, it saved a lot of time on my end.

[1] https://gitlab.com/Xenomai/xenomai4/linux-evl/-/tree/next/v6.12.y-cip-evl-rebase?ref_type=heads

Signature · 1 line
Philippe.
#4 lore raw

Am 22.05.26 um 17:40 schrieb Philippe Gerum:

Quoted 52 lines
Quoted 43 lines · Hannes Diethelm

Thanks for the detailed answer. I might have been not precise enough.

The -S and the -R mode work as designed. To show the issue with connect() in evl, I changed the -S mode to:
connect()
while{
oob_sendmsg()
oob_recvmsg()
}

This is the classical UDP client pattern. It works with vanilla linux (net-udp.c) but not with evl (oob-net-udp.c), I do not receive any data.

By just sending the modified code, it is easy to explain and hopefully for you to reproduce. This is also why I attached the files instead of sending a patch. Be aware that this is just to demonstrate what is not working, not intended as a patch.

I run Xenomai4 in a VM and communicate with the host for debugging but I have also a real PC as the final target where I have the same issues.

First start on the host:
echo Hello | nc -u -l 5201

Then in the VM:
sudo evl net -ei enp7s0
sudo oob-net-udp -d -i enp7s0 -a 192.168.122.1 -p 5201 -S

On the host:
Mellow sword!

In the VM:
== bound to enp7s0
== sender mode (=> 192.168.122.1:5201)
--------tx--------

IP-Adresse: 192.168.122.1
Port:       5201
Family:     512
--------rx--------
IP-Adresse: 192.168.122.155
Port:       58422
Family:     512
Quoted 2 lines

The package is visible in wireshark but oob_recvmsg does not return:
No "= 6 bytes received: Hello" and no second transmit.

Ok, I totally misinterpreted your previous post, sorry for that. Brain received -ENOCOFFEE.

Quoted 1 line
Quoted 6 lines
Quoted 3 lines

It looks like the auto assigned and bound port from connect() is not forwarded to the oob stage, so no data is received in oob_recvmsg().

This is exactly the point, indeed. Could you please try this branch [1]? The two commits on top improve the situation with your test code here.

Thanks for the very fast fix. Connect works now as expected. And I was able to remove the workaround.

I switched to libevl r58, r57 did not work any more. Is there any visible link libevl->kernel? I just got an operation not permitted in oob_sleep_until.

But there are two new issues:

-oob_sendmsg returns "Invalid argument" errno 22 exactly every second. The last number is the system time in ns.
ERROR: oob_sendmsg Invalid argument 22 806999652287
ERROR: oob_sendmsg Invalid argument 22 807999655503
ERROR: oob_sendmsg Invalid argument 22 808999650416

I have this with the exact same code as before using bind() and also with the now working connect(). There are 3000 tx / 1000 rx packages/s.

I tried do{oob_sendmsg}while(errno == 22) but that resulted in a full freeze of the PC.

-The last commit a4cc7967 on the next branch doesn't compile. Just FYI, I took one commit before, so I was able to test it.

Error:
In file included from ./include/evl/sched.h:14,

                 from ./include/evl/lock.h:9,
                 from ./include/asm-generic/evl/net.h:8,
                 from ./arch/x86/include/dovetail/net.h:6,
                 from ./include/net/net_namespace.h:41,
                 from ./include/linux/netdevice.h:38,
                 from ./include/net/sock.h:46,
                 from mm/memcontrol.c:67:
./include/evl/thread.h: In function ‘evl_unblock_kthread’:
./include/evl/thread.h:415:9: error: implicit declaration of function ‘evl_schedule’; did you mean ‘io_schedule’? [-Wimplicit-function-declaration]
  415 |         evl_schedule();
      |         ^~~~~~~~~~~~
      |         io_schedule
./include/evl/sched.h: At top level:
./include/evl/sched.h:290:20: warning: conflicting types for ‘evl_schedule’; have ‘void(void)’
  290 | static inline void evl_schedule(void)
      |                    ^~~~~~~~~~~~
./include/evl/sched.h:290:20: error: static declaration of ‘evl_schedule’ follows non-static declaration
./include/evl/thread.h:415:9: note: previous implicit declaration of ‘evl_schedule’ with type ‘void(void)’
  415 |         evl_schedule();
      |         ^~~~~~~~~~~~
Quoted 28 lines
Quoted 4 lines

But might be evl was never intended to work using connect() in classical UDP client style?

IMO, the evl netstack (and evl in general) should follow the POLA principle as closely as possible, and any UDP user can reasonably expect auto-binding to be handled. So this needs fixing.

Quoted 9 lines

If you think this this example is useful, I can finalize it (for now with the bind() workaround) and also add a server mode. So there would be 4 modes in total. With a server mode, you can run the server on one host, the client on the other and continuously send data forward / backward and measure delays. I would use:

(quoted diff) +0 -4
-T send (previously it was -S but then I have nothing for server)
-R receive
-S server: Waits for data and sends a response for each received package.
-C client: Sends data and measures how long it takes for the server to response.
Quoted 3 lines

As an alternative, I could just create a second example oob-net-udp-server-client.c. This would result in a bit of duplicated code but not to much.

What do you prefer?

It is definitely useful. I would go for option #1, i.e. integrated send/recv/server/client example. First because all the boilerplate and ancillary support for parsing options and setting up connections is already there and the code running the client scenario to be added is likely small enough.

Quoted 13 lines

Next because the I'd rather have a 'client' mode measuring round-trip times explicitly in the context of some example code, rather than letting people think that we would actually provide a 'ping' command that way. Reason is about performance: the standard in-band ICMP server is operated from kernel context; although the latency would bite compared to any oob-based server under high load, on average the figures obtained on an idle system would be somewhat misleading compared to the oob server in application space, because reinstating a userland context for handling ICMP requests may be more time-consuming than handling it directly as close as possible from the packet delivery point in kernel space, i.e. without entailing any context switching to userland (even to an oob thread).

Ok, I will finalize this and send a patch.

Quoted 11 lines
Quoted 10 lines

I also created oob-net-ping in the same style as oob-net-icmp but this sends out a ping, receives the response and measures the delay, similar as the ping command:
./oob-net-ping -i enp7s0 -a 192.168.122.1
[0] count=98, proto=0x800, ifindex=3, type=0, halen=6, mac=52:54:00:6b:05:f1 rtt=317.1us
[1] count=98, proto=0x800, ifindex=3, type=0, halen=6, mac=52:54:00:6b:05:f1 rtt=218.5us
[2] count=98, proto=0x800, ifindex=3, type=0, halen=6, mac=52:54:00:6b:05:f1 rtt=252.5us
[3] count=98, proto=0x800, ifindex=3, type=0, halen=6, mac=52:54:00:6b:05:f1 rtt=320.1us
It has to be cleaned it up a bit and integrated it into the libevl repo but then I will also send a patch.

Quoted 4 lines

I think we need a simple agent somewhere in the evl netstack in kernel space answering ICMP_ECHO requests flowing in oob channels directly, just like the in-band stack does for in-band traffic. I can look into this.

The oob-net-ping sends out pings, so basically the inverse of the existing oob-net-icmp. Now you can run oob-net-ping on one machine and oob-net-icmp on the other to ping between. For my application, I use it to ping an FPGA board to see if the connection basically works.

ICMP_ECHO would help in some cases, but ^ works also.

Quoted 3 lines

PS: thanks for the test code you provided, it saved a lot of time on my end.

You are welcome, I had to create it anyway to understand what was going wrong. Thanks for the easy to understand example code, helped me a lot to create the test code.

Quoted 3 lines

[1] https://gitlab.com/Xenomai/xenomai4/linux-evl/-/tree/next/v6.12.y-cip-evl-rebase?ref_type=heads

#5 lore raw
Quoted 55 lines · Hannes Diethelm

Am 22.05.26 um 17:40 schrieb Philippe Gerum:

Quoted 54 lines
Quoted 43 lines · Hannes Diethelm

Thanks for the detailed answer. I might have been not precise enough.

The -S and the -R mode work as designed. To show the issue with connect() in evl, I changed the -S mode to:
connect()
while{
oob_sendmsg()
oob_recvmsg()
}

This is the classical UDP client pattern. It works with vanilla linux (net-udp.c) but not with evl (oob-net-udp.c), I do not receive any data.

By just sending the modified code, it is easy to explain and hopefully for you to reproduce. This is also why I attached the files instead of sending a patch. Be aware that this is just to demonstrate what is not working, not intended as a patch.

I run Xenomai4 in a VM and communicate with the host for debugging but I have also a real PC as the final target where I have the same issues.

First start on the host:
echo Hello | nc -u -l 5201

Then in the VM:
sudo evl net -ei enp7s0
sudo oob-net-udp -d -i enp7s0 -a 192.168.122.1 -p 5201 -S

On the host:
Mellow sword!

In the VM:
== bound to enp7s0
== sender mode (=> 192.168.122.1:5201)
--------tx--------

IP-Adresse: 192.168.122.1
Port:       5201
Family:     512
--------rx--------
IP-Adresse: 192.168.122.155
Port:       58422
Family:     512
Quoted 2 lines

The package is visible in wireshark but oob_recvmsg does not return:
No "= 6 bytes received: Hello" and no second transmit.

Ok, I totally misinterpreted your previous post, sorry for that. Brain received -ENOCOFFEE.

Quoted 4 lines

It looks like the auto assigned and bound port from connect() is not forwarded to the oob stage, so no data is received in oob_recvmsg().

Quoted 8 lines
Quoted 3 lines

This is exactly the point, indeed. Could you please try this branch [1]?
The two commits on top improve the situation with your test code here.

Thanks for the very fast fix. Connect works now as expected. And I was able to remove the workaround.

I switched to libevl r58, r57 did not work any more. Is there any visible link libevl->kernel? I just got an operation not permitted in oob_sleep_until.

Recent evl ABI updates are likely causing this, r58 is required to run any kernel with ABI #44. Every single change affecting the ABI also used to cause its revision number to be incremented, hence the seemingly high value (implementing the evl core started back in 2018). The model has recently switched to bulk updates instead, i.e. a series of ABI updates under a single revision.

On the kernel side, the file include/uapi/evl/control-abi.h tracks the base/earliest and current ABI revisions the evl core supports, such decoupling helps in providing backward compatibility from the latter to the former, e.g. if EVL_ABI_BASE is 30 and EVL_ABI_LEVEL is 45, then an application which was compiled against any ABI level >= 30 can use this core. Looking at include/evl/version.h in libevl, you should see the symbol EVL_ABI_PREREQ set to the earliest ABI revision that particular version of libevl can work with, i.e. matched to EVL_ABI_BASE.

A recent string of ABI changes went in to support the upcoming POSIX interface, they have been grouped in a single update which triggered ABI #44. That one was going to break backward compat as I hinted at a couple of months ago, aligning EVL_ABI_BASE on EVL_ABI_LEVEL to #44.

The development tip for each kernel is now hosted in some next/* branch in the repo, e.g. next/v6.12.y-cip-evl-rebase, which contains staging code until it moves to the rebase/ branch,
e.g. v6.12.y-cip-evl-rebase. The next/* kernel branches match the libevl -next branch ABI-wise.

IOW, in order to work with the bleeding-edge code implementing any recently discussed changes, you may want to switch to libevl/next and any next/* branch on the kernel side (v6.12.y-cip-evl, v6.18.y-evl, or v7.0-evl ATM).

Quoted 8 lines

But there are two new issues:

-oob_sendmsg returns "Invalid argument" errno 22 exactly every second. The last number is the system time in ns.
ERROR: oob_sendmsg Invalid argument 22 806999652287
ERROR: oob_sendmsg Invalid argument 22 807999655503
ERROR: oob_sendmsg Invalid argument 22 808999650416

Quoted 5 lines

I have this with the exact same code as before using bind() and also with the now working connect(). There are 3000 tx / 1000 rx packages/s.

I tried do{oob_sendmsg}while(errno == 22) but that resulted in a full freeze of the PC.

Sounds like an ABI issue, I cannot reproduce this. Switching to the 'next' branches on both sides may help.

Quoted 2 lines

-The last commit a4cc7967 on the next branch doesn't compile. Just FYI, I took one commit before, so I was able to test it.

My bad, fixed in the kernel next/* branch.

Quoted 10 lines
Quoted 6 lines
Quoted 1 line

I think we need a simple agent somewhere in the evl netstack in kernel
space answering ICMP_ECHO requests flowing in oob channels directly, just like the in-band stack does for in-band traffic. I can look into this.

The oob-net-ping sends out pings, so basically the inverse of the existing oob-net-icmp. Now you can run oob-net-ping on one machine and oob-net-icmp on the other to ping between. For my application, I use it to ping an FPGA board to see if the connection basically works.

Ok, makes sense too. I'm ok with both approaches actually, it's your call.

Quoted 2 lines

ICMP_ECHO would help in some cases, but ^ works also.

Agreed, we need a built-in ICMP_ECHO responder in the core, which we could disable programmatically as well, so that a ping service implemented in userland which would use the raw packet interface may switch it off for receiving ICMP requests.

Signature · 1 line
Philippe.
#6 lore raw

Am 23.05.26 um 10:42 schrieb Philippe Gerum:

Quoted 93 lines
Quoted 55 lines · Hannes Diethelm

Am 22.05.26 um 17:40 schrieb Philippe Gerum:

Quoted 54 lines
Quoted 43 lines · Hannes Diethelm

Thanks for the detailed answer. I might have been not precise enough.

The -S and the -R mode work as designed. To show the issue with connect() in evl, I changed the -S mode to:
connect()
while{
oob_sendmsg()
oob_recvmsg()
}

This is the classical UDP client pattern. It works with vanilla linux (net-udp.c) but not with evl (oob-net-udp.c), I do not receive any data.

By just sending the modified code, it is easy to explain and hopefully for you to reproduce. This is also why I attached the files instead of sending a patch. Be aware that this is just to demonstrate what is not working, not intended as a patch.

I run Xenomai4 in a VM and communicate with the host for debugging but I have also a real PC as the final target where I have the same issues.

First start on the host:
echo Hello | nc -u -l 5201

Then in the VM:
sudo evl net -ei enp7s0
sudo oob-net-udp -d -i enp7s0 -a 192.168.122.1 -p 5201 -S

On the host:
Mellow sword!

In the VM:
== bound to enp7s0
== sender mode (=> 192.168.122.1:5201)
--------tx--------

IP-Adresse: 192.168.122.1
Port:       5201
Family:     512
--------rx--------
IP-Adresse: 192.168.122.155
Port:       58422
Family:     512
Quoted 2 lines

The package is visible in wireshark but oob_recvmsg does not return:
No "= 6 bytes received: Hello" and no second transmit.

Ok, I totally misinterpreted your previous post, sorry for that. Brain received -ENOCOFFEE.

Quoted 4 lines

It looks like the auto assigned and bound port from connect() is not forwarded to the oob stage, so no data is received in oob_recvmsg().

Quoted 8 lines
Quoted 3 lines

This is exactly the point, indeed. Could you please try this branch [1]?
The two commits on top improve the situation with your test code here.

Thanks for the very fast fix. Connect works now as expected. And I was able to remove the workaround.

I switched to libevl r58, r57 did not work any more. Is there any visible link libevl->kernel? I just got an operation not permitted in oob_sleep_until.

Recent evl ABI updates are likely causing this, r58 is required to run any kernel with ABI #44. Every single change affecting the ABI also used to cause its revision number to be incremented, hence the seemingly high value (implementing the evl core started back in 2018). The model has recently switched to bulk updates instead, i.e. a series of ABI updates under a single revision.

On the kernel side, the file include/uapi/evl/control-abi.h tracks the base/earliest and current ABI revisions the evl core supports, such decoupling helps in providing backward compatibility from the latter to the former, e.g. if EVL_ABI_BASE is 30 and EVL_ABI_LEVEL is 45, then an application which was compiled against any ABI level >= 30 can use this core. Looking at include/evl/version.h in libevl, you should see the symbol EVL_ABI_PREREQ set to the earliest ABI revision that particular version of libevl can work with, i.e. matched to EVL_ABI_BASE.

A recent string of ABI changes went in to support the upcoming POSIX interface, they have been grouped in a single update which triggered ABI #44. That one was going to break backward compat as I hinted at a couple of months ago, aligning EVL_ABI_BASE on EVL_ABI_LEVEL to #44.

The development tip for each kernel is now hosted in some next/* branch in the repo, e.g. next/v6.12.y-cip-evl-rebase, which contains staging code until it moves to the rebase/ branch,
e.g. v6.12.y-cip-evl-rebase. The next/* kernel branches match the libevl -next branch ABI-wise.

Quoted 5 lines

IOW, in order to work with the bleeding-edge code implementing any recently discussed changes, you may want to switch to libevl/next and any next/* branch on the kernel side (v6.12.y-cip-evl, v6.18.y-evl, or v7.0-evl ATM).

Thanks for the details. For now, libevl r58 works well with next kernel but I will go to next on both repos if I see any issues and test it there also before reporting them.
The inegrated check works if I go back to r57 with a small test program:
evl: ABI mismatch, see -ENOEXEC at https://v4.xenomai.org/core/user-api/init/#evl_init
./oob-net-udp: cannot attach to the EVL core: Exec format error

I think I just had so many error messages that I did not see ^ in the real application.

Quoted 8 lines
Quoted 8 lines

But there are two new issues:

-oob_sendmsg returns "Invalid argument" errno 22 exactly every second. The last number is the system time in ns.
ERROR: oob_sendmsg Invalid argument 22 806999652287
ERROR: oob_sendmsg Invalid argument 22 807999655503
ERROR: oob_sendmsg Invalid argument 22 808999650416

Quoted 8 lines
Quoted 5 lines

I have this with the exact same code as before using bind() and also with the now working connect(). There are 3000 tx / 1000 rx packages/s.

I tried do{oob_sendmsg}while(errno == 22) but that resulted in a full freeze of the PC.

Sounds like an ABI issue, I cannot reproduce this. Switching to the 'next' branches on both sides may help.

This was an -ENOCOFFEE on my side. I was using:
evl_read_clock(EVL_CLOCK_MONOTONIC, &ts_timeout); ts_timeout.tv_nsec += 1000*1000;
...
oob_sendmsg(board->sockfd, &msghdr, &ts_timeout, flags);

Of course this overflows tv_nsec exactly every second. It seams you or some else verifyes this now and return "Invalid argument".

With this, everything works now:
evl_read_clock(EVL_CLOCK_MONOTONIC, &ts_timeout);
ts_timeout.tv_nsec += 1000*1000;

while(ts_timeout.tv_nsec >= 1000000000){
    ts_timeout.tv_nsec -= 1000000000;
    ts_timeout.tv_sec ++;
}

...
oob_sendmsg(board->sockfd, &msghdr, &ts_timeout, flags);

Quoted 19 lines
Quoted 3 lines

-The last commit a4cc7967 on the next branch doesn't compile. Just FYI, I took one commit before, so I was able to test it.

My bad, fixed in the kernel next/* branch.

Quoted 10 lines
Quoted 6 lines
Quoted 1 line

I think we need a simple agent somewhere in the evl netstack in kernel
space answering ICMP_ECHO requests flowing in oob channels directly, just like the in-band stack does for in-band traffic. I can look into this.

The oob-net-ping sends out pings, so basically the inverse of the existing oob-net-icmp. Now you can run oob-net-ping on one machine and oob-net-icmp on the other to ping between. For my application, I use it to ping an FPGA board to see if the connection basically works.

Ok, makes sense too. I'm ok with both approaches actually, it's your call.

Quoted 8 lines
Quoted 2 lines

ICMP_ECHO would help in some cases, but ^ works also.

Agreed, we need a built-in ICMP_ECHO responder in the core, which we could disable programmatically as well, so that a ping service implemented in userland which would use the raw packet interface may switch it off for receiving ICMP requests.

Ok, I will send a patch as soon as it is ready. Can take some time, depending on what is going on otherwhise.

#7 lore raw
Quoted 159 lines · Hannes Diethelm

Am 23.05.26 um 10:42 schrieb Philippe Gerum:

Quoted 87 lines
Quoted 55 lines · Hannes Diethelm

Am 22.05.26 um 17:40 schrieb Philippe Gerum:

Quoted 54 lines
Quoted 43 lines · Hannes Diethelm

Thanks for the detailed answer. I might have been not precise enough.

The -S and the -R mode work as designed. To show the issue with connect() in evl, I changed the -S mode to:
connect()
while{
oob_sendmsg()
oob_recvmsg()
}

This is the classical UDP client pattern. It works with vanilla linux (net-udp.c) but not with evl (oob-net-udp.c), I do not receive any data.

By just sending the modified code, it is easy to explain and hopefully for you to reproduce. This is also why I attached the files instead of sending a patch. Be aware that this is just to demonstrate what is not working, not intended as a patch.

I run Xenomai4 in a VM and communicate with the host for debugging but I have also a real PC as the final target where I have the same issues.

First start on the host:
echo Hello | nc -u -l 5201

Then in the VM:
sudo evl net -ei enp7s0
sudo oob-net-udp -d -i enp7s0 -a 192.168.122.1 -p 5201 -S

On the host:
Mellow sword!

In the VM:
== bound to enp7s0
== sender mode (=> 192.168.122.1:5201)
--------tx--------

IP-Adresse: 192.168.122.1
Port:       5201
Family:     512
--------rx--------
IP-Adresse: 192.168.122.155
Port:       58422
Family:     512
Quoted 2 lines

The package is visible in wireshark but oob_recvmsg does not return:
No "= 6 bytes received: Hello" and no second transmit.

Ok, I totally misinterpreted your previous post, sorry for that. Brain received -ENOCOFFEE.

Quoted 4 lines

It looks like the auto assigned and bound port from connect() is not forwarded to the oob stage, so no data is received in oob_recvmsg().

Quoted 8 lines
Quoted 3 lines

This is exactly the point, indeed. Could you please try this branch [1]?
The two commits on top improve the situation with your test code here.

Thanks for the very fast fix. Connect works now as expected. And I was able to remove the workaround.

I switched to libevl r58, r57 did not work any more. Is there any visible link libevl->kernel? I just got an operation not permitted in oob_sleep_until.

Recent evl ABI updates are likely causing this, r58 is required to run
any kernel with ABI #44. Every single change affecting the ABI also used to cause its revision number to be incremented, hence the seemingly high value (implementing the evl core started back in 2018). The model has recently switched to bulk updates instead, i.e. a series of ABI updates under a single revision.
On the kernel side, the file include/uapi/evl/control-abi.h tracks the
base/earliest and current ABI revisions the evl core supports, such decoupling helps in providing backward compatibility from the latter to the former, e.g. if EVL_ABI_BASE is 30 and EVL_ABI_LEVEL is 45, then an application which was compiled against any ABI level >= 30 can use this core. Looking at include/evl/version.h in libevl, you should see the symbol EVL_ABI_PREREQ set to the earliest ABI revision that particular version of libevl can work with, i.e. matched to EVL_ABI_BASE. A recent string of ABI changes went in to support the upcoming POSIX interface, they have been grouped in a single update which triggered ABI #44. That one was going to break backward compat as I hinted at a couple of months ago, aligning EVL_ABI_BASE on EVL_ABI_LEVEL to #44. The development tip for each kernel is now hosted in some next/* branch

Quoted 9 lines

in the repo, e.g. next/v6.12.y-cip-evl-rebase, which contains staging code until it moves to the rebase/ branch,
e.g. v6.12.y-cip-evl-rebase. The next/* kernel branches match the libevl -next branch ABI-wise.
IOW, in order to work with the bleeding-edge code implementing any recently discussed changes, you may want to switch to libevl/next and any next/* branch on the kernel side (v6.12.y-cip-evl, v6.18.y-evl, or v7.0-evl ATM).

Thanks for the details. For now, libevl r58 works well with next kernel but I will go to next on both repos if I see any issues and test it there also before reporting them.
The inegrated check works if I go back to r57 with a small test program:
evl: ABI mismatch, see -ENOEXEC at https://v4.xenomai.org/core/user-api/init/#evl_init
./oob-net-udp: cannot attach to the EVL core: Exec format error

I think I just had so many error messages that I did not see ^ in the real application.

Quoted 8 lines
Quoted 8 lines

But there are two new issues:

-oob_sendmsg returns "Invalid argument" errno 22 exactly every second. The last number is the system time in ns.
ERROR: oob_sendmsg Invalid argument 22 806999652287
ERROR: oob_sendmsg Invalid argument 22 807999655503
ERROR: oob_sendmsg Invalid argument 22 808999650416

Quoted 7 lines
Quoted 5 lines

I have this with the exact same code as before using bind() and also with the now working connect(). There are 3000 tx / 1000 rx packages/s.

I tried do{oob_sendmsg}while(errno == 22) but that resulted in a full freeze of the PC.

Sounds like an ABI issue, I cannot reproduce this. Switching to the 'next' branches on both sides may help.

This was an -ENOCOFFEE on my side. I was using:
evl_read_clock(EVL_CLOCK_MONOTONIC, &ts_timeout); ts_timeout.tv_nsec += 1000*1000;
...
oob_sendmsg(board->sockfd, &msghdr, &ts_timeout, flags);

Of course this overflows tv_nsec exactly every second. It seams you or some else verifyes this now and return "Invalid argument".

With this, everything works now:
evl_read_clock(EVL_CLOCK_MONOTONIC, &ts_timeout);
ts_timeout.tv_nsec += 1000*1000;

while(ts_timeout.tv_nsec >= 1000000000){
    ts_timeout.tv_nsec -= 1000000000;
    ts_timeout.tv_sec ++;
}

...
oob_sendmsg(board->sockfd, &msghdr, &ts_timeout, flags);

Quoted 18 lines
Quoted 3 lines

-The last commit a4cc7967 on the next branch doesn't compile. Just FYI, I took one commit before, so I was able to test it.

My bad, fixed in the kernel next/* branch.

Quoted 10 lines
Quoted 6 lines
Quoted 1 line

I think we need a simple agent somewhere in the evl netstack in kernel
space answering ICMP_ECHO requests flowing in oob channels directly, just like the in-band stack does for in-band traffic. I can look into this.

The oob-net-ping sends out pings, so basically the inverse of the existing oob-net-icmp. Now you can run oob-net-ping on one machine and oob-net-icmp on the other to ping between. For my application, I use it to ping an FPGA board to see if the connection basically works.

Ok, makes sense too. I'm ok with both approaches actually, it's your call.

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

ICMP_ECHO would help in some cases, but ^ works also.

Agreed, we need a built-in ICMP_ECHO responder in the core, which we could disable programmatically as well, so that a ping service implemented in userland which would use the raw packet interface may switch it off for receiving ICMP requests.

Ok, I will send a patch as soon as it is ready. Can take some time, depending on what is going on otherwhise.

Nice, thanks. I believe that since we may have in-kernel ICMP_ECHO reply and oob-net-ping at about the same time, we should make the latter a general utility (libevl/utils) instead of a tidbit/example, e.g. evl-ping. This way, we would have a standard command for pinging a remote oob-enabled machine, that would also work with oob-net-icmp when disabling the in-kernel ICMP handling.

e.g.:

# Probing side

$ evl ping 10.10.10.10

# ICMP server side

$ oob-net-icmp -i eth0.42
Signature · 1 line
Philippe.