aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStanislav Fomichev <[email protected]>2025-05-20 20:30:42 +0000
committerDavid S. Miller <[email protected]>2025-05-26 09:00:48 +0000
commit384492c48e6a88c9a7f0376d8e8ac7f557988e92 (patch)
tree95547cd8576faaa0b3228588c91fb4d24c35278e
parentnet: ethernet: mtk_eth_soc: Correct spelling (diff)
downloadkernel-384492c48e6a88c9a7f0376d8e8ac7f557988e92.tar.gz
kernel-384492c48e6a88c9a7f0376d8e8ac7f557988e92.zip
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: bd61848900bf ("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]>
-rw-r--r--include/linux/uio.h8
-rw-r--r--net/core/datagram.c3
2 files changed, 9 insertions, 2 deletions
diff --git a/include/linux/uio.h b/include/linux/uio.h
index 49ece9e1888f..393d0622cc28 100644
--- a/include/linux/uio.h
+++ b/include/linux/uio.h
@@ -99,7 +99,13 @@ static inline const struct iovec *iter_iov(const struct iov_iter *iter)
}
#define iter_iov_addr(iter) (iter_iov(iter)->iov_base + (iter)->iov_offset)
-#define iter_iov_len(iter) (iter_iov(iter)->iov_len - (iter)->iov_offset)
+
+static inline size_t iter_iov_len(const struct iov_iter *i)
+{
+ if (i->iter_type == ITER_UBUF)
+ return i->count;
+ return iter_iov(i)->iov_len - i->iov_offset;
+}
static inline enum iter_type iov_iter_type(const struct iov_iter *i)
{
diff --git a/net/core/datagram.c b/net/core/datagram.c
index b352a1009304..94cc4705e91d 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -702,7 +702,8 @@ zerocopy_fill_skb_from_devmem(struct sk_buff *skb, struct iov_iter *from,
* iov_addrs are interpreted as an offset in bytes into the dma-buf to
* send from. We do not support other iter types.
*/
- if (iov_iter_type(from) != ITER_IOVEC)
+ if (iov_iter_type(from) != ITER_IOVEC &&
+ iov_iter_type(from) != ITER_UBUF)
return -EFAULT;
while (length && iov_iter_count(from)) {