53 Commits

Author SHA1 Message Date
Rainer Gerhards
b326c76f45 style: normalize C source formatting via clang-format (PoC)
This commit applies the new canonical formatting style using `clang-format` with custom settings (notably 4-space indentation), as part of our shift toward automated formatting normalization.

⚠️ No functional changes are included — only whitespace and layout modifications as produced by `clang-format`.

This change is part of the formatting modernization strategy discussed in:
https://github.com/rsyslog/rsyslog/issues/5747

Key context:
- Formatting is now treated as a disposable view, normalized via tooling.
- The `.clang-format` file defines the canonical style.
- A fixup script (`devtools/format-code.sh`) handles remaining edge cases.
- Formatting commits are added to `.git-blame-ignore-revs` to reduce noise.
- Developers remain free to format code however they prefer locally.
2025-07-16 13:56:21 +02:00
Rainer Gerhards
7225999b77 refactor: modernize macro definitions to support formatting and clarity
This commit performs a broad modernization of widely used rsyslog
macros to align with modern C practices and support automated
formatting tools like clang-format. The changes focus on improving
syntactic regularity, readability, and tooling compatibility — without
altering behavior.

Macros refactored in this commit now follow a consistent,
statement-like form with explicit trailing semicolons. Where
applicable, macro blocks that define module interfaces (`queryEtryPt`)
have been updated to use simple `if` statements instead of `else if`
chains. While this slightly increases evaluation time, the affected
functions are only called once per module during load time to register
supported interfaces — making the performance cost irrelevant in
practice.

These improvements serve multiple purposes:
- Enable reliable clang-format usage without mangling macro logic
- Simplify reasoning about macro-expanded code for human readers
- Reduce style drift and merge conflicts
- Facilitate development for contributors using assistive tools
- Support future formatting pipelines using:
  1. `clang-format`
  2. a post-fixup normalization script

Refactored macros:
- MODULE_TYPE_NOKEEP
- MODULE_TYPE_KEEP
- MODULE_TYPE_INPUT
- MODULE_TYPE_OUTPUT
- MODULE_TYPE_FUNCTION
- MODULE_TYPE_PARSER
- MODULE_TYPE_LIB
- DEF_IMOD_STATIC_DATA
- DEF_OMOD_STATIC_DATA
- DEF_PMOD_STATIC_DATA
- DEF_FMOD_STATIC_DATA
- DEFobjStaticHelpers
- SIMP_PROP(...)

And all `queryEtryPt()` dispatch macros:
- CODEqueryEtryPt_STD_MOD_QUERIES
- CODEqueryEtryPt_STD_OMOD_QUERIES
- CODEqueryEtryPt_STD_OMODTX_QUERIES
- CODEqueryEtryPt_STD_OMOD8_QUERIES
- CODEqueryEtryPt_TXIF_OMOD_QUERIES
- CODEqueryEtryPt_IsCompatibleWithFeature_IF_OMOD_QUERIES
- CODEqueryEtryPt_STD_IMOD_QUERIES
- CODEqueryEtryPt_STD_CONF2_QUERIES
- CODEqueryEtryPt_STD_CONF2_setModCnf_QUERIES
- CODEqueryEtryPt_STD_CONF2_OMOD_QUERIES
- CODEqueryEtryPt_STD_CONF2_IMOD_QUERIES
- CODEqueryEtryPt_STD_CONF2_PREPRIVDROP_QUERIES
- CODEqueryEtryPt_STD_CONF2_CNFNAME_QUERIES
- CODEqueryEtryPt_STD_PMOD_QUERIES
- CODEqueryEtryPt_STD_PMOD2_QUERIES
- CODEqueryEtryPt_STD_FMOD_QUERIES
- CODEqueryEtryPt_STD_SMOD_QUERIES
- CODEqueryEtryPt_doHUPWrkr
- CODEqueryEtryPt_doHUP

This general modernization reduces macro misuse, improves DX, and
lays the foundation for a robust, automated style normalization
system.

See also: https://github.com/rsyslog/rsyslog/issues/5747
2025-07-15 08:25:58 +02:00
Rainer Gerhards
dd6621672a
netstrm: optimized interface for passing connection err info 2025-05-12 17:31:35 +02:00
Rainer Gerhards
c3027a6d5e
tcpsrv bugfix: do not busy wait on io events
Depending on circumstances, tcpsrv worker threads did effectively
busy-wait on io events to handle. Not always, but often. This was
caused be improperly re-arming the inotify subsystem.

This effected overall system performance, but not general rsyslog
stability. The bug was introduced on March 1st 2025 into the
daily stable build.

