Skip to contentSkip to conversation

io_uring-udp fix, manpage fix, and hppa cross-compiler

PATCH Applied Ammar Faizi 2 participants 5 messages Apr 15, 2023 io_uring

lore
Share & tools
lore
#0 lore raw

cover io_uring-udp fix, manpage fix, and hppa cross-compiler

Hi Jens,

There are three patches in this series:

1. Fix the wrong IPv6 address in io_uring-udp (me).

Before:

    port bound to 49567
    received 4 bytes 28 from ::2400:6180:0:d1:0:0:47048
    received 4 bytes 28 from ::2400:6180:0:d1:0:0:54755
    received 4 bytes 28 from ::2400:6180:0:d1:0:0:57968

(the IPv6 address is wrong)

After:

    port bound to 48033
    received 4 bytes 28 from [2400:6180:0:d1::6a4:a00f]:40456
    received 4 bytes 28 from [2400:6180:0:d1::6a4:a00f]:50306
    received 4 bytes 28 from [2400:6180:0:d1::6a4:a00f]:52291

2. io_uring_cqe_get_data() manpage fix (me).

The return value of io_uring_cqe_get_data() will be undefined if the user_data is not set from the SQE side.

3. Add hppa cross-compiler to the CI (Alviro).

---

Alviro Iskandar Setiawan (1):
github: Add hppa cross compiler

Ammar Faizi (2):
io_uring-udp: Fix the wrong IPv6 binary to string conversion man/io_uring_cqe_get_data.3: Fix a misleading return value

 .github/workflows/build.yml |  7 +++++++
 examples/io_uring-udp.c     | 14 +++++++++++---
 man/io_uring_cqe_get_data.3 |  2 +-
 3 files changed, 19 insertions(+), 4 deletions(-)

base-commit: 4fed79510a189cc7997f6d04855ebf7fb66cc323

Signature · 1 line
Ammar Faizi
#1 lore raw

PATCH 1/3 io_uring-udp: Fix the wrong IPv6 binary to string conversion

Another io_uring-udp fix. The verbose output shows the wrong address when using IPv6.

When the address family is AF_INET6, the pointer should be cast to 'struct sockaddr_in6', not 'struct sockaddr_in'.

While in there, also add a square bracket around the IP address to easily read the port number, especially for IPv6.

Before this patch:

    port bound to 49567
    received 4 bytes 28 from ::2400:6180:0:d1:0:0:47048
    received 4 bytes 28 from ::2400:6180:0:d1:0:0:54755
    received 4 bytes 28 from ::2400:6180:0:d1:0:0:57968

(the IPv6 address is wrong)

After this patch:

    port bound to 48033
    received 4 bytes 28 from [2400:6180:0:d1::6a4:a00f]:40456
    received 4 bytes 28 from [2400:6180:0:d1::6a4:a00f]:50306
    received 4 bytes 28 from [2400:6180:0:d1::6a4:a00f]:52291
---
 examples/io_uring-udp.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
