From: "plaisthos (Code Review)" Date: Wed, 29 Oct 2025 14:58:54 +0000 References: Reply-To: arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <7812d72e190572b9cca4dd7369f4404f26caf3fc-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="vYf/NhR0Q9Y="; charset=UTF-8 Subject: [Openvpn-devel] [L] Change in openvpn[master]: Remove --memstats feature List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: openvpn-devel --vYf/NhR0Q9Y= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld. Hello flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1329?usp=3Demail to review the following change. Change subject: Remove --memstats feature ...................................................................... Remove --memstats feature The ``--mememstat`` was largely undocumented and there is no known user of this feature. This feature provided very limited statistics (number of users, link bytes read/written) and we do not except any usage because of this. The only documentation was a mention in --help without any mention of the (binary) format of the mmap file or other usage instructions. This deals also with issues reported by zeropath regarding potentially insecure handling of the file permission of the memory mapped file. Reported-by: Joshua Rogers Found-by: ZeroPath (https://zeropath.com/) Change-Id: I5f57e7bf52e3f6289462ef05e1f6e81ab0133d0d Signed-off-by: Arne Schwabe --- M CMakeLists.txt M Changes.rst M src/openvpn/Makefile.am M src/openvpn/error.c M src/openvpn/forward.c M src/openvpn/init.c D src/openvpn/mstats.c D src/openvpn/mstats.h M src/openvpn/multi.c M src/openvpn/options.c M src/openvpn/options.h M src/openvpn/syshead.h 12 files changed, 5 insertions(+), 257 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/29/1329/1 diff --git a/CMakeLists.txt b/CMakeLists.txt index bf754f3..c9301e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -490,8 +490,6 @@ src/openvpn/mroute.h src/openvpn/mss.c src/openvpn/mss.h - src/openvpn/mstats.c - src/openvpn/mstats.h src/openvpn/mtcp.c src/openvpn/mtcp.h src/openvpn/mtu.c diff --git a/Changes.rst b/Changes.rst index 4feacad2..41af103 100644 --- a/Changes.rst +++ b/Changes.rst @@ -217,6 +217,11 @@ ``--allow-compression yes`` is now an alias for ``--allow-compression asym``. +``--memstats`` feature removed + The ``--mememstat`` was largely undocumented and there is no known + user of this feature. This feature provided very limited statistics + (number of users, link bytes read/written) and we do not except any + usage because of this. User-visible Changes -------------------- diff --git a/src/openvpn/Makefile.am b/src/openvpn/Makefile.am index dc58cd1..db87dfc 100644 --- a/src/openvpn/Makefile.am +++ b/src/openvpn/Makefile.am @@ -90,7 +90,6 @@ mbedtls_compat.h \ mroute.c mroute.h \ mss.c mss.h \ - mstats.c mstats.h \ mtcp.c mtcp.h \ mtu.c mtu.h \ mudp.c mudp.h \ diff --git a/src/openvpn/error.c b/src/openvpn/error.c index 735d259..bd588d4 100644 --- a/src/openvpn/error.c +++ b/src/openvpn/error.c @@ -37,8 +37,6 @@ #include "status.h" #include "integer.h" #include "ps.h" -#include "mstats.h" - #if SYSLOG_CAPABILITY #ifndef LOG_OPENVPN @@ -723,10 +721,6 @@ } #endif -#ifdef ENABLE_MEMSTATS - mstats_close(); -#endif - #ifdef ABORT_ON_ERROR if (status =3D=3D OPENVPN_EXIT_STATUS_ERROR) { diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 7f72000..5bbac13 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -44,8 +44,6 @@ #include "memdbg.h" -#include "mstats.h" - counter_type link_read_bytes_global; /* GLOBAL */ counter_type link_write_bytes_global; /* GLOBAL */ @@ -992,12 +990,6 @@ { c->c2.link_read_bytes +=3D c->c2.buf.len; link_read_bytes_global +=3D c->c2.buf.len; -#ifdef ENABLE_MEMSTATS - if (mmap_stats) - { - mmap_stats->link_read_bytes =3D link_read_bytes_global; - } -#endif c->c2.original_recv_size =3D c->c2.buf.len; } else @@ -1821,12 +1813,6 @@ c->c2.max_send_size_local =3D max_int(size, c->c2.max_send= _size_local); c->c2.link_write_bytes +=3D size; link_write_bytes_global +=3D size; -#ifdef ENABLE_MEMSTATS - if (mmap_stats) - { - mmap_stats->link_write_bytes =3D link_write_bytes_glob= al; - } -#endif } } diff --git a/src/openvpn/init.c b/src/openvpn/init.c index aa2611d..1bdaf27 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -44,7 +44,6 @@ #include "ps.h" #include "lladdr.h" #include "ping.h" -#include "mstats.h" #include "ssl_verify.h" #include "ssl_ncp.h" #include "tls_crypt.h" @@ -908,22 +907,6 @@ return false; #endif -#ifdef MSTATS_TEST - { - int i; - mstats_open("/dev/shm/mstats.dat"); - for (i =3D 0; i < 30; ++i) - { - mmap_stats->n_clients +=3D 1; - mmap_stats->link_write_bytes +=3D 8; - mmap_stats->link_read_bytes +=3D 16; - sleep(1); - } - mstats_close(); - return false; - } -#endif - return true; } @@ -1233,13 +1216,6 @@ } } -#ifdef ENABLE_MEMSTATS - if (c->first_time && c->options.memstats_fn) - { - mstats_open(c->options.memstats_fn); - } -#endif - #ifdef ENABLE_SELINUX /* Apply a SELinux context in order to restrict what OpenVPN can do * to _only_ what it is supposed to do after initialization is com= plete diff --git a/src/openvpn/mstats.c b/src/openvpn/mstats.c deleted file mode 100644 index bd6316c..0000000 --- a/src/openvpn/mstats.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - * OpenVPN -- An application to securely tunnel IP networks - * over a single TCP/UDP port, with support for SSL/TLS-based - * session authentication and key exchange, - * packet encryption, packet authentication, and - * packet compression. - * - * Copyright (C) 2002-2025 OpenVPN Inc - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - */ - -/* - * Maintain usage stats in a memory-mapped file - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "syshead.h" - -#if defined(ENABLE_MEMSTATS) - -#include - -#include "error.h" -#include "misc.h" -#include "mstats.h" - -#include "memdbg.h" - -volatile struct mmap_stats *mmap_stats =3D NULL; /* GLOBAL */ -static char mmap_fn[128]; - -void -mstats_open(const char *fn) -{ - void *data; - ssize_t stat; - int fd; - struct mmap_stats ms; - - if (mmap_stats) /* already called? */ - { - return; - } - - /* verify that filename is not too long */ - if (strlen(fn) >=3D sizeof(mmap_fn)) - { - msg(M_FATAL, "mstats_open: filename too long"); - } - - /* create file that will be memory mapped */ - fd =3D open(fn, O_CREAT | O_TRUNC | O_RDWR, S_IRUSR | S_IWUSR); - if (fd < 0) - { - msg(M_ERR, "mstats_open: cannot open: %s", fn); - return; - } - - /* set the file to the correct size to contain a - * struct mmap_stats, and zero it */ - CLEAR(ms); - ms.state =3D MSTATS_ACTIVE; - stat =3D write(fd, &ms, sizeof(ms)); - if (stat !=3D sizeof(ms)) - { - msg(M_ERR, "mstats_open: write error: %s", fn); - close(fd); - return; - } - - /* mmap the file */ - data =3D mmap(NULL, sizeof(struct mmap_stats), PROT_READ | PROT_WRITE,= MAP_SHARED, fd, 0); - if (data =3D=3D MAP_FAILED) - { - msg(M_ERR, "mstats_open: write error: %s", fn); - close(fd); - return; - } - - /* close the fd (mmap now controls the file) */ - if (close(fd)) - { - msg(M_ERR, "mstats_open: close error: %s", fn); - } - - /* save filename so we can delete it later */ - strcpy(mmap_fn, fn); - - /* save a global pointer to memory-mapped region */ - mmap_stats =3D (struct mmap_stats *)data; - - msg(M_INFO, "memstats data will be written to %s", fn); -} - -void -mstats_close(void) -{ - if (mmap_stats) - { - mmap_stats->state =3D MSTATS_EXPIRED; - if (munmap((void *)mmap_stats, sizeof(struct mmap_stats))) - { - msg(M_WARN | M_ERRNO, "mstats_close: munmap error"); - } - platform_unlink(mmap_fn); - mmap_stats =3D NULL; - } -} - -#endif /* if defined(ENABLE_MEMSTATS) */ diff --git a/src/openvpn/mstats.h b/src/openvpn/mstats.h deleted file mode 100644 index c38b0f2..0000000 --- a/src/openvpn/mstats.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * OpenVPN -- An application to securely tunnel IP networks - * over a single TCP/UDP port, with support for SSL/TLS-based - * session authentication and key exchange, - * packet encryption, packet authentication, and - * packet compression. - * - * Copyright (C) 2002-2025 OpenVPN Inc - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - */ - -/* - * Maintain usage stats in a memory-mapped file - */ - -#if !defined(OPENVPN_MEMSTATS_H) && defined(ENABLE_MEMSTATS) -#define OPENVPN_MEMSTATS_H - -#include "basic.h" - -/* this struct is mapped to the file */ -struct mmap_stats -{ - counter_type link_read_bytes; /* counter_type can be assumed to be a u= int64_t */ - counter_type link_write_bytes; - int n_clients; - -#define MSTATS_UNDEF 0 -#define MSTATS_ACTIVE 1 -#define MSTATS_EXPIRED 2 - int state; -}; - -extern volatile struct mmap_stats *mmap_stats; /* GLOBAL */ - -void mstats_open(const char *fn); - -void mstats_close(void); - -#endif /* if !defined(OPENVPN_MEMSTATS_H) && defined(ENABLE_MEMSTATS) */ diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index 285671d..e243843 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -37,7 +37,6 @@ #include "run_command.h" #include "otime.h" #include "gremlin.h" -#include "mstats.h" #include "ssl_verify.h" #include "ssl_ncp.h" #include "vlan.h" @@ -80,17 +79,6 @@ } #endif -static inline void -update_mstat_n_clients(const int n_clients) -{ -#ifdef ENABLE_MEMSTATS - if (mmap_stats) - { - mmap_stats->n_clients =3D n_clients; - } -#endif -} - static bool learn_address_script(const struct multi_context *m, const struct multi_ins= tance *mi, const char *op, const struct mroute_addr *addr) @@ -589,7 +577,6 @@ /* adjust current client connection count */ m->n_clients +=3D mi->n_clients_delta; - update_mstat_n_clients(m->n_clients); mi->n_clients_delta =3D 0; /* prevent dangling pointers */ @@ -2799,7 +2786,6 @@ /* increment number of current authenticated clients */ ++m->n_clients; - update_mstat_n_clients(m->n_clients); --mi->n_clients_delta; #ifdef ENABLE_MANAGEMENT diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 9c02a8c..ecf9374 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -323,9 +323,6 @@ " via a VRF present on the system.\n" #endif "--txqueuelen n : Set the tun/tap TX queue length to n (Linux only).\= n" -#ifdef ENABLE_MEMSTATS - "--memstats file : Write live usage stats to memory mapped binary file= .\n" -#endif "--mlock : Disable Paging -- ensures key material and tunnel\n" " data will never be written to disk.\n" "--up cmd : Run command cmd after successful tun device open.\n" @@ -6333,13 +6330,6 @@ options->log =3D true; redirect_stdout_stderr(p[1], true); } -#ifdef ENABLE_MEMSTATS - else if (streq(p[0], "memstats") && p[1] && !p[2]) - { - VERIFY_PERMISSION(OPT_P_GENERAL); - options->memstats_fn =3D p[1]; - } -#endif else if (streq(p[0], "mlock") && !p[1]) { VERIFY_PERMISSION(OPT_P_GENERAL); diff --git a/src/openvpn/options.h b/src/openvpn/options.h index 125e524..9d2ff9f 100644 --- a/src/openvpn/options.h +++ b/src/openvpn/options.h @@ -336,10 +336,6 @@ bool mtu_test; -#ifdef ENABLE_MEMSTATS - char *memstats_fn; -#endif - bool mlock; int keepalive_ping; /* a proxy for ping/ping-restart */ diff --git a/src/openvpn/syshead.h b/src/openvpn/syshead.h index 26a553b..90045a9 100644 --- a/src/openvpn/syshead.h +++ b/src/openvpn/syshead.h @@ -528,13 +528,6 @@ #define USE_COMP #endif -/* - * Enable --memstats option - */ -#ifdef TARGET_LINUX -#define ENABLE_MEMSTATS -#endif - #ifdef _MSC_VER #ifndef PATH_MAX #define PATH_MAX MAX_PATH -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1329?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I5f57e7bf52e3f6289462ef05e1f6e81ab0133d0d Gerrit-Change-Number: 1329 Gerrit-PatchSet: 1 Gerrit-Owner: plaisthos Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-Attention: flichtenheld --vYf/NhR0Q9Y= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: flichtenheld.

plaisthos would like flichtenheld to review this change.

V= iew Change

Remove --memstats feature

The ``--me= memstat`` was largely undocumented and there is no known
user of this fe= ature. This feature provided very limited statistics
(number of users, = link bytes read/written) and we do not except any
usage because of this.=

The only documentation was a mention in --help without any mention = of
the (binary) format of the mmap file or other usage instructions.
=
This deals also with issues reported by zeropath regarding potentially<= br>insecure handling of the file permission of the memory mapped file.
<= br>Reported-by: Joshua Rogers <contact@...2949...>
Found-by: ZeroP= ath (https://zeropath.com/)
Change-Id: I5f57e7bf52e3f6289462ef05e1f6e81a= b0133d0d
Signed-off-by: Arne Schwabe <arne@...1227...>
---
M= CMakeLists.txt
M Changes.rst
M src/openvpn/Makefile.am
M src/open= vpn/error.c
M src/openvpn/forward.c
M src/openvpn/init.c
D src/ope= nvpn/mstats.c
D src/openvpn/mstats.h
M src/openvpn/multi.c
M src/o= penvpn/options.c
M src/openvpn/options.h
M src/openvpn/syshead.h
1= 2 files changed, 5 insertions(+), 257 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/29/1329/1<=
/pre>
-    src/openvpn/mstats.c
- src/openvpn/mstats.h
src/openvpn/mtcp.c<= /span>
src/openvpn/mtcp.h
src/openvpn/mt= u.c
diff --git a/Changes.rst b/Changes.rst
= index 4feacad2..41af103 100644
--- a/Changes.rst
= +++ b/Changes.rst
@@ -217,6 +217,11 @@
``--allow-compression yes`` is now an alias for

= ``--allow-compression asym``.

+``--memstats`` feature removed
+ The ``--mememstat`` was largely= undocumented and there is no known
+ user of this feature. This feature provided very limit= ed statistics
+ (n= umber of users, link bytes read/written) and we do not except any+ usage because of this.

User-visible Changes
----= ----------------
diff --git a/src/openvpn/Makefile.am b/src= /openvpn/Makefile.am
index dc58cd1..db87dfc 100644--- a/src/openvpn/Makefile.am
+++ b/src/openvpn/Mak= efile.am
@@ -90,7 +90,6 @@
mbedtls_compat= .h \
mroute.c mroute.h \
mss.c mss.h \<= /span>
- mstats.c mstats.h \
mtcp.c mtcp.h \
mtu.c mtu.h \
= mudp.c mudp.h \
diff --git a/src/openvpn/error.c b/= src/openvpn/error.c
index 735d259..bd588d4 100644--- a/src/openvpn/error.c
+++ b/src/openvpn/error.c<= /span>
@@ -37,8 +37,6 @@
#include "status.h&= quot;
#include "integer.h"
#inc= lude "ps.h"
-= #include "mstats.h"
-

#if SYSLOG_CAPABILITY #ifndef LOG_OPENVPN
@@ -723,10 +721,6 @@
= }
#endif

-#ifdef ENABLE_MEMSTATS
- mstats_close();

-#endif

-
#ifdef ABORT_ON_ERROR
= if (status =3D=3D OPENVPN_EXIT_STATUS_ERROR)
{

diff --git a/src/openvpn/forward.c b/src/openvp= n/forward.c
index 7f72000..5bbac13 100644
-= -- a/src/openvpn/forward.c
+++ b/src/openvpn/forward.c
@@ -44,8 +44,6 @@

#include &= quot;memdbg.h"

-#include "mstats.h"
-
counter_type link_read_bytes_glob= al; /* GLOBAL */
counter_type link_write_bytes_global; /*= GLOBAL */

@@ -992,12 +990,6 @@ {
c->c2.link_read_bytes +=3D c->= c2.buf.len;
link_read_bytes_global +=3D c->c2.b= uf.len;
-#ifdef ENABLE_= MEMSTATS
- if (m= map_stats)
- {
- mmap_stats-= >link_read_bytes =3D link_read_bytes_global;
- }
-#endif
c->c2.original_recv_size = =3D c->c2.buf.len;
}
else
@@ -1821,12 +1813,6 @@
c->c= 2.max_send_size_local =3D max_int(size, c->c2.max_send_size_local);
c->c2.link_write_bytes +=3D size; link_write_bytes_global +=3D size;
-#ifdef ENABLE_MEMSTATS
- if (mmap_stats)
- {- mmap_stats-= >link_write_bytes =3D link_write_bytes_global;
- }
-#endif
}
}


