]> git.ipfire.org Git - thirdparty/ulogd2.git/commitdiff
add support for setting of SO_RCVBUF socket option to libipulog and ulogd (rmem confi...
authorlaforge <laforge>
Sun, 4 May 2003 10:00:10 +0000 (10:00 +0000)
committerlaforge <laforge>
Sun, 4 May 2003 10:00:10 +0000 (10:00 +0000)
libipulog/include/libipulog/libipulog.h
libipulog/libipulog.c
ulogd.c
ulogd.conf.in

index 8a023c13e82df3b01411bf726c68b3dddbe7dd1c..307510cd3b81ca1e07cac123fea3aae3e6c8455c 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef _LIBIPULOG_H
 #define _LIBIPULOG_H
 
-/* $Id: libipulog.h,v 1.5 2002/07/30 07:04:12 laforge Exp $ */
+/* $Id: libipulog.h,v 1.6 2002/07/30 07:23:36 laforge Exp $ */
 
 #include <errno.h>
 #include <unistd.h>
@@ -24,7 +24,7 @@ extern int ipulog_errno;
 
 u_int32_t ipulog_group2gmask(u_int32_t group);
 
-struct ipulog_handle *ipulog_create_handle(u_int32_t gmask);
+struct ipulog_handle *ipulog_create_handle(u_int32_t gmask, u_int32_t rmem);
 
 void ipulog_destroy_handle(struct ipulog_handle *h);
 
@@ -39,4 +39,20 @@ char *ipulog_strerror(int errcode);
 
 void ipulog_perror(const char *s);
 
+enum 
+{
+       IPULOG_ERR_NONE = 0,
+       IPULOG_ERR_IMPL,
+       IPULOG_ERR_HANDLE,
+       IPULOG_ERR_SOCKET,
+       IPULOG_ERR_BIND,
+       IPULOG_ERR_RECVBUF,
+       IPULOG_ERR_RECV,
+       IPULOG_ERR_NLEOF,
+       IPULOG_ERR_TRUNC,
+       IPULOG_ERR_INVGR,
+       IPULOG_ERR_INVNL,
+};
+#define IPULOG_MAXERR IPULOG_ERR_INVNL
+
 #endif /* _LIBULOG_H */
index bee00385d4ea0cbf534bd6a389a5586201d5e8f7..0b82fee68dd0d7be0ae55b133e5abda4380c309d 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * libipulog.c, $Revision: 1.9 $
+ * libipulog.c, $Revision: 1.10 $
  *
  * netfilter ULOG userspace library.
  *
@@ -21,7 +21,7 @@
  * This library is still under development, so be aware of sudden interface
  * changes
  *
- * $Id: libipulog.c,v 1.9 2001/09/01 11:53:41 laforge Exp $
+ * $Id: libipulog.c,v 1.10 2002/07/30 07:04:12 laforge Exp $
  */
 
 #include <stdlib.h>
@@ -42,22 +42,6 @@ struct ipulog_handle
 
 /* internal */
 
-enum 
-{
-       IPULOG_ERR_NONE = 0,
-       IPULOG_ERR_IMPL,
-       IPULOG_ERR_HANDLE,
-       IPULOG_ERR_SOCKET,
-       IPULOG_ERR_BIND,
-       IPULOG_ERR_RECVBUF,
-       IPULOG_ERR_RECV,
-       IPULOG_ERR_NLEOF,
-       IPULOG_ERR_TRUNC,
-       IPULOG_ERR_INVGR,
-       IPULOG_ERR_INVNL,
-};
-
-#define IPULOG_MAXERR IPULOG_ERR_INVNL
 
 int ipulog_errno = IPULOG_ERR_NONE;
 
@@ -139,7 +123,8 @@ u_int32_t ipulog_group2gmask(u_int32_t group)
 }
 
 /* create a ipulog handle for the reception of packets sent to gmask */
-struct ipulog_handle *ipulog_create_handle(unsigned int gmask)
+struct ipulog_handle *ipulog_create_handle(u_int32_t gmask, 
+                                          u_int32_t rcvbufsize)
 {
        struct ipulog_handle *h;
        int status;
@@ -176,6 +161,16 @@ struct ipulog_handle *ipulog_create_handle(unsigned int gmask)
        h->peer.nl_pid = 0;
        h->peer.nl_groups = gmask;
 
+       status = setsockopt(h->fd, SOL_SOCKET, SO_RCVBUF, &rcvbufsize,
+                           sizeof(rcvbufsize));
+       if (status == -1)
+       {
+               ipulog_errno = IPULOG_ERR_RECVBUF;
+               close(h->fd);
+               free(h);
+               return NULL;
+       }
+
        return h;
 } 
 
