]> git.ipfire.org Git - thirdparty/ulogd2.git/log
thirdparty/ulogd2.git
3 years agoXML: support nflog pkt output
Ken-ichirou MATSUZAWA [Fri, 17 Sep 2021 22:08:23 +0000 (07:08 +0900)] 
XML: support nflog pkt output

plugin input type ULOGD_DTYPE_RAW was missing

Signed-off-by: Ken-ichirou MATSUZAWA <chamas@h4.dion.ne.jp>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
4 years agoprintpkt: print pkt mark like kernel
Cole Dishington [Mon, 24 May 2021 20:59:13 +0000 (08:59 +1200)] 
printpkt: print pkt mark like kernel

Print the pkt mark in hex with a preceding '0x', like the kernel prints
pkts logged by netfilter.

Signed-off-by: Cole Dishington <Cole.Dishington@alliedtelesis.co.nz>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
4 years agoraw2packet: fix comma instead of semicolon
Timon Ulrich [Fri, 30 Oct 2020 14:30:47 +0000 (15:30 +0100)] 
raw2packet: fix comma instead of semicolon

Signed-off-by: Timon Ulrich <t.ulrich@anapur.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
5 years agoulogd: printpkt: always print IPv6 protocol
Andreas Jaggi [Fri, 21 Feb 2020 06:40:36 +0000 (07:40 +0100)] 
ulogd: printpkt: always print IPv6 protocol

Print the protocol number for protocols not known by name.

Signed-off-by: Andreas Jaggi <andreas.jaggi@waterwave.ch>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
6 years agoIPFIX: Introduce template record support
Ander Juaristi [Fri, 26 Apr 2019 07:58:07 +0000 (09:58 +0200)] 
IPFIX: Introduce template record support

This commit adds the ability to send template records
to the remote collector.

In addition, it also introduces a new
configuration parameter 'send_template', which tells when template
records should be sent. It accepts the following string values:

 - "once": Send the template record only the first time (might be coalesced
    with data records).
 - "always": Send the template record always, with every data record that is sent
    to the collector (multiple data records might be sent together).
 - "never": Assume the collector knows the schema already. Do not send template records.

If omitted, the default value for 'send_template' is "once".

Signed-off-by: Ander Juaristi <a@juaristi.eus>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
6 years agoIPFIX: Add IPFIX output plugin
Ander Juaristi [Fri, 26 Apr 2019 07:58:06 +0000 (09:58 +0200)] 
IPFIX: Add IPFIX output plugin

This patch adds an IPFIX output plugin to ulogd2. It generates NetFlow/IPFIX
traces and sends them to a remote server (collector) via TCP or UDP.

Based on original work by Holger Eitzenberger <holger@eitzenberger.org>.

How to test this
----------------

I am currently testing this with the NFCT input and Wireshark.

Place the following in ulogd.conf:

      # this will print all flows on screen
      loglevel=1

      # load NFCT and IPFIX plugins
      plugin="/lib/ulogd/ulogd_inpflow_NFCT.so"
      plugin="/lib/ulogd/ulogd_output_IPFIX.so"

      stack=ct1:NFCT,ipfix1:IPFIX

      [ct1]
      netlink_socket_buffer_size=217088
      netlink_socket_buffer_maxsize=1085440
      accept_proto_filter=tcp,sctp

      [ipfix1]
      oid=1
      host="127.0.0.1"
      #port=4739
      #send_template="once"

I am currently testing it by launching a plain NetCat listener on port
4739 (the default for IPFIX) and then running Wireshark and see that it
dissects the IPFIX/NetFlow traffic correctly (obviously this relies on
the Wireshark NetFlow dissector being correct).

First:

      nc -vvvv -l 127.0.0.1 4739

Then:

      sudo ulogd -vc ulogd.conf

Signed-off-by: Ander Juaristi <a@juaristi.eus>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
6 years agoulogd: fix build with musl libc
Cameron Norman [Sat, 27 Oct 2018 20:05:45 +0000 (13:05 -0700)] 
ulogd: fix build with musl libc

The attached patch fixes building ulogd2 with musl libc. It is being
used on Void Linux right now.

Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1278
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
7 years agoulogd: json: send messages to a remote host / unix socket
Andreas Jaggi [Wed, 30 May 2018 20:15:36 +0000 (22:15 +0200)] 
ulogd: json: send messages to a remote host / unix socket

Extend the JSON output plugin so that the generated JSON stream can be
sent to a remote host via TCP/UDP or to a local unix socket.

Signed-off-by: Andreas Jaggi <andreas.jaggi@waterwave.ch>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
7 years agoremove ulogd2.rotate and ulogd2.spec from Makefile.am ulogd-2.0.7
Arturo Borrero Gonzalez [Thu, 26 Apr 2018 22:58:00 +0000 (00:58 +0200)] 
remove ulogd2.rotate and ulogd2.spec from Makefile.am

Fixes: 42b384044dab ("ulogd2: cleanup downstream files")
Signed-off-by: Arturo Borrero Gonzalez <arturo@netfilter.org>
7 years agoSet release number to 2.0.7.
Arturo Borrero Gonzalez [Thu, 26 Apr 2018 22:53:53 +0000 (00:53 +0200)] 
Set release number to 2.0.7.

Signed-off-by: Arturo Borrero Gonzalez <arturo@netfilter.org>
7 years agoulogd2: cleanup downstream files
Arturo Borrero Gonzalez [Tue, 3 Apr 2018 10:08:09 +0000 (12:08 +0200)] 
ulogd2: cleanup downstream files