diff --git a/src/openvpn/in= it.c b/src/openvpn/init.c
index aa2611d..1bdaf27 100644
--- a/src/openvpn/init.c
+++ b/src/openvpn/ini= t.c
@@ -44,7 +44,6 @@
#include "ps.h&= quot;
#include "lladdr.h"
#incl= ude "ping.h"
= -#include "mstats.h"
#include "ssl_verify.h= "
#include "ssl_ncp.h"
#in= clude "tls_crypt.h"
@@ -908,22 +907,6 @@ return false;
#endif
=
-#ifdef MSTATS_TEST- {
- int i;
- mstats_open("/dev/shm/mstats.dat");<= /span>
- for (i =3D 0; = i < 30; ++i)
- = {
- mmap_s= tats->n_clients +=3D 1;
- mmap_stats->link_write_bytes +=3D 8;
- mmap_stats->link_read_byt= es +=3D 16;
- = sleep(1);
- }<= /span>
- mstats_close()= ;
- return false= ;
- }
-#endif

-
return true;
= }

@@ -1233,13 +1216,6 @@
}

}

-#ifdef ENABLE_MEMSTATS

- if (c->first_time &&= amp; c->options.memstats_fn)

- {
- = mstats_open(c->options.memstats_fn);
- }
-#endif
= -
#ifdef ENABLE_SELINUX
/* Apply = a SELinux context in order to restrict what OpenVPN can do
= * to _only_ what it is supposed to do after initialization is com= plete
diff --git a/src/openvpn/mstats.c b/src/openvpn/mstat= s.c
deleted file mode 100644
index bd6316c.= .0000000
--- a/src/openvpn/mstats.c
+++ /de= v/null
@@ -1,124 +0,0 @@
-/*
-= * OpenVPN -- An application to securely tunnel IP networks
- * over a single TCP/UDP= port, with support for SSL/TLS-based

- * session authentication and key exchange,
- * packet enc= ryption, packet authentication, and
- * packet compression.
- *
- * Copyright (C) 2002-2025 OpenVPN Inc <sales@...515...>
- *
- * This program is free software; you can = redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2<= /span>
- * as published by th= e Free Software Foundation.
- *
- * This prog= ram is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even= the implied warranty of
- * GNU General Public Licen= se for more details.
- = *
- * You should have = received a copy of the GNU General Public License along
- * with this program; if not, see <ht= tps://www.gnu.org/licenses/>.
- */
-=
-/*
- * Maintain usage stats in a memory-mapped file=
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "= ;syshead.h"
-
-#if defined(ENABLE_MEMSTAT= S)
-
-#include <sys/mman.h>
-

-#include "error.h"
-#include "misc.h"
-#include "mstats.h"
-

-#include "memdbg.h"
-
-volatile struct mmap_stats *mmap_stats =3D NULL; /* GLOBAL */=
-static char mmap_fn[128];
-
-void
-mstats_open(const char *fn)
-{
= - void *data;
- s= size_t stat;
- int f= d;
- struct mmap_sta= ts ms;
-
- if (mmap_stats) /* already calle= d? */

- {
= - return;
- }
-
-= /* verify that filename is not too long */
- if (strlen(fn) >=3D sizeof(mmap_fn))=
- {
- msg(M_FATAL, "mstats_open: fil= ename too long");
= - }
-
- /* create file that will be memo= ry mapped */

- fd = =3D open(fn, O_CREAT | O_TRUNC | O_RDWR, S_IRUSR | S_IWUSR);
- if (fd < 0)

- {
- msg(M_ERR, "mstats_open: cannot open: %s&q= uot;, fn);
- ret= urn;
- }
<= span style=3D"color: hsl(0, 100%, 40%);">-

- /* set the file to the correct size to contain a
- * struct mmap_stat= s, and zero it */
- = CLEAR(ms);
- ms.stat= e =3D MSTATS_ACTIVE;
- = stat =3D write(fd, &ms, sizeof(ms));
- if (stat !=3D sizeof(ms))
- {
- msg(M_ERR, "mstats_open: write error: %s"= , fn);
- close(f= d);
- return;
- }
-
- /* mmap the file */
- data =3D mmap(NULL, sizeof(struct mmap_stats), PROT_REA= D | PROT_WRITE, MAP_SHARED, fd, 0);
- if (data =3D=3D MAP_FAILED)
- {
- msg(M_ERR, "mstats_open: write error: %s", fn);
- close(fd);
- return;
= - }
-
- /* close the fd (mmap now controls the file) */
- if (close(fd))
- {
- msg(M_ERR, "mstats_open: close error: %s"= ;, fn);
- }-
- /* save filename so we can delete it later */
- strcpy(mmap_fn, fn)= ;
-
- /* save a global pointer to memory-ma= pped region */
- mma= p_stats =3D (struct mmap_stats *)data;
-
- = msg(M_INFO, "memstats data will be written to %s", fn);-}
-
-mstats_close(v= oid)
-{
- if (mmap_stats)

- {
- mmap_stats->state =3D MSTATS_EXPIRED;=
- if (munmap((void *)m= map_stats, sizeof(struct mmap_stats)))
- {
- msg(M_WARN | M_ERRNO, "mstats_close: munmap error&quo= t;);
- }<= br>- platform_unlink(mmap_= fn);
- mmap_stat= s =3D NULL;
- }
-}
-
-#endif /* if defined(ENABLE_MEMSTATS) */
diff --git= a/src/openvpn/mstats.h b/src/openvpn/mstats.h
deleted file= mode 100644
index c38b0f2..0000000
--- a/s= rc/openvpn/mstats.h
+++ /dev/null
@@ -1,51 = +0,0 @@
-/*
<= span style=3D"color: hsl(0, 100%, 40%);">- * OpenVPN -- An application to = securely tunnel IP networks

- * over a single TCP/UDP port, with support for SSL/TLS-b= ased
- * se= ssion authentication and key exchange,
- * packet encryption, packet authentication, a= nd
- * pack= et compression.
- *
- * Copyright (C) 2002-20= 25 OpenVPN Inc <sales@...515...>
- *
- *= This program is free software; you can redistribute it and/or modify
- * it under the terms of = the GNU General Public License version 2
- * as published by the Free Software Foundation.=
- *
- * This program is distributed in the hope tha= t it will be useful,
- = * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS = FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *

- * You should have received a copy of the GNU General= Public License along
-= * with this program; if not, see <https://www.gnu.org/licenses/>.
- */
-
-/*
- * Mai= ntain usage stats in a memory-mapped file
- */
-
-#if !defined(OPENVP= N_MEMSTATS_H) && defined(ENABLE_MEMSTATS)
-#define OPENVPN_MEMSTATS_H
-
-#include "basic.h"
-
-/*= this struct is mapped to the file */
-struct mmap_stats
-{
- coun= ter_type link_read_bytes; /* counter_type can be assumed to be a uint64_t *= /
- counter_type lin= k_write_bytes;
- int= n_clients;
--#define MSTATS_UNDEF 0=
-#define MSTATS_ACTIVE 1
-#define MSTATS_EXPIRED 2<= /span>
- int state;<= br>-};
-
-extern volatile struct mmap_stats *mmap_stats; /* GLOBAL */-
-void mstats_open(const char *fn);
-
-void mstats_close(void);
-
-#end= if /* if !defined(OPENVPN_MEMSTATS_H) && defined(ENABLE_MEMSTATS) *= /
diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c
index 285671d..e243843 100644
--- a/src/openv= pn/multi.c
+++ b/src/openvpn/multi.c
@@ -37= ,7 +37,6 @@
#include "run_command.h"
<= span> #include "otime.h"

#include "gremlin.= h"
-#include "= ;mstats.h"
#include "ssl_verify.h" #include "ssl_ncp.h"
#include "vla= n.h"
@@ -80,17 +79,6 @@
}
<= span> #endif


-static inline void
-update_mstat_n_clients(const int n_clients)
-{
-#ifdef ENABLE_MEMSTATS
- if (mmap_stats)
- {
- m= map_stats->n_clients =3D n_clients;
- }
= -#endif
-}
-

static bool
learn_address_script(const struct multi_context *m, const stru= ct multi_instance *mi, const char *op,
= const struct mroute_addr *addr)
@@ -589,7 +577,6 @@


/* adjust current client connection count= */
m->n_clients +=3D mi->n_clients_delta;
- update_mstat_n_clients(= m->n_clients);
mi->n_clients_delta =3D 0;=

/* prevent dangling pointers */
= @@ -2799,7 +2786,6 @@

/* incre= ment number of current authenticated clients */
++m-&g= t;n_clients;
- updat= e_mstat_n_clients(m->n_clients);
--mi->n_clients= _delta;

#ifdef ENABLE_MANAGEMENT<= br>diff --git a/src/openvpn/options.c b/src/openvpn/options.c<= br>index 9c02a8c..ecf9374 100644
--- a/src/openvpn/op= tions.c
+++ b/src/openvpn/options.c
@@ -323= ,9 +323,6 @@
" via a VRF present= on the system.\n"
#endif
"= --txqueuelen n : Set the tun/tap TX queue length to n (Linux only).\n"= ;
-#ifdef ENABLE_MEMSTA= TS
- "--memstat= s file : Write live usage stats to memory mapped binary file.\n"
-#endif
= "--mlock : Disable Paging -- ensures key material and tunnel\= n"
" data will never be wri= tten to disk.\n"
"--up cmd : Run comm= and cmd after successful tun device open.\n"
@@ -6333,= 13 +6330,6 @@
options->log =3D true;
= redirect_stdout_stderr(p[1], true);
}
-#ifdef ENABLE_MEMSTATS<= /span>
- else if (streq(p[0= ], "memstats") && p[1] && !p[2])
- {
- VERIFY_PERMISSION(OPT_P_GENERAL);
- options->memstats_fn = =3D p[1];

- }=
-#endif
= else if (streq(p[0], "mlock") && !p[1])
= {
VERIFY_PERMISSION(OPT_P_GENERAL);
= diff --git a/src/openvpn/options.h b/src/openvpn/options.h
= index 125e524..9d2ff9f 100644
--- a/src/openvpn/optio= ns.h
+++ b/src/openvpn/options.h
@@ -336,10= +336,6 @@

bool mtu_test;
=
-#ifdef ENABLE_= MEMSTATS
- char *mem= stats_fn;
-#endif
-
bool = mlock;

int keepalive_ping; /* a prox= y for ping/ping-restart */
diff --git a/src/openvpn/syshead= .h b/src/openvpn/syshead.h
index 26a553b..90045a9 100644
--- a/src/openvpn/syshead.h
+++ b/src/openvpn= /syshead.h
@@ -528,13 +528,6 @@
#define US= E_COMP
#endif

-/*
- * Enable --memstats option
- */
-#ifd= ef TARGET_LINUX
-#defin= e ENABLE_MEMSTATS
-#end= if
-
#= ifdef _MSC_VER
#ifndef PATH_MAX
#define P= ATH_MAX MAX_PATH

To view, visit change 1329= . To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I5f57e7bf52e3f6289462ef05e1f= 6e81ab0133d0d
Gerrit-Change-Number: 1329
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
= --vYf/NhR0Q9Y=--