summaryrefslogtreecommitdiffstats
path: root/util/db.c
Commit message (Collapse)AuthorAgeFilesLines
* Use stdint types everywhereFelix Janda2015-06-261-1/+1
| | | | Signed-off-by: Felix Janda <felix.janda@posteo.de>
* db: don't loose one packet on reconnectEric Leblond2014-01-261-1/+2
| | | | | | This patch improves database reconnection handling in ring buffer mode. Ulogd now redo the failed query and do not loose anymore one packet.
* db: cancel injection thread when terminatingEric Leblond2014-01-251-0/+17
| | | | | | Injection thread was not cancelled when a termination signal was sent. This was causing a crash in some cases. This patch fixes this by canceling the thread when a SIGTERM or SIGINT signal is received.
* db: db ring has precedence over backlog.Eric Leblond2013-05-211-5/+7
|
* db: disable SIGHUP if ring buffer is used.Eric Leblond2013-05-211-3/+8
| | | | | | | The handling of signal when using threads can be complicated. When ring buffer is used for query, this means ulogd will have to follow some sort of mutex. Thus, it is easier and better performance wise to disable the reload via SIGHUP when the ring buffer is used.
* db: add ring buffer for DB queryEric Leblond2013-05-211-12/+141
| | | | | | | | | | | This patch adds an optional ring buffer option which modify the way database queries are made. The main thread is only handling kernel message reading and query formatting. The SQL request is made in a separate dedicated thread. The idea is to try to avoid buffer overrun by minimizing the time requested to treat kernel message. Doing synchronous SQL request, as it was made before was causing a delay which could cause some messages to be lost in case of burst from kernel side.
* db: use offset instead of direct pointer.Eric Leblond2013-05-211-7/+9
| | | | | Use an offset approach to get the start of values printing area. It is more generic and will be use soon.
* db: suppress field in db structureEric Leblond2013-05-211-18/+18
| | | | | The field is currently only used in a single function as a string pointer and can thus be removed from the db instance structure.
* db: store data in memory during database downtimeEric Leblond2013-05-211-28/+142
| | | | | | | This patch is adding a mechanism to store query in a backlog build in memory. This allow to store events during downtime in memory and realize the effective insertion when the database comes back. A memory cap is used to avoid any memory flooding.
* Get rid of SVN tag in comment.Eric Leblond2013-01-181-2/+1
| | | | This patch also update some copyright and licence declaration.
* Support stored mysql procedures besides stored functionsJozsef Kadlecsik2012-01-161-0/+2
| | | | | | | | | | | MySQL stored procedures must be invoked by the "CALL" SQL command and not by "SELECT". Add the convention that if the procedure name starts with "CALL", then the issued SQL command is "CALL procedurename(args)". The stored procedure support in MySQL automatically brings transaction support too. Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
* DB output: fix crash in SIGHUP handlingEric Leblond2010-09-221-8/+15
| | | | | | This patch fixes the handling of SIGHUP when a SQL plugin is used. A freed structure was previoulsy used to build the request and this was leading to a crash.
* DB plugins: fixed bug with INSERT* proceduresRomain Bignon2009-04-181-10/+13
| | | | | | | When procedure begins with INSERT* (without space), it considers it as an INSERT statement. Signed-off-by: Romain Bignon <romain@inl.fr>
* DB plugin: add capability to specify complete INSERT commandEric Leblond2009-04-171-3/+8
| | | | | This patch modifies the procedure name parsing to be able to specify a complete INSERT command.
* db plugins: free memory at exit.Eric Leblond2009-03-101-0/+7
| | | | This patches frees an allocated buffer when ulogd is quitting.
* Allow plain INSERT instead of procedurePierre Chifflier2009-01-071-1/+26
| | | | | | | | | If the procedure name specified in configuration is INSERT, than use a regular insertion instead of a stored procedure. This should be used when performance is needed, with a flat SQL schema, to reduce the cost of SQL procedure calls. Signed-off-by: Pierre Chifflier <chifflier@inl.fr>
* cleanup: fix warning about integer formatEric Leblond2008-07-311-2/+3
| | | | | | | | This patch uses PRIu64 and PRId64 macros from inttypes.h to have a correct definition of 64 bit integer format for 64bits and 32bits arch. Signed-off-by: Eric Leblond <eric@inl.fr> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* cleanup: fix compilation warnings related to pointer comparisonsEric Leblond2008-07-311-1/+1
| | | | | | | | This patch cast to (char *) some (void *) to avoid a gcc warning in string format parsing. Signed-off-by: Eric Leblond <eric@inl.fr> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org
* cleanup: fix compilation warning related to signed and unsigned comparisonsEric Leblond2008-07-311-2/+2
| | | | | | This patch fixes the warning related to signed and unsigned comparaison. Signed-off-by: Eric Leblond <eric@inl.fr>
* cleanup: fix gcc warningsEric Leblond2008-07-291-4/+1
| | | | | | | | | This patch fixes some gcc warnings: * Unused variables * Functions with wrong return (or without return) Signed-off-by: Eric Leblond <eric@inl.fr> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* Fix a trivial typoEric Leblond2008-07-231-1/+1
| | | | | | | This patch fixes a trivial typo. Signed-off-by: Eric Leblond <eric@inl.fr> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* Fix computation of allocated size for queryEric Leblond2008-07-101-2/+3
| | | | | | | This patch fixes the computation of the allocation size for the query. It was not taking into account the length of the name of the procedure. Signed-off-by: Eric Leblond <eric@inl.fr>
* This patch suppress a now unused option. Each database module/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org2008-04-071-11/+0
| | | | | | have now to be used with a defined IP storage type. Signed-off-by: Eric Leblond <eric@inl.fr>
* This patch fixes a problem in SQL reconnection algorithm which is managed in/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org2008-04-051-2/+7
| | | | | | | | | | | | | | the db.c file for PgSQL and MySQL. In case of problem during request execution a new connection to the database was immediatly started without closing the previous one. The consequence was to block the database by having too much simultaneous open connections. This patch fixes the problem by disconnectinng from the database after a request failure and trying to reconnect after a delay which is by default of 2 secondes. This delay can be customized via the reconnect configuration variable in the database configuration section. Signed-off-by: Eric Leblond <eric@inl.fr>
* IP2BIN filter convert IP address from host storage to a "binary" string which/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org2008-03-251-1/+4
| | | | | | | | | | | can be use by MySQL. This is not strictly speaking raw data but it was of type RAW. Following remark from Hugo Mildenberger, I introduce in this patch a dedicated type ULOGD_RET_RAWSTR. The main reason not to use a ULOGD_RET_STRING parameter is that the paramater is not human readable. Signed-off-by: Eric Leblond <eric@inl.fr>
* From: Eric Leblond <eric@inl.fr>/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org2008-02-031-3/+1
| | | | | MySQL need no to be able to print RAW data to be able to display IP addresses.
* From: Eric leblond <eric@inl.fr>/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org2008-02-031-1/+1
| | | | This patch clarifies code which will be modified in next patch.
* From: Eric leblond <eric@inl.fr>/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org2008-02-031-19/+4
| | | | | | | | | This patch adds new SQL schema for MySQL and PGsql. The goal is to improve the one line per entry format. There is no more a big table with all fields because this sort of storage is causing bad performance (databases don't like to have a lot of NULL fields to store). Main changes are : * Add new schema for MySQL and PGsql * Use call to configurable procedure in SQL OUTPUT modules * Arguments of a procedure are given by the list of fields of a selected table
* Ulogd2: fix db OUTPUT system/C=EU/ST=EU/CN=Patrick McHardy/emailAddress=kaber@trash.net2008-01-121-1/+4
| | | | | | | | | | The following patch fixes MySQL and Pgsql output modules. The callback function was not correctly initialized and this was leading to a crash by calling the a NULL function. This patch correctly inits the callback. Eric Leblond <eric@inl.fr>
* db.c warning fix/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org2006-01-121-0/+2
| | | | Signed-off-by: Christian Hentschel <chentschel@people.netfilter.org>
* move error handling in plugin/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org2006-01-071-4/+1
|
* use driver's open_db routine/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org2005-12-151-1/+1
|
* forgot to rename some function calls with last commit/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org2005-12-151-2/+2
|
* don't "#include" a .c file but rather compile db.c on it's own/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org2005-12-151-54/+14
|
* close_db() is a member function and not a global symbol/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org2005-12-141-1/+2
|
* schema support fixes/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org2005-12-121-2/+3
|
* new database core api/C=DE/ST=Berlin/L=Berlin/O=Netfilter Project/OU=Development/CN=laforge/emailAddress=laforge@netfilter.org2005-12-081-0/+382