aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/inet_fragment.c13
-rw-r--r--net/ipv4/ip_fragment.c2
2 files changed, 11 insertions, 4 deletions
diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
index 3b01959bf4bb..930d23870811 100644
--- a/net/ipv4/inet_fragment.c
+++ b/net/ipv4/inet_fragment.c
@@ -46,6 +46,12 @@ const u8 ip_frag_ecn_table[16] = {
46}; 46};
47EXPORT_SYMBOL(ip_frag_ecn_table); 47EXPORT_SYMBOL(ip_frag_ecn_table);
48 48
49static unsigned int
50inet_frag_hashfn(const struct inet_frags *f, const struct inet_frag_queue *q)
51{
52 return f->hashfn(q) & (INETFRAGS_HASHSZ - 1);
53}
54
49static void inet_frag_secret_rebuild(unsigned long dummy) 55static void inet_frag_secret_rebuild(unsigned long dummy)
50{ 56{
51 struct inet_frags *f = (struct inet_frags *)dummy; 57 struct inet_frags *f = (struct inet_frags *)dummy;
@@ -63,7 +69,7 @@ static void inet_frag_secret_rebuild(unsigned long dummy)
63 69
64 hb = &f->hash[i]; 70 hb = &f->hash[i];
65 hlist_for_each_entry_safe(q, n, &hb->chain, list) { 71 hlist_for_each_entry_safe(q, n, &hb->chain, list) {
66 unsigned int hval = f->hashfn(q); 72 unsigned int hval = inet_frag_hashfn(f, q);
67 73
68 if (hval != i) { 74 if (hval != i) {
69 struct inet_frag_bucket *hb_dest; 75 struct inet_frag_bucket *hb_dest;
@@ -133,7 +139,7 @@ static inline void fq_unlink(struct inet_frag_queue *fq, struct inet_frags *f)
133 unsigned int hash; 139 unsigned int hash;
134 140
135 read_lock(&f->lock); 141 read_lock(&f->lock);
136 hash = f->hashfn(fq); 142 hash = inet_frag_hashfn(f, fq);
137 hb = &f->hash[hash]; 143 hb = &f->hash[hash];
138 144
139 spin_lock(&hb->chain_lock); 145 spin_lock(&hb->chain_lock);
@@ -252,7 +258,7 @@ static struct inet_frag_queue *inet_frag_intern(struct netns_frags *nf,
252 * the rnd seed, so we need to re-calculate the hash 258 * the rnd seed, so we need to re-calculate the hash
253 * chain. Fortunatelly the qp_in can be used to get one. 259 * chain. Fortunatelly the qp_in can be used to get one.
254 */ 260 */
255 hash = f->hashfn(qp_in); 261 hash = inet_frag_hashfn(f, qp_in);
256 hb = &f->hash[hash]; 262 hb = &f->hash[hash];
257 spin_lock(&hb->chain_lock); 263 spin_lock(&hb->chain_lock);
258 264
@@ -326,6 +332,7 @@ struct inet_frag_queue *inet_frag_find(struct netns_frags *nf,
326 struct inet_frag_queue *q; 332 struct inet_frag_queue *q;
327 int depth = 0; 333 int depth = 0;
328 334
335 hash &= (INETFRAGS_HASHSZ - 1);
329 hb = &f->hash[hash]; 336 hb = &f->hash[hash];
330 337
331 spin_lock(&hb->chain_lock); 338 spin_lock(&hb->chain_lock);
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index 586e6aaf9e6e..b769eb6c83c0 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -109,7 +109,7 @@ static unsigned int ipqhashfn(__be16 id, __be32 saddr, __be32 daddr, u8 prot)
109 net_get_random_once(&ip4_frags.rnd, sizeof(ip4_frags.rnd)); 109 net_get_random_once(&ip4_frags.rnd, sizeof(ip4_frags.rnd));
110 return jhash_3words((__force u32)id << 16 | prot, 110 return jhash_3words((__force u32)id << 16 | prot,
111 (__force u32)saddr, (__force u32)daddr, 111 (__force u32)saddr, (__force u32)daddr,
112 ip4_frags.rnd) & (INETFRAGS_HASHSZ - 1); 112 ip4_frags.rnd);
113} 113}
114 114
115static unsigned int ip4_hashfn(const struct inet_frag_queue *q) 115static unsigned int ip4_hashfn(const struct inet_frag_queue *q)