Skip to contentSkip to conversation

Change in openvpn[release/2.6]: tunnel_server_*(): close correct inotify fd

Openvpn-devel In review cron2 (Code Review) 2 participants 6 messages Jan 28 – Jan 29 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1769611655000.Idcb1421b9f7fcbee9620fd1d45cceab050751373@...2715...

#1 lore raw

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1499?usp=email

to review the following change.

Change subject: tunnel_server_*(): close correct inotify fd
......................................................................

tunnel_server_*(): close correct inotify fd

On a full SIGUSR1 restart of a p2mp server compiled with --enable-async-push, tunnel_server_{udp,tcp}() will try to close and reopen the "inotify" control file descriptor. For whatever reason, the original code referenced the wrong context, always closing fd 0.

As a consequence of this, on the second SIGUSR1 restart, the server will close() the first active socket file descriptor, and if there are active DCO clients, the resulting event confusion will lead to an ASSERT(!mi->halt).

Fix by closing the correct FD. Add logging.

This is a backport of commit 5521872f80313060 to the "old p2mp code" with a separate mudp.c and mtcp.c for UDP and TCP servers, respectively.

Github: fixes OpenVPN/openvpn#966

Change-Id Idcb1421b9f7fcbee9620fd1d45cceab050751373

---
M src/openvpn/mtcp.c
M src/openvpn/mudp.c

2 files changed, 6 insertions(+), 2 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/99/1499/1

src/openvpn/mtcp.c +3 -1
index 96408d1..3e33b15 100644
@@ -850,7 +850,9 @@
     }
 
 #ifdef ENABLE_ASYNC_PUSH
-    close(top->c2.inotify_fd);
+    msg(D_LOW, "%s: close multi.top.c2.inotify_fd (%d)",
+        __func__, multi.top.c2.inotify_fd);
+    close(multi.top.c2.inotify_fd);
 #endif
 
     /* shut down management interface */
src/openvpn/mudp.c +3 -1
index 0492311..f7c9ffd 100644
@@ -524,7 +524,9 @@
     }
 
 #ifdef ENABLE_ASYNC_PUSH
-    close(top->c2.inotify_fd);
+    msg(D_LOW, "%s: close multi.top.c2.inotify_fd (%d)",
+        __func__, multi.top.c2.inotify_fd);
+    close(multi.top.c2.inotify_fd);
 #endif
 
     /* shut down management interface */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1499?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: release/2.6
Gerrit-Change-Id: Idcb1421b9f7fcbee9620fd1d45cceab050751373
Gerrit-Change-Number: 1499
Gerrit-PatchSet: 1
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: cron2.

plaisthos has posted comments on this change by cron2. ( http://gerrit.openvpn.net/c/openvpn/+/1499?usp=email )

Change subject: tunnel_server_*(): close correct inotify fd
......................................................................

Patch Set 1: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1499?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: release/2.6
Gerrit-Change-Id: Idcb1421b9f7fcbee9620fd1d45cceab050751373
Gerrit-Change-Number: 1499
Gerrit-PatchSet: 1
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Comment-Date: Wed, 28 Jan 2026 14:59:58 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

#3 lore raw

PATCH 1/1 tunnel_server_*(): close correct inotify fd

In reply to a message not in the archive

On a full SIGUSR1 restart of a p2mp server compiled with --enable-async-push, tunnel_server_{udp,tcp}() will try to close and reopen the "inotify" control file descriptor. For whatever reason, the original code referenced the wrong context, always closing fd 0.

As a consequence of this, on the second SIGUSR1 restart, the server will close() the first active socket file descriptor, and if there are active DCO clients, the resulting event confusion will lead to an ASSERT(!mi->halt).

Fix by closing the correct FD. Add logging.

This is a backport of commit 5521872f80313060 to the "old p2mp code" with a separate mudp.c and mtcp.c for UDP and TCP servers, respectively.

Github: fixes OpenVPN/openvpn#966

Change-Id Idcb1421b9f7fcbee9620fd1d45cceab050751373

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1499
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to release/2.6.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1499
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Arne Schwabe <[email protected]...>

src/openvpn/mtcp.c +3 -1
index 96408d1..3e33b15 100644
@@ -850,7 +850,9 @@
     }
 
 #ifdef ENABLE_ASYNC_PUSH
-    close(top->c2.inotify_fd);
+    msg(D_LOW, "%s: close multi.top.c2.inotify_fd (%d)",
+        __func__, multi.top.c2.inotify_fd);
+    close(multi.top.c2.inotify_fd);
 #endif
 
     /* shut down management interface */
src/openvpn/mudp.c +3 -1
index 0492311..f7c9ffd 100644
@@ -524,7 +524,9 @@
     }
 
 #ifdef ENABLE_ASYNC_PUSH
-    close(top->c2.inotify_fd);
+    msg(D_LOW, "%s: close multi.top.c2.inotify_fd (%d)",
+        __func__, multi.top.c2.inotify_fd);
+    close(multi.top.c2.inotify_fd);
 #endif
 
     /* shut down management interface */
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: tunnel_server_*(): close correct inotify fd

As it says on the lid, this is a backport of the master commit to multi.c, to the "until 2.6" source files for separate UDP and TCP servers, mudp.c and mtcp.c. Verified with "run server, look at lsof -P -p $pid, send SIGUSR1, look at lsof again" (and see the FD 0 now change roles).

..