examples/io_uring-udp.c +11 -3
index b81a5e7c47afd9c8..4697af171ba68999 100644
@@ -271,14 +271,22 @@ static int process_cqe_recv(struct ctx *ctx, struct io_uring_cqe *cqe,
 	}
 
 	if (ctx->verbose) {
+		struct sockaddr_in *addr = io_uring_recvmsg_name(o);
+		struct sockaddr_in6 *addr6 = (void *)addr;
 		char buff[INET6_ADDRSTRLEN + 1];
 		const char *name;
-		struct sockaddr_in *addr = io_uring_recvmsg_name(o);
+		void *paddr;
 
-		name = inet_ntop(ctx->af, &addr->sin_addr, buff, sizeof(buff));
+		if (ctx->af == AF_INET6)
+			paddr = &addr6->sin6_addr;
+		else
+			paddr = &addr->sin_addr;
+
+		name = inet_ntop(ctx->af, paddr, buff, sizeof(buff));
 		if (!name)
 			name = "<INVALID>";
-		fprintf(stderr, "received %u bytes %d from %s:%d\n",
+
+		fprintf(stderr, "received %u bytes %d from [%s]:%d\n",
 			io_uring_recvmsg_payload_length(o, cqe->res, &ctx->msg),
 			o->namelen, name, (int)ntohs(addr->sin_port));
 	}
Signature · 1 line
Ammar Faizi
#2 lore raw

PATCH 2/3 github: Add hppa cross compiler

In reply to Ammar Faizi

From: Alviro Iskandar Setiawan <[email protected]>

Since commit 9c6689848ebf ("Default to mmap'ed provided buffers for hppa"), the core library has hppa specific code. Add hppa cross compiler on the GitHub bot CI to catch build breakage for this arch.

---
 .github/workflows/build.yml | 7 +++++++
 1 file changed, 7 insertions(+)
.github/workflows/build.yml +7 -0
index fed5b38c3a507336..8dd22dfd125692de 100644
@@ -85,6 +85,13 @@ jobs:
             cc: mips-linux-gnu-gcc
             cxx: mips-linux-gnu-g++
 
+          # hppa
+          - arch: hppa
+            cc_pkg: gcc-hppa-linux-gnu
+            cxx_pkg: g++-hppa-linux-gnu
+            cc: hppa-linux-gnu-gcc
+            cxx: hppa-linux-gnu-g++
+
     env:
       FLAGS: -g -O3 -Wall -Wextra -Werror -Wno-sign-compare ${{matrix.extra_flags}}
 
Signature · 1 line
Ammar Faizi
#3 lore raw

PATCH 3/3 man/io_uring_cqe_get_data.3: Fix a misleading return value

In reply to Ammar Faizi

Since commit 8ecd3fd959634df8 ("Don't clear sqe->user_data as part of command prep"), the prep functions no longer zero the user data. If the user_data is not set, it will contain whatever previous value in it.

Therefore, the returned value when the user_data is-not-set is not always NULL. And oh, someone once hit an issue because they assume the return value is NULL if the user_data is not set. See the link below.

Fix the manpage, tell that the return value will be undefined.

---
 man/io_uring_cqe_get_data.3 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
man/io_uring_cqe_get_data.3 +1 -1
index 4cbb32cd864e12c2..a4d2988a49d92aa8 100644
@@ -46,7 +46,7 @@ or
 If the
 .I user_data
 value has been set before submitting the request, it will be returned.
-Otherwise the functions returns NULL.
+Otherwise, the return value is undefined.
 .SH SEE ALSO
 .BR io_uring_get_sqe (3),
 .BR io_uring_sqe_set_data (3),
Signature · 1 line
Ammar Faizi
maintainer Applied
#4 lore raw
In reply to Ammar Faizi
Quoted 22 lines · Ammar Faizi

Hi Jens,

There are three patches in this series:

1. Fix the wrong IPv6 address in io_uring-udp (me).

Before:

    port bound to 49567
    received 4 bytes 28 from ::2400:6180:0:d1:0:0:47048
    received 4 bytes 28 from ::2400:6180:0:d1:0:0:54755
    received 4 bytes 28 from ::2400:6180:0:d1:0:0:57968

(the IPv6 address is wrong)

After:

    port bound to 48033
    received 4 bytes 28 from [2400:6180:0:d1::6a4:a00f]:40456
    received 4 bytes 28 from [2400:6180:0:d1::6a4:a00f]:50306
    received 4 bytes 28 from [2400:6180:0:d1::6a4:a00f]:52291
Quoted 6 lines

2. io_uring_cqe_get_data() manpage fix (me).

The return value of io_uring_cqe_get_data() will be undefined if the user_data is not set from the SQE side.

3. Add hppa cross-compiler to the CI (Alviro).

Applied, thanks.

Signature · 1 line
Jens Axboe