aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2007-10-15 05:38:08 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-15 15:26:41 -0400
commit321a3a99e4717b960e21c62fc6a140d21453df7f (patch)
tree118ae0f39bd2344b731670d601abf0bcbbf8faa7 /net/ipv6
parent277e650ddfc6944ef5f5466fd898b8da7f06cd82 (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/ipv6')
-rw-r--r--net/ipv6/netfilter/nf_conntrack_reasm.c34
-rw-r--r--net/ipv6/reassembly.c37
2 files changed, 10 insertions, 61 deletions
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
index 2ebe515d914e..a3aef387bcfb 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -106,32 +106,12 @@ static unsigned int ip6qhashfn(__be32 id, struct in6_addr *saddr,
106 return c & (INETFRAGS_HASHSZ - 1); 106 return c & (INETFRAGS_HASHSZ - 1);
107} 107}
108 108
109static void nf_ct_frag6_secret_rebuild(unsigned long dummy) 109static unsigned int nf_hashfn(struct inet_frag_queue *q)
110{ 110{
111 unsigned long now = jiffies; 111 struct nf_ct_frag6_queue *nq;
112 int i;
113 112
114 write_lock(&nf_frags.lock); 113 nq = container_of(q, struct nf_ct_frag6_queue, q);
115 get_random_bytes(&nf_frags.rnd, sizeof(u32)); 114 return ip6qhashfn(nq->id, &nq->saddr, &nq->daddr);
116 for (i = 0; i < INETFRAGS_HASHSZ; i++) {
117 struct nf_ct_frag6_queue *q;
118 struct hlist_node *p, *n;
119
120 hlist_for_each_entry_safe(q, p, n, &nf_frags.hash[i], q.list) {
121 unsigned int hval = ip6qhashfn(q->id,
122 &q->saddr,
123 &q->daddr);
124 if (hval != i) {
125 hlist_del(&q->q.list);
126 /* Relink to new hash chain. */
127 hlist_add_head(&q->q.list,
128 &nf_frags.hash[hval]);
129 }
130 }
131 }
132 write_unlock(&nf_frags.lock);
133
134 mod_timer(&nf_frags.secret_timer, now + nf_frags_ctl.secret_interval);
135} 115}
136 116
137/* Memory Tracking Functions. */ 117/* Memory Tracking Functions. */
@@ -817,11 +797,8 @@ int nf_ct_frag6_kfree_frags(struct sk_buff *skb)
817 797
818int nf_ct_frag6_init(void) 798int nf_ct_frag6_init(void)
819{ 799{
820 setup_timer(&nf_frags.secret_timer, nf_ct_frag6_secret_rebuild, 0);
821 nf_frags.secret_timer.expires = jiffies + nf_frags_ctl.secret_interval;
822 add_timer(&nf_frags.secret_timer);
823
824 nf_frags.ctl = &nf_frags_ctl; 800 nf_frags.ctl = &nf_frags_ctl;
801 nf_frags.hashfn = nf_hashfn;
825 inet_frags_init(&nf_frags); 802 inet_frags_init(&nf_frags);
826 803
827 return 0; 804 return 0;
@@ -831,7 +808,6 @@ void nf_ct_frag6_cleanup(void)
831{ 808{
832 inet_frags_fini(&nf_frags); 809 inet_frags_fini(&nf_frags);
833 810
834 del_timer(&nf_frags.secret_timer);
835 nf_frags_ctl.low_thresh = 0; 811 nf_frags_ctl.low_thresh = 0;
836 nf_ct_frag6_evictor(); 812 nf_ct_frag6_evictor();
837} 813}
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index db129a7a6192..c7d4961bbcf7 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -135,35 +135,12 @@ static unsigned int ip6qhashfn(__be32 id, struct in6_addr *saddr,
135 return c & (INETFRAGS_HASHSZ - 1); 135 return c & (INETFRAGS_HASHSZ - 1);
136} 136}
137 137
138static void ip6_frag_secret_rebuild(unsigned long dummy) 138static unsigned int ip6_hashfn(struct inet_frag_queue *q)
139{ 139{
140 unsigned long now = jiffies; 140 struct frag_queue *fq;
141 int i;
142
143 write_lock(&ip6_frags.lock);
144 get_random_bytes(&ip6_frags.rnd, sizeof(u32));
145 for (i = 0; i < INETFRAGS_HASHSZ; i++) {
146 struct frag_queue *q;
147 struct hlist_node *p, *n;
148
149 hlist_for_each_entry_safe(q, p, n, &ip6_frags.hash[i], q.list) {
150 unsigned int hval = ip6qhashfn(q->id,
151 &q->saddr,
152 &q->daddr);
153
154 if (hval != i) {
155 hlist_del(&q->q.list);
156
157 /* Relink to new hash chain. */
158 hlist_add_head(&q->q.list,
159 &ip6_frags.hash[hval]);
160
161 }
162 }
163 }
164 write_unlock(&ip6_frags.lock);
165 141
166 mod_timer(&ip6_frags.secret_timer, now + ip6_frags_ctl.secret_interval); 142 fq = container_of(q, struct frag_queue, q);
143 return ip6qhashfn(fq->id, &fq->saddr, &fq->daddr);
167} 144}
168 145
169/* Memory Tracking Functions. */ 146/* Memory Tracking Functions. */
@@ -765,11 +742,7 @@ void __init ipv6_frag_init(void)
765 if (inet6_add_protocol(&frag_protocol, IPPROTO_FRAGMENT) < 0) 742 if (inet6_add_protocol(&frag_protocol, IPPROTO_FRAGMENT) < 0)
766 printk(KERN_ERR "ipv6_frag_init: Could not register protocol\n"); 743 printk(KERN_ERR "ipv6_frag_init: Could not register protocol\n");
767 744
768 init_timer(&ip6_frags.secret_timer);
769 ip6_frags.secret_timer.function = ip6_frag_secret_rebuild;
770 ip6_frags.secret_timer.expires = jiffies + ip6_frags_ctl.secret_interval;
771 add_timer(&ip6_frags.secret_timer);
772
773 ip6_frags.ctl = &ip6_frags_ctl; 745 ip6_frags.ctl = &ip6_frags_ctl;
746 ip6_frags.hashfn = ip6_hashfn;
774 inet_frags_init(&ip6_frags); 747 inet_frags_init(&ip6_frags);
775} 748}