From 04004d5b08a271cee71da169fdc2b8a376c2cb0a Mon Sep 17 00:00:00 2001 From: laforge Date: Tue, 30 Jul 2002 07:15:54 +0000 Subject: make MYBUFSIZ constant a configuration parameter (bogdan dobrota) --- ulogd/ulogd.c | 23 +++++++++++++++++------ ulogd/ulogd.conf | 6 +++++- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/ulogd/ulogd.c b/ulogd/ulogd.c index 55ec461..e2564bf 100644 --- a/ulogd/ulogd.c +++ b/ulogd/ulogd.c @@ -1,6 +1,6 @@ -/* ulogd, Version $Revision: 1.25 $ +/* ulogd, Version $Revision: 1.26 $ * - * $Id: ulogd.c,v 1.25 2002/06/13 12:57:25 laforge Exp $ + * $Id: ulogd.c,v 1.26 2002/07/30 07:04:12 laforge Exp $ * * userspace logging daemon for the netfilter ULOG target * of the linux 2.4 netfilter subsystem. @@ -20,7 +20,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: ulogd.c,v 1.25 2002/06/13 12:57:25 laforge Exp $ + * $Id: ulogd.c,v 1.26 2002/07/30 07:04:12 laforge Exp $ * * Modifications: * 14 Jun 2001 Martin Josefsson @@ -51,7 +51,7 @@ /* Size of the netlink receive buffer. If you have _big_ in-kernel * queues, you may have to increase this number. * ( --qthreshold 100 * 1500 bytes/packet = 150kB */ -#define MYBUFSIZ 65535 +#define ULOGD_BUFSIZE_DEFAULT 65535 #ifdef DEBUG #define DEBUGP(format, args...) fprintf(stderr, format, ## args) @@ -506,7 +506,11 @@ static config_entry_t logf_ce = { NULL, "logfile", CONFIG_TYPE_STRING, CONFIG_OPT_NONE, 0, { string: ULOGD_LOGFILE_DEFAULT } }; -static config_entry_t plugin_ce = { &logf_ce, "plugin", CONFIG_TYPE_CALLBACK, +static config_entry_t bufsiz_ce = { &logf_ce, "bufsize", CONFIG_TYPE_INT, + CONFIG_OPT_NONE, 0, + { value: ULOGD_BUFSIZE_DEFAULT } }; + +static config_entry_t plugin_ce = { &bufsiz_ce, "plugin", CONFIG_TYPE_CALLBACK, CONFIG_OPT_MULTI, 0, { parser: &load_plugin } }; @@ -626,7 +630,14 @@ int main(int argc, char* argv[]) #endif /* allocate a receive buffer */ - libulog_buf = (unsigned char *) malloc(MYBUFSIZ); + libulog_buf = (unsigned char *) malloc(bufsiz_ce.u.value); + + if (!libulog_buf) { + ulogd_log(ULOGD_FATAL, "unable to allocate receive buffer" + "of %d bytes\n", bufsiz_ce.u.value); + ipulog_perror(NULL); + exit(1); + } /* create ipulog handle */ libulog_h = diff --git a/ulogd/ulogd.conf b/ulogd/ulogd.conf index a3a998a..e06a3ae 100644 --- a/ulogd/ulogd.conf +++ b/ulogd/ulogd.conf @@ -1,5 +1,5 @@ # Example configuration for ulogd -# $Id: ulogd.conf,v 1.6 2001/10/02 16:39:17 laforge Exp $ +# $Id: ulogd.conf,v 1.7 2002/07/30 07:04:12 laforge Exp $ # ###################################################################### @@ -15,6 +15,10 @@ logfile /var/log/ulogd.log # loglevel: debug(1), info(3), notice(5), error(7) or fatal(8) loglevel 5 +# libipulog receive buffer size (should be at least the size of the +# in-kernel buffer (ipt_ULOG.o 'nlbufsiz' parameter) +bufsize 65535 + ###################################################################### # PLUGIN OPTIONS ###################################################################### -- cgit v1.2.3