From: Cong Wang <cong.w...@bytedance.com> We already have unix_dgram_sendmsg(), we can just build its ->sendmsg_locked() on top of it.
Cc: John Fastabend <john.fastab...@gmail.com> Cc: Daniel Borkmann <dan...@iogearbox.net> Cc: Jakub Sitnicki <ja...@cloudflare.com> Cc: Lorenz Bauer <l...@cloudflare.com> Signed-off-by: Cong Wang <cong.w...@bytedance.com> --- net/unix/af_unix.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 41c3303c3357..4e1fa4ecbcfb 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -659,6 +659,7 @@ static ssize_t unix_stream_sendpage(struct socket *, struct page *, int offset, static ssize_t unix_stream_splice_read(struct socket *, loff_t *ppos, struct pipe_inode_info *, size_t size, unsigned int flags); +static int __unix_dgram_sendmsg(struct sock*, struct msghdr *, size_t); static int unix_dgram_sendmsg(struct socket *, struct msghdr *, size_t); static int unix_dgram_recvmsg(struct socket *, struct msghdr *, size_t, int); static int unix_dgram_connect(struct socket *, struct sockaddr *, @@ -738,6 +739,7 @@ static const struct proto_ops unix_dgram_ops = { .listen = sock_no_listen, .shutdown = unix_shutdown, .sendmsg = unix_dgram_sendmsg, + .sendmsg_locked = __unix_dgram_sendmsg, .recvmsg = unix_dgram_recvmsg, .mmap = sock_no_mmap, .sendpage = sock_no_sendpage, @@ -1611,10 +1613,10 @@ static void scm_stat_del(struct sock *sk, struct sk_buff *skb) * Send AF_UNIX data. */ -static int unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg, - size_t len) +static int __unix_dgram_sendmsg(struct sock *sk, struct msghdr *msg, + size_t len) { - struct sock *sk = sock->sk; + struct socket *sock = sk->sk_socket; struct net *net = sock_net(sk); struct unix_sock *u = unix_sk(sk); DECLARE_SOCKADDR(struct sockaddr_un *, sunaddr, msg->msg_name); @@ -1814,6 +1816,12 @@ static int unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg, return err; } +static int unix_dgram_sendmsg(struct socket *sock, struct msghdr *msg, + size_t len) +{ + return __unix_dgram_sendmsg(sock->sk, msg, len); +} + /* We use paged skbs for stream sockets, and limit occupancy to 32768 * bytes, and a minimum of a full page. */ -- 2.25.1