aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/inet_fragment.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/ipv4/inet_fragment.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/ipv4/inet_fragment.c')
-rw-r--r--net/ipv4/inet_fragment.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c
index 484cf512858f..15054eb3d4b9 100644
--- a/net/ipv4/inet_fragment.c
+++ b/net/ipv4/inet_fragment.c
@@ -172,3 +172,40 @@ int inet_frag_evictor(struct inet_frags *f)
172 return evicted; 172 return evicted;
173} 173}
174EXPORT_SYMBOL(inet_frag_evictor); 174EXPORT_SYMBOL(inet_frag_evictor);
175
176struct inet_frag_queue *inet_frag_intern(struct inet_frag_queue *qp_in,
177 struct inet_frags *f, unsigned int hash)
178{
179 struct inet_frag_queue *qp;
180#ifdef CONFIG_SMP
181 struct hlist_node *n;
182#endif
183
184 write_lock(&f->lock);
185#ifdef CONFIG_SMP
186 /* With SMP race we have to recheck hash table, because
187 * such entry could be created on other cpu, while we
188 * promoted read lock to write lock.
189 */
190 hlist_for_each_entry(qp, n, &f->hash[hash], list) {
191 if (f->equal(qp, qp_in)) {
192 atomic_inc(&qp->refcnt);
193 write_unlock(&f->lock);
194 qp_in->last_in |= COMPLETE;
195 inet_frag_put(qp_in, f);
196 return qp;
197 }
198 }
199#endif
200 qp = qp_in;
201 if (!mod_timer(&qp->timer, jiffies + f->ctl->timeout))
202 atomic_inc(&qp->refcnt);
203
204 atomic_inc(&qp->refcnt);
205 hlist_add_head(&qp->list, &f->hash[hash]);
206 list_add_tail(&qp->lru_list, &f->lru_list);
207 f->nqueues++;
208 write_unlock(&f->lock);
209 return qp;
210}
211EXPORT_SYMBOL(inet_frag_intern);