These files are outdated and they belong to downstream users (distributions).
Providing outdated and unmaintained files here serves no purpose other than
confusing users and annoy packagers.

If an user is using ulogd2 directly from the source tarball, I would expect it
to be proficient enough to generate these files by itself.

Signed-off-by: Arturo Borrero Gonzalez <arturo@netfilter.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
7 years agoulogd: load all plugins by default
Arturo Borrero Gonzalez [Mon, 2 Oct 2017 13:06:49 +0000 (15:06 +0200)] 
ulogd: load all plugins by default

This new configuration behaviour option eases a bit the configuration of ulogd2
by allowing to load all plugins in one go, without having to know their full
path.

Choosing concrete plugins and using full path for them is great for some
environmnets, but I don't think it's a common case. The common case is to
load all plugins, even ignoring where do they live in the filesystem.

Even worse, the full path may be architecture-dependant, which makes copying
the ulogd.conf file between machines unnecesarily complex.

To experiment this new behaviour, don't put any 'plugin=' directive in the
config file. Plugins will be loaded from a default directory, choosen at
build/configure time (--with-ulogd2libdir). If no specified, this is something
like '/usr/local/lib/ulogd/'.

This new configuration option doesn't implement any special logic. We simply
open the dir and try to load all files ending with '.so'.

The log message level for plugins loading is increased so users can see by
default which plugins are loaded.

Signed-off-by: Arturo Borrero Gonzalez <arturo@netfilter.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
7 years agoulogd: use a RT scheduler by default
Arturo Borrero Gonzalez [Thu, 7 Sep 2017 11:36:53 +0000 (13:36 +0200)] 
ulogd: use a RT scheduler by default

Is common that ulogd runs in scenarios where a lot of packets are to be logged.
If there are more packets than ulogd can handle, users can start seing log
messages like this:

 ulogd[556]: We are losing events. Please, consider using the clauses \
 `netlink_socket_buffer_size' and `netlink_socket_buffer_maxsize'

Which means that Netlink buffer overrun have happened.
There are several approaches to prevent this situation:

 * in the ruleset, limit the amount of packet queued for log
 * in the ruleset, instruct the kernel to use a queue-threshold
 * from userspace, increment Netlink buffer sizes
 * from userspace, configure ulogd to run as high priority process

The first 3 method can be configured by users at runtime.
This patch deals with the last method. SCHED_RR is configured by default,
with no associated configuration parameter for users, since I believe
this is common enough, and should produce no harm.

A similar approach is used in the conntrackd daemon.

Signed-off-by: Arturo Borrero Gonzalez <arturo@netfilter.org>
Acked-by: Eric Leblond <eric@regit.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
8 years agoip2bin: fix plugin link for some compiler
Eric Leblond [Sun, 2 Jul 2017 15:57:54 +0000 (17:57 +0200)] 
ip2bin: fix plugin link for some compiler

Declaring a function inline and building with -O0 was causing the
following message:
 undefined symbol: uint32_to_ipv6
By declaring the function as static we fix the problem.

8 years agoulogd: fix crash when plugin version are incorrect
Eric Leblond [Sat, 1 Jul 2017 23:20:48 +0000 (01:20 +0200)] 
ulogd: fix crash when plugin version are incorrect

Format string in error message had more arguments than given and
it was resulting in a crash at start.

8 years agoSet release number to 2.0.6.
Eric Leblond [Mon, 15 May 2017 22:07:56 +0000 (00:07 +0200)] 
Set release number to 2.0.6.

8 years agorotate all default output files
Kaarle Ritvanen [Mon, 27 Mar 2017 18:43:39 +0000 (21:43 +0300)] 
rotate all default output files

Signed-off-by: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
8 years agoharmonize log file defaults with ulogd.conf
Kaarle Ritvanen [Mon, 27 Mar 2017 18:43:38 +0000 (21:43 +0300)] 
harmonize log file defaults with ulogd.conf

Signed-off-by: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
8 years agoulogd.conf: fix incorrect stack
Eric Leblond [Tue, 21 Mar 2017 21:08:58 +0000 (22:08 +0100)] 
ulogd.conf: fix incorrect stack

The stack was not correctly defined triggering an error on
type conflict.

Signed-off-by: Eric Leblond <eric@regit.org>
8 years agoulogd: use strncpy instead of memcpy
Eric Leblond [Tue, 21 Mar 2017 20:49:46 +0000 (21:49 +0100)] 
ulogd: use strncpy instead of memcpy

On some architecture, ulogd is not starting due to a
crash in memcpy. This patch switches to strncpy to
avoid the problem.

Reported-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Signed-off-by: Eric Leblond <eric@regit.org>
8 years agoulogd: add automake option
Eric Leblond [Thu, 31 Mar 2016 07:17:46 +0000 (09:17 +0200)] 
ulogd: add automake option

This option will be needed for future version of automake.

Signed-off-by: Eric Leblond <eric@regit.org>
8 years agoulogd: fix crash when ipv4 packet is truncated
Liping Zhang [Tue, 11 Oct 2016 14:22:27 +0000 (22:22 +0800)] 
ulogd: fix crash when ipv4 packet is truncated

If ipv4 packet is truncated, we should not try to dereference the
iph pointer. Otherwise, if the user add such iptables rules
"-j NFLOG --nflog-size 0", we will dereference the NULL pointer
and crash may happen.

Reported-by: Chris Caputo <ccaputo@alt.net>
Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
9 years agoulogd: fix indentation in acinclude.m4
Eric Leblond [Thu, 31 Mar 2016 06:45:19 +0000 (08:45 +0200)] 
ulogd: fix indentation in acinclude.m4

Some imbricated tests were not indented.

