Skip to content

Commit 9c55e84

Browse files
syzzercron2
authored andcommitted
Remove perf.c/perf.h
This code was always disabled by ENABLE_PERFORMANCE_METRICS being commented out in perf.h. There was no configure flag. None of the active developers remembers using it, the git log shows no actual code changes since at least the project structure overhaul of 2012, and tools like gprof are nowadays the go-to tool for performance profiling. So, out with our custom implementation. This was triggered by a bug report submitted by Joshua Rogers, who used ZeroPath to discover we missed a perf_pop() call in one of the error paths of ssl_mbedtls.c. This commit resolves that using git rm. Change-Id: I5bb666a73b4381066e86f53d957e1987fa07303b Signed-off-by: Steffan Karger <[email protected]> Acked-by: Gert Doering <[email protected]> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1303 Message-Id: <[email protected]> URL: https://www.mail-archive.com/[email protected]/msg33868.html Signed-off-by: Gert Doering <[email protected]>
1 parent a69d9b6 commit 9c55e84

File tree

16 files changed

+0
-496
lines changed

16 files changed

+0
-496
lines changed

CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,6 @@ set(SOURCE_FILES
519519
src/openvpn/ovpn_dco_win.h
520520
src/openvpn/packet_id.c
521521
src/openvpn/packet_id.h
522-
src/openvpn/perf.c
523-
src/openvpn/perf.h
524522
src/openvpn/ping.c
525523
src/openvpn/ping.h
526524
src/openvpn/pkcs11.c

src/openvpn/Makefile.am

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ openvpn_SOURCES = \
112112
options_parse.c \
113113
otime.c otime.h \
114114
packet_id.c packet_id.h \
115-
perf.c perf.h \
116115
ping.c ping.h \
117116
plugin.c plugin.h \
118117
pool.c pool.h \

src/openvpn/error.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include "socket.h"
3535
#include "tun.h"
3636
#include "otime.h"
37-
#include "perf.h"
3837
#include "status.h"
3938
#include "integer.h"
4039
#include "ps.h"
@@ -734,11 +733,6 @@ openvpn_exit(const int status)
734733
abort();
735734
}
736735
#endif
737-
738-
if (status == OPENVPN_EXIT_STATUS_GOOD)
739-
{
740-
perf_output_results();
741-
}
742736
}
743737

744738
exit(status);

src/openvpn/event.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
#include "win32.h"
2727
#include "sig.h"
28-
#include "perf.h"
2928

3029
/*
3130
* rwflags passed to event_ctl and returned by
@@ -189,9 +188,7 @@ static inline int
189188
event_wait(struct event_set *es, const struct timeval *tv, struct event_set_return *out, int outlen)
190189
{
191190
int ret;
192-
perf_push(PERF_IO_WAIT);
193191
ret = (*es->func.wait)(es, tv, out, outlen);
194-
perf_pop();
195192
return ret;
196193
}
197194

src/openvpn/forward.c

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -932,8 +932,6 @@ read_incoming_link(struct context *c, struct link_socket *sock)
932932

933933
/*ASSERT (!c->c2.to_tun.len);*/
934934

935-
perf_push(PERF_READ_IN_LINK);
936-
937935
c->c2.buf = c->c2.buffers->read_link_buf;
938936
ASSERT(buf_init(&c->c2.buf, c->c2.frame.buf.headroom));
939937

@@ -966,7 +964,6 @@ read_incoming_link(struct context *c, struct link_socket *sock)
966964
msg(D_STREAM_ERRORS, "Connection reset, restarting [%d]", status);
967965
}
968966
}
969-
perf_pop();
970967
return;
971968
}
972969

@@ -983,8 +980,6 @@ read_incoming_link(struct context *c, struct link_socket *sock)
983980

984981
/* Remove socks header if applicable */
985982
socks_postprocess_incoming_link(c, sock);
986-
987-
perf_pop();
988983
}
989984

