35
35
#define NET_IPQ_QMAX 2088
36
36
#define NET_IPQ_QMAX_NAME "ip_queue_maxlen"
37
37
38
- struct ipq_queue_entry {
39
- struct list_head list ;
40
- struct nf_info * info ;
41
- struct sk_buff * skb ;
42
- };
43
-
44
- typedef int (* ipq_cmpfn )(struct ipq_queue_entry * , unsigned long );
38
+ typedef int (* ipq_cmpfn )(struct nf_queue_entry * , unsigned long );
45
39
46
40
static unsigned char copy_mode __read_mostly = IPQ_COPY_NONE ;
47
41
static unsigned int queue_maxlen __read_mostly = IPQ_QMAX_DEFAULT ;
@@ -56,22 +50,20 @@ static LIST_HEAD(queue_list);
56
50
static DEFINE_MUTEX (ipqnl_mutex );
57
51
58
52
static void
59
- ipq_issue_verdict (struct ipq_queue_entry * entry , int verdict )
53
+ ipq_issue_verdict (struct nf_queue_entry * entry , int verdict )
60
54
{
61
55
/* TCP input path (and probably other bits) assume to be called
62
56
* from softirq context, not from syscall, like ipq_issue_verdict is
63
57
* called. TCP input path deadlocks with locks taken from timer
64
58
* softirq, e.g. We therefore emulate this by local_bh_disable() */
65
59
66
60
local_bh_disable ();
67
- nf_reinject (entry -> skb , entry -> info , verdict );
61
+ nf_reinject (entry , verdict );
68
62
local_bh_enable ();
69
-
70
- kfree (entry );
71
63
}
72
64
73
65
static inline void
74
- __ipq_enqueue_entry (struct ipq_queue_entry * entry )
66
+ __ipq_enqueue_entry (struct nf_queue_entry * entry )
75
67
{
76
68
list_add_tail (& entry -> list , & queue_list );
77
69
queue_total ++ ;
@@ -114,10 +106,10 @@ __ipq_reset(void)
114
106
__ipq_flush (NULL , 0 );
115
107
}
116
108
117
- static struct ipq_queue_entry *
109
+ static struct nf_queue_entry *
118
110
ipq_find_dequeue_entry (unsigned long id )
119
111
{
120
- struct ipq_queue_entry * entry = NULL , * i ;
112
+ struct nf_queue_entry * entry = NULL , * i ;
121
113
122
114
write_lock_bh (& queue_lock );
123
115
@@ -140,7 +132,7 @@ ipq_find_dequeue_entry(unsigned long id)
140
132
static void
141
133
__ipq_flush (ipq_cmpfn cmpfn , unsigned long data )
142
134
{
143
- struct ipq_queue_entry * entry , * next ;
135
+ struct nf_queue_entry * entry , * next ;
144
136
145
137
list_for_each_entry_safe (entry , next , & queue_list , list ) {
146
138
if (!cmpfn || cmpfn (entry , data )) {
@@ -160,7 +152,7 @@ ipq_flush(ipq_cmpfn cmpfn, unsigned long data)
160
152
}
161
153
162
154
static struct sk_buff *
163
- ipq_build_packet_message (struct ipq_queue_entry * entry , int * errp )
155
+ ipq_build_packet_message (struct nf_queue_entry * entry , int * errp )
164
156
{
165
157
sk_buff_data_t old_tail ;
166
158
size_t size = 0 ;
@@ -217,20 +209,20 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp)
217
209
pmsg -> timestamp_sec = tv .tv_sec ;
218
210
pmsg -> timestamp_usec = tv .tv_usec ;
219
211
pmsg -> mark = entry -> skb -> mark ;
220
- pmsg -> hook = entry -> info -> hook ;
212
+ pmsg -> hook = entry -> hook ;
221
213
pmsg -> hw_protocol = entry -> skb -> protocol ;
222
214
223
- if (entry -> info -> indev )
224
- strcpy (pmsg -> indev_name , entry -> info -> indev -> name );
215
+ if (entry -> indev )
216
+ strcpy (pmsg -> indev_name , entry -> indev -> name );
225
217
else
226
218
pmsg -> indev_name [0 ] = '\0' ;
227
219
228
- if (entry -> info -> outdev )
229
- strcpy (pmsg -> outdev_name , entry -> info -> outdev -> name );
220
+ if (entry -> outdev )
221
+ strcpy (pmsg -> outdev_name , entry -> outdev -> name );
230
222
else
231
223
pmsg -> outdev_name [0 ] = '\0' ;
232
224
233
- if (entry -> info -> indev && entry -> skb -> dev ) {
225
+ if (entry -> indev && entry -> skb -> dev ) {
234
226
pmsg -> hw_type = entry -> skb -> dev -> type ;
235
227
pmsg -> hw_addrlen = dev_parse_header (entry -> skb ,
236
228
pmsg -> hw_addr );
@@ -252,28 +244,17 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp)
252
244
}
253
245
254
246
static int
255
- ipq_enqueue_packet (struct sk_buff * skb , struct nf_info * info ,
256
- unsigned int queuenum )
247
+ ipq_enqueue_packet (struct nf_queue_entry * entry , unsigned int queuenum )
257
248
{
258
249
int status = - EINVAL ;
259
250
struct sk_buff * nskb ;
260
- struct ipq_queue_entry * entry ;
261
251
262
252
if (copy_mode == IPQ_COPY_NONE )
263
253
return - EAGAIN ;
264
254
265
- entry = kmalloc (sizeof (* entry ), GFP_ATOMIC );
266
- if (entry == NULL ) {
267
- printk (KERN_ERR "ip_queue: OOM in ipq_enqueue_packet()\n" );
268
- return - ENOMEM ;
269
- }
270
-
271
- entry -> info = info ;
272
- entry -> skb = skb ;
273
-
274
255
nskb = ipq_build_packet_message (entry , & status );
275
256
if (nskb == NULL )
276
- goto err_out_free ;
257
+ return status ;
277
258
278
259
write_lock_bh (& queue_lock );
279
260
@@ -307,14 +288,11 @@ ipq_enqueue_packet(struct sk_buff *skb, struct nf_info *info,
307
288
308
289
err_out_unlock :
309
290
write_unlock_bh (& queue_lock );
310
-
311
- err_out_free :
312
- kfree (entry );
313
291
return status ;
314
292
}
315
293
316
294
static int
317
- ipq_mangle_ipv4 (ipq_verdict_msg_t * v , struct ipq_queue_entry * e )
295
+ ipq_mangle_ipv4 (ipq_verdict_msg_t * v , struct nf_queue_entry * e )
318
296
{
319
297
int diff ;
320
298
int err ;
@@ -352,7 +330,7 @@ ipq_mangle_ipv4(ipq_verdict_msg_t *v, struct ipq_queue_entry *e)
352
330
static int
353
331
ipq_set_verdict (struct ipq_verdict_msg * vmsg , unsigned int len )
354
332
{
355
- struct ipq_queue_entry * entry ;
333
+ struct nf_queue_entry * entry ;
356
334
357
335
if (vmsg -> value > NF_MAX_VERDICT )
358
336
return - EINVAL ;
@@ -412,13 +390,13 @@ ipq_receive_peer(struct ipq_peer_msg *pmsg,
412
390
}
413
391
414
392
static int
415
- dev_cmp (struct ipq_queue_entry * entry , unsigned long ifindex )
393
+ dev_cmp (struct nf_queue_entry * entry , unsigned long ifindex )
416
394
{
417
- if (entry -> info -> indev )
418
- if (entry -> info -> indev -> ifindex == ifindex )
395
+ if (entry -> indev )
396
+ if (entry -> indev -> ifindex == ifindex )
419
397
return 1 ;
420
- if (entry -> info -> outdev )
421
- if (entry -> info -> outdev -> ifindex == ifindex )
398
+ if (entry -> outdev )
399
+ if (entry -> outdev -> ifindex == ifindex )
422
400
return 1 ;
423
401
#ifdef CONFIG_BRIDGE_NETFILTER
424
402
if (entry -> skb -> nf_bridge ) {
0 commit comments