summaryrefslogtreecommitdiff
path: root/app-admin/rsyslog/files/8-stable/rsyslog-8.24.0-fix-tcpflood-without-librelp-r1.patch
blob: a03a6562722aadbd747f31630ad49134628342a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
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 <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 @@
 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);