Skip to content

Commit 3b4ba04

Browse files
Jason Wangdavem330
authored andcommitted
tap: support receiving skb from msg_control
This patch makes tap_recvmsg() can receive from skb from its caller through msg_control. Vhost_net will be the first user. Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ac77cfd commit 3b4ba04

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎drivers/net/tap.c‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -824,15 +824,17 @@ static ssize_t tap_put_user(struct tap_queue *q,
824824

825825
static ssize_t tap_do_read(struct tap_queue *q,
826826
struct iov_iter *to,
827-
int noblock)
827+
int noblock, struct sk_buff *skb)
828828
{
829829
DEFINE_WAIT(wait);
830-
struct sk_buff *skb;
831830
ssize_t ret = 0;
832831

833832
if (!iov_iter_count(to))
834833
return 0;
835834

835+
if (skb)
836+
goto put;
837+
836838
while (1) {
837839
if (!noblock)
838840
prepare_to_wait(sk_sleep(&q->sk), &wait,
@@ -856,6 +858,7 @@ static ssize_t tap_do_read(struct tap_queue *q,
856858
if (!noblock)
857859
finish_wait(sk_sleep(&q->sk), &wait);
858860

861+
put:
859862
if (skb) {
860863
ret = tap_put_user(q, skb, to);
861864
if (unlikely(ret < 0))
@@ -872,7 +875,7 @@ static ssize_t tap_read_iter(struct kiocb *iocb, struct iov_iter *to)
872875
struct tap_queue *q = file->private_data;
873876
ssize_t len = iov_iter_count(to), ret;
874877

875-
ret = tap_do_read(q, to, file->f_flags & O_NONBLOCK);
878+
ret = tap_do_read(q, to, file->f_flags & O_NONBLOCK, NULL);
876879
ret = min_t(ssize_t, ret, len);
877880
if (ret > 0)
878881
iocb->ki_pos = ret;
@@ -1155,7 +1158,8 @@ static int tap_recvmsg(struct socket *sock, struct msghdr *m,
11551158
int ret;
11561159
if (flags & ~(MSG_DONTWAIT|MSG_TRUNC))
11571160
return -EINVAL;
1158-
ret = tap_do_read(q, &m->msg_iter, flags & MSG_DONTWAIT);
1161+
ret = tap_do_read(q, &m->msg_iter, flags & MSG_DONTWAIT,
1162+
m->msg_control);
11591163
if (ret > total_len) {
11601164
m->msg_flags |= MSG_TRUNC;
11611165
ret = flags & MSG_TRUNC ? ret : total_len;

0 commit comments

Comments
 (0)