990985
bool
@@ -1212,15 +1207,11 @@ process_incoming_link_part2(struct context *c, struct link_socket_info *lsi,
12121207
static void
12131208
process_incoming_link(struct context *c, struct link_socket *sock)
12141209
{
1215-
perf_push(PERF_PROC_IN_LINK);
1216-
12171210
struct link_socket_info *lsi = &sock->info;
12181211
const uint8_t *orig_buf = c->c2.buf.data;
12191212

12201213
process_incoming_link_part1(c, lsi, false);
12211214
process_incoming_link_part2(c, lsi, orig_buf);
1222-
1223-
perf_pop();
12241215
}
12251216

12261217
void
@@ -1326,8 +1317,6 @@ read_incoming_tun(struct context *c)
13261317
*/
13271318
/*ASSERT (!c->c2.to_link.len);*/
13281319

1329-
perf_push(PERF_READ_IN_TUN);
1330-
13311320
c->c2.buf = c->c2.buffers->read_tun_buf;
13321321

13331322
#ifdef _WIN32
@@ -1360,7 +1349,6 @@ read_incoming_tun(struct context *c)
13601349
{
13611350
register_signal(c->sig, SIGTERM, "tun-stop");
13621351
msg(M_INFO, "TUN/TAP interface has been stopped, exiting");
1363-
perf_pop();
13641352
return;
13651353
}
13661354

@@ -1370,14 +1358,11 @@ read_incoming_tun(struct context *c)
13701358
register_signal(c->sig, SIGHUP, "tun-abort");
13711359
c->persist.restart_sleep_seconds = 10;
13721360
msg(M_INFO, "TUN/TAP I/O operation aborted, restarting");
1373-
perf_pop();
13741361
return;
13751362
}
13761363

13771364
/* Check the status return from read() */
13781365
check_status(c->c2.buf.len, "read from TUN/TAP", NULL, c->c1.tuntap);
1379-
1380-
perf_pop();
13811366
}
13821367

13831368
/**
@@ -1497,8 +1482,6 @@ process_incoming_tun(struct context *c, struct link_socket *out_sock)
14971482
{
14981483
struct gc_arena gc = gc_new();
14991484

1500-
perf_push(PERF_PROC_IN_TUN);
1501-
15021485
if (c->c2.buf.len > 0)
15031486
{
15041487
c->c2.tun_read_bytes += c->c2.buf.len;
@@ -1542,7 +1525,6 @@ process_incoming_tun(struct context *c, struct link_socket *out_sock)
15421525
{
15431526
buf_reset(&c->c2.to_link);
15441527
}
1545-
perf_pop();
15461528
gc_free(&gc);
15471529
}
15481530

@@ -1770,8 +1752,6 @@ process_outgoing_link(struct context *c, struct link_socket *sock)
17701752
struct gc_arena gc = gc_new();
17711753
int error_code = 0;
17721754

1773-
perf_push(PERF_PROC_OUT_LINK);
1774-
17751755
if (c->c2.to_link.len > 0 && c->c2.to_link.len <= c->c2.frame.buf.payload_size)
17761756
{
17771757
/*
@@ -1899,7 +1879,6 @@ process_outgoing_link(struct context *c, struct link_socket *sock)
18991879

19001880
buf_reset(&c->c2.to_link);
19011881

1902-
perf_pop();
19031882
gc_free(&gc);
19041883
}
19051884

@@ -1919,8 +1898,6 @@ process_outgoing_tun(struct context *c, struct link_socket *in_sock)
19191898
return;
19201899
}
19211900

1922-
perf_push(PERF_PROC_OUT_TUN);
1923-
19241901
/*
19251902
* The --mssfix option requires
19261903
* us to examine the IP header (IPv4 or IPv6).
@@ -1993,8 +1970,6 @@ process_outgoing_tun(struct context *c, struct link_socket *in_sock)
19931970
}
19941971

19951972
buf_reset(&c->c2.to_tun);
1996-
1997-
perf_pop();
19981973
}
19991974

20001975
#if defined(__GNUC__) || defined(__clang__)

src/openvpn/multi.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,6 @@ multi_client_disconnect_script(struct multi_context *m, struct multi_instance *m
580580
void
581581
multi_close_instance(struct multi_context *m, struct multi_instance *mi, bool shutdown)
582582
{
583-
perf_push(PERF_MULTI_CLOSE_INSTANCE);
584-
585583
ASSERT(!mi->halt);
586584
mi->halt = true;
587585
bool is_dgram = proto_is_dgram(mi->context.c2.link_sockets[0]->info.proto);
@@ -672,8 +670,6 @@ multi_close_instance(struct multi_context *m, struct multi_instance *mi, bool sh
672670
* vhash reaper deal with it.
673671
*/
674672
multi_instance_dec_refcount(mi);
675-
676-
perf_pop();
677673
}
678674

