aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv6')
-rw-r--r--net/ipv6/netfilter/nf_conntrack_reasm.c44
-rw-r--r--net/ipv6/reassembly.c32
2 files changed, 19 insertions, 57 deletions
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
index a3aef387bcfb..785f5cda188e 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -114,25 +114,25 @@ static unsigned int nf_hashfn(struct inet_frag_queue *q)
114 return ip6qhashfn(nq->id, &nq->saddr, &nq->daddr); 114 return ip6qhashfn(nq->id, &nq->saddr, &nq->daddr);
115} 115}
116 116
117static void nf_skb_free(struct sk_buff *skb)
118{
119 if (NFCT_FRAG6_CB(skb)->orig)
120 kfree_skb(NFCT_FRAG6_CB(skb)->orig);
121}
122
117/* Memory Tracking Functions. */ 123/* Memory Tracking Functions. */
118static inline void frag_kfree_skb(struct sk_buff *skb, unsigned int *work) 124static inline void frag_kfree_skb(struct sk_buff *skb, unsigned int *work)
119{ 125{
120 if (work) 126 if (work)
121 *work -= skb->truesize; 127 *work -= skb->truesize;
122 atomic_sub(skb->truesize, &nf_frags.mem); 128 atomic_sub(skb->truesize, &nf_frags.mem);
123 if (NFCT_FRAG6_CB(skb)->orig) 129 nf_skb_free(skb);
124 kfree_skb(NFCT_FRAG6_CB(skb)->orig);
125
126 kfree_skb(skb); 130 kfree_skb(skb);
127} 131}
128 132
129static inline void frag_free_queue(struct nf_ct_frag6_queue *fq, 133static void nf_frag_free(struct inet_frag_queue *q)
130 unsigned int *work)
131{ 134{
132 if (work) 135 kfree(container_of(q, struct nf_ct_frag6_queue, q));
133 *work -= sizeof(struct nf_ct_frag6_queue);
134 atomic_sub(sizeof(struct nf_ct_frag6_queue), &nf_frags.mem);
135 kfree(fq);
136} 136}
137 137
138static inline struct nf_ct_frag6_queue *frag_alloc_queue(void) 138static inline struct nf_ct_frag6_queue *frag_alloc_queue(void)
@@ -147,31 +147,10 @@ static inline struct nf_ct_frag6_queue *frag_alloc_queue(void)
147 147
148/* Destruction primitives. */ 148/* Destruction primitives. */
149 149
150/* Complete destruction of fq. */
151static void nf_ct_frag6_destroy(struct nf_ct_frag6_queue *fq,
152 unsigned int *work)
153{
154 struct sk_buff *fp;
155
156 BUG_TRAP(fq->q.last_in&COMPLETE);
157 BUG_TRAP(del_timer(&fq->q.timer) == 0);
158
159 /* Release all fragment data. */
160 fp = fq->q.fragments;
161 while (fp) {
162 struct sk_buff *xp = fp->next;
163
164 frag_kfree_skb(fp, work);
165 fp = xp;
166 }
167
168 frag_free_queue(fq, work);
169}
170
171static __inline__ void fq_put(struct nf_ct_frag6_queue *fq, unsigned int *work) 150static __inline__ void fq_put(struct nf_ct_frag6_queue *fq, unsigned int *work)
172{ 151{
173 if (atomic_dec_and_test(&fq->q.refcnt)) 152 if (atomic_dec_and_test(&fq->q.refcnt))
174 nf_ct_frag6_destroy(fq, work); 153 inet_frag_destroy(&fq->q, &nf_frags, work);
175} 154}
176 155
177/* Kill fq entry. It is not destroyed immediately, 156/* Kill fq entry. It is not destroyed immediately,
@@ -799,6 +778,9 @@ int nf_ct_frag6_init(void)
799{ 778{
800 nf_frags.ctl = &nf_frags_ctl; 779 nf_frags.ctl = &nf_frags_ctl;
801 nf_frags.hashfn = nf_hashfn; 780 nf_frags.hashfn = nf_hashfn;
781 nf_frags.destructor = nf_frag_free;
782 nf_frags.skb_free = nf_skb_free;
783 nf_frags.qsize = sizeof(struct nf_ct_frag6_queue);
802 inet_frags_init(&nf_frags); 784 inet_frags_init(&nf_frags);
803 785
804 return 0; 786 return 0;
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index c7d4961bbcf7..940b7d2383ec 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -152,12 +152,9 @@ static inline void frag_kfree_skb(struct sk_buff *skb, int *work)
152 kfree_skb(skb); 152 kfree_skb(skb);
153} 153}
154 154
155static inline void frag_free_queue(struct frag_queue *fq, int *work) 155static void ip6_frag_free(struct inet_frag_queue *fq)
156{ 156{
157 if (work) 157 kfree(container_of(fq, struct frag_queue, q));
158 *work -= sizeof(struct frag_queue);
159 atomic_sub(sizeof(struct frag_queue), &ip6_frags.mem);
160 kfree(fq);
161} 158}
162 159
163static inline struct frag_queue *frag_alloc_queue(void) 160static inline struct frag_queue *frag_alloc_queue(void)
@@ -172,30 +169,10 @@ static inline struct frag_queue *frag_alloc_queue(void)
172 169
173/* Destruction primitives. */ 170/* Destruction primitives. */
174 171
175/* Complete destruction of fq. */
176static void ip6_frag_destroy(struct frag_queue *fq, int *work)
177{
178 struct sk_buff *fp;
179
180 BUG_TRAP(fq->q.last_in&COMPLETE);
181 BUG_TRAP(del_timer(&fq->q.timer) == 0);
182
183 /* Release all fragment data. */
184 fp = fq->q.fragments;
185 while (fp) {
186 struct sk_buff *xp = fp->next;
187
188 frag_kfree_skb(fp, work);
189 fp = xp;
190 }
191
192 frag_free_queue(fq, work);
193}
194
195static __inline__ void fq_put(struct frag_queue *fq, int *work) 172static __inline__ void fq_put(struct frag_queue *fq, int *work)
196{ 173{
197 if (atomic_dec_and_test(&fq->q.refcnt)) 174 if (atomic_dec_and_test(&fq->q.refcnt))
198 ip6_frag_destroy(fq, work); 175 inet_frag_destroy(&fq->q, &ip6_frags, work);
199} 176}
200 177
201/* Kill fq entry. It is not destroyed immediately, 178/* Kill fq entry. It is not destroyed immediately,
@@ -744,5 +721,8 @@ void __init ipv6_frag_init(void)
744 721
745 ip6_frags.ctl = &ip6_frags_ctl; 722 ip6_frags.ctl = &ip6_frags_ctl;
746 ip6_frags.hashfn = ip6_hashfn; 723 ip6_frags.hashfn = ip6_hashfn;
724 ip6_frags.destructor = ip6_frag_free;
725 ip6_frags.skb_free = NULL;
726 ip6_frags.qsize = sizeof(struct frag_queue);
747 inet_frags_init(&ip6_frags); 727 inet_frags_init(&ip6_frags);
748} 728}