sctp: support MSG_ERRQUEUE flag in recvmsg()
Subsystems (3)
PATCH 1/1 sctp: support MSG_ERRQUEUE flag in recvmsg()
For some reason sctp_poll() generates EPOLLERR if sk->sk_error_queue is not empty but recvmsg() can not drain the error queue yet.
This is needed to better support timestamping.
I had to export inet_recv_error(), since sctp
can be compiled as a module.
--- net/ipv4/af_inet.c | 1 + net/sctp/socket.c | 3 +++ 2 files changed, 4 insertions(+)
net/ipv4/af_inet.c +1 -0
@@ -1633,6 +1633,7 @@ int inet_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len)#endif return -EINVAL ; } +EXPORT_SYMBOL (inet_recv_error);int inet_gro_complete (struct sk_buff *skb,int nhoff) {
net/sctp/socket.c +3 -0
@@ -2099,6 +2099,9 @@ static int sctp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,pr_debug ("%s: sk:%p, msghdr:%p, len:%zd, flags:0x%x, addr_len:%p)\n" , __func__, sk, msg, len, flags, addr_len); +if (unlikely (flags &MSG_ERRQUEUE )) +return inet_recv_error (sk, msg, len, addr_len); +lock_sock (sk); if (sctp_style(sk, TCP) && !sctp_sstate(sk, ESTABLISHED) &&
Signature · 1 line
2.43.0.472.g3155946c3a-goog
Xin Long
maintainerQuoted 3 lines · Eric Dumazet
For some reason
sctp_poll()generates EPOLLERR ifsk->sk_error_queueis not empty butrecvmsg()can not drain the error queue yet.
I'm checking the code but can't see how SCTP may enqueue skbs into sk->sk_error_queue. Have you ever seen it happen in any of your cases?
Quoted 2 lines
This is needed to better support timestamping.
I think SCTP doesn't support timestamping, there's no functions like tcp_tx_timestamp()/tcp_gso_tstamp() to enable it.
Or do you mean SO_TXTIME socket option, and then tc-etf may enqueue a skb into sk->sk_error_queue if it's enabled?
Quoted 42 lines
I had to export
inet_recv_error(), since sctp
can be compiled as a module.Signed-off-by Eric Dumazet <[email protected]>Cc Xin Long <[email protected]>Cc Marcelo Ricardo Leitner <[email protected]>Cc Willem de Bruijn <[email protected]>--- net/ipv4/af_inet.c | 1 + net/sctp/socket.c | 3 +++ 2 files changed, 4 insertions(+)net/ipv4/af_inet.c +1
-0@@ -1633,6 +1633,7 @@ int inet_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len)#endif return -EINVAL ; } +EXPORT_SYMBOL (inet_recv_error);int inet_gro_complete (struct sk_buff *skb,int nhoff) {net/sctp/socket.c +3
-1@@ -2099,6 +2099,9 @@ static int sctp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,pr_debug ("%s: sk:%p, msghdr:%p, len:%zd, flags:0x%x, addr_len:%p)\n" , __func__, sk, msg, len, flags, addr_len); +if (unlikely (flags &MSG_ERRQUEUE )) +return inet_recv_error (sk, msg, len, addr_len); +lock_sock (sk); if (sctp_style(sk, TCP) && !sctp_sstate(sk, ESTABLISHED) && --2.43.0.472.g3155946c3a-goog
Quoted 9 lines · Xin Long
Quoted 3 lines · Eric Dumazet
For some reason
sctp_poll()generates EPOLLERR ifsk->sk_error_queueis not empty butrecvmsg()can not drain the error queue yet.I'm checking the code but can't see how SCTP may enqueue skbs into
sk->sk_error_queue. Have you ever seen it happen in any of your cases?Quoted 1 line
Quoted 7 lines
Quoted 1 line
This is needed to better support timestamping.
I think SCTP doesn't support timestamping, there's no functions like tcp_tx_timestamp()/tcp_gso_tstamp() to enable it.
Or do you mean
SO_TXTIMEsocket option, and then tc-etf may enqueue a skb intosk->sk_error_queueif it's enabled?
I think this is the goal yes.
Also this prevents developers from using MSG_ERRQUEUE and having the kernel read the receive queue.
mptcp had a similar issue in the past, Paolo fixed it.
Quoted 42 lines
Quoted 42 lines
I had to export
inet_recv_error(), since sctp
can be compiled as a module.Signed-off-by Eric Dumazet <[email protected]>Cc Xin Long <[email protected]>Cc Marcelo Ricardo Leitner <[email protected]>Cc Willem de Bruijn <[email protected]>--- net/ipv4/af_inet.c | 1 + net/sctp/socket.c | 3 +++ 2 files changed, 4 insertions(+)net/ipv4/af_inet.c +1
-0@@ -1633,6 +1633,7 @@ int inet_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len)#endif return -EINVAL ; } +EXPORT_SYMBOL (inet_recv_error);int inet_gro_complete (struct sk_buff *skb,int nhoff) {net/sctp/socket.c +3
-1@@ -2099,6 +2099,9 @@ static int sctp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,pr_debug ("%s: sk:%p, msghdr:%p, len:%zd, flags:0x%x, addr_len:%p)\n" , __func__, sk, msg, len, flags, addr_len); +if (unlikely (flags &MSG_ERRQUEUE )) +return inet_recv_error (sk, msg, len, addr_len); +lock_sock (sk); if (sctp_style(sk, TCP) && !sctp_sstate(sk, ESTABLISHED) && --2.43.0.472.g3155946c3a-goog
Quoted 64 lines · Eric Dumazet
Quoted 9 lines · Xin Long
Quoted 3 lines · Eric Dumazet
For some reason
sctp_poll()generates EPOLLERR ifsk->sk_error_queueis not empty butrecvmsg()can not drain the error queue yet.I'm checking the code but can't see how SCTP may enqueue skbs into
sk->sk_error_queue. Have you ever seen it happen in any of your cases?Quoted 1 line
Quoted 7 lines
Quoted 1 line
This is needed to better support timestamping.
I think SCTP doesn't support timestamping, there's no functions like tcp_tx_timestamp()/tcp_gso_tstamp() to enable it.
Or do you mean
SO_TXTIMEsocket option, and then tc-etf may enqueue a skb intosk->sk_error_queueif it's enabled?I think this is the goal yes.
Also this prevents developers from using
MSG_ERRQUEUEand having the kernel read the receive queue.mptcp had a similar issue in the past, Paolo fixed it.
Quoted 38 lines
Quoted 38 lines
I had to export
inet_recv_error(), since sctp
can be compiled as a module.Signed-off-by Eric Dumazet <[email protected]>Cc Xin Long <[email protected]>Cc Marcelo Ricardo Leitner <[email protected]>Cc Willem de Bruijn <[email protected]>--- net/ipv4/af_inet.c | 1 + net/sctp/socket.c | 3 +++ 2 files changed, 4 insertions(+)net/ipv4/af_inet.c +1
-0@@ -1633,6 +1633,7 @@ int inet_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len)#endif return -EINVAL ; } +EXPORT_SYMBOL (inet_recv_error);int inet_gro_complete (struct sk_buff *skb,int nhoff) {net/sctp/socket.c +3
-0@@ -2099,6 +2099,9 @@ static int sctp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,pr_debug ("%s: sk:%p, msghdr:%p, len:%zd, flags:0x%x, addr_len:%p)\n" , __func__, sk, msg, len, flags, addr_len); +if (unlikely (flags &MSG_ERRQUEUE )) +return inet_recv_error (sk, msg, len, addr_len); +lock_sock (sk);
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
net/sctp/socket.c +0
-1if (sctp_style(sk, TCP) && !sctp_sstate(sk, ESTABLISHED) && --2.43.0.472.g3155946c3a-goog
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Tue, 12 Dec 2023 14:55:50 +0000 you wrote:
For some reason
sctp_poll()generates EPOLLERR ifsk->sk_error_queueis not empty butrecvmsg()can not drain the error queue yet.This is needed to better support timestamping.
I had to export
inet_recv_error(), since sctp
can be compiled as a module.[...]
Here is the summary with links:
- [net-next] sctp: support MSG_ERRQUEUE flag in recvmsg()
https://git.kernel.org/netdev/net-next/c/4746b36b1abe
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html