tcp: Use ahash
This patch replaces uses of the long obsolete hash interface with ahash. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Acked-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
@@ -81,7 +81,7 @@
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/seq_file.h>
|
||||
|
||||
#include <linux/crypto.h>
|
||||
#include <crypto/hash.h>
|
||||
#include <linux/scatterlist.h>
|
||||
|
||||
int sysctl_tcp_tw_reuse __read_mostly;
|
||||
@@ -1031,21 +1031,22 @@ static int tcp_v4_md5_hash_pseudoheader(struct tcp_md5sig_pool *hp,
|
||||
bp->len = cpu_to_be16(nbytes);
|
||||
|
||||
sg_init_one(&sg, bp, sizeof(*bp));
|
||||
return crypto_hash_update(&hp->md5_desc, &sg, sizeof(*bp));
|
||||
ahash_request_set_crypt(hp->md5_req, &sg, NULL, sizeof(*bp));
|
||||
return crypto_ahash_update(hp->md5_req);
|
||||
}
|
||||
|
||||
static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
|
||||
__be32 daddr, __be32 saddr, const struct tcphdr *th)
|
||||
{
|
||||
struct tcp_md5sig_pool *hp;
|
||||
struct hash_desc *desc;
|
||||
struct ahash_request *req;
|
||||
|
||||
hp = tcp_get_md5sig_pool();
|
||||
if (!hp)
|
||||
goto clear_hash_noput;
|
||||
desc = &hp->md5_desc;
|
||||
req = hp->md5_req;
|
||||
|
||||
if (crypto_hash_init(desc))
|
||||
if (crypto_ahash_init(req))
|
||||
goto clear_hash;
|
||||
if (tcp_v4_md5_hash_pseudoheader(hp, daddr, saddr, th->doff << 2))
|
||||
goto clear_hash;
|
||||
@@ -1053,7 +1054,8 @@ static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
|
||||
goto clear_hash;
|
||||
if (tcp_md5_hash_key(hp, key))
|
||||
goto clear_hash;
|
||||
if (crypto_hash_final(desc, md5_hash))
|
||||
ahash_request_set_crypt(req, NULL, md5_hash, 0);
|
||||
if (crypto_ahash_final(req))
|
||||
goto clear_hash;
|
||||
|
||||
tcp_put_md5sig_pool();
|
||||
@@ -1071,7 +1073,7 @@ int tcp_v4_md5_hash_skb(char *md5_hash, const struct tcp_md5sig_key *key,
|
||||
const struct sk_buff *skb)
|
||||
{
|
||||
struct tcp_md5sig_pool *hp;
|
||||
struct hash_desc *desc;
|
||||
struct ahash_request *req;
|
||||
const struct tcphdr *th = tcp_hdr(skb);
|
||||
__be32 saddr, daddr;
|
||||
|
||||
@@ -1087,9 +1089,9 @@ int tcp_v4_md5_hash_skb(char *md5_hash, const struct tcp_md5sig_key *key,
|
||||
hp = tcp_get_md5sig_pool();
|
||||
if (!hp)
|
||||
goto clear_hash_noput;
|
||||
desc = &hp->md5_desc;
|
||||
req = hp->md5_req;
|
||||
|
||||
if (crypto_hash_init(desc))
|
||||
if (crypto_ahash_init(req))
|
||||
goto clear_hash;
|
||||
|
||||
if (tcp_v4_md5_hash_pseudoheader(hp, daddr, saddr, skb->len))
|
||||
@@ -1100,7 +1102,8 @@ int tcp_v4_md5_hash_skb(char *md5_hash, const struct tcp_md5sig_key *key,
|
||||
goto clear_hash;
|
||||
if (tcp_md5_hash_key(hp, key))
|
||||
goto clear_hash;
|
||||
if (crypto_hash_final(desc, md5_hash))
|
||||
ahash_request_set_crypt(req, NULL, md5_hash, 0);
|
||||
if (crypto_ahash_final(req))
|
||||
goto clear_hash;
|
||||
|
||||
tcp_put_md5sig_pool();
|
||||
|
Reference in New Issue
Block a user