diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2007-10-15 05:39:14 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-15 15:26:42 -0400 |
commit | 1e4b82873af0f21002e37a81ef063d2e5410deb3 (patch) | |
tree | 9c4054c8393f03bae9565f98a109cc5721cf490f /net/ipv4/ip_fragment.c | |
parent | 321a3a99e4717b960e21c62fc6a140d21453df7f (diff) |
[INET]: Consolidate the xxx_frag_destroy
To make in possible we need to know the exact frag queue
size for inet_frags->mem management and two callbacks:
* to destoy the skb (optional, used in conntracks only)
* to free the queue itself (mandatory, but later I plan to
move the allocation and the destruction of frag_queues
into the common place, so this callback will most likely
be optional too).
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.c | 39 |
1 files changed, 10 insertions, 29 deletions
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index e231c248aea7..e8736632094a 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c | |||
@@ -132,11 +132,13 @@ static __inline__ void frag_kfree_skb(struct sk_buff *skb, int *work) | |||
132 | kfree_skb(skb); | 132 | kfree_skb(skb); |
133 | } | 133 | } |
134 | 134 | ||
135 | static __inline__ void frag_free_queue(struct ipq *qp, int *work) | 135 | static __inline__ void ip4_frag_free(struct inet_frag_queue *q) |
136 | { | 136 | { |
137 | if (work) | 137 | struct ipq *qp; |
138 | *work -= sizeof(struct ipq); | 138 | |
139 | atomic_sub(sizeof(struct ipq), &ip4_frags.mem); | 139 | qp = container_of(q, struct ipq, q); |
140 | if (qp->peer) | ||
141 | inet_putpeer(qp->peer); | ||
140 | kfree(qp); | 142 | kfree(qp); |
141 | } | 143 | } |
142 | 144 | ||
@@ -153,34 +155,10 @@ static __inline__ struct ipq *frag_alloc_queue(void) | |||
153 | 155 | ||
154 | /* Destruction primitives. */ | 156 | /* Destruction primitives. */ |
155 | 157 | ||
156 | /* Complete destruction of ipq. */ | ||
157 | static void ip_frag_destroy(struct ipq *qp, int *work) | ||
158 | { | ||
159 | struct sk_buff *fp; | ||
160 | |||
161 | BUG_TRAP(qp->q.last_in&COMPLETE); | ||
162 | BUG_TRAP(del_timer(&qp->q.timer) == 0); | ||
163 | |||
164 | if (qp->peer) | ||
165 | inet_putpeer(qp->peer); | ||
166 | |||
167 | /* Release all fragment data. */ | ||
168 | fp = qp->q.fragments; | ||
169 | while (fp) { | ||
170 | struct sk_buff *xp = fp->next; | ||
171 | |||
172 | frag_kfree_skb(fp, work); | ||
173 | fp = xp; | ||
174 | } | ||
175 | |||
176 | /* Finally, release the queue descriptor itself. */ | ||
177 | frag_free_queue(qp, work); | ||
178 | } | ||
179 | |||
180 | static __inline__ void ipq_put(struct ipq *ipq, int *work) | 158 | static __inline__ void ipq_put(struct ipq *ipq, int *work) |
181 | { | 159 | { |
182 | if (atomic_dec_and_test(&ipq->q.refcnt)) | 160 | if (atomic_dec_and_test(&ipq->q.refcnt)) |
183 | ip_frag_destroy(ipq, work); | 161 | inet_frag_destroy(&ipq->q, &ip4_frags, work); |
184 | } | 162 | } |
185 | 163 | ||
186 | /* Kill ipq entry. It is not destroyed immediately, | 164 | /* Kill ipq entry. It is not destroyed immediately, |
@@ -721,6 +699,9 @@ void __init ipfrag_init(void) | |||
721 | { | 699 | { |
722 | ip4_frags.ctl = &ip4_frags_ctl; | 700 | ip4_frags.ctl = &ip4_frags_ctl; |
723 | ip4_frags.hashfn = ip4_hashfn; | 701 | ip4_frags.hashfn = ip4_hashfn; |
702 | ip4_frags.destructor = ip4_frag_free; | ||
703 | ip4_frags.skb_free = NULL; | ||
704 | ip4_frags.qsize = sizeof(struct ipq); | ||
724 | inet_frags_init(&ip4_frags); | 705 | inet_frags_init(&ip4_frags); |
725 | } | 706 | } |
726 | 707 | ||