Signed-off-by: Eric Leblond <eric@regit.org>
9 years agoulogd: fix cross compilation errors with mysql_config
Helmut Schaa [Fri, 18 Mar 2016 14:43:24 +0000 (15:43 +0100)] 
ulogd: fix cross compilation errors with mysql_config

When cross-compiling ulogd, mysql_config and pg_config will return build host
configuration not build target configuration. This leads to build failures
if mysql_config is installed on the host system but mysql is not available
on the build target.

Fix this by not using mysql_config and pg_config for cross-compilation.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
9 years agoulogd: add missing newline in log message
Eric Leblond [Fri, 5 Feb 2016 10:55:26 +0000 (11:55 +0100)] 
ulogd: add missing newline in log message

9 years agoulogd: restructures signal handling by self-pipe trick
Hironobu Ishii [Tue, 2 Feb 2016 14:01:41 +0000 (23:01 +0900)] 
ulogd: restructures signal handling by self-pipe trick

ulogd had a critical bug that is calling Async-Signal-Unsafe functions
in signal hander context.
  - Most of libc functions like fopen(), malloc() are Async-Signal-Unsafe.
    So you should not call these functions in signal handler context.
  - Calling pluginstances in signal handler context is danger.
    For implementer of pluginstances, it is very hard to recognize their
    functions are called in signal handler context.

To solve the issue, I restructured signal handling by self-pipe trick.
For more detail on self-pipe trick, please see the following.
https://lwn.net/Articles/177897/

This patch will solve various symptoms like following.
  - Deadlock
  - Segmentation fault caused by libc management data corruption,
  - Other unpredictable behavior.

Deadlock example
================
This bug was already filed at:
https://bugzilla.netfilter.org/show_bug.cgi?id=1030

I also hit this bug. The backtrace of this issue is following.
In this case, main thread was calling ctime(),
and signal handler called localtime_r().
That caused the dead lock while getting tzset_lock in __tz_convert().
Because vsyslog() is Async-Signal-Unsafe function, we cannot call
this function in signal handler context.

 (gdb) bt
 #0  __lll_lock_wait_private () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
 #1  0x00007f3c3fc7e4ac in _L_lock_2462 () at tzset.c:621
 #2  0x00007f3c3fc7e2e7 in __tz_convert (timer=0x7f3c3ff8bf00 <tzset_lock>,
     timer@entry=0x7fffcfa923b8, use_localtime=use_localtime@entry=1,
     tp=tp@entry=0x7fffcfa92400) at tzset.c:624
 #3  0x00007f3c3fc7c28d in __localtime_r (t=t@entry=0x7fffcfa923b8,
     tp=tp@entry=0x7fffcfa92400) at localtime.c:32
 #4  0x00007f3c3fcbf1ba in __GI___vsyslog_chk (pri=<optimized out>, flag=1,
     fmt=0x406fa8 "signal received, calling pluginstances\n", ap=0x7fffcfa924a0)
     at ../misc/syslog.c:199
 #5  0x00000000004037b5 in __ulogd_log ()
 #6  0x00000000004047be in signal_handler ()
 #7  <signal handler called>
 #8  0x00007f3c3fcb62f5 in __GI___xstat (vers=<optimized out>,
     name=0x7f3c3fd4b2c3 "/etc/localtime", buf=0x7fffcfa92c10)
     at ../sysdeps/unix/sysv/linux/wordsize-64/xstat.c:37
 #9  0x00007f3c3fc7e5f6 in __tzfile_read (file=file@entry=0x7f3c3fd4b2c3 "/etc/localtime",
     extra=extra@entry=0, extrap=extrap@entry=0x0) at tzfile.c:170
 #10 0x00007f3c3fc7d954 in tzset_internal (always=<optimized out>,
     explicit=explicit@entry=1) at tzset.c:444
 #11 0x00007f3c3fc7e303 in __tz_convert (timer=0x7fffcfa92d50,
     use_localtime=use_localtime@entry=1, tp=tp@entry=0x7f3c3ff8ed80 <_tmbuf>)
     at tzset.c:629
 #12 0x00007f3c3fc7c2a1 in __GI_localtime (t=<optimized out>) at localtime.c:42
 #13 0x00007f3c3fc7c1f9 in ctime (t=<optimized out>) at ctime.c:27
 #14 0x00007f3c3e180ec2 in ?? ()
 #15 0x0000000056a100c2 in ?? ()
 #16 0xf8570f79d4fc4200 in ?? ()
 #17 0x000000000209bec0 in ?? ()
 #18 0x00007f3c4059f1f8 in ?? ()
 #19 0x000000000000003c in ?? ()
 #20 0x0000000000404952 in ulogd_propagate_results ()
 #21 0x00007f3c3f9cc203 in ?? ()
 #22 0x0000000000000000 in ?? ()

Segmentation fault in free()
============================
>From my experience, I think this was caused by some routine called
malloc()/free() in signal handler context.
By that, malloc() management data became inconsistent.
As a result, free() made a wrong dereference.