679675
/*
@@ -734,8 +730,6 @@ multi_create_instance(struct multi_context *m, const struct mroute_addr *real,
734730
struct gc_arena gc = gc_new();
735731
struct multi_instance *mi;
736732

737-
perf_push(PERF_MULTI_CREATE_INSTANCE);
738-
739733
msg(D_MULTI_MEDIUM, "MULTI: multi_create_instance called");
740734

741735
ALLOC_OBJ_CLEAR(mi, struct multi_instance);
@@ -807,13 +801,11 @@ multi_create_instance(struct multi_context *m, const struct mroute_addr *real,
807801
mi->ev_arg.type = EVENT_ARG_MULTI_INSTANCE;
808802
mi->ev_arg.u.mi = mi;
809803

810-
perf_pop();
811804
gc_free(&gc);
812805
return mi;
813806

814807
err:
815808
multi_close_instance(m, mi, false);
816-
perf_pop();
817809
gc_free(&gc);
818810
return NULL;
819811
}
@@ -2907,7 +2899,6 @@ multi_bcast(struct multi_context *m, const struct buffer *buf,
29072899

29082900
if (BLEN(buf) > 0)
29092901
{
2910-
perf_push(PERF_MULTI_BCAST);
29112902
#ifdef MULTI_DEBUG_EVENT_LOOP
29122903
printf("BCAST len=%d\n", BLEN(buf));
29132904
#endif
@@ -2929,7 +2920,6 @@ multi_bcast(struct multi_context *m, const struct buffer *buf,
29292920

29302921
hash_iterator_free(&hi);
29312922
mbuf_free_buf(mb);
2932-
perf_pop();
29332923
}
29342924
}
29352925

@@ -3399,7 +3389,6 @@ multi_process_incoming_link(struct multi_context *m, struct multi_instance *inst
33993389

34003390
/* decrypt in instance context */
34013391

3402-
perf_push(PERF_PROC_IN_LINK);
34033392
lsi = &sock->info;
34043393
orig_buf = c->c2.buf.data;
34053394
if (process_incoming_link_part1(c, lsi, floated))
@@ -3412,7 +3401,6 @@ multi_process_incoming_link(struct multi_context *m, struct multi_instance *inst
34123401

34133402
process_incoming_link_part2(c, lsi, orig_buf);
34143403
}
3415-
perf_pop();
34163404

34173405
if (TUNNEL_TYPE(m->top.c1.tuntap) == DEV_TYPE_TUN)
34183406
{
@@ -4180,8 +4168,6 @@ tunnel_server_loop(struct multi_context *multi)
41804168

41814169
while (true)
41824170
{
4183-
perf_push(PERF_EVENT_LOOP);
4184-
41854171
/* wait on tun/socket list */
41864172
multi_get_timeout(multi, &multi->top.c2.timeval);
41874173
status = multi_io_wait(multi);
@@ -4202,7 +4188,6 @@ tunnel_server_loop(struct multi_context *multi)
42024188
}
42034189

42044190
MULTI_CHECK_SIG(multi);
4205-
perf_pop();
42064191
}
42074192
}
42084193

src/openvpn/multi.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#include "mudp.h"
3939
#include "mtcp.h"
4040
#include "multi_io.h"
41-
#include "perf.h"
4241
#include "vlan.h"
4342
#include "reflect_filter.h"
4443

src/openvpn/multi_io.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,7 @@ multi_io_wait_lite(struct multi_context *m, struct multi_instance *mi, const int
242242
tun_input_pending = NULL;
243243
/* For some reason, the Linux 2.2 TUN/TAP driver hits this timeout */
244244
c->c2.timeval.tv_sec = 1;
245-
perf_push(PERF_PROC_OUT_TUN_MTCP);
246245
io_wait(c, IOW_TO_TUN);
247-
perf_pop();
248246
break;
249247

250248
case TA_SOCKET_WRITE:

src/openvpn/openvpn.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ tunnel_point_to_point(struct context *c)
7272
/* main event loop */
7373
while (true)
7474
{
75-
perf_push(PERF_EVENT_LOOP);
76-
7775
/* process timers, TLS, etc. */
7876
pre_select(c);
7977
P2P_CHECK_SIG();
@@ -85,15 +83,12 @@ tunnel_point_to_point(struct context *c)
8583
/* timeout? */
8684
if (c->c2.event_set_status == ES_TIMEOUT)
8785
{
88-
perf_pop();
8986
continue;
9087
}
9188

9289
/* process the I/O which triggered select */
9390
process_io(c, c->c2.link_sockets[0]);
9491
P2P_CHECK_SIG();
95-
96-
perf_pop();
9792
}
9893

9994
persist_client_stats(c);

src/openvpn/openvpn.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,6 @@ struct context
524524
if (IS_SIG(c)) \
525525
{ \
526526
const int brk = func(arg); \
527-
perf_pop(); \
528527
if (brk) \
529528
{ \
530529
break; \

0 commit comments

Comments
 (0)