aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2007-10-17 22:43:37 -0400
committerDavid S. Miller <davem@davemloft.net>2007-10-17 22:43:37 -0400
commitfd9e63544cac30a34c951f0ec958038f0529e244 (patch)
treeab50911ec813780ee1e472089f4b02a3be6a69e6 /net
parentbe07664599fa94d0b85c3e0f525aee2432d15fbf (diff)
[INET]: Omit double hash calculations in xxx_frag_intern
Since the hash value is already calculated in xxx_find, we can simply use it later. This is already done in netfilter code, so make the same in ipv4 and ipv6. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/ip_fragment.c11
-rw-r--r--net/ipv6/reassembly.c11
2 files changed, 9 insertions, 13 deletions
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index 443b3f89192f..d12a18b8f568 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -212,17 +212,14 @@ out:
212 212
213/* Creation primitives. */ 213/* Creation primitives. */
214 214
215static struct ipq *ip_frag_intern(struct ipq *qp_in) 215static struct ipq *ip_frag_intern(struct ipq *qp_in, unsigned int hash)
216{ 216{
217 struct ipq *qp; 217 struct ipq *qp;
218#ifdef CONFIG_SMP 218#ifdef CONFIG_SMP
219 struct hlist_node *n; 219 struct hlist_node *n;
220#endif 220#endif
221 unsigned int hash;
222 221
223 write_lock(&ip4_frags.lock); 222 write_lock(&ip4_frags.lock);
224 hash = ipqhashfn(qp_in->id, qp_in->saddr, qp_in->daddr,
225 qp_in->protocol);
226#ifdef CONFIG_SMP 223#ifdef CONFIG_SMP
227 /* With SMP race we have to recheck hash table, because 224 /* With SMP race we have to recheck hash table, because
228 * such entry could be created on other cpu, while we 225 * such entry could be created on other cpu, while we
@@ -257,7 +254,7 @@ static struct ipq *ip_frag_intern(struct ipq *qp_in)
257} 254}
258 255
259/* Add an entry to the 'ipq' queue for a newly received IP datagram. */ 256/* Add an entry to the 'ipq' queue for a newly received IP datagram. */
260static struct ipq *ip_frag_create(struct iphdr *iph, u32 user) 257static struct ipq *ip_frag_create(struct iphdr *iph, u32 user, unsigned int h)
261{ 258{
262 struct ipq *qp; 259 struct ipq *qp;
263 260
@@ -278,7 +275,7 @@ static struct ipq *ip_frag_create(struct iphdr *iph, u32 user)
278 spin_lock_init(&qp->q.lock); 275 spin_lock_init(&qp->q.lock);
279 atomic_set(&qp->q.refcnt, 1); 276 atomic_set(&qp->q.refcnt, 1);
280 277
281 return ip_frag_intern(qp); 278 return ip_frag_intern(qp, h);
282 279
283out_nomem: 280out_nomem:
284 LIMIT_NETDEBUG(KERN_ERR "ip_frag_create: no memory left !\n"); 281 LIMIT_NETDEBUG(KERN_ERR "ip_frag_create: no memory left !\n");
@@ -313,7 +310,7 @@ static inline struct ipq *ip_find(struct iphdr *iph, u32 user)
313 } 310 }
314 read_unlock(&ip4_frags.lock); 311 read_unlock(&ip4_frags.lock);
315 312
316 return ip_frag_create(iph, user); 313 return ip_frag_create(iph, user, hash);
317} 314}
318 315
319/* Is the fragment too far ahead to be part of ipq? */ 316/* Is the fragment too far ahead to be part of ipq? */
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index 6ad19cfc2025..0a1bf43bd489 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -233,16 +233,15 @@ out:
233/* Creation primitives. */ 233/* Creation primitives. */
234 234
235 235
236static struct frag_queue *ip6_frag_intern(struct frag_queue *fq_in) 236static struct frag_queue *ip6_frag_intern(struct frag_queue *fq_in,
237 unsigned int hash)
237{ 238{
238 struct frag_queue *fq; 239 struct frag_queue *fq;
239 unsigned int hash;
240#ifdef CONFIG_SMP 240#ifdef CONFIG_SMP
241 struct hlist_node *n; 241 struct hlist_node *n;
242#endif 242#endif
243 243
244 write_lock(&ip6_frags.lock); 244 write_lock(&ip6_frags.lock);
245 hash = ip6qhashfn(fq_in->id, &fq_in->saddr, &fq_in->daddr);
246#ifdef CONFIG_SMP 245#ifdef CONFIG_SMP
247 hlist_for_each_entry(fq, n, &ip6_frags.hash[hash], q.list) { 246 hlist_for_each_entry(fq, n, &ip6_frags.hash[hash], q.list) {
248 if (fq->id == fq_in->id && 247 if (fq->id == fq_in->id &&
@@ -273,7 +272,7 @@ static struct frag_queue *ip6_frag_intern(struct frag_queue *fq_in)
273 272
274static struct frag_queue * 273static struct frag_queue *
275ip6_frag_create(__be32 id, struct in6_addr *src, struct in6_addr *dst, 274ip6_frag_create(__be32 id, struct in6_addr *src, struct in6_addr *dst,
276 struct inet6_dev *idev) 275 struct inet6_dev *idev, unsigned int hash)
277{ 276{
278 struct frag_queue *fq; 277 struct frag_queue *fq;
279 278
@@ -290,7 +289,7 @@ ip6_frag_create(__be32 id, struct in6_addr *src, struct in6_addr *dst,
290 spin_lock_init(&fq->q.lock); 289 spin_lock_init(&fq->q.lock);
291 atomic_set(&fq->q.refcnt, 1); 290 atomic_set(&fq->q.refcnt, 1);
292 291
293 return ip6_frag_intern(fq); 292 return ip6_frag_intern(fq, hash);
294 293
295oom: 294oom:
296 IP6_INC_STATS_BH(idev, IPSTATS_MIB_REASMFAILS); 295 IP6_INC_STATS_BH(idev, IPSTATS_MIB_REASMFAILS);
@@ -318,7 +317,7 @@ fq_find(__be32 id, struct in6_addr *src, struct in6_addr *dst,
318 } 317 }
319 read_unlock(&ip6_frags.lock); 318 read_unlock(&ip6_frags.lock);
320 319
321 return ip6_frag_create(id, src, dst, idev); 320 return ip6_frag_create(id, src, dst, idev, hash);
322} 321}
323 322
324 323