closes: https://github.com/rsyslog/rsyslog/issues/5623
2025-04-22 11:51:58 +02:00
Rainer Gerhards
1c0f9bba50
omfwd: implement native load balancing - phase 1
This patch implements a simple round-robin load balancer
for omfwd. It provides equal distribution of load to a pool
of target servers.

The code currently has no different modes and no special tuning
for the load balancer. However, it works very well in the most
common use cases. Furthermore, it provides a solid base on which
more elaborate functionality can be build if there is need to.

The new functionality is fully backwards compatible with previous
configuration settings.

New action() config params:
* pool.resumeinterval

New/"changed" rstats counters
Each target receives its own set of pstats counters. Most
importantly this is the case for byte counts. That counter retains
the same naming, but there may now be multiple of these counters,
one for each target ip, port tuple.

New pstats message count to target
Among others, this can be used for checking that the load balancer
works as intended. The so-far byte count emitted does not provide
a clear indication of how many messages the targets had actually
processed.

For obvious reasons, this message count makes most sense in
advanced load balancing scenarios, but also provides additional
insight into round-robin. Non-matches indicate that targets
went offline, and we can now evaluate the impact this had
on processing.

- re-design rebind functionality

This now works at the transaction level. It causes a rebind of all
pool members. Previous code did not work 100% correct since for a
couple of years now (after output batching integration).

As cleanup, rebindInterval support has been removed from tcpClt,
because omfwd is the only user. This permits a cleaner code path.

We also noticed a bug with rebindInterval:  it caused some mild
message duplication for quite some time. This went unnoticed.
To address that efficiently, rebindInterval in the future will
be considered once per batch. That means up to (maxBatchSize - 1)
messages may be transmitted more than the rebindinterval is.
That's the cleanest mode of operation and should not make any
difference for real deployments.

Some additional work done in this commit:

netstream: harden component against upper-layer logic errors

network subsystem: better handle API errors and provide more info

omfwd: add new parameter "iobuffer.maxsize"

add new global parameter debug.abortoninternalerror and use it

This parameter permits to make test runs fail when an internal error
is detected and gracefully handled by rsyslog. While it is great to
have it gracefully handled in practice, we should not accept this
during testing. The new parameter permits to abort in this case and
emits the related error message beforehand. It is turned on by
default in our regular tests.

add dedicated error code for "hard" program errors

omfwd: some cleanup + error message fix + new debug level messages

imptcp: improve error messages

add omfwd option to NOT do extended connection check

also output wrkr id in some omfwd messages (primarily debugging aid)

better debug info via LogMsg() interface

improve messages regarding imptcp and omfwd suspension / thread IDs

refactor and enchance minitcpsrvr for mimicing died servers

new global (debugging) option, correction of an informational msg

add global option allmessagestostderr

add new tests
2024-08-19 08:54:31 +02:00
Darren J Moffat
844d1795a2 TLS CRL Support Issue 5081 2023-07-06 10:36:39 +02:00
Michael Biebl
6569133c75
Typo fixes (#4801)
* typo fix: ambigious -> ambiguous

* typo fix: aquire -> acquire

* typo fix: assgined -> assigned

* typo fix: cancelation -> cancellation

* typo fix: childs -> children

* typo fix: configuraton -> configuration

* typo fix: delemiter -> delimiter

* typo fix: forwardig -> forwarding

* typo fix: initializiation -> initialization

* typo fix: intializing -> initializing

* typo fix: lengh -> length

* typo fix: mesage -> message

* typo fix: occured -> occurred

* typo fix: occurence -> occurrence

* typo fix: paramter -> parameter

* typo fix: remaing -> remaining

* typo fix: resetted -> reset

* typo fix: suppored -> supported

* typo fix: Sytem -> System

* typo fix: uncommited -> uncommitted

* typo fix: depricated -> deprecated

* typo fix: stoping -> stopping

* type fix: allow to -> allow one to
2022-02-17 10:54:12 +01:00
Rainer Gerhards
39e81e133b
omfwd: add capability for action-specific TLS certificate settings
This permits to override the global definitions for TLS certificates
at the action() level.
2021-08-06 09:00:24 +02:00
Rainer Gerhards
926e207575
phase 1: consolidate current imtcp input params in a single structure
see also https://github.com/rsyslog/rsyslog/issues/3727
2021-04-22 08:44:55 +02:00
fcffb063e3 tls: Added support to configure certificate verify depth
Support added in omfwd as instance parameter:
streamdriver.TlsVerifyDepth
Support added in imtcp as module parameter:
streamdriver.TlsVerifyDepth

Can be 2 or higher.

Support added into ossl driver
Support added into gtls driver
Added testcases for both drivers.

Parameter
streamdriver.TlsVerifyDepth

closes: https://github.com/rsyslog/rsyslog/issues/4035
2020-01-08 11:40:14 +01:00
Jiri Vymazal
937e278fdf Stricter GnuTLS operation
This commit adds to new flags which can be set to allow
1) checking of extendedKeyUsage certificate field
2) stricter checking of certificate name/adresses
2019-08-30 09:40:25 +02:00
3d9b8df6fb tls(ossl/gtls): add new Option "StreamDriver.PermitExpiredCerts"
The new Option can have one of the following values:
on = Expired certificates are allowed
off = Expired certificates are not allowed
warn = Expired certificates are allowed but warning will be logged (Default)

