diff options
author | Harald Welte <laforge@netfilter.org> | 2005-08-09 23:19:44 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2005-08-29 18:50:57 -0400 |
commit | 2669d63d20683828f673b606915957f3a070602d (patch) | |
tree | 7e8ab15a956035e63b22237ffdd6d0101b391589 | |
parent | bb97d31f5130d677644d9931ef38613d1164ec94 (diff) |
[NETFILTER]: move conntrack helper buffers from BSS to kmalloc()ed memory
According to DaveM, it is preferrable to have large data structures be
allocated dynamically from the module init() function rather than
putting them as static global variables into BSS.
This patch moves the conntrack helper packet buffers into dynamically
allocated memory.
Signed-off-by: Harald Welte <laforge@netfilter.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv4/netfilter/ip_conntrack_amanda.c | 18 | ||||
-rw-r--r-- | net/ipv4/netfilter/ip_conntrack_ftp.c | 9 | ||||
-rw-r--r-- | net/ipv4/netfilter/ip_conntrack_irc.c | 7 |
3 files changed, 29 insertions, 5 deletions
diff --git a/net/ipv4/netfilter/ip_conntrack_amanda.c b/net/ipv4/netfilter/ip_conntrack_amanda.c index 01e1b58322a9..be4c9eb3243f 100644 --- a/net/ipv4/netfilter/ip_conntrack_amanda.c +++ b/net/ipv4/netfilter/ip_conntrack_amanda.c | |||
@@ -40,7 +40,7 @@ MODULE_PARM_DESC(master_timeout, "timeout for the master connection"); | |||
40 | static char *conns[] = { "DATA ", "MESG ", "INDEX " }; | 40 | static char *conns[] = { "DATA ", "MESG ", "INDEX " }; |
41 | 41 | ||
42 | /* This is slow, but it's simple. --RR */ | 42 | /* This is slow, but it's simple. --RR */ |
43 | static char amanda_buffer[65536]; | 43 | static char *amanda_buffer; |
44 | static DEFINE_SPINLOCK(amanda_buffer_lock); | 44 | static DEFINE_SPINLOCK(amanda_buffer_lock); |
45 | 45 | ||
46 | unsigned int (*ip_nat_amanda_hook)(struct sk_buff **pskb, | 46 | unsigned int (*ip_nat_amanda_hook)(struct sk_buff **pskb, |
@@ -153,11 +153,25 @@ static struct ip_conntrack_helper amanda_helper = { | |||
153 | static void __exit fini(void) | 153 | static void __exit fini(void) |
154 | { | 154 | { |
155 | ip_conntrack_helper_unregister(&amanda_helper); | 155 | ip_conntrack_helper_unregister(&amanda_helper); |
156 | kfree(amanda_buffer); | ||
156 | } | 157 | } |
157 | 158 | ||
158 | static int __init init(void) | 159 | static int __init init(void) |
159 | { | 160 | { |
160 | return ip_conntrack_helper_register(&amanda_helper); | 161 | int ret; |
162 | |||
163 | amanda_buffer = kmalloc(65536, GFP_KERNEL); | ||
164 | if (!amanda_buffer) | ||
165 | return -ENOMEM; | ||
166 | |||
167 | ret = ip_conntrack_helper_register(&amanda_helper); | ||
168 | if (ret < 0) { | ||
169 | kfree(amanda_buffer); | ||
170 | return ret; | ||
171 | } | ||
172 | return 0; | ||
173 | |||
174 | |||
161 | } | 175 | } |
162 | 176 | ||
163 | module_init(init); | 177 | module_init(init); |
diff --git a/net/ipv4/netfilter/ip_conntrack_ftp.c b/net/ipv4/netfilter/ip_conntrack_ftp.c index 9658896f899a..3a2627db1729 100644 --- a/net/ipv4/netfilter/ip_conntrack_ftp.c +++ b/net/ipv4/netfilter/ip_conntrack_ftp.c | |||
@@ -25,8 +25,7 @@ MODULE_AUTHOR("Rusty Russell <rusty@rustcorp.com.au>"); | |||
25 | MODULE_DESCRIPTION("ftp connection tracking helper"); | 25 | MODULE_DESCRIPTION("ftp connection tracking helper"); |
26 | 26 | ||
27 | /* This is slow, but it's simple. --RR */ | 27 | /* This is slow, but it's simple. --RR */ |
28 | static char ftp_buffer[65536]; | 28 | static char *ftp_buffer; |
29 | |||
30 | static DEFINE_SPINLOCK(ip_ftp_lock); | 29 | static DEFINE_SPINLOCK(ip_ftp_lock); |
31 | 30 | ||
32 | #define MAX_PORTS 8 | 31 | #define MAX_PORTS 8 |
@@ -461,6 +460,8 @@ static void fini(void) | |||
461 | ports[i]); | 460 | ports[i]); |
462 | ip_conntrack_helper_unregister(&ftp[i]); | 461 | ip_conntrack_helper_unregister(&ftp[i]); |
463 | } | 462 | } |
463 | |||
464 | kfree(ftp_buffer); | ||
464 | } | 465 | } |
465 | 466 | ||
466 | static int __init init(void) | 467 | static int __init init(void) |
@@ -468,6 +469,10 @@ static int __init init(void) | |||
468 | int i, ret; | 469 | int i, ret; |
469 | char *tmpname; | 470 | char *tmpname; |
470 | 471 | ||
472 | ftp_buffer = kmalloc(65536, GFP_KERNEL); | ||
473 | if (!ftp_buffer) | ||
474 | return -ENOMEM; | ||
475 | |||
471 | if (ports_c == 0) | 476 | if (ports_c == 0) |
472 | ports[ports_c++] = FTP_PORT; | 477 | ports[ports_c++] = FTP_PORT; |
473 | 478 | ||
diff --git a/net/ipv4/netfilter/ip_conntrack_irc.c b/net/ipv4/netfilter/ip_conntrack_irc.c index 4a28f297d502..25438eec21a1 100644 --- a/net/ipv4/netfilter/ip_conntrack_irc.c +++ b/net/ipv4/netfilter/ip_conntrack_irc.c | |||
@@ -39,7 +39,7 @@ static int ports_c; | |||
39 | static int max_dcc_channels = 8; | 39 | static int max_dcc_channels = 8; |
40 | static unsigned int dcc_timeout = 300; | 40 | static unsigned int dcc_timeout = 300; |
41 | /* This is slow, but it's simple. --RR */ | 41 | /* This is slow, but it's simple. --RR */ |
42 | static char irc_buffer[65536]; | 42 | static char *irc_buffer; |
43 | static DEFINE_SPINLOCK(irc_buffer_lock); | 43 | static DEFINE_SPINLOCK(irc_buffer_lock); |
44 | 44 | ||
45 | unsigned int (*ip_nat_irc_hook)(struct sk_buff **pskb, | 45 | unsigned int (*ip_nat_irc_hook)(struct sk_buff **pskb, |
@@ -257,6 +257,10 @@ static int __init init(void) | |||
257 | printk("ip_conntrack_irc: dcc_timeout must be a positive integer\n"); | 257 | printk("ip_conntrack_irc: dcc_timeout must be a positive integer\n"); |
258 | return -EBUSY; | 258 | return -EBUSY; |
259 | } | 259 | } |
260 | |||
261 | irc_buffer = kmalloc(65536, GFP_KERNEL); | ||
262 | if (!irc_buffer) | ||
263 | return -ENOMEM; | ||
260 | 264 | ||
261 | /* If no port given, default to standard irc port */ | 265 | /* If no port given, default to standard irc port */ |
262 | if (ports_c == 0) | 266 | if (ports_c == 0) |
@@ -304,6 +308,7 @@ static void fini(void) | |||
304 | ports[i]); | 308 | ports[i]); |
305 | ip_conntrack_helper_unregister(&irc_helpers[i]); | 309 | ip_conntrack_helper_unregister(&irc_helpers[i]); |
306 | } | 310 | } |
311 | kfree(irc_buffer); | ||
307 | } | 312 | } |
308 | 313 | ||
309 | module_init(init); | 314 | module_init(init); |