public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Chris Lew <clew@codeaurora.org>
To: Bjorn Andersson <bjorn.andersson@linaro.org>,
	"David S. Miller" <davem@davemloft.net>
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH v2] net: qrtr: Expose tunneling endpoint to user space
Date: Thu, 26 Apr 2018 15:29:53 -0700	[thread overview]
Message-ID: <46fe45d8-6f3a-5bed-c02c-6e61ba1175d2@codeaurora.org> (raw)
In-Reply-To: <20180423214653.10016-1-bjorn.andersson@linaro.org>



On 4/23/2018 2:46 PM, Bjorn Andersson wrote:
> This implements a misc character device named "qrtr-tun" for the purpose
> of allowing user space applications to implement endpoints in the qrtr
> network.
> 
> This allows more advanced (and dynamic) testing of the qrtr code as well
> as opens up the ability of tunneling qrtr over a network or USB link.
> 
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>

Acked-by: Chris Lew <clew@codeaurora.org>

> +static ssize_t qrtr_tun_read_iter(struct kiocb *iocb, struct iov_iter *to)
> +{
> +	struct file *filp = iocb->ki_filp;
> +	struct qrtr_tun *tun = filp->private_data;
> +	struct sk_buff *skb;
> +	int count;
> +
> +	while (!(skb = skb_dequeue(&tun->queue))) {
> +		if (filp->f_flags & O_NONBLOCK)
> +			return -EAGAIN;
> +
> +		/* Wait until we get data or the endpoint goes away */
> +		if (wait_event_interruptible(tun->readq,
> +					     !skb_queue_empty(&tun->queue)))
> +			return -ERESTARTSYS;
> +	}
> +
> +	count = min_t(size_t, iov_iter_count(to), skb->len);
> +	if (copy_to_iter(skb->data, count, to) != count)
> +		count = -EFAULT;
> +
> +	kfree_skb(skb);

Is it better to use consume_skb() since this is the expected behavior path?

> +
> +	return count;
> +}
> +

Thanks,
Chris

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

  reply	other threads:[~2018-04-26 22:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-23 21:46 [PATCH v2] net: qrtr: Expose tunneling endpoint to user space Bjorn Andersson
2018-04-26 22:29 ` Chris Lew [this message]
2018-04-27 14:55 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46fe45d8-6f3a-5bed-c02c-6e61ba1175d2@codeaurora.org \
    --to=clew@codeaurora.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=davem@davemloft.net \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox