diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2007-10-15 05:38:08 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-15 15:26:41 -0400 |
commit | 321a3a99e4717b960e21c62fc6a140d21453df7f (patch) | |
tree | 118ae0f39bd2344b731670d601abf0bcbbf8faa7 /net/ipv4/inet_fragment.c | |
parent | 277e650ddfc6944ef5f5466fd898b8da7f06cd82 (diff) |
[INET]: Consolidate xxx_the secret_rebuild
This code works with the generic data types as well, so
move this into inet_fragment.c
This move makes it possible to hide the secret_timer
management and the secret_rebuild routine completely in
the inet_fragment.c
Introduce the ->hashfn() callback in inet_frags() to get
the hashfun for a given inet_frag_queue() object.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/inet_fragment.c')
-rw-r--r-- | net/ipv4/inet_fragment.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c index 534eaa8cdcf3..ec10e05c6666 100644 --- a/net/ipv4/inet_fragment.c +++ b/net/ipv4/inet_fragment.c | |||
@@ -16,9 +16,38 @@ | |||
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/timer.h> | 17 | #include <linux/timer.h> |
18 | #include <linux/mm.h> | 18 | #include <linux/mm.h> |
19 | #include <linux/random.h> | ||
19 | 20 | ||
20 | #include <net/inet_frag.h> | 21 | #include <net/inet_frag.h> |
21 | 22 | ||
23 | static void inet_frag_secret_rebuild(unsigned long dummy) | ||
24 | { | ||
25 | struct inet_frags *f = (struct inet_frags *)dummy; | ||
26 | unsigned long now = jiffies; | ||
27 | int i; | ||
28 | |||
29 | write_lock(&f->lock); | ||
30 | get_random_bytes(&f->rnd, sizeof(u32)); | ||
31 | for (i = 0; i < INETFRAGS_HASHSZ; i++) { | ||
32 | struct inet_frag_queue *q; | ||
33 | struct hlist_node *p, *n; | ||
34 | |||
35 | hlist_for_each_entry_safe(q, p, n, &f->hash[i], list) { | ||
36 | unsigned int hval = f->hashfn(q); | ||
37 | |||
38 | if (hval != i) { | ||
39 | hlist_del(&q->list); | ||
40 | |||
41 | /* Relink to new hash chain. */ | ||
42 | hlist_add_head(&q->list, &f->hash[hval]); | ||
43 | } | ||
44 | } | ||
45 | } | ||
46 | write_unlock(&f->lock); | ||
47 | |||
48 | mod_timer(&f->secret_timer, now + f->ctl->secret_interval); | ||
49 | } | ||
50 | |||
22 | void inet_frags_init(struct inet_frags *f) | 51 | void inet_frags_init(struct inet_frags *f) |
23 | { | 52 | { |
24 | int i; | 53 | int i; |
@@ -35,11 +64,17 @@ void inet_frags_init(struct inet_frags *f) | |||
35 | f->nqueues = 0; | 64 | f->nqueues = 0; |
36 | atomic_set(&f->mem, 0); | 65 | atomic_set(&f->mem, 0); |
37 | 66 | ||
67 | init_timer(&f->secret_timer); | ||
68 | f->secret_timer.function = inet_frag_secret_rebuild; | ||
69 | f->secret_timer.data = (unsigned long)f; | ||
70 | f->secret_timer.expires = jiffies + f->ctl->secret_interval; | ||
71 | add_timer(&f->secret_timer); | ||
38 | } | 72 | } |
39 | EXPORT_SYMBOL(inet_frags_init); | 73 | EXPORT_SYMBOL(inet_frags_init); |
40 | 74 | ||
41 | void inet_frags_fini(struct inet_frags *f) | 75 | void inet_frags_fini(struct inet_frags *f) |
42 | { | 76 | { |
77 | del_timer(&f->secret_timer); | ||
43 | } | 78 | } |
44 | EXPORT_SYMBOL(inet_frags_fini); | 79 | EXPORT_SYMBOL(inet_frags_fini); |
45 | 80 | ||