Program terminated with signal SIGSEGV, Segmentation fault.
 #0  __GI___libc_free (mem=0x7f430f011000) at malloc.c:2903
 2903      if (chunk_is_mmapped(p))                       /* release mmapped memory. */
 (gdb) bt
 #0  __GI___libc_free (mem=0x7f430f011000) at malloc.c:2903
 #1  0x00007f430e68affa in __GI__IO_free_backup_area (fp=fp@entry=0x742500)
     at genops.c:210
 #2  0x00007f430e68a795 in _IO_new_file_overflow (f=0x742500, ch=-1) at fileops.c:849
 #3  0x00007f430e689511 in _IO_new_file_xsputn (f=0x742500, data=<optimized out>, n=15)
     at fileops.c:1372
 #4  0x00007f430e65aa4d in _IO_vfprintf_internal (s=s@entry=0x742500,
     format=<optimized out>, format@entry=0x7f430cbc4008 "%.15s %s %s",
     ap=ap@entry=0x7fff456ece38) at vfprintf.c:1635
 #5  0x00007f430e71d615 in ___fprintf_chk (fp=0x742500, flag=flag@entry=1,
     format=format@entry=0x7f430cbc4008 "%.15s %s %s") at fprintf_chk.c:36
 #6  0x00007f430cbc3f04 in fprintf (__fmt=0x7f430cbc4008 "%.15s %s %s",
     __stream=<optimized out>) at /usr/include/bits/stdio2.h:97
 #7  _output_logemu (upi=0x74e5a0) at ulogd_output_LOGEMU.c:102
 #8  0x0000000000404952 in ulogd_propagate_results ()
 #9  0x00007f430e40f203 in interp_packet (ldata=0x7fff456ed060, pf_family=2 '\002',
     upi=0x74a6b0) at ulogd_inppkt_NFLOG.c:400
 #10 msg_cb (gh=<optimized out>, nfmsg=0x7f430efe2020, nfa=0x7fff456ed060, data=0x74a6b0)
     at ulogd_inppkt_NFLOG.c:483
 #11 0x00007f430e20a307 in __nflog_rcv_pkt (nlh=<optimized out>, nfa=<optimized out>,
     data=<optimized out>) at libnetfilter_log.c:160
 #12 0x00007f430e0056b7 in __nfnl_handle_msg (len=268, nlh=0x7f430efe2010, h=0x74e8e0)
     at libnfnetlink.c:1236
 #13 nfnl_handle_packet (h=0x74e8e0, buf=0x7f430efe2010 "\f\001", len=<optimized out>)
     at libnfnetlink.c:1256
 #14 0x00007f430e20a508 in nflog_handle_packet (h=<optimized out>, buf=<optimized out>,
     len=<optimized out>) at libnetfilter_log.c:323
 #15 0x00007f430e40eaed in nful_read_cb (fd=<optimized out>, what=<optimized out>,
     param=0x74a6b0) at ulogd_inppkt_NFLOG.c:463
 #16 0x0000000000404ee0 in ulogd_select_main ()
 #17 0x0000000000402b17 in main ()

Signed-off-by: Hironobu Ishii <ishii.hironobu@jp.fujitsu.com>
9 years agosqlite3: Remove unused "buffer" option.
Alex Xu [Wed, 13 Jan 2016 20:37:58 +0000 (15:37 -0500)] 
sqlite3: Remove unused "buffer" option.

This option was left behind when the code was rewritten and is no longer
functional or useful. Remove it entirely.

Signed-off-by: Alex Xu (Hello71) <alex_y_xu@yahoo.ca>
9 years agojson: append timezone information to ISO 8601 date
Vincent Bernat [Fri, 2 Oct 2015 15:00:58 +0000 (17:00 +0200)] 
json: append timezone information to ISO 8601 date

While this is not strictly needed for ISO 8601, this is helpful since
otherwise, the receiver can't assume anything about the
timezone.

This uses a GNU extension but as ulogd is quite Linux-specific, this
shouldn't be a problem. The POSIX variables (tzname and daylight) are
quite difficult to use because daylight handling is incomplete (daylight
don't say if DST is now in effect, it just says it is sometimes in
effect).

A timezone offset is used instead of a timezone since it is usually
easier to parse (strptime in glibc is not able to parse a timezone name)
and don't require an up-to-date TZ database.

Signed-off-by: Vincent Bernat <Vincent.Bernat@exoscale.ch>
9 years agojson: output messages in JSONv1 format
Vincent Bernat [Wed, 30 Sep 2015 12:32:07 +0000 (14:32 +0200)] 
json: output messages in JSONv1 format

While Logstash is quite flexible in the JSON messages received, the
canonical format it "expects" is the JSON Event v1 format. The timestamp
should be keyed by `@timestamp` and there should be a `@version` key
whose value is 1. All other keys are free.

There is no formal specification of this format. It is however described
here:

 https://github.com/elastic/logstash/blob/1.5/lib/logstash/event.rb#L26-L47

It's useful to respect this format as it allows a user to use a less
capable receiver. The new format is enabled only when `eventv1=1` is set
in plugin configuration.

Signed-off-by: Vincent Bernat <Vincent.Bernat@exoscale.ch>
10 years agoUse stdint types everywhere
Felix Janda [Wed, 24 Jun 2015 17:53:34 +0000 (19:53 +0200)] 
Use stdint types everywhere

Signed-off-by: Felix Janda <felix.janda@posteo.de>
10 years agoulogd: Use /dev/null as dummy logfile when logging to syslog
Felix Janda [Sat, 16 May 2015 15:43:23 +0000 (17:43 +0200)] 
ulogd: Use /dev/null as dummy logfile when logging to syslog

Fixes compilation error with musl libc:

ulogd.c:86:13: error: storage size of 'syslog_dummy' isn't known
 static FILE syslog_dummy;

Signed-off-by: Felix Janda <felix.janda@posteo.de>
10 years agoDefine _GNU_SOURCE to get members of tcphdr
Felix Janda [Sat, 16 May 2015 13:44:32 +0000 (15:44 +0200)] 
Define _GNU_SOURCE to get members of tcphdr

The source uses linux names for members of tcphdr. For example
"source" instead of "th_sport", ... musl libc's headers need
_GNU_SOURCE defined in order to expose these.

