Hi,
When I test rsyslog with imtcp module in tls mode, but the first message send
faild.
Expected behavior
server can accept the first message
Actual behavior
server can not accept the first message,The second message is acceptable
l Environment
rsyslog version:
rsyslog-8.1907.0
platform:
for configuration questions/issues, include rsyslog.conf and included config
files
client:
$DefaultNetstreamDriverCAFile /root/certificate/CA.cert
$DefaultNetstreamDriverCertFile /root/certificate/client.cert
$DefaultNetstreamDriverKeyFile /root/certificate/client.key
#$ActionSendStreamDriverAuthMode x509/certvalid
#$ActionSendStreamDriverMode 1
if ($programname == 'local6')
then action( type="omfwd" protocol="tcp" target="9.82.254.194" port="11514"
StreamDriver="gtls" StreamDriverMode="1" StreamDriverAuthMode="x509/certvalid")
& ~
server:
$ModLoad imtcp
$DefaultNetstreamDriver gtls
$DefaultNetstreamDriverCAFile /root/certificate/CA.cert
$DefaultNetstreamDriverCertFile /root/certificate/server.cert
$DefaultNetstreamDriverKeyFile /root/certificate/server.key
$InputTCPServerStreamDriverAuthMode x509/certvalid
$InputTCPServerKeepAlive on
$InputTCPServerStreamDriverMode 1
$InputTCPServerRun 11514
$template Remote, "/var/log/syslog/%fromhost-ip%/%$YEAR%-%$MONTH%-%$DAY%.log"
:fromhost-ip, !isequal, "127.0.0.1" ?Remote
l
Steps to reproduce the behavior
1、server: systemctl restart rsyslog
2、client:Print a log to the server(eg:logger -it local6 "111111111111111111117")
3、Observe whether the server receives the message
l
Failure Cause Analysis
In function CheckConnection,
……
rc = recv(pThis->sock, msgbuf, 1, MSG_DONTWAIT | MSG_PEEK);
if(rc == 0 && errno != EAGAIN) {
dbgprintf("CheckConnection detected broken connection - closing it (rc
%d, errno %d)\n", rc, errno);
/* in this case, the remote peer had shut down the connection and we
* need to close our side, too.
If the server restarted rsyslog, the connection with the client was lost.
When a new log needs to be transmitted to the server, the client calls recv ()
to return 0, and errno is not set.
So, the judgment of errno in the code is an incorrect judgment, which results
in that the connection is not re-established and the message is lost.
l Follow is my patch
Signed-off-by: wangshouping
<[email protected]<mailto:[email protected]>>
---
runtime/nsd_ptcp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/runtime/nsd_ptcp.c b/runtime/nsd_ptcp.c
index 68bed5b..30470b7 100644
--- a/runtime/nsd_ptcp.c
+++ b/runtime/nsd_ptcp.c
@@ -901,7 +901,7 @@ CheckConnection(nsd_t *pNsd)
ISOBJ_TYPE_assert(pThis, nsd_ptcp);
rc = recv(pThis->sock, msgbuf, 1, MSG_DONTWAIT | MSG_PEEK);
- if(rc == 0 && errno != EAGAIN) {
+ if(rc == 0) {
dbgprintf("CheckConnection detected broken connection - closing it (rc
%d, errno %d)\n", rc, errno);
/* in this case, the remote peer had shut down the connection and we
* need to close our side, too.
--
2.19.1
_______________________________________________
rsyslog mailing list
https://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of
sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE
THAT.