Commit 0cf00c6f authored by Gu Zheng's avatar Gu Zheng Committed by David S. Miller

net/socket.c : introduce helper function do_sock_sendmsg to replace reduplicate code

Introduce helper function do_sock_sendmsg() to simplify sock_sendmsg{_nosec},
and replace reduplicate code.
Signed-off-by: default avatarGu Zheng <guz.fnst@cn.fujitsu.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 42eef7a0
...@@ -651,7 +651,8 @@ static inline int __sock_sendmsg(struct kiocb *iocb, struct socket *sock, ...@@ -651,7 +651,8 @@ static inline int __sock_sendmsg(struct kiocb *iocb, struct socket *sock,
return err ?: __sock_sendmsg_nosec(iocb, sock, msg, size); return err ?: __sock_sendmsg_nosec(iocb, sock, msg, size);
} }
int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size) static int do_sock_sendmsg(struct socket *sock, struct msghdr *msg,
size_t size, bool nosec)
{ {
struct kiocb iocb; struct kiocb iocb;
struct sock_iocb siocb; struct sock_iocb siocb;
...@@ -659,25 +660,22 @@ int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size) ...@@ -659,25 +660,22 @@ int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
init_sync_kiocb(&iocb, NULL); init_sync_kiocb(&iocb, NULL);
iocb.private = &siocb; iocb.private = &siocb;
ret = __sock_sendmsg(&iocb, sock, msg, size); ret = nosec ? __sock_sendmsg_nosec(&iocb, sock, msg, size) :
__sock_sendmsg(&iocb, sock, msg, size);
if (-EIOCBQUEUED == ret) if (-EIOCBQUEUED == ret)
ret = wait_on_sync_kiocb(&iocb); ret = wait_on_sync_kiocb(&iocb);
return ret; return ret;
} }
int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
{
return do_sock_sendmsg(sock, msg, size, false);
}
EXPORT_SYMBOL(sock_sendmsg); EXPORT_SYMBOL(sock_sendmsg);
static int sock_sendmsg_nosec(struct socket *sock, struct msghdr *msg, size_t size) static int sock_sendmsg_nosec(struct socket *sock, struct msghdr *msg, size_t size)
{ {
struct kiocb iocb; return do_sock_sendmsg(sock, msg, size, true);
struct sock_iocb siocb;
int ret;
init_sync_kiocb(&iocb, NULL);
iocb.private = &siocb;
ret = __sock_sendmsg_nosec(&iocb, sock, msg, size);
if (-EIOCBQUEUED == ret)
ret = wait_on_sync_kiocb(&iocb);
return ret;
} }
int kernel_sendmsg(struct socket *sock, struct msghdr *msg, int kernel_sendmsg(struct socket *sock, struct msghdr *msg,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment