summaryrefslogtreecommitdiffstats
path: root/net/core/iovec.c
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2009-04-20 01:25:46 +0000
committerDavid S. Miller <davem@davemloft.net>2009-04-21 05:42:44 -0700
commit0a1ec07a67bd8b0033dace237249654d015efa21 (patch)
tree1963b9ba273f0786c8a972c27b5599dfb4a19f06 /net/core/iovec.c
parent0cededf3ffbb775c3716aa1d246338fdc24b1259 (diff)
downloadop-kernel-dev-0a1ec07a67bd8b0033dace237249654d015efa21.zip
op-kernel-dev-0a1ec07a67bd8b0033dace237249654d015efa21.tar.gz
net: skb_copy_datagram_const_iovec()
There's an skb_copy_datagram_iovec() to copy out of a paged skb, but it modifies the iovec, and does not support starting at an offset in the destination. We want both in tun.c, so let's add the function. It's a carbon copy of skb_copy_datagram_iovec() with enough changes to be annoying. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/iovec.c')
-rw-r--r--net/core/iovec.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/net/core/iovec.c b/net/core/iovec.c
index 4c9c012..a215545 100644
--- a/net/core/iovec.c
+++ b/net/core/iovec.c
@@ -98,6 +98,31 @@ int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len)
}
/*
+ * Copy kernel to iovec. Returns -EFAULT on error.
+ */
+
+int memcpy_toiovecend(const struct iovec *iov, unsigned char *kdata,
+ int offset, int len)
+{
+ int copy;
+ for (; len > 0; ++iov) {
+ /* Skip over the finished iovecs */
+ if (unlikely(offset >= iov->iov_len)) {
+ offset -= iov->iov_len;
+ continue;
+ }
+ copy = min_t(unsigned int, iov->iov_len - offset, len);
+ offset = 0;
+ if (copy_to_user(iov->iov_base, kdata, copy))
+ return -EFAULT;
+ kdata += copy;
+ len -= copy;
+ }
+
+ return 0;
+}
+
+/*
* Copy iovec to kernel. Returns -EFAULT on error.
*
* Note: this modifies the original iovec.
@@ -236,3 +261,4 @@ EXPORT_SYMBOL(csum_partial_copy_fromiovecend);
EXPORT_SYMBOL(memcpy_fromiovec);
EXPORT_SYMBOL(memcpy_fromiovecend);
EXPORT_SYMBOL(memcpy_toiovec);
+EXPORT_SYMBOL(memcpy_toiovecend);
OpenPOWER on IntegriCloud