2017-04-02 02:27:03 +03:00
|
|
|
Patch to allow building of tcpflood without librelp
|
2017-03-22 08:49:54 +03:00
|
|
|
|
2017-04-02 02:27:03 +03:00
|
|
|
Cherry pick of
|
|
|
|
https://github.com/rsyslog/rsyslog/commit/73e3b7ab2f8a3974d31844b492ad02d61ed5727f
|
|
|
|
https://github.com/rsyslog/rsyslog/pull/1493
|
2017-03-22 08:49:54 +03:00
|
|
|
|
2017-04-02 02:27:03 +03:00
|
|
|
|
|
|
|
Gentoo-Bug: https://bugs.gentoo.org/613264
|
|
|
|
Gentoo-Bug: https://bugs.gentoo.org/614424
|
|
|
|
|
|
|
|
diff -u b/tests/tcpflood.c b/tests/tcpflood.c
|
|
|
|
--- b/tests/tcpflood.c
|
2017-03-22 08:49:54 +03:00
|
|
|
+++ b/tests/tcpflood.c
|
2017-04-02 02:27:03 +03:00
|
|
|
@@ -96,7 +96,9 @@
|
|
|
|
#include <string.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
+#ifdef ENABLE_RELP
|
|
|
|
#include <librelp.h>
|
|
|
|
+#endif
|
|
|
|
#include <sys/resource.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <errno.h>
|
|
|
|
@@ -149,7 +151,9 @@
|
2017-03-22 08:49:54 +03:00
|
|
|
static int numConnections = 1; /* number of connections to create */
|
|
|
|
static int softLimitConnections = 0; /* soft connection limit, see -c option description */
|
|
|
|
static int *sockArray; /* array of sockets to use */
|
|
|
|
+#ifdef ENABLE_RELP
|
|
|
|
static relpClt_t **relpCltArray; /* array of sockets to use */
|
|
|
|
+#endif
|
|
|
|
static int msgNum = 0; /* initial message number to start with */
|
|
|
|
static int bShowProgress = 1; /* show progress messages */
|
|
|
|
static int bSilent = 0; /* completely silent operation */
|
2017-04-02 02:27:03 +03:00
|
|
|
@@ -216,6 +220,7 @@
|
2017-03-22 08:49:54 +03:00
|
|
|
static int sendTLS(int i, char *buf, int lenBuf);
|
|
|
|
static void closeTLSSess(int __attribute__((unused)) i);
|
|
|
|
|
|
|
|
+#ifdef ENABLE_RELP
|
|
|
|
/* RELP subsystem */
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wformat-security"
|
2017-04-02 02:27:03 +03:00
|
|
|
@@ -235,6 +240,7 @@
|
2017-03-22 08:49:54 +03:00
|
|
|
CHKRELP(relpEngineSetEnableCmd(pRelpEngine, (unsigned char*)"syslog",
|
|
|
|
eRelpCmdState_Required));
|
|
|
|
}
|
|
|
|
+#endif /* #ifdef ENABLE_RELP */
|
|
|
|
|
|
|
|
/* prepare send subsystem for UDP send */
|
|
|
|
static int
|
2017-04-02 02:27:03 +03:00
|
|
|
@@ -273,6 +279,7 @@
|
2017-03-22 08:49:54 +03:00
|
|
|
port = targetPort;
|
|
|
|
}
|
|
|
|
if(transport == TP_RELP_PLAIN) {
|
|
|
|
+ #ifdef ENABLE_RELP
|
|
|
|
relpRetVal relp_r;
|
|
|
|
relpClt_t *relpClt;
|
|
|
|
char relpPort[16];
|
2017-04-02 02:27:03 +03:00
|
|
|
@@ -286,6 +293,7 @@
|
2017-03-22 08:49:54 +03:00
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
*fd = 1; /* mimic "all ok" state */
|
|
|
|
+ #endif
|
|
|
|
} else { /* TCP, with or without TLS */
|
|
|
|
if((sock=socket(AF_INET, SOCK_STREAM, 0))==-1) {
|
|
|
|
perror("\nsocket()");
|
2017-04-02 02:27:03 +03:00
|
|
|
@@ -336,8 +344,10 @@
|
2017-03-22 08:49:54 +03:00
|
|
|
sessArray = calloc(numConnections, sizeof(gnutls_session_t));
|
|
|
|
# endif
|
|
|
|
sockArray = calloc(numConnections, sizeof(int));
|
|
|
|
+ #ifdef ENABLE_RELP
|
|
|
|
if(transport == TP_RELP_PLAIN)
|
|
|
|
relpCltArray = calloc(numConnections, sizeof(relpClt_t*));
|
|
|
|
+ #endif
|
|
|
|
for(i = 0 ; i < numConnections ; ++i) {
|
|
|
|
if(i % 10 == 0) {
|
|
|
|
if(bShowProgress)
|
2017-04-02 02:27:03 +03:00
|
|
|
@@ -356,8 +366,10 @@
|
2017-03-22 08:49:54 +03:00
|
|
|
* at least something.
|
|
|
|
*/
|
|
|
|
if(transport == TP_RELP_PLAIN) {
|
|
|
|
+ #ifdef ENABLE_RELP
|
|
|
|
CHKRELP(relpEngineCltDestruct(pRelpEngine,
|
|
|
|
relpCltArray+i));
|
|
|
|
+ #endif
|
|
|
|
} else { /* TCP and TLS modes */
|
|
|
|
if(transport == TP_TLS)
|
|
|
|
closeTLSSess(i);
|
2017-04-02 02:27:03 +03:00
|
|
|
@@ -403,14 +415,13 @@
|
2017-03-22 08:49:54 +03:00
|
|
|
|
|
|
|
if(bShowProgress)
|
|
|
|
if(write(1, " close connections", sizeof(" close connections")-1)){}
|
|
|
|
- //if(transport == TP_RELP_PLAIN)
|
|
|
|
- //sleep(10); /* we need to let librelp settle a bit */
|
|
|
|
for(i = 0 ; i < numConnections ; ++i) {
|
|
|
|
if(i % 10 == 0 && bShowProgress) {
|
|
|
|
lenMsg = sprintf(msgBuf, "\r%5.5d", i);
|
|
|
|
if(write(1, msgBuf, lenMsg)){}
|
|
|
|
}
|
|
|
|
if(transport == TP_RELP_PLAIN) {
|
|
|
|
+ #ifdef ENABLE_RELP
|
|
|
|
relpRetVal relpr;
|
|
|
|
if(sockArray[i] != -1) {
|
|
|
|
relpr = relpEngineCltDestruct(pRelpEngine, relpCltArray+i);
|
2017-04-02 02:27:03 +03:00
|
|
|
@@ -419,6 +430,7 @@
|
2017-03-22 08:49:54 +03:00
|
|
|
}
|
|
|
|
sockArray[i] = -1;
|
|
|
|
}
|
|
|
|
+ #endif
|
|
|
|
} else { /* TCP and TLS modes */
|
|
|
|
if(sockArray[i] != -1) {
|
|
|
|
/* we try to not overrun the receiver by trying to flush buffers
|
2017-04-02 02:27:03 +03:00
|
|
|
@@ -610,6 +622,7 @@
|
2017-03-22 08:49:54 +03:00
|
|
|
offsSendBuf = lenBuf;
|
|
|
|
}
|
|
|
|
} else if(transport == TP_RELP_PLAIN) {
|
|
|
|
+ #ifdef ENABLE_RELP
|
|
|
|
relpRetVal relp_ret;
|
|
|
|
if(sockArray[socknum] == -1) {
|
|
|
|
/* connection was dropped, need to re-establish */
|
2017-04-02 02:27:03 +03:00
|
|
|
@@ -627,6 +640,7 @@
|
2017-03-22 08:49:54 +03:00
|
|
|
printf("\nrelpCltSendSyslog() failed with relp error code %d\n",
|
|
|
|
relp_ret);
|
|
|
|
}
|
|
|
|
+ #endif
|
|
|
|
}
|
|
|
|
if(lenSend != lenBuf) {
|
|
|
|
printf("\r%5.5d\n", i);
|
2017-04-02 02:27:03 +03:00
|
|
|
@@ -1106,7 +1120,9 @@
|
2017-03-22 08:49:54 +03:00
|
|
|
transport = TP_RELP_PLAIN;
|
|
|
|
# else
|
|
|
|
fprintf(stderr, "compiled without RELP support: "
|
|
|
|
- "\"-Trelp-plain\" not supported!\n");
|
|
|
|
+ "\"-Trelp-plain\" not supported!\n"
|
|
|
|
+ "(add --enable-relp to ./configure options "
|
|
|
|
+ "if desired)\n");
|
|
|
|
exit(1);
|
|
|
|
# endif
|
|
|
|
} else {
|
2017-04-02 02:27:03 +03:00
|
|
|
@@ -1168,7 +1184,9 @@
|
2017-03-22 08:49:54 +03:00
|
|
|
if(transport == TP_TLS) {
|
|
|
|
initTLS();
|
|
|
|
} else if(transport == TP_RELP_PLAIN) {
|
|
|
|
+ #ifdef ENABLE_RELP
|
|
|
|
initRELP_PLAIN();
|
|
|
|
+ #endif
|
|
|
|
}
|
|
|
|
|
|
|
|
if(openConnections() != 0) {
|
2017-04-02 02:27:03 +03:00
|
|
|
@@ -1183,9 +1201,11 @@
|
2017-03-22 08:49:54 +03:00
|
|
|
|
|
|
|
closeConnections(); /* this is important so that we do not finish too early! */
|
|
|
|
|
|
|
|
+ #ifdef ENABLE_RELP
|
|
|
|
if(transport == TP_RELP_PLAIN) {
|
|
|
|
CHKRELP(relpEngineDestruct(&pRelpEngine));
|
|
|
|
}
|
|
|
|
+ #endif
|
|
|
|
|
|
|
|
if(nConnDrops > 0 && !bSilent)
|
|
|
|
printf("-D option initiated %ld connection closures\n", nConnDrops);
|