diff --git a/ulogd.c b/ulogd.c
index 6325dd1d4c2ac0f5e5b7d7da9a046612faf04e3f..88ab5820128c8d6c184e7877e69207797a4a32d7 100644 (file)
--- a/ulogd.c
+++ b/ulogd.c
@@ -1,6 +1,6 @@
-/* ulogd, Version $Revision: 1.33 $
+/* ulogd, Version $Revision: 1.34 $
  *
- * $Id: ulogd.c,v 1.33 2003/02/08 12:21:18 laforge Exp $
+ * $Id: ulogd.c,v 1.34 2003/03/05 23:03:49 laforge Exp $
  *
  * userspace logging daemon for the iptables 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.33 2003/02/08 12:21:18 laforge Exp $
+ * $Id: ulogd.c,v 1.34 2003/03/05 23:03:49 laforge Exp $
  *
  * Modifications:
  *     14 Jun 2001 Martin Josefsson <gandalf@wlug.westbo.se>
 #include <ulogd/conffile.h>
 #include <ulogd/ulogd.h>
 
-/* 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 ULOGD_BUFSIZE_DEFAULT 65535
+/* Size of the socket recevive memory.  Should be at least the same size as the
+ * 'nlbufsiz' module loadtime parameter of ipt_ULOG.o
+ * If you have _big_ in-kernel queues, you may have to increase this number.  (
+ * --qthreshold 100 * 1500 bytes/packet = 150kB  */
+#define ULOGD_RMEM_DEFAULT     131071
+
+/* Size of the receive buffer for the netlink socket.  Should be at least of
+ * RMEM_DEFAULT size.  */
+#define ULOGD_BUFSIZE_DEFAULT  150000
 
 #ifdef DEBUG
 #define DEBUGP(format, args...) fprintf(stderr, format, ## args)
@@ -529,13 +534,16 @@ static config_entry_t nlgroup_ce = { &plugin_ce, "nlgroup", CONFIG_TYPE_INT,
 static config_entry_t loglevel_ce = { &nlgroup_ce, "loglevel", CONFIG_TYPE_INT,
                                      CONFIG_OPT_NONE, 0, 
                                      { value: 1 } };
+static config_entry_t rmem_ce = { &loglevel_ce, "rmem", CONFIG_TYPE_INT,
+                                 CONFIG_OPT_NONE, 0, 
+                                 { value: ULOGD_RMEM_DEFAULT } };
 
 static int init_conffile(char *file)
 {
        if (config_register_file(file))
                return 1;
 
-       config_register_key(&loglevel_ce);
+       config_register_key(&rmem_ce);
        
        /* parse config file the first time (for logfile name, ...) */
        return parse_conffile(0);
@@ -658,10 +666,10 @@ int main(int argc, char* argv[])
                ipulog_perror(NULL);
                exit(1);
        }
-       
+
        /* create ipulog handle */
-       libulog_h = 
-               ipulog_create_handle(ipulog_group2gmask(nlgroup_ce.u.value));
+       libulog_h = ipulog_create_handle(ipulog_group2gmask(nlgroup_ce.u.value),
+                                        rmem_ce.u.value);
 
        if (!libulog_h) {
                /* if some error occurrs, print it to stderr */
index c1b3bbbf7dbbbb4a25359680d35fe73c0329f44a..0a6b1e3a27a34d48e45fea65e8793c91e070b688 100644 (file)
@@ -1,5 +1,5 @@
 # Example configuration for ulogd
-# $Id: ulogd.conf,v 1.8 2002/07/30 07:15:54 laforge Exp $
+# $Id: ulogd.conf.in,v 1.1 2003/04/27 07:47:26 laforge Exp $
 #
 
 ######################################################################
@@ -15,9 +15,12 @@ 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
+# socket receive buffer size (should be at least the size of the
 # in-kernel buffer (ipt_ULOG.o 'nlbufsiz' parameter)
-bufsize 65535
+rmem 131071
+
+# libipulog/ulogd receive buffer size, should be > rmem
+bufsize 150000
 
 ######################################################################
 # PLUGIN OPTIONS