diff mbox series

[RFC,net-next,af_unix,v1,1/1] net:af_unix: Allow unix sockets to raise SIGURG

Message ID 20210518074343.980438-1-Rao.Shoaib@oracle.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series [RFC,net-next,af_unix,v1,1/1] net:af_unix: Allow unix sockets to raise SIGURG | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 6 maintainers not CCed: gustavoars@kernel.org jingxiangfeng@huawei.com orcohen2006@gmail.com jamorris@linux.microsoft.com mkl@pengutronix.de christian.brauner@ubuntu.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 4 this patch: 4
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 17 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 4 this patch: 4
netdev/header_inline success Link

Commit Message

Shoaib Rao May 18, 2021, 7:43 a.m. UTC
From: Rao Shoaib <rao.shoaib@oracle.com>

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.

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 <rao.shoaib@oracle.com>
Signed-off-by: Matthew Wilcox <matthew.wilcox@oracle.com>
---
 net/unix/af_unix.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Matthew Wilcox May 18, 2021, 4:55 p.m. UTC | #1
On Tue, May 18, 2021 at 12:43:43AM -0700, Rao Shoaib wrote:
> From: Rao Shoaib <rao.shoaib@oracle.com>
> 
> 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.
> 
> 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 <rao.shoaib@oracle.com>
> Signed-off-by: Matthew Wilcox <matthew.wilcox@oracle.com>

Please don't forge my Signed-off-by.  With that line deleted,

Reviewed-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 5a31307ceb76..c8400c002882 100644
> --- a/net/unix/af_unix.c
> +++ b/net/unix/af_unix.c
> @@ -1838,8 +1838,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;
> @@ -1904,6 +1902,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;
> -- 
> 2.31.1
>
diff mbox series

Patch

diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 5a31307ceb76..c8400c002882 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -1838,8 +1838,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;
@@ -1904,6 +1902,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;