aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/reassembly.c
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2007-10-17 22:44:34 -0400
committerDavid S. Miller <davem@davemloft.net>2007-10-17 22:44:34 -0400
commit2588fe1d782f1686847493ad643157d5d10bf602 (patch)
tree7513851819330d4ff6aadc9f76b1b45bc03f8f82 /net/ipv6/reassembly.c
parentfd9e63544cac30a34c951f0ec958038f0529e244 (diff)
[INET]: Consolidate xxx_frag_intern
This routine checks for the existence of a given entry in the hash table and inserts the new one if needed. The ->equal callback is used to compare two frag_queue-s together, but this one is temporary and will be removed later. The netfilter code and the ipv6 one use the same routine to compare frags. The inet_frag_intern() always returns non-NULL pointer, so convert the inet_frag_queue into protocol specific one (with the container_of) without any checks. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/reassembly.c')
-rw-r--r--net/ipv6/reassembly.c46
1 files changed, 16 insertions, 30 deletions
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index 0a1bf43bd489..73ea204eaa6f 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -143,6 +143,18 @@ static unsigned int ip6_hashfn(struct inet_frag_queue *q)
143 return ip6qhashfn(fq->id, &fq->saddr, &fq->daddr); 143 return ip6qhashfn(fq->id, &fq->saddr, &fq->daddr);
144} 144}
145 145
146int ip6_frag_equal(struct inet_frag_queue *q1, struct inet_frag_queue *q2)
147{
148 struct frag_queue *fq1, *fq2;
149
150 fq1 = container_of(q1, struct frag_queue, q);
151 fq2 = container_of(q2, struct frag_queue, q);
152 return (fq1->id == fq2->id &&
153 ipv6_addr_equal(&fq2->saddr, &fq1->saddr) &&
154 ipv6_addr_equal(&fq2->daddr, &fq1->daddr));
155}
156EXPORT_SYMBOL(ip6_frag_equal);
157
146/* Memory Tracking Functions. */ 158/* Memory Tracking Functions. */
147static inline void frag_kfree_skb(struct sk_buff *skb, int *work) 159static inline void frag_kfree_skb(struct sk_buff *skb, int *work)
148{ 160{
@@ -236,37 +248,10 @@ out:
236static struct frag_queue *ip6_frag_intern(struct frag_queue *fq_in, 248static struct frag_queue *ip6_frag_intern(struct frag_queue *fq_in,
237 unsigned int hash) 249 unsigned int hash)
238{ 250{
239 struct frag_queue *fq; 251 struct inet_frag_queue *q;
240#ifdef CONFIG_SMP
241 struct hlist_node *n;
242#endif
243
244 write_lock(&ip6_frags.lock);
245#ifdef CONFIG_SMP
246 hlist_for_each_entry(fq, n, &ip6_frags.hash[hash], q.list) {
247 if (fq->id == fq_in->id &&
248 ipv6_addr_equal(&fq_in->saddr, &fq->saddr) &&
249 ipv6_addr_equal(&fq_in->daddr, &fq->daddr)) {
250 atomic_inc(&fq->q.refcnt);
251 write_unlock(&ip6_frags.lock);
252 fq_in->q.last_in |= COMPLETE;
253 fq_put(fq_in);
254 return fq;
255 }
256 }
257#endif
258 fq = fq_in;
259
260 if (!mod_timer(&fq->q.timer, jiffies + ip6_frags_ctl.timeout))
261 atomic_inc(&fq->q.refcnt);
262 252
263 atomic_inc(&fq->q.refcnt); 253 q = inet_frag_intern(&fq_in->q, &ip6_frags, hash);
264 hlist_add_head(&fq->q.list, &ip6_frags.hash[hash]); 254 return container_of(q, struct frag_queue, q);
265 INIT_LIST_HEAD(&fq->q.lru_list);
266 list_add_tail(&fq->q.lru_list, &ip6_frags.lru_list);
267 ip6_frags.nqueues++;
268 write_unlock(&ip6_frags.lock);
269 return fq;
270} 255}
271 256
272 257
@@ -699,5 +684,6 @@ void __init ipv6_frag_init(void)
699 ip6_frags.destructor = ip6_frag_free; 684 ip6_frags.destructor = ip6_frag_free;
700 ip6_frags.skb_free = NULL; 685 ip6_frags.skb_free = NULL;
701 ip6_frags.qsize = sizeof(struct frag_queue); 686 ip6_frags.qsize = sizeof(struct frag_queue);
687 ip6_frags.equal = ip6_frag_equal;
702 inet_frags_init(&ip6_frags); 688 inet_frags_init(&ip6_frags);
703} 689}