37
37
#include <getopt.h>
38
38
#include <linux/netfilter.h>
39
39
#include <netinet/ip.h>
40
- #include <netinet /tcp.h>
40
+ #include <linux /tcp.h>
41
41
#include <arpa/inet.h>
42
42
#include <net/if.h>
43
43
@@ -246,14 +246,15 @@ static void logger_fn(void)
246
246
struct pep_proxy * proxy ;
247
247
time_t tm ;
248
248
char ip_src [17 ], ip_dst [17 ];
249
- int len , i = 0 ;
249
+ int len , i = 0 , tcp_info_length ;
250
+ struct tcp_info tcp_info ;
250
251
251
252
PEP_DEBUG ("Logger invoked!" );
252
253
SYNTAB_LOCK_READ ();
253
254
tm = time (NULL );
254
255
fprintf (logger .file , "{\"time\":%.f,\"proxies\":[" ,difftime (tm , (time_t ) 0 ));
255
256
syntab_foreach_connection (proxy ) {
256
- if (i > 0 )
257
+ if (i ++ > 0 )
257
258
fprintf (logger .file , "," );
258
259
259
260
toip (ip_src , proxy -> src .addr );
@@ -266,11 +267,23 @@ static void logger_fn(void)
266
267
fprintf (logger .file , "\"sync_recv\":%.f" , difftime (proxy -> syn_time , (time_t ) 0 ));
267
268
268
269
if (proxy -> last_rxtx != 0 ) {
269
- fprintf (logger .file , ",\"last_act \":\"%s \"" , difftime (proxy -> last_rxtx , (time_t ) 0 ));
270
+ fprintf (logger .file , ",\"last_rxtx \":\"%.f \"" , difftime (proxy -> last_rxtx , (time_t ) 0 ));
270
271
}
271
272
273
+ tcp_info_length = sizeof (tcp_info );
274
+ if ( getsockopt (proxy -> dst .fd , IPPROTO_TCP , TCP_INFO , (void * )& tcp_info ,
275
+ (socklen_t * )& tcp_info_length ) == 0 ) {
276
+ fprintf (logger .file ,"\",rto\":%u," , tcp_info .tcpi_rto );
277
+ fprintf (logger .file ,"\"retrans\":%u," , tcp_info .tcpi_total_retrans );
278
+ fprintf (logger .file ,"\"rtt\":%u," , tcp_info .tcpi_rtt );
279
+ fprintf (logger .file ,"\"rtt_var\":%u," , tcp_info .tcpi_rttvar );
280
+ fprintf (logger .file ,"\"btyes_recv\":%u," , tcp_info .tcpi_bytes_received );
281
+ fprintf (logger .file ,"\"segs_in\":%u," , tcp_info .tcpi_segs_in );
282
+ fprintf (logger .file ,"\"segs_out\":%u," , tcp_info .tcpi_segs_out );
283
+ fprintf (logger .file ,"\"tcp_delivery_rate_byps\":%lu" , tcp_info .tcpi_delivery_rate );
284
+ }
285
+
272
286
fprintf (logger .file , "}" );
273
- i ++ ;
274
287
}
275
288
fprintf (logger .file , "]}\n" );
276
289
@@ -639,7 +652,7 @@ void *listener_loop(void UNUSED(*unused))
639
652
/* Set TCP_FASTOPEN socket option */
640
653
if (fastopen ) {
641
654
optval = 5 ;
642
- ret = setsockopt (listenfd , SOL_TCP , TCP_FASTOPEN ,
655
+ ret = setsockopt (listenfd , IPPROTO_TCP , TCP_FASTOPEN ,
643
656
& optval , sizeof (optval ));
644
657
if (ret < 0 ) {
645
658
pep_error ("Failed to set TCP_FASTOPEN option! [RET = %d]" , ret );
0 commit comments