openvpn 4513 root   0u     IPv4 61650705      0t0     UDP *:31194 
openvpn 4513 root   5r  a_inode     0,12        0    2066 inotify
openvpn 4513 root   6r  a_inode     0,12        0    2066 inotify

..

Patch has been applied to the release/2.6 and release/2.5 branches.

(It would apply and bugfix release/2.4 as well, but this is *so* out of maintenance that I did do this. 2.3.x does not have inotify support yet)

commit 172fe07129f02be2d3e6779c632ed1e8081c412c (release/2.6) commit 477775b032c2c47322d1453bdfff11b607fbac91 (release/2.5)

Author: Gert Doering
Date:   Wed Jan 28 16:06:35 2026 +0100
     tunnel_server_*(): close correct inotify fd

     Signed-off-by: Gert Doering <[email protected]...>
     Acked-by: Arne Schwabe <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1499
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg35493.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

Hello plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1499?usp=email

to look at the new patch set (#2).

The following approvals got outdated and were removed:
Code-Review+2 by plaisthos

Change subject: tunnel_server_*(): close correct inotify fd
......................................................................

tunnel_server_*(): close correct inotify fd

On a full SIGUSR1 restart of a p2mp server compiled with --enable-async-push, tunnel_server_{udp,tcp}() will try to close and reopen the "inotify" control file descriptor. For whatever reason, the original code referenced the wrong context, always closing fd 0.

As a consequence of this, on the second SIGUSR1 restart, the server will close() the first active socket file descriptor, and if there are active DCO clients, the resulting event confusion will lead to an ASSERT(!mi->halt).

Fix by closing the correct FD. Add logging.

This is a backport of commit 5521872f80313060 to the "old p2mp code" with a separate mudp.c and mtcp.c for UDP and TCP servers, respectively.

Github: fixes OpenVPN/openvpn#966

Change-Id Idcb1421b9f7fcbee9620fd1d45cceab050751373

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1499
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg35493.html

---
M src/openvpn/mtcp.c
M src/openvpn/mudp.c

2 files changed, 6 insertions(+), 2 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/99/1499/2

src/openvpn/mtcp.c +3 -1
index 96408d1..3e33b15 100644
@@ -850,7 +850,9 @@
     }
 
 #ifdef ENABLE_ASYNC_PUSH
-    close(top->c2.inotify_fd);
+    msg(D_LOW, "%s: close multi.top.c2.inotify_fd (%d)",
+        __func__, multi.top.c2.inotify_fd);
+    close(multi.top.c2.inotify_fd);
 #endif
 
     /* shut down management interface */
src/openvpn/mudp.c +3 -1
index 0492311..f7c9ffd 100644
@@ -524,7 +524,9 @@
     }
 
 #ifdef ENABLE_ASYNC_PUSH
-    close(top->c2.inotify_fd);
+    msg(D_LOW, "%s: close multi.top.c2.inotify_fd (%d)",
+        __func__, multi.top.c2.inotify_fd);
+    close(multi.top.c2.inotify_fd);
 #endif
 
     /* shut down management interface */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1499?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: release/2.6
Gerrit-Change-Id: Idcb1421b9f7fcbee9620fd1d45cceab050751373
Gerrit-Change-Number: 1499
Gerrit-PatchSet: 2
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1499?usp=email )

Change subject: tunnel_server_*(): close correct inotify fd
......................................................................

tunnel_server_*(): close correct inotify fd

On a full SIGUSR1 restart of a p2mp server compiled with --enable-async-push, tunnel_server_{udp,tcp}() will try to close and reopen the "inotify" control file descriptor. For whatever reason, the original code referenced the wrong context, always closing fd 0.

As a consequence of this, on the second SIGUSR1 restart, the server will close() the first active socket file descriptor, and if there are active DCO clients, the resulting event confusion will lead to an ASSERT(!mi->halt).

Fix by closing the correct FD. Add logging.

This is a backport of commit 5521872f80313060 to the "old p2mp code" with a separate mudp.c and mtcp.c for UDP and TCP servers, respectively.

Github: fixes OpenVPN/openvpn#966

Change-Id Idcb1421b9f7fcbee9620fd1d45cceab050751373

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1499
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg35493.html

---
M src/openvpn/mtcp.c
M src/openvpn/mudp.c

2 files changed, 6 insertions(+), 2 deletions(-)
src/openvpn/mtcp.c +3 -1
index 96408d1..3e33b15 100644
@@ -850,7 +850,9 @@
     }
 
 #ifdef ENABLE_ASYNC_PUSH
-    close(top->c2.inotify_fd);
+    msg(D_LOW, "%s: close multi.top.c2.inotify_fd (%d)",
+        __func__, multi.top.c2.inotify_fd);
+    close(multi.top.c2.inotify_fd);
 #endif
 
     /* shut down management interface */
src/openvpn/mudp.c +3 -1
index 0492311..f7c9ffd 100644
@@ -524,7 +524,9 @@
     }
 
 #ifdef ENABLE_ASYNC_PUSH
-    close(top->c2.inotify_fd);
+    msg(D_LOW, "%s: close multi.top.c2.inotify_fd (%d)",
+        __func__, multi.top.c2.inotify_fd);
+    close(multi.top.c2.inotify_fd);
 #endif
 
     /* shut down management interface */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1499?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: release/2.6
Gerrit-Change-Id: Idcb1421b9f7fcbee9620fd1d45cceab050751373
Gerrit-Change-Number: 1499
Gerrit-PatchSet: 2
Gerrit-Owner: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>