Signed-off-by: Felix Janda <felix.janda@posteo.de>
10 years agoSync with kernel headers
Felix Janda [Sat, 16 May 2015 13:01:30 +0000 (15:01 +0200)] 
Sync with kernel headers

Signed-off-by: Felix Janda <felix.janda@posteo.de>
10 years agoconfigure.ac: Add --without-{mysql,pgsql}
Harald Welte [Sun, 3 May 2015 09:08:54 +0000 (11:08 +0200)] 
configure.ac: Add --without-{mysql,pgsql}

In some cases you may not want to build a certain output plugin, even
if the headers/libraries actually exist on the build host.

10 years agoAdd missing enableval to configure ulogd-2.0.5
Eric Leblond [Fri, 24 Apr 2015 19:52:46 +0000 (21:52 +0200)] 
Add missing enableval to configure

Without that --disable-FEATURE is not working correctly.

10 years agoAdd flag to disable ULOG input plugin
Eric Leblond [Fri, 24 Apr 2015 19:44:58 +0000 (21:44 +0200)] 
Add flag to disable ULOG input plugin

ULOG target is removed from kernel so we can prepare the removal
of the plugin for ulogd. For now, we just add a configure flag.

10 years agoSet release number to 2.0.5.
Eric Leblond [Fri, 3 Apr 2015 00:48:45 +0000 (02:48 +0200)] 
Set release number to 2.0.5.

10 years agoinclude: keep a copy of linux/netfilter_ipv4/ipt_ULOG.h
Pablo Neira Ayuso [Fri, 7 Nov 2014 17:33:01 +0000 (18:33 +0100)] 
include: keep a copy of linux/netfilter_ipv4/ipt_ULOG.h

This fixes compilation if you use a Linux kernel >= 3.17. This problem
occurs since ULOG was removed from mainstream:

http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=7200135bc1e61f1437dc326ae2ef2f310c50b4eb

Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=986
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
11 years agoFix JSON output on big endian systems
Jimmy Jones [Sat, 26 Jul 2014 20:48:38 +0000 (21:48 +0100)] 
Fix JSON output on big endian systems

Signed-off-by: Jimmy Jones <jimmyjones2@gmx.co.uk>
11 years agogitignore: add manpage
Eric Leblond [Tue, 1 Jul 2014 19:09:19 +0000 (21:09 +0200)] 
gitignore: add manpage

Signed-off-by: Eric Leblond <eric@regit.org>
11 years agogitignore: ignore generated documentation
Vincent Bernat [Fri, 27 Jun 2014 08:13:57 +0000 (10:13 +0200)] 
gitignore: ignore generated documentation

Signed-off-by: Vincent Bernat <Vincent.Bernat@exoscale.ch>
11 years agoSet release number to 2.0.4. ulogd-2.0.4
Eric Leblond [Mon, 3 Mar 2014 23:21:10 +0000 (00:21 +0100)] 
Set release number to 2.0.4.

Signed-off-by: Eric Leblond <eric@regit.org>
11 years agoulogd: fix loglevel handling
Ken-ichirou MATSUZAWA [Fri, 7 Mar 2014 22:03:48 +0000 (23:03 +0100)] 
ulogd: fix loglevel handling

It was always default if not specified by command parameter.

Signed-off-by: Ken-ichirou MATSUZAWA <chamas@h4.dion.ne.jp>
11 years agoprintpkt: oob.time.sec was not used
Eric Leblond [Fri, 7 Mar 2014 21:49:37 +0000 (22:49 +0100)] 
printpkt: oob.time.sec was not used

This patch supresses the oob.time.sec from the input keys as this
is not used when creating the string corresponding to the packet.

Signed-off-by: Eric Leblond <eric@regit.org>
11 years agojson: use packet timestamp if available
Eric Leblond [Fri, 7 Mar 2014 20:11:47 +0000 (21:11 +0100)] 
json: use packet timestamp if available

This patch updates the JSON output plugin to have it use the
timestamp of the packet if available. The date format used
for the timestamp is now using ISO 8601 to have an easy
import in most software (tested with logstash and splunk).

Signed-off-by: Eric Leblond <eric@regit.org>
11 years agonfct: use start timestamp if provided
Eric Leblond [Sat, 22 Feb 2014 13:05:56 +0000 (14:05 +0100)] 
nfct: use start timestamp if provided

When hash table is not used, the start timestamp was not used even
if the kernel is sending it. This patch modifies the code to use it
when available. This allows to log connection with start and end
with a single message per connection and without the cost of
maintaining the hash table.

11 years agoulogd: add carriage return as separator
Eric Leblond [Tue, 4 Feb 2014 08:27:45 +0000 (09:27 +0100)] 
ulogd: add carriage return as separator

If the file is in DOS mode, the string coming from config file
parsing are containing the carriage return. The result is that
string are not correct and the parsing of confuguration file
is failling.

11 years agoulogd: avoid potential double print of message
Eric Leblond [Mon, 3 Feb 2014 23:33:47 +0000 (00:33 +0100)] 
ulogd: avoid potential double print of message

In case there is no logfile, ulogd could possibly display each
log message twice to stderr.

11 years agojson: introduce new JSON output plugin
Eric Leblond [Sun, 26 Jan 2014 16:05:29 +0000 (17:05 +0100)] 
json: introduce new JSON output plugin

This patch introduces a new JSON output plugin. This
patch displays CIM field name instead of ulogd key valu
if this CIM field is available.

