diff options
author | Patrick McHardy <kaber@trash.net> | 2006-02-27 16:02:52 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2006-02-27 16:02:52 -0500 |
commit | e02f7d1603c955126e88cc08149509d00be25cb9 (patch) | |
tree | ebd48da4b8cc55fb8070af70139e62e77a6f423c /net | |
parent | 752c1f4c78fe86d0fd6497387f763306b0d8fc53 (diff) |
[NETFILTER]: nf_queue: don't copy registered rerouter data
Use the registered data structure instead of copying it.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/netfilter/nf_queue.c | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/net/netfilter/nf_queue.c b/net/netfilter/nf_queue.c index d3a4f30a7f22..24ad41e6601b 100644 --- a/net/netfilter/nf_queue.c +++ b/net/netfilter/nf_queue.c | |||
@@ -16,7 +16,7 @@ | |||
16 | * for queueing and must reinject all packets it receives, no matter what. | 16 | * for queueing and must reinject all packets it receives, no matter what. |
17 | */ | 17 | */ |
18 | static struct nf_queue_handler *queue_handler[NPROTO]; | 18 | static struct nf_queue_handler *queue_handler[NPROTO]; |
19 | static struct nf_queue_rerouter *queue_rerouter; | 19 | static struct nf_queue_rerouter *queue_rerouter[NPROTO]; |
20 | 20 | ||
21 | static DEFINE_RWLOCK(queue_handler_lock); | 21 | static DEFINE_RWLOCK(queue_handler_lock); |
22 | 22 | ||
@@ -64,7 +64,7 @@ int nf_register_queue_rerouter(int pf, struct nf_queue_rerouter *rer) | |||
64 | return -EINVAL; | 64 | return -EINVAL; |
65 | 65 | ||
66 | write_lock_bh(&queue_handler_lock); | 66 | write_lock_bh(&queue_handler_lock); |
67 | memcpy(&queue_rerouter[pf], rer, sizeof(queue_rerouter[pf])); | 67 | queue_rerouter[pf] = rer; |
68 | write_unlock_bh(&queue_handler_lock); | 68 | write_unlock_bh(&queue_handler_lock); |
69 | 69 | ||
70 | return 0; | 70 | return 0; |
@@ -77,7 +77,7 @@ int nf_unregister_queue_rerouter(int pf) | |||
77 | return -EINVAL; | 77 | return -EINVAL; |
78 | 78 | ||
79 | write_lock_bh(&queue_handler_lock); | 79 | write_lock_bh(&queue_handler_lock); |
80 | memset(&queue_rerouter[pf], 0, sizeof(queue_rerouter[pf])); | 80 | queue_rerouter[pf] = NULL; |
81 | write_unlock_bh(&queue_handler_lock); | 81 | write_unlock_bh(&queue_handler_lock); |
82 | return 0; | 82 | return 0; |
83 | } | 83 | } |
@@ -123,7 +123,7 @@ int nf_queue(struct sk_buff **skb, | |||
123 | return 1; | 123 | return 1; |
124 | } | 124 | } |
125 | 125 | ||
126 | info = kmalloc(sizeof(*info)+queue_rerouter[pf].rer_size, GFP_ATOMIC); | 126 | info = kmalloc(sizeof(*info)+queue_rerouter[pf]->rer_size, GFP_ATOMIC); |
127 | if (!info) { | 127 | if (!info) { |
128 | if (net_ratelimit()) | 128 | if (net_ratelimit()) |
129 | printk(KERN_ERR "OOM queueing packet %p\n", | 129 | printk(KERN_ERR "OOM queueing packet %p\n", |
@@ -155,14 +155,14 @@ int nf_queue(struct sk_buff **skb, | |||
155 | if (physoutdev) dev_hold(physoutdev); | 155 | if (physoutdev) dev_hold(physoutdev); |
156 | } | 156 | } |
157 | #endif | 157 | #endif |
158 | if (queue_rerouter[pf].save) | 158 | if (queue_rerouter[pf]->save) |
159 | queue_rerouter[pf].save(*skb, info); | 159 | queue_rerouter[pf]->save(*skb, info); |
160 | 160 | ||
161 | status = queue_handler[pf]->outfn(*skb, info, queuenum, | 161 | status = queue_handler[pf]->outfn(*skb, info, queuenum, |
162 | queue_handler[pf]->data); | 162 | queue_handler[pf]->data); |
163 | 163 | ||
164 | if (status >= 0 && queue_rerouter[pf].reroute) | 164 | if (status >= 0 && queue_rerouter[pf]->reroute) |
165 | status = queue_rerouter[pf].reroute(skb, info); | 165 | status = queue_rerouter[pf]->reroute(skb, info); |
166 | 166 | ||
167 | read_unlock(&queue_handler_lock); | 167 | read_unlock(&queue_handler_lock); |
168 | 168 | ||
@@ -322,22 +322,12 @@ int __init netfilter_queue_init(void) | |||
322 | { | 322 | { |
323 | #ifdef CONFIG_PROC_FS | 323 | #ifdef CONFIG_PROC_FS |
324 | struct proc_dir_entry *pde; | 324 | struct proc_dir_entry *pde; |
325 | #endif | ||
326 | queue_rerouter = kmalloc(NPROTO * sizeof(struct nf_queue_rerouter), | ||
327 | GFP_KERNEL); | ||
328 | if (!queue_rerouter) | ||
329 | return -ENOMEM; | ||
330 | 325 | ||
331 | #ifdef CONFIG_PROC_FS | ||
332 | pde = create_proc_entry("nf_queue", S_IRUGO, proc_net_netfilter); | 326 | pde = create_proc_entry("nf_queue", S_IRUGO, proc_net_netfilter); |
333 | if (!pde) { | 327 | if (!pde) |
334 | kfree(queue_rerouter); | ||
335 | return -1; | 328 | return -1; |
336 | } | ||
337 | pde->proc_fops = &nfqueue_file_ops; | 329 | pde->proc_fops = &nfqueue_file_ops; |
338 | #endif | 330 | #endif |
339 | memset(queue_rerouter, 0, NPROTO * sizeof(struct nf_queue_rerouter)); | ||
340 | |||
341 | return 0; | 331 | return 0; |
342 | } | 332 | } |
343 | 333 | ||