Skip to contentSkip to conversation

Add F_SETFL for fcntl in test_sockmap

PATCH Superseded Geliang Tang 2 participants 4 messages Jun 11, 2024 – Jun 12, 2024

Subsystems (6)

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v6 cover Add F_SETFL for fcntl in test_sockmap

From: Geliang Tang <[email protected]>

v6:
- add a fix for tls_sw_recvmsg().

v5:
- add a new patch "Check recv lengths in test_sockmap" instead of using "continue" in msg_loop.

v4:
- address Martin's comments for v3. (thanks.)
- add Yonghong's "Acked-by" tags. (thanks.)
- update subject-prefix from "bpf-next" to "bpf".

Patch 1, v3 of "selftests/bpf: Add F_SETFL for fcntl":
- detect nonblock flag automatically, then test_sockmap can run in both block and nonblock modes.
- use continue instead of again in v2.

Patch 2, fix for umount cgroup2 error.

Geliang Tang (2):
tls: wait for receiving next skb for sk_redirect selftests/bpf: Add F_SETFL for fcntl in test_sockmap

 net/tls/tls_sw.c                           | 2 ++
 tools/testing/selftests/bpf/test_sockmap.c | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v6 1/2 tls: wait for receiving next skb for sk_redirect

From: Geliang Tang <[email protected]>

tls_sw_recvmsg() doesn't work in nonblock mode, it returns -EAGAIN in that case. This patch fixes it, always wait for receiving the next skb for sk_redirect.

---
 net/tls/tls_sw.c | 2 ++
 1 file changed, 2 insertions(+)
net/tls/tls_sw.c +2 -0
index 305a412785f5..d2558856ceeb 100644
@@ -2099,6 +2099,8 @@ int tls_sw_recvmsg(struct sock *sk,
 					rxm->full_len = 0;
 					if (err == __SK_DROP)
 						consume_skb(skb);
+					if (err == __SK_REDIRECT && flags & MSG_DONTWAIT)
+						tls_rx_rec_wait(sk, psock, false, released);
 					continue;
 				}
 			}
Signature · 1 line
2.43.0
maintainer
#2 lore raw

Re: [PATCH net-next v6 1/2] tls: wait for receiving next skb for sk_redirect

Quoted 3 lines · On Tue, 11 Jun 2024 17:13:34 +0800 Geliang Tang wrote:

tls_sw_recvmsg() doesn't work in nonblock mode, it returns -EAGAIN in that case. This patch fixes it, always wait for receiving the next skb for sk_redirect.

Is this commit message basically saying "block in nonblock mode" or am I missing something? Either way you have to at least improve the commit message..

Signature · 1 line
pw-bot: cr
#3 lore raw

PATCH v6 2/2 selftests/bpf: Add F_SETFL for fcntl in test_sockmap

In reply to Geliang Tang

From: Geliang Tang <[email protected]>

Incorrect arguments are passed to fcntl() in test_sockmap.c when invoking it to set file status flags. If O_NONBLOCK is used as 2nd argument and passed into fcntl, -EINVAL will be returned (See do_fcntl() in fs/fcntl.c). The correct approach is to use F_SETFL as 2nd argument, and O_NONBLOCK as 3rd one.

Fixes 16962b2404ac ("bpf: sockmap, add selftests")
---
 tools/testing/selftests/bpf/test_sockmap.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/test_sockmap.c +3 -1
index 9cba4ec844a5..99d3ca8e44bb 100644
@@ -604,7 +604,9 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt,
 		struct timeval timeout;
 		fd_set w;
 
-		fcntl(fd, fd_flags);
+		if (fcntl(fd, F_SETFL, fd_flags))
+			goto out_errno;
+
 		/* Account for pop bytes noting each iteration of apply will
 		 * call msg_pop_data helper so we need to account for this
 		 * by calculating the number of apply iterations. Note user
Signature · 1 line
2.43.0