The module does not display binary address but uses the
string version of them. So a complete stack is for example:
 stack=log2:NFLOG,base1:BASE,ifi1:IFINDEX,ip2str1:IP2STR,mac2str1:HWHDR,json1:JSON

If boolean_label is set to 1, then the numeric_label put on packet
by the input plugin is coding the decision on packet. If 0, then
packet has been blocked and if non null it has been accepted.

11 years agostore Common Information Model name in ulogd key
Eric Leblond [Sun, 26 Jan 2014 21:21:42 +0000 (22:21 +0100)] 
store Common Information Model name in ulogd key

This patch adds storage for CIM field name in ulogd key. This
will be used by JSON output to interoperate with logging
collector such as logstash or splunk.

Common Information Model is an open standard that defines how managed
elements in an IT environment are represented as a common set of objects
and relationships between them:
 http://www.dmtf.org/standards/cim

This seems to be mainly XML based but there is a JSON version of some
aspects of the model. One of the main documentation on CIM in JSON
format seems to be:
 http://docs.splunk.com/Documentation/PCI/2.0/DataSource/CommonInformationModelFieldReference

Using the correct CIM field name allow events coming from ulogd to be
correlated with events coming from other sources.

11 years agodb: don't loose one packet on reconnect
Eric Leblond [Sun, 26 Jan 2014 10:33:54 +0000 (11:33 +0100)] 
db: don't loose one packet on reconnect

This patch improves database reconnection handling in ring buffer
mode. Ulogd now redo the failed query and do not loose anymore
one packet.

11 years agodb: cancel injection thread when terminating
Eric Leblond [Sat, 25 Jan 2014 11:51:49 +0000 (12:51 +0100)] 
db: cancel injection thread when terminating

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.

11 years agodb: set ring default size to 0
Eric Leblond [Sat, 25 Jan 2014 11:26:38 +0000 (12:26 +0100)] 
db: set ring default size to 0

As default size was non null, the ring system was activated by
default. It was only possible to desactivate the ring system
by setting it to ring_buffer_size to 0 in the configuration.

This was not the attended behavior. This patch set it to 0 to have
only explicit activation of the ring feature.

11 years agoutil: fix warning on format string
Eric Leblond [Sat, 25 Jan 2014 10:46:52 +0000 (11:46 +0100)] 
util: fix warning on format string

pp_print macro was not correctly formatting u64. This patch renames
it to pp_print_u as it is only used to print integer. It also use
the PRIu* macros to have a correct format string for all integers
type.

11 years agonacct: fix format warning
Eric Leblond [Sat, 25 Jan 2014 10:46:14 +0000 (11:46 +0100)] 
nacct: fix format warning

Some counter have been recently switch to u64. This has caused warnings
relative to format string. This patch uses PRIu64 macro to fix these
warnings.

11 years agoulogd: use AC_SEARCH_LIBS for libpthread
Gustavo Zacarias [Tue, 10 Dec 2013 12:24:12 +0000 (09:24 -0300)] 
ulogd: use AC_SEARCH_LIBS for libpthread

Some uClibc-based toolchains lack threading support, so use
AC_SEARCH_LIB instead of AC_CHECK_LIB to check for libpthread
availability and link conditionally if found since it's only used for
the database backends.

Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
11 years agoSet release number to 2.0.3. ulogd-2.0.3
Eric Leblond [Sun, 13 Oct 2013 21:21:30 +0000 (23:21 +0200)] 
Set release number to 2.0.3.

Signed-off-by: Eric Leblond <eric@regit.org>
11 years agoulogd: ulogd_inppkt_NFLOG: close nflog handle after unbinding
Chris Boot [Mon, 18 Nov 2013 11:09:14 +0000 (11:09 +0000)] 
ulogd: ulogd_inppkt_NFLOG: close nflog handle after unbinding

The nflog handle is closed, and then nflog_unbind_pf() is called on it, which
triggers an assertion failure within libnfnetlink. This patch simply moves
the nflog_close() just after the nflog_unbind_pf() calls.

Signed-off-by: Chris Boot <bootc@bootc.net>
11 years agonfct: make NFCT packet counter/length 64 bit
Ulrich Weber [Wed, 9 Oct 2013 10:00:01 +0000 (12:00 +0200)] 
nfct: make NFCT packet counter/length 64 bit

Kernel and libnetfilter_conntrack counters are 64bit,
so use 64bit too in ulogd instead of 32bit.

Worked fine on little endian systems but big endian systems
had zero counter...

Didn't test ipfix output, but RFC allows template with
either 32 or 64 counters, so should be safe.

Signed-off-by: Ulrich Weber <uw@xyne.com>
Signed-off-by: Eric Leblond <eric@regit.org>
11 years agoulogd: use daemon() function
Eric Leblond [Sat, 20 Jul 2013 10:08:33 +0000 (12:08 +0200)] 
ulogd: use daemon() function

