Re: [PATCH] af_unix: Allow Unix sockets to raise SIGURG
From: Shoaib Rao <hidden>
Date: 2021-01-29 18:00:03
Also in:
lkml, netdev
On 1/25/21 3:36 PM, Jakub Kicinski wrote:
On Fri, 22 Jan 2021 15:06:37 +0000 Matthew Wilcox (Oracle) wrote:quoted
From: Rao Shoaib <redacted> TCP sockets allow SIGURG to be sent to the process holding the other end of the socket. Extend Unix sockets to have the same ability. The API is the same in that the sender uses sendmsg() with MSG_OOB to raise SIGURG. Unix sockets behave in the same way as TCP sockets with SO_OOBINLINE set.Noob question, if we only want to support the inline mode, why don't we require SO_OOBINLINE to have been called on @other? Wouldn't that provide more consistent behavior across address families? With the current implementation the receiver will also not see MSG_OOB set in msg->msg_flags, right?
SO_OOBINLINE does not control the delivery of signal, It controls how OOB Byte is delivered. It may not be obvious but this change does not deliver any Byte, just a signal. So, as long as sendmsg flag contains MSG_OOB, signal will be delivered just like it happens for TCP. Shoaib
quoted
SIGURG is ignored by default, so applications which do not know about this feature will be unaffected. In addition to installing a SIGURG handler, the receiving application must call F_SETOWN or F_SETOWN_EX to indicate which process or thread should receive the signal. Signed-off-by: Rao Shoaib <redacted> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> --- net/unix/af_unix.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 41c3303c3357..849dff688c2c 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c@@ -1837,8 +1837,6 @@ static int unix_stream_sendmsg(struct socket *sock, struct msghdr *msg, return err; err = -EOPNOTSUPP; - if (msg->msg_flags&MSG_OOB) - goto out_err; if (msg->msg_namelen) { err = sk->sk_state == TCP_ESTABLISHED ? -EISCONN : -EOPNOTSUPP;@@ -1903,6 +1901,9 @@ static int unix_stream_sendmsg(struct socket *sock, struct msghdr *msg, sent += size; } + if (msg->msg_flags & MSG_OOB) + sk_send_sigurg(other); + scm_destroy(&scm); return sent;