mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-18 18:23:53 +08:00
[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>
This commit is contained in:
parent
bb97d31f51
commit
2669d63d20
@ -40,7 +40,7 @@ MODULE_PARM_DESC(master_timeout, "timeout for the master connection");
|
||||
static char *conns[] = { "DATA ", "MESG ", "INDEX " };
|
||||
|
||||
/* This is slow, but it's simple. --RR */
|
||||
static char amanda_buffer[65536];
|
||||
static char *amanda_buffer;
|
||||
static DEFINE_SPINLOCK(amanda_buffer_lock);
|
||||
|
||||
unsigned int (*ip_nat_amanda_hook)(struct sk_buff **pskb,
|
||||
@ -153,11 +153,25 @@ static struct ip_conntrack_helper amanda_helper = {
|
||||
static void __exit fini(void)
|
||||
{
|
||||
ip_conntrack_helper_unregister(&amanda_helper);
|
||||
kfree(amanda_buffer);
|
||||
}
|
||||
|
||||
static int __init init(void)
|
||||
{
|
||||
return ip_conntrack_helper_register(&amanda_helper);
|
||||
int ret;
|
||||
|
||||
amanda_buffer = kmalloc(65536, GFP_KERNEL);
|
||||
if (!amanda_buffer)
|
||||
return -ENOMEM;
|
||||
|
||||
ret = ip_conntrack_helper_register(&amanda_helper);
|
||||
if (ret < 0) {
|
||||
kfree(amanda_buffer);
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
module_init(init);
|
||||
|
@ -25,8 +25,7 @@ MODULE_AUTHOR("Rusty Russell <rusty@rustcorp.com.au>");
|
||||
MODULE_DESCRIPTION("ftp connection tracking helper");
|
||||
|
||||
/* This is slow, but it's simple. --RR */
|
||||
static char ftp_buffer[65536];
|
||||
|
||||
static char *ftp_buffer;
|
||||
static DEFINE_SPINLOCK(ip_ftp_lock);
|
||||
|
||||
#define MAX_PORTS 8
|
||||
@ -461,6 +460,8 @@ static void fini(void)
|
||||
ports[i]);
|
||||
ip_conntrack_helper_unregister(&ftp[i]);
|
||||
}
|
||||
|
||||
kfree(ftp_buffer);
|
||||
}
|
||||
|
||||
static int __init init(void)
|
||||
@ -468,6 +469,10 @@ static int __init init(void)
|
||||
int i, ret;
|
||||
char *tmpname;
|
||||
|
||||
ftp_buffer = kmalloc(65536, GFP_KERNEL);
|
||||
if (!ftp_buffer)
|
||||
return -ENOMEM;
|
||||
|
||||
if (ports_c == 0)
|
||||
ports[ports_c++] = FTP_PORT;
|
||||
|
||||
|
@ -39,7 +39,7 @@ static int ports_c;
|
||||
static int max_dcc_channels = 8;
|
||||
static unsigned int dcc_timeout = 300;
|
||||
/* This is slow, but it's simple. --RR */
|
||||
static char irc_buffer[65536];
|
||||
static char *irc_buffer;
|
||||
static DEFINE_SPINLOCK(irc_buffer_lock);
|
||||
|
||||
unsigned int (*ip_nat_irc_hook)(struct sk_buff **pskb,
|
||||
@ -258,6 +258,10 @@ static int __init init(void)
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
irc_buffer = kmalloc(65536, GFP_KERNEL);
|
||||
if (!irc_buffer)
|
||||
return -ENOMEM;
|
||||
|
||||
/* If no port given, default to standard irc port */
|
||||
if (ports_c == 0)
|
||||
ports[ports_c++] = IRC_PORT;
|
||||
@ -304,6 +308,7 @@ static void fini(void)
|
||||
ports[i]);
|
||||
ip_conntrack_helper_unregister(&irc_helpers[i]);
|
||||
}
|
||||
kfree(irc_buffer);
|
||||
}
|
||||
|
||||
module_init(init);
|
||||
|
Loading…
Reference in New Issue
Block a user