This patches update the daemonization code. It is done earlier and
it uses the daemon(à function which is used for daemonization by
most projects.

Signed-off-by: Eric Leblond <eric@regit.org>
11 years agoulogd.conf: add missing quote.
Eric Leblond [Sat, 20 Jul 2013 10:17:08 +0000 (12:17 +0200)] 
ulogd.conf: add missing quote.

Pcap file variable was not quoted. This was confusing
as the correct file was not open if the user did
uncomment the variable.

Signed-off-by: Eric Leblond <eric@regit.org>
12 years agopgsql: add var to specify arbitrary conn params
Eric Leblond [Tue, 28 May 2013 19:58:57 +0000 (21:58 +0200)] 
pgsql: add var to specify arbitrary conn params

This patch adds a configuration variable for PostgreSQL output.
Named connstring it stores the character string that will be
used to connect to the PostgreSQL server. This allows the user
to use all options available like TLS parameters for example.

Signed-off-by: Eric Leblond <eric@regit.org>
12 years agoImprove pid file handling.
Eric Leblond [Sat, 18 May 2013 13:25:11 +0000 (15:25 +0200)] 
Improve pid file handling.

This patch improves latest patch by splitting in two part the pid
file creation. This allows to display a message to stdout when
ulogd can not be started. Another linked improvement is that the
plugin initialization is not done if the pid file existence will
result in a ulogd exit.

Signed-off-by: Eric Leblond <eric@regit.org>
12 years agoulogd: Implement PID file writing
Chris Boot [Sun, 12 May 2013 12:47:40 +0000 (13:47 +0100)] 
ulogd: Implement PID file writing

The deamon currently does not have the ability to write a PID file to track its
process ID. This is very useful to an init script and to ensure there is only
one running instance. This patch implements this functionality.

Signed-off-by: Chris Boot <bootc@bootc.net>
12 years agoulogd: Perform nice() before giving up root
Chris Boot [Sat, 11 May 2013 17:01:52 +0000 (18:01 +0100)] 
ulogd: Perform nice() before giving up root

The daemon code currently tries to nice(-1) just after having given up root
privileges, which fails. This patch moves the nice(-1) call to just before
the code that gives up the required privileges.

Signed-off-by: Chris Boot <bootc@bootc.net>
12 years agoExec libmnl config check only if nfacct is enabled
Victor Julien [Fri, 5 Apr 2013 16:28:14 +0000 (18:28 +0200)] 
Exec libmnl config check only if nfacct is enabled

In case nfacct is not enabled in ulogd2, libmnl is not used. So it shouldn't
be a hard global dependency, but instead only a dependency in case nfacct is
enabled.

12 years agodb: db ring has precedence over backlog.
Eric Leblond [Thu, 9 May 2013 10:57:20 +0000 (12:57 +0200)] 
db: db ring has precedence over backlog.

12 years agodb: disable SIGHUP if ring buffer is used.
Eric Leblond [Thu, 9 May 2013 09:20:37 +0000 (11:20 +0200)] 
db: disable SIGHUP if ring buffer is used.

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.

12 years agodb: add ring buffer for DB query
Eric Leblond [Sat, 20 Apr 2013 10:44:17 +0000 (12:44 +0200)] 
db: add ring buffer for DB query

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.

12 years agodb: use offset instead of direct pointer.
Eric Leblond [Tue, 19 Mar 2013 23:03:35 +0000 (00:03 +0100)] 
db: use offset instead of direct pointer.

Use an offset approach to get the start of values printing area. It
is more generic and will be use soon.

12 years agodb: suppress field in db structure
Eric Leblond [Tue, 19 Mar 2013 22:57:16 +0000 (23:57 +0100)] 
db: suppress field in db structure

The field is currently only used in a single function as a string
pointer and can thus be removed from the db instance structure.

12 years agodb: store data in memory during database downtime
Eric Leblond [Sun, 17 Mar 2013 18:41:36 +0000 (19:41 +0100)] 
db: store data in memory during database downtime

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.

12 years agosqlite3: add sanity checking
Eric Leblond [Sun, 17 Mar 2013 23:25:01 +0000 (00:25 +0100)] 
sqlite3: add sanity checking

Nullify sqlite3 handler at deinit.

12 years agomysql: add sanity checking
Eric Leblond [Sun, 17 Mar 2013 23:24:17 +0000 (00:24 +0100)] 
mysql: add sanity checking

Nullify mysql handler at deinit.

12 years agopostgresql: add sanity checking
Eric Leblond [Sun, 17 Mar 2013 20:43:51 +0000 (21:43 +0100)] 
postgresql: add sanity checking

Clean postgresql handler at deinit.

12 years agoFix automagic support of dbi, pcap and sqlite3
Ilya Tumaykin [Wed, 20 Mar 2013 10:54:36 +0000 (14:54 +0400)] 
Fix automagic support of dbi, pcap and sqlite3

ulogd has automagic deps for several output plugins right now, namely dbi,
pcap and sqlite3. These plugins are built if the appropriate libs are present
on user's system. While this situation is fine with binary distros it is not OK
on source-based ones such as Gentoo.

The problem arises when such a program links against libs without user's
request and libs are later removed from system which leaves program in a
broken state.

This patch is modifying configure.ac which we apply in our package and which
fixes mentioned issue. It adds 3 new configure options: --
without-{dbi,pcap.sqlite}. I would like to emphasize that this patch doesn't
change default behaviour of configure script at all, so all other distros won't
suffer. We simply add options to explicitly disable any attempts to try and
detect libs for automagic deps, which is enough to avoid unnecessary linkage.

12 years agoulogd: display stack during configuration
Eric Leblond [Tue, 19 Mar 2013 23:24:17 +0000 (00:24 +0100)] 
ulogd: display stack during configuration

12 years agoRevert "ulogd: close logfile description in the exit path of parent process"
Pablo Neira Ayuso [Tue, 26 Mar 2013 23:07:31 +0000 (00:07 +0100)] 
Revert "ulogd: close logfile description in the exit path of parent process"

This reverts commit 3179bd4de89de7c2388849f5bc48e8f5aad9e5b9.

Pointing to the wrong place. This is not the file descriptor
that ulogd is leaking.

12 years agoulogd: close logfile description in the exit path of parent process
Pablo Neira Ayuso [Tue, 26 Mar 2013 21:48:58 +0000 (22:48 +0100)] 
ulogd: close logfile description in the exit path of parent process

Joan Touzet reported that file descriptor 3 was not ever closed
in the exit path of the parent process:

open("ulogd.conf", O_RDONLY)            = 3

That corresponds to the the file descriptor that was used to
parse the configuration file was not closed.

This closes: http://bugzilla.netfilter.org/show_bug.cgi?id=793

Reported-by: Joan Touzet <joant@cloudant.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
12 years agoulogd: change verbosity of a message
Eric Leblond [Tue, 19 Mar 2013 23:18:06 +0000 (00:18 +0100)] 
ulogd: change verbosity of a message

The "registering plugin" message is not really useful as the message
is really explicit if a plugin is missing.

12 years agonfct: use timestamp of conntrack object.
Eric Leblond [Sat, 2 Mar 2013 20:16:41 +0000 (21:16 +0100)] 
nfct: use timestamp of conntrack object.

If conntrack object sent by connection tracking system is containing
a timestamp we use it instead of a gettimeofday() based counter.

Signed-off-by: Eric Leblond <eric@regit.org>
12 years agoPrepare release number to 2.0.2 ulogd-2.0.2
Eric Leblond [Fri, 25 Jan 2013 19:37:26 +0000 (20:37 +0100)] 
Prepare release number to 2.0.2

Update release number and delete Changes file because we can use
git changelog fot that.

12 years agoUpdate README
Eric Leblond [Wed, 20 Feb 2013 18:10:23 +0000 (19:10 +0100)] 
Update README

Get rid of ULOG only documentation and adds some new stuffs.

12 years agoUpdate man page.
Eric Leblond [Wed, 20 Feb 2013 17:33:59 +0000 (18:33 +0100)] 
Update man page.

12 years agologemu: return error if configuration is invalid.
Eric Leblond [Mon, 18 Feb 2013 15:03:25 +0000 (16:03 +0100)] 
logemu: return error if configuration is invalid.

12 years agoAdd handling of too long line and arguments.
Eric Leblond [Sat, 9 Feb 2013 20:36:48 +0000 (21:36 +0100)] 
Add handling of too long line and arguments.

When an argument or a line is too long, it can not be store
into ulogd configuration and this must results in a error.

12 years agoFix typo in comments.
Eric Leblond [Sat, 9 Feb 2013 19:55:16 +0000 (20:55 +0100)] 
Fix typo in comments.

12 years agoUse access to ensure readability of config gile
Eric Leblond [Sat, 9 Feb 2013 19:49:56 +0000 (20:49 +0100)] 
Use access to ensure readability of config gile

This patch adds a call to access to check the readability of the
configuration file.

12 years agoSuppress dead FIXME.
Eric Leblond [Sat, 9 Feb 2013 19:17:33 +0000 (20:17 +0100)] 
Suppress dead FIXME.

12 years agoUpdate TODO.
Eric Leblond [Sun, 27 Jan 2013 08:40:30 +0000 (09:40 +0100)] 
Update TODO.

Try to sync TODO with real state of the project.

12 years agographite: fix crash on i386
Eric Leblond [Sun, 17 Feb 2013 21:59:40 +0000 (22:59 +0100)] 
graphite: fix crash on i386

It seems a cast of time_t is needed for i386 system to avoid a
crash. I've added a cast to uint64_t that should be ok on all
Linux system.

Reported-by: netfilter@openenterprise.co.uk
12 years agoFix make distcheck
Eric Leblond [Fri, 25 Jan 2013 19:31:57 +0000 (20:31 +0100)] 
Fix make distcheck

Recently introduced addr.h was missing from Makefile.am.

12 years agoAdd TAGS to .gitignore
Eric Leblond [Fri, 25 Jan 2013 19:20:43 +0000 (20:20 +0100)] 
Add TAGS to .gitignore

12 years agographite: fix warning about gnu extension usage
Eric Leblond [Fri, 18 Jan 2013 20:11:09 +0000 (21:11 +0100)] 
graphite: fix warning about gnu extension usage

clang is complaining about missing = being a gnu extension. This
patch adds equal sign to fix the warning.

12 years agobase: fix warning on pointer handling
Eric Leblond [Fri, 18 Jan 2013 20:10:32 +0000 (21:10 +0100)] 
base: fix warning on pointer handling

12 years agoFix warning on format
Eric Leblond [Fri, 18 Jan 2013 20:09:30 +0000 (21:09 +0100)] 
Fix warning on format

It seems Z is a libc5 only format modifier. Using standard 'z'
instead.

12 years agoGet rid of SVN tag in comment.
Eric Leblond [Fri, 18 Jan 2013 19:19:28 +0000 (20:19 +0100)] 
Get rid of SVN tag in comment.

This patch also update some copyright and licence declaration.

12 years agoAdd -l option to set log level from command line
Eric Leblond [Fri, 18 Jan 2013 18:43:06 +0000 (19:43 +0100)] 
Add -l option to set log level from command line

This patch adds a '-l' option which can be used to setup ulogd
loglevel. Command line option has precedence on the configuration
file one.

12 years agoconf: add flag to allow option setup tuning
Eric Leblond [Fri, 18 Jan 2013 18:41:19 +0000 (19:41 +0100)] 
conf: add flag to allow option setup tuning

This patch adds a flag to the config_entry structure to be able to
tune setup. First usage is to ask config parser not to update a key
if it has been already set.

12 years agoulogd: add -v option to display message on stderr.
Eric Leblond [Sun, 6 Jan 2013 22:12:39 +0000 (23:12 +0100)] 
ulogd: add -v option to display message on stderr.

If can be painful to have to check the logfile, so this patch adds
a '-v' option which display logs message to stderr.