Includes necessary tests to validate new code.

closes https://github.com/rsyslog/rsyslog/issues/3364
2018-12-21 15:24:41 +01:00
PascalWithopf
df85be1130 tcp driver: add support for parameter LstnPortFileName 2018-08-29 15:14:29 +02:00
PascalWithopf
19133327cc correct codestyle in rsyslog 2018-07-31 09:44:27 +02:00
Rainer Gerhards
dc2e06d6b8 "fix" Coverity scan cosmetic issues
Let us get rid of some dismissed CID entries...
2017-11-21 09:15:31 +01:00
Rainer Gerhards
5c5a7a3ed5 tcpsrv subsystem: better error messages
Most importantly, output os error messages on API failures.
Among others, this improves error messages in imtcp.

closes https://github.com/rsyslog/rsyslog/issues/1749
2017-09-05 15:47:12 +02:00
Rainer Gerhards
cbd00f8e2d Merge pull request #1707 from PascalWithopf/i-1093
omfwd, imtcp: add possibility to use priority string
2017-08-08 16:48:02 +02:00
PascalWithopf
717092d93e gnutls: add possibility to use priority string 2017-08-08 14:57:15 +02:00
Rainer Gerhards
ef411c7d06 omfwd refactor: use new-style errmsg object API
see also https://github.com/rsyslog/rsyslog/issues/1684
2017-07-20 14:55:41 +02:00
David Ahern
19e5d06f66 omfwd imudp: Add support for bind-to-device
Add support for bind-to-device option to omfwd and imudp modules.
Configured using device="name". Only new syntax format is supported.
e.g.,

input(type="imudp" port=["10514"] device="eth0" name="udp")
action(type="omfwd" Target="192.168.1.23" Port="10514" Device="eth0")

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
2016-11-15 17:55:56 -07:00
Reed Morrison
e301ed53d5 Adding options for tcp keep alive. 2014-12-13 18:15:51 +01:00
Rainer Gerhards
537a5aa90a undo commit 077d59c2c7984eb0273be949969585be241408c8 due to regression
There is a regression in this feature-add commit and I don't have the
time to search for it. Refering it back to contributor.

see also https://github.com/rsyslog/rsyslog/pull/145
2014-11-03 17:05:18 +01:00
Tomas Heinrich
077d59c2c7 imtcp: add options to configure keep-alive params
New options:        (legacy counterparts)
keepalive.time      $inputtcpserverkeepalive_time
keepalive.probes    $inputtcpserverkeepalive_probes
keepalive.interval  $inputtcpserverkeepalive_interval

The options are set separately for each instance.

