Skip to content

Commit

Permalink
net: allow skb_datagram_iter to be called from any context
Browse files Browse the repository at this point in the history
[ Upstream commit d2d30a3 ]

We only use the mapping in a single context, so kmap_local is sufficient
and cheaper. Make sure to use skb_frag_foreach_page as skb frags may
contain compound pages and we need to map page by page.

Reported-by: kernel test robot <[email protected]>
Closes: https://lore.kernel.org/oe-lkp/[email protected]
Fixes: 950fcae ("datagram: consolidate datagram copy to iter helpers")
Signed-off-by: Sagi Grimberg <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Paolo Abeni <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
sagigrimberg authored and gregkh committed Jul 11, 2024
1 parent b368762 commit 12f6119
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions net/core/datagram.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,15 +434,22 @@ static int __skb_datagram_iter(const struct sk_buff *skb, int offset,

end = start + skb_frag_size(frag);
if ((copy = end - offset) > 0) {
struct page *page = skb_frag_page(frag);
u8 *vaddr = kmap(page);
u32 p_off, p_len, copied;
struct page *p;
u8 *vaddr;

if (copy > len)
copy = len;
n = INDIRECT_CALL_1(cb, simple_copy_to_iter,
vaddr + skb_frag_off(frag) + offset - start,
copy, data, to);
kunmap(page);

skb_frag_foreach_page(frag,
skb_frag_off(frag) + offset - start,
copy, p, p_off, p_len, copied) {
vaddr = kmap_local_page(p);
n = INDIRECT_CALL_1(cb, simple_copy_to_iter,
vaddr + p_off, p_len, data, to);
kunmap_local(vaddr);
}

offset += n;
if (n != copy)
goto short_copy;
Expand Down

0 comments on commit 12f6119

Please sign in to comment.