diff options
author | Sagi Grimberg <sagi@lightbitslabs.com> | 2018-12-03 20:52:10 -0500 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2018-12-13 03:58:55 -0500 |
commit | 65d69e2505bb64f6a8d7f417f6e46e2a351174c6 (patch) | |
tree | 12a8a9edd9ef57ee9f77abf770f5f3c8d658c6f5 /net | |
parent | d05f443554b3c7dc6d46e3ba9c3c4de468875d4f (diff) |
datagram: introduce skb_copy_and_hash_datagram_iter helper
Introduce a helper to copy datagram into an iovec iterator
but also update a predefined hash. This is useful for
consumers of skb_copy_datagram_iter to also support inflight
data digest without having to finish to copy and only then
traverse the iovec and calculate the digest hash.
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sagi Grimberg <sagi@lightbitslabs.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/datagram.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/net/core/datagram.c b/net/core/datagram.c index 382543302ae5..ef262282c8be 100644 --- a/net/core/datagram.c +++ b/net/core/datagram.c | |||
@@ -465,7 +465,7 @@ int __skb_datagram_iter(const struct sk_buff *skb, int offset, | |||
465 | if (copy > len) | 465 | if (copy > len) |
466 | copy = len; | 466 | copy = len; |
467 | if (__skb_datagram_iter(frag_iter, offset - start, | 467 | if (__skb_datagram_iter(frag_iter, offset - start, |
468 | to, copy, short_copy, cb, data)) | 468 | to, copy, fault_short, cb, data)) |
469 | goto fault; | 469 | goto fault; |
470 | if ((len -= copy) == 0) | 470 | if ((len -= copy) == 0) |
471 | return 0; | 471 | return 0; |
@@ -492,6 +492,24 @@ short_copy: | |||
492 | return 0; | 492 | return 0; |
493 | } | 493 | } |
494 | 494 | ||
495 | /** | ||
496 | * skb_copy_and_hash_datagram_iter - Copy datagram to an iovec iterator | ||
497 | * and update a hash. | ||
498 | * @skb: buffer to copy | ||
499 | * @offset: offset in the buffer to start copying from | ||
500 | * @to: iovec iterator to copy to | ||
501 | * @len: amount of data to copy from buffer to iovec | ||
502 | * @hash: hash request to update | ||
503 | */ | ||
504 | int skb_copy_and_hash_datagram_iter(const struct sk_buff *skb, int offset, | ||
505 | struct iov_iter *to, int len, | ||
506 | struct ahash_request *hash) | ||
507 | { | ||
508 | return __skb_datagram_iter(skb, offset, to, len, true, | ||
509 | hash_and_copy_to_iter, hash); | ||
510 | } | ||
511 | EXPORT_SYMBOL(skb_copy_and_hash_datagram_iter); | ||
512 | |||
495 | static size_t simple_copy_to_iter(const void *addr, size_t bytes, | 513 | static size_t simple_copy_to_iter(const void *addr, size_t bytes, |
496 | void *data __always_unused, struct iov_iter *i) | 514 | void *data __always_unused, struct iov_iter *i) |
497 | { | 515 | { |