aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_ipv4.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2016-01-24 08:20:23 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2016-01-27 07:36:18 -0500
commitcf80e0e47e0e7a8994dfadefec0e1395c622817a (patch)
tree65f0d15e1420f2a1567afea63b032ac7e55cb900 /net/ipv4/tcp_ipv4.c
parent5821c769706561da81e9fcec4a6ca6dbbb2f30cb (diff)
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>
Diffstat (limited to 'net/ipv4/tcp_ipv4.c')
-rw-r--r--net/ipv4/tcp_ipv4.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 5ced3e4013e3..85854db3e094 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -81,7 +81,7 @@
81#include <linux/proc_fs.h> 81#include <linux/proc_fs.h>
82#include <linux/seq_file.h> 82#include <linux/seq_file.h>
83 83
84#include <linux/crypto.h> 84#include <crypto/hash.h>
85#include <linux/scatterlist.h> 85#include <linux/scatterlist.h>
86 86
87int sysctl_tcp_tw_reuse __read_mostly; 87int sysctl_tcp_tw_reuse __read_mostly;
@@ -1031,21 +1031,22 @@ static int tcp_v4_md5_hash_pseudoheader(struct tcp_md5sig_pool *hp,
1031 bp->len = cpu_to_be16(nbytes); 1031 bp->len = cpu_to_be16(nbytes);
1032 1032
1033 sg_init_one(&sg, bp, sizeof(*bp)); 1033 sg_init_one(&sg, bp, sizeof(*bp));
1034 return crypto_hash_update(&hp->md5_desc, &sg, sizeof(*bp)); 1034 ahash_request_set_crypt(hp->md5_req, &sg, NULL, sizeof(*bp));
1035 return crypto_ahash_update(hp->md5_req);
1035} 1036}
1036 1037
1037static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key, 1038static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
1038 __be32 daddr, __be32 saddr, const struct tcphdr *th) 1039 __be32 daddr, __be32 saddr, const struct tcphdr *th)
1039{ 1040{
1040 struct tcp_md5sig_pool *hp; 1041 struct tcp_md5sig_pool *hp;
1041 struct hash_desc *desc; 1042 struct ahash_request *req;
1042 1043
1043 hp = tcp_get_md5sig_pool(); 1044 hp = tcp_get_md5sig_pool();
1044 if (!hp) 1045 if (!hp)
1045 goto clear_hash_noput; 1046 goto clear_hash_noput;
1046 desc = &hp->md5_desc; 1047 req = hp->md5_req;
1047 1048
1048 if (crypto_hash_init(desc)) 1049 if (crypto_ahash_init(req))
1049 goto clear_hash; 1050 goto clear_hash;
1050 if (tcp_v4_md5_hash_pseudoheader(hp, daddr, saddr, th->doff << 2)) 1051 if (tcp_v4_md5_hash_pseudoheader(hp, daddr, saddr, th->doff << 2))
1051 goto clear_hash; 1052 goto clear_hash;
@@ -1053,7 +1054,8 @@ static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
1053 goto clear_hash; 1054 goto clear_hash;
1054 if (tcp_md5_hash_key(hp, key)) 1055 if (tcp_md5_hash_key(hp, key))
1055 goto clear_hash; 1056 goto clear_hash;
1056 if (crypto_hash_final(desc, md5_hash)) 1057 ahash_request_set_crypt(req, NULL, md5_hash, 0);
1058 if (crypto_ahash_final(req))
1057 goto clear_hash; 1059 goto clear_hash;
1058 1060
1059 tcp_put_md5sig_pool(); 1061 tcp_put_md5sig_pool();
@@ -1071,7 +1073,7 @@ int tcp_v4_md5_hash_skb(char *md5_hash, const struct tcp_md5sig_key *key,
1071 const struct sk_buff *skb) 1073 const struct sk_buff *skb)
1072{ 1074{
1073 struct tcp_md5sig_pool *hp; 1075 struct tcp_md5sig_pool *hp;
1074 struct hash_desc *desc; 1076 struct ahash_request *req;
1075 const struct tcphdr *th = tcp_hdr(skb); 1077 const struct tcphdr *th = tcp_hdr(skb);
1076 __be32 saddr, daddr; 1078 __be32 saddr, daddr;
1077 1079
@@ -1087,9 +1089,9 @@ int tcp_v4_md5_hash_skb(char *md5_hash, const struct tcp_md5sig_key *key,
1087 hp = tcp_get_md5sig_pool(); 1089 hp = tcp_get_md5sig_pool();
1088 if (!hp) 1090 if (!hp)
1089 goto clear_hash_noput; 1091 goto clear_hash_noput;
1090 desc = &hp->md5_desc; 1092 req = hp->md5_req;
1091 1093
1092 if (crypto_hash_init(desc)) 1094 if (crypto_ahash_init(req))
1093 goto clear_hash; 1095 goto clear_hash;
1094 1096
1095 if (tcp_v4_md5_hash_pseudoheader(hp, daddr, saddr, skb->len)) 1097 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,
1100 goto clear_hash; 1102 goto clear_hash;
1101 if (tcp_md5_hash_key(hp, key)) 1103 if (tcp_md5_hash_key(hp, key))
1102 goto clear_hash; 1104 goto clear_hash;
1103 if (crypto_hash_final(desc, md5_hash)) 1105 ahash_request_set_crypt(req, NULL, md5_hash, 0);
1106 if (crypto_ahash_final(req))
1104 goto clear_hash; 1107 goto clear_hash;
1105 1108
1106 tcp_put_md5sig_pool(); 1109 tcp_put_md5sig_pool();