aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/ip_fragment.c
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/ipv4/ip_fragment.c
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/ipv4/ip_fragment.c')
-rw-r--r--net/ipv4/ip_fragment.c34
1 files changed, 5 insertions, 29 deletions
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index 7416c05dd334..e231c248aea7 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -115,32 +115,12 @@ static unsigned int ipqhashfn(__be16 id, __be32 saddr, __be32 daddr, u8 prot)
115 ip4_frags.rnd) & (INETFRAGS_HASHSZ - 1); 115 ip4_frags.rnd) & (INETFRAGS_HASHSZ - 1);
116} 116}
117 117
118static void ipfrag_secret_rebuild(unsigned long dummy) 118static unsigned int ip4_hashfn(struct inet_frag_queue *q)
119{ 119{
120 unsigned long now = jiffies; 120 struct ipq *ipq;
121 int i;
122 121
123 write_lock(&ip4_frags.lock); 122 ipq = container_of(q, struct ipq, q);
124 get_random_bytes(&ip4_frags.rnd, sizeof(u32)); 123 return ipqhashfn(ipq->id, ipq->saddr, ipq->daddr, ipq->protocol);
125 for (i = 0; i < INETFRAGS_HASHSZ; i++) {
126 struct ipq *q;
127 struct hlist_node *p, *n;
128
129 hlist_for_each_entry_safe(q, p, n, &ip4_frags.hash[i], q.list) {
130 unsigned int hval = ipqhashfn(q->id, q->saddr,
131 q->daddr, q->protocol);
132
133 if (hval != i) {
134 hlist_del(&q->q.list);
135
136 /* Relink to new hash chain. */
137 hlist_add_head(&q->q.list, &ip4_frags.hash[hval]);
138 }
139 }
140 }
141 write_unlock(&ip4_frags.lock);
142
143 mod_timer(&ip4_frags.secret_timer, now + ip4_frags_ctl.secret_interval);
144} 124}
145 125
146/* Memory Tracking Functions. */ 126/* Memory Tracking Functions. */
@@ -739,12 +719,8 @@ int ip_defrag(struct sk_buff *skb, u32 user)
739 719
740void __init ipfrag_init(void) 720void __init ipfrag_init(void)
741{ 721{
742 init_timer(&ip4_frags.secret_timer);
743 ip4_frags.secret_timer.function = ipfrag_secret_rebuild;
744 ip4_frags.secret_timer.expires = jiffies + ip4_frags_ctl.secret_interval;
745 add_timer(&ip4_frags.secret_timer);
746
747 ip4_frags.ctl = &ip4_frags_ctl; 722 ip4_frags.ctl = &ip4_frags_ctl;
723 ip4_frags.hashfn = ip4_hashfn;
748 inet_frags_init(&ip4_frags); 724 inet_frags_init(&ip4_frags);
749} 725}
750 726