This patch bumps the interface version of the nsd,
netstrm and tcpsrv modules.
2014-10-30 15:34:39 +01:00
Rainer Gerhards
0d71694fb3 optimize: have dns cache pre-create rsyslog prop_t's 2013-01-24 06:19:13 +01:00
Rainer Gerhards
dc52b123fe Simplify 2012-09-20 15:13:14 +02:00
8b19c7bc05 Added missing iRet handler code into CheckConnection() in netstrm.c 2012-09-20 03:39:48 -07:00
88faed212c Fixed TCP CheckConnection handling in omfwd.c.
Interface needed to be changed in lower stream classes. Syslog TCP Sending is now resumed properly.
2012-08-25 12:08:08 -07:00
Rainer Gerhards
48ab717fed fixing regression: multi-threading had races 2011-01-31 13:13:00 +01:00
Rainer Gerhards
b61e5fffc4 strmsrv now supports KEEPALIVE socket option 2009-06-02 13:11:18 +02:00
Rainer Gerhards
a900a7c34b greatly enhanced testbench
The imdiag module now can very effectively inject messages, which also
frees us from uncertainties of tcp reception and processing. All shell
script based tests have been modularized, what makes it far easier to
create new tests. Also, the test bench now executes more reliable and
much faster, because we can now rely on actual engine information where
we previously did just a dumb sleep.
2009-05-27 11:29:47 +02:00
Rainer Gerhards
eb1615068c added new testing module imdiag
which enables to talk to the rsyslog core at runtime. The current
implementation is only a beginning, but can be expanded over time
2009-05-25 10:47:22 +02:00
Rainer Gerhards
aba90e8248 added capability to run multiple tcp listeners (on different ports)
Well, actually this and a lot of related things. I improved the
testbench so that the new capabilities are automatically tested and
also did some general cleanup. The current multiple tcp listener
solution will probably receive some further cleanup, too, but looks
quite OK so far. I also reviewed the way tcpsrv et all work, in
preparation of using this code for imdiag. I need to document the
findings, especially as the code is rather complicated "thanks" to
the combination of plain tcp and gssapi transport modes.
2009-05-22 17:06:52 +02:00
Rainer Gerhards
97b89435aa bugfix: $AllowedSender handled invalidly for plain TCP transport 2008-11-29 09:47:04 +01:00
Rainer Gerhards
55e01da2ec somewhat improved plain tcp syslog reliability
...by doing a connection check before sending. Credits to Martin
Schuette for providing the idea. Details are available at
http://blog.gerhards.net/2008/06/reliable-plain-tcp-syslog-once-again.html
2008-06-09 12:40:54 +02:00
Rainer Gerhards
85b587f93d first implementation of TLS server client authentication check
The TLS server now checks the client fingerprint. This works, but
is highly experimental. Needs to be refined for practice. Also:
- implemented permittedPeers helper construct to store names
- changed omfwd implementation to use new permittedPeers
2008-05-19 18:52:44 +02:00
Rainer Gerhards
6ea98ec5ff added first rough ability to authenticate the server against its certificate
This is very experimental and needs some more work. It probably even
segfaults - but the base code is there and running. The rest is
refinement.

While working on this, I did these two bugfixes:
- bugfix: small mem leak in omfwd on exit (strmdriver name was not freed)
- bugfix: $ActionSendStreamDriver had no effect
2008-05-16 18:26:25 +02:00
Rainer Gerhards
7022e9019e support for different forwarding stream drivers added
they can now be set on an action-by-action basis
2008-05-05 14:19:12 +02:00
Rainer Gerhards
b9cbb0d696 made imgssapi work with new netstrm driver model
there were a couple of things where imgssapi was not compatible
with the new encapsulation. I did a somewhat dirty fix. The real
solution would be to turn gssapi functionality into a netstream
driver, which is too much for now (after all, we want to release
some time AND we need to have the code mature in practice
before we go for the next target...).
2008-05-05 11:45:41 +02:00
Rainer Gerhards
1cce2e35b0 removed loadbale module leak
- moved netstrms, netstrm and nssel into a single loadble module
  because they belong together
- fixed "loadbale module leak"
2008-04-29 12:21:52 +02:00
Rainer Gerhards
a3ff7eaf85 added $ActionSendStreamDriverMode config directive 2008-04-28 14:21:58 +02:00
Rainer Gerhards
75cf92117c made gtls server driver work in plain tcp mode 2008-04-25 12:54:59 +02:00
Rainer Gerhards
4b05bef636 Merge branch 'sock-abstract' into tls
Conflicts:

	runtime/Makefile.am
	runtime/netstrm.c
	runtime/nsd.h
	runtime/nsd_ptcp.c
	runtime/rsyslog.h
2008-04-24 17:43:45 +02:00
Rainer Gerhards
a7040a9623 some cleanup 2008-04-24 11:03:34 +02:00
Rainer Gerhards
bf3d2c1b39 message reception via TCP work again
... at least in some cases ;) I assume there are still a couple
of bugs inside the code. But at least we have something from
where we can continue to work on.
2008-04-24 09:57:43 +02:00
Rainer Gerhards
721b9ee252 client functionality works again (with the new socket abstraction) 2008-04-23 17:48:13 +02:00
Rainer Gerhards
50fe2ec2ea removed listener array from inidividual netstrm (mostly finished) 2008-04-23 16:31:35 +02:00
Rainer Gerhards
1892fc75f9 added new netstrms class
netstrms is at the top layer of the socket abstraction
2008-04-23 15:07:19 +02:00
Rainer Gerhards
2be459c4d7 objects for receive-side socket abstraction specified
The objects for receiver-side socket abstraction have now be
specified. The project as whole does not yet compile and
definitely not run, but I'd like to commit some milestones along
this way.
2008-04-23 09:59:01 +02:00
Rainer Gerhards
2069ab114e first working TLS-enabled plain TCP sender
implemented a first working version of a TLS-enabled plain TCP
sender (but, of course, the implementation is insecure as it is)
2008-04-18 18:29:02 +02:00
Rainer Gerhards
1daf8d492f converted netstrm into generic netstrm and the nsd_pctp driver 2008-04-18 11:40:15 +02:00