Skip to content

Commit b5f0e20

Browse files
dhowellsbrauner
authored andcommitted
iov_iter, net: Move hash_and_copy_to_iter() to net/
Move hash_and_copy_to_iter() to be with its only caller in networking code. Signed-off-by: David Howells <dhowells@redhat.com> Link: https://lore.kernel.org/r/20230925120309.1731676-13-dhowells@redhat.com cc: Alexander Viro <viro@zeniv.linux.org.uk> cc: Jens Axboe <axboe@kernel.dk> cc: Christoph Hellwig <hch@lst.de> cc: Christian Brauner <christian@brauner.io> cc: Matthew Wilcox <willy@infradead.org> cc: Linus Torvalds <torvalds@linux-foundation.org> cc: David Laight <David.Laight@ACULAB.COM> cc: "David S. Miller" <davem@davemloft.net> cc: Eric Dumazet <edumazet@google.com> cc: Jakub Kicinski <kuba@kernel.org> cc: Paolo Abeni <pabeni@redhat.com> cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org cc: netdev@vger.kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 7c6f353 commit b5f0e20

3 files changed

Lines changed: 19 additions & 23 deletions

File tree

include/linux/uio.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,6 @@ iov_iter_npages_cap(struct iov_iter *i, int maxpages, size_t max_bytes)
338338
return npages;
339339
}
340340

341-
size_t hash_and_copy_to_iter(const void *addr, size_t bytes, void *hashp,
342-
struct iov_iter *i);
343-
344341
struct iovec *iovec_from_user(const struct iovec __user *uvector,
345342
unsigned long nr_segs, unsigned long fast_segs,
346343
struct iovec *fast_iov, bool compat);

lib/iov_iter.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// SPDX-License-Identifier: GPL-2.0-only
2-
#include <crypto/hash.h>
32
#include <linux/export.h>
43
#include <linux/bvec.h>
54
#include <linux/fault-inject-usercopy.h>
@@ -1089,25 +1088,6 @@ ssize_t iov_iter_get_pages_alloc2(struct iov_iter *i,
10891088
}
10901089
EXPORT_SYMBOL(iov_iter_get_pages_alloc2);
10911090

1092-
size_t hash_and_copy_to_iter(const void *addr, size_t bytes, void *hashp,
1093-
struct iov_iter *i)
1094-
{
1095-
#ifdef CONFIG_CRYPTO_HASH
1096-
struct ahash_request *hash = hashp;
1097-
struct scatterlist sg;
1098-
size_t copied;
1099-
1100-
copied = copy_to_iter(addr, bytes, i);
1101-
sg_init_one(&sg, addr, copied);
1102-
ahash_request_set_crypt(hash, &sg, NULL, copied);
1103-
crypto_ahash_update(hash);
1104-
return copied;
1105-
#else
1106-
return 0;
1107-
#endif
1108-
}
1109-
EXPORT_SYMBOL(hash_and_copy_to_iter);
1110-
11111091
static int iov_npages(const struct iov_iter *i, int maxpages)
11121092
{
11131093
size_t skip = i->iov_offset, size = i->count;

net/core/datagram.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
#include <net/tcp_states.h>
6262
#include <trace/events/skb.h>
6363
#include <net/busy_poll.h>
64+
#include <crypto/hash.h>
6465

6566
/*
6667
* Is a socket 'connection oriented' ?
@@ -489,6 +490,24 @@ static int __skb_datagram_iter(const struct sk_buff *skb, int offset,
489490
return 0;
490491
}
491492

493+
static size_t hash_and_copy_to_iter(const void *addr, size_t bytes, void *hashp,
494+
struct iov_iter *i)
495+
{
496+
#ifdef CONFIG_CRYPTO_HASH
497+
struct ahash_request *hash = hashp;
498+
struct scatterlist sg;
499+
size_t copied;
500+
501+
copied = copy_to_iter(addr, bytes, i);
502+
sg_init_one(&sg, addr, copied);
503+
ahash_request_set_crypt(hash, &sg, NULL, copied);
504+
crypto_ahash_update(hash);
505+
return copied;
506+
#else
507+
return 0;
508+
#endif
509+
}
510+
492511
/**
493512
* skb_copy_and_hash_datagram_iter - Copy datagram to an iovec iterator
494513
* and update a hash.

0 commit comments

Comments
 (0)