Skip to content

Commit 384492c

Browse files
Stanislav Fomichevdavem330
authored andcommitted
net: devmem: support single IOV with sendmsg
sendmsg() with a single iov becomes ITER_UBUF, sendmsg() with multiple iovs becomes ITER_IOVEC. iter_iov_len does not return correct value for UBUF, so teach to treat UBUF differently. Cc: Al Viro <[email protected]> Cc: Pavel Begunkov <[email protected]> Cc: Mina Almasry <[email protected]> Fixes: bd61848 ("net: devmem: Implement TX path") Signed-off-by: Stanislav Fomichev <[email protected]> Acked-by: Mina Almasry <[email protected]> Reviewed-by: Pavel Begunkov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d09a8a4 commit 384492c

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

include/linux/uio.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,13 @@ static inline const struct iovec *iter_iov(const struct iov_iter *iter)
9999
}
100100

101101
#define iter_iov_addr(iter) (iter_iov(iter)->iov_base + (iter)->iov_offset)
102-
#define iter_iov_len(iter) (iter_iov(iter)->iov_len - (iter)->iov_offset)
102+
103+
static inline size_t iter_iov_len(const struct iov_iter *i)
104+
{
105+
if (i->iter_type == ITER_UBUF)
106+
return i->count;
107+
return iter_iov(i)->iov_len - i->iov_offset;
108+
}
103109

104110
static inline enum iter_type iov_iter_type(const struct iov_iter *i)
105111
{

net/core/datagram.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,8 @@ zerocopy_fill_skb_from_devmem(struct sk_buff *skb, struct iov_iter *from,
702702
* iov_addrs are interpreted as an offset in bytes into the dma-buf to
703703
* send from. We do not support other iter types.
704704
*/
705-
if (iov_iter_type(from) != ITER_IOVEC)
705+
if (iov_iter_type(from) != ITER_IOVEC &&
706+
iov_iter_type(from) != ITER_UBUF)
706707
return -EFAULT;
707708

708709
while (length && iov_iter_count(from)) {

0 commit comments

Comments
 (0)