Patch to allow building of tcpflood without librelp Cherry pick of https://github.com/rsyslog/rsyslog/commit/73e3b7ab2f8a3974d31844b492ad02d61ed5727f https://github.com/rsyslog/rsyslog/pull/1493 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 +++ b/tests/tcpflood.c @@ -96,7 +96,9 @@ #include #include #include +#ifdef ENABLE_RELP #include +#endif #include #include #include @@ -149,7 +151,9 @@ 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 */ @@ -216,6 +220,7 @@ 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" @@ -235,6 +240,7 @@ CHKRELP(relpEngineSetEnableCmd(pRelpEngine, (unsigned char*)"syslog", eRelpCmdState_Required)); } +#endif /* #ifdef ENABLE_RELP */ /* prepare send subsystem for UDP send */ static int @@ -273,6 +279,7 @@ port = targetPort; } if(transport == TP_RELP_PLAIN) { + #ifdef ENABLE_RELP relpRetVal relp_r; relpClt_t *relpClt; char relpPort[16]; @@ -286,6 +293,7 @@ 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()"); @@ -336,8 +344,10 @@ 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) @@ -356,8 +366,10 @@ * 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); @@ -403,14 +415,13 @@ 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); @@ -419,6 +430,7 @@ } 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 @@ -610,6 +622,7 @@ 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 */ @@ -627,6 +640,7 @@ printf("\nrelpCltSendSyslog() failed with relp error code %d\n", relp_ret); } + #endif } if(lenSend != lenBuf) { printf("\r%5.5d\n", i); @@ -1106,7 +1120,9 @@ 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 { @@ -1168,7 +1184,9 @@ if(transport == TP_TLS) { initTLS(); } else if(transport == TP_RELP_PLAIN) { + #ifdef ENABLE_RELP initRELP_PLAIN(); + #endif } if(openConnections() != 0) { @@ -1183,9 +1201,11 @@ 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);