Skip to content

Commit 0345f93

Browse files
tstrukdavem330
authored andcommitted
net: socket: add support for async operations
Add support for async operations. Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8f2ddaa commit 0345f93

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

include/linux/socket.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ struct msghdr {
5151
void *msg_control; /* ancillary data */
5252
__kernel_size_t msg_controllen; /* ancillary data buffer length */
5353
unsigned int msg_flags; /* flags on received message */
54+
struct kiocb *msg_iocb; /* ptr to iocb for async requests */
5455
};
5556

5657
struct user_msghdr {

net/compat.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ ssize_t get_compat_msghdr(struct msghdr *kmsg,
7979
if (nr_segs > UIO_MAXIOV)
8080
return -EMSGSIZE;
8181

82+
kmsg->msg_iocb = NULL;
83+
8284
err = compat_rw_copy_check_uvector(save_addr ? READ : WRITE,
8385
compat_ptr(uiov), nr_segs,
8486
UIO_FASTIOV, *iov, iov);

net/socket.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,8 @@ static ssize_t sock_read_iter(struct kiocb *iocb, struct iov_iter *to)
798798
{
799799
struct file *file = iocb->ki_filp;
800800
struct socket *sock = file->private_data;
801-
struct msghdr msg = {.msg_iter = *to};
801+
struct msghdr msg = {.msg_iter = *to,
802+
.msg_iocb = iocb};
802803
ssize_t res;
803804

804805
if (file->f_flags & O_NONBLOCK)
@@ -819,7 +820,8 @@ static ssize_t sock_write_iter(struct kiocb *iocb, struct iov_iter *from)
819820
{
820821
struct file *file = iocb->ki_filp;
821822
struct socket *sock = file->private_data;
822-
struct msghdr msg = {.msg_iter = *from};
823+
struct msghdr msg = {.msg_iter = *from,
824+
.msg_iocb = iocb};
823825
ssize_t res;
824826

825827
if (iocb->ki_pos != 0)
@@ -1894,6 +1896,8 @@ static ssize_t copy_msghdr_from_user(struct msghdr *kmsg,
18941896
if (nr_segs > UIO_MAXIOV)
18951897
return -EMSGSIZE;
18961898

1899+
kmsg->msg_iocb = NULL;
1900+
18971901
err = rw_copy_check_uvector(save_addr ? READ : WRITE,
18981902
uiov, nr_segs,
18991903
UIO_FASTIOV, *iov, iov);

0 commit comments

Comments
 (0)