aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tun.c
diff options
context:
space:
mode:
authorJason Wang <jasowang@redhat.com>2013-08-06 05:45:03 -0400
committerDavid S. Miller <davem@davemloft.net>2013-08-07 19:52:33 -0400
commitb4bf07771faaf959b0a916d35b1b930c030e30a8 (patch)
tree9292ea7010fc74fb5c3f5039ee3886b1f42702f3 /drivers/net/tun.c
parent6261d983f226f0a6a8d4d32b57a032bc23a5ebb6 (diff)
net: move iov_pages() to net/core/iovec.c
To let it be reused and reduce code duplication. Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/tun.c')
-rw-r--r--drivers/net/tun.c23
1 files changed, 0 insertions, 23 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 5dce262f538e..18527ef0cc75 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1041,29 +1041,6 @@ static int zerocopy_sg_from_iovec(struct sk_buff *skb, const struct iovec *from,
1041 return 0; 1041 return 0;
1042} 1042}
1043 1043
1044static unsigned long iov_pages(const struct iovec *iv, int offset,
1045 unsigned long nr_segs)
1046{
1047 unsigned long seg, base;
1048 int pages = 0, len, size;
1049
1050 while (nr_segs && (offset >= iv->iov_len)) {
1051 offset -= iv->iov_len;
1052 ++iv;
1053 --nr_segs;
1054 }
1055
1056 for (seg = 0; seg < nr_segs; seg++) {
1057 base = (unsigned long)iv[seg].iov_base + offset;
1058 len = iv[seg].iov_len - offset;
1059 size = ((base & ~PAGE_MASK) + len + ~PAGE_MASK) >> PAGE_SHIFT;
1060 pages += size;
1061 offset = 0;
1062 }
1063
1064 return pages;
1065}
1066
1067/* Get packet from user space buffer */ 1044/* Get packet from user space buffer */
1068static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, 1045static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
1069 void *msg_control, const struct iovec *iv, 1046 void *msg_control, const struct iovec *iv,