Skip to contentSkip to conversation

Change in openvpn[master]: route: close socket in Haiku get_default_gateway()

Openvpn-devel In review Răzvan Cojocaru (Code Review) via Openvpn-devel 3 participants 6 messages Nov 2 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.1793636884000.Ia0304e5ef5f8a553262a32d78ed21577973ee2e9@gerrit.openvpn.net

#1 lore raw

Attention is currently required from: Arne Schwabe.

Hello Arne Schwabe,

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

    https://gerrit.openvpn.net/c/openvpn/+/2093?usp=email

to review the following change.

Change subject: route: close socket in Haiku get_default_gateway()
......................................................................

route: close socket in Haiku get_default_gateway()

The socket used for the routing table ioctls was never closed. Close it on the early returns and right after the last ioctl.

Broken since 7da14925 ("Haiku: Add calls to manage routing table").

Change-Id Ia0304e5ef5f8a553262a32d78ed21577973ee2e9

---
M src/openvpn/route.c

1 file changed, 5 insertions(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/93/2093/1

src/openvpn/route.c +5 -1
index 0bce966..e8de2d5 100644
@@ -3719,12 +3719,14 @@
     if (ioctl(sockfd, SIOCGRTSIZE, &config, sizeof(struct ifconf)) < 0)
     {
         msg(M_ERRNO, "%s: Error getting routing table size", __func__);
+        close(sockfd);
         return;
     }
 
     uint32 size = (uint32)config.ifc_value;
     if (size == 0)
     {
+        close(sockfd);
         return;
     }
 
@@ -3733,7 +3735,9 @@
 
     config.ifc_len = size;
     config.ifc_buf = buffer;
-    if (ioctl(sockfd, SIOCGRTTABLE, &config, sizeof(struct ifconf)) < 0)
+    int ret = ioctl(sockfd, SIOCGRTTABLE, &config, sizeof(struct ifconf));
+    close(sockfd);
+    if (ret < 0)
     {
         free(buffer);
         return;

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

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia0304e5ef5f8a553262a32d78ed21577973ee2e9
Gerrit-Change-Number: 2093
Gerrit-PatchSet: 1
Gerrit-Owner: Răzvan Cojocaru <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

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

Attention is currently required from: Arne Schwabe, Răzvan Cojocaru.

Frank Lichtenheld has posted comments on this change by Răzvan Cojocaru. ( https://gerrit.openvpn.net/c/openvpn/+/2093?usp=email )

Change subject: route: close socket in Haiku get_default_gateway()
......................................................................

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia0304e5ef5f8a553262a32d78ed21577973ee2e9
Gerrit-Change-Number: 2093
Gerrit-PatchSet: 1
Gerrit-Owner: Răzvan Cojocaru <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-Reviewer: Frank Lichtenheld <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Răzvan Cojocaru <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>
Gerrit-Comment-Date: Mon, 02 Nov 2026 16:47:32 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#3 lore raw

PATCH 1/1 route: close socket in Haiku get_default_gateway()

In reply to a message not in the archive

From: Razvan Cojocaru <[email protected]>

The socket used for the routing table ioctls was never closed. Close it on the early returns and right after the last ioctl.

Broken since 7da14925 ("Haiku: Add calls to manage routing table").

Change-Id Ia0304e5ef5f8a553262a32d78ed21577973ee2e9

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

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

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

Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <[email protected]>

src/openvpn/route.c +5 -1
index 0bce966..e8de2d5 100644
@@ -3719,12 +3719,14 @@
     if (ioctl(sockfd, SIOCGRTSIZE, &config, sizeof(struct ifconf)) < 0)
     {
         msg(M_ERRNO, "%s: Error getting routing table size", __func__);
+        close(sockfd);
         return;
     }
 
     uint32 size = (uint32)config.ifc_value;
     if (size == 0)
     {
+        close(sockfd);
         return;
     }
 
@@ -3733,7 +3735,9 @@
 
     config.ifc_len = size;
     config.ifc_buf = buffer;
-    if (ioctl(sockfd, SIOCGRTTABLE, &config, sizeof(struct ifconf)) < 0)
+    int ret = ioctl(sockfd, SIOCGRTTABLE, &config, sizeof(struct ifconf));
+    close(sockfd);
+    if (ret < 0)
     {
         free(buffer);
         return;

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Acked-by Frank Lichtenheld on v1 1/1
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: route: close socket in Haiku get_default_gateway()

Interesting find ;-)

Not tested beyond "looks reasonable"...

Your patch has been applied to the master and release/2.7 branch (bugfix).

commit e9ecd3c6ded76c03b9d74c1b37c87a07b54e10e6 (master)

Author: Razvan Cojocaru
Date:   Mon Nov 2 17:59:27 2026 +0100

route: close socket in Haiku get_default_gateway()

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2093
Message-Id: <[email protected]>
URL: https://lore.kernel.org/openvpn-devel/[email protected]

--
kind regards,

Gert Doering

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

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

Gert Doering has uploaded a new patch set (#2) to the change originally created by Răzvan Cojocaru. ( https://gerrit.openvpn.net/c/openvpn/+/2093?usp=email )

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

Change subject: route: close socket in Haiku get_default_gateway()
......................................................................

route: close socket in Haiku get_default_gateway()

The socket used for the routing table ioctls was never closed. Close it on the early returns and right after the last ioctl.

Broken since 7da14925 ("Haiku: Add calls to manage routing table").

Change-Id Ia0304e5ef5f8a553262a32d78ed21577973ee2e9

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2093
Message-Id: <[email protected]>
URL: https://lore.kernel.org/openvpn-devel/[email protected]

---
M src/openvpn/route.c

1 file changed, 5 insertions(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/93/2093/2

src/openvpn/route.c +5 -1
index 0bce966..e8de2d5 100644
@@ -3719,12 +3719,14 @@
     if (ioctl(sockfd, SIOCGRTSIZE, &config, sizeof(struct ifconf)) < 0)
     {
         msg(M_ERRNO, "%s: Error getting routing table size", __func__);
+        close(sockfd);
         return;
     }
 
     uint32 size = (uint32)config.ifc_value;
     if (size == 0)
     {
+        close(sockfd);
         return;
     }
 
@@ -3733,7 +3735,9 @@
 
     config.ifc_len = size;
     config.ifc_buf = buffer;
-    if (ioctl(sockfd, SIOCGRTTABLE, &config, sizeof(struct ifconf)) < 0)
+    int ret = ioctl(sockfd, SIOCGRTTABLE, &config, sizeof(struct ifconf));
+    close(sockfd);
+    if (ret < 0)
     {
         free(buffer);
         return;

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

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia0304e5ef5f8a553262a32d78ed21577973ee2e9
Gerrit-Change-Number: 2093
Gerrit-PatchSet: 2
Gerrit-Owner: Răzvan Cojocaru <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-Reviewer: Frank Lichtenheld <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

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

Gert Doering has submitted this change. ( https://gerrit.openvpn.net/c/openvpn/+/2093?usp=email )

Change subject: route: close socket in Haiku get_default_gateway()
......................................................................

route: close socket in Haiku get_default_gateway()

The socket used for the routing table ioctls was never closed. Close it on the early returns and right after the last ioctl.

Broken since 7da14925 ("Haiku: Add calls to manage routing table").

Change-Id Ia0304e5ef5f8a553262a32d78ed21577973ee2e9

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2093
Message-Id: <[email protected]>
URL: https://lore.kernel.org/openvpn-devel/[email protected]

---
M src/openvpn/route.c

1 file changed, 5 insertions(+), 1 deletion(-)
src/openvpn/route.c +5 -1
index 0bce966..e8de2d5 100644
@@ -3719,12 +3719,14 @@
     if (ioctl(sockfd, SIOCGRTSIZE, &config, sizeof(struct ifconf)) < 0)
     {
         msg(M_ERRNO, "%s: Error getting routing table size", __func__);
+        close(sockfd);
         return;
     }
 
     uint32 size = (uint32)config.ifc_value;
     if (size == 0)
     {
+        close(sockfd);
         return;
     }
 
@@ -3733,7 +3735,9 @@
 
     config.ifc_len = size;
     config.ifc_buf = buffer;
-    if (ioctl(sockfd, SIOCGRTTABLE, &config, sizeof(struct ifconf)) < 0)
+    int ret = ioctl(sockfd, SIOCGRTTABLE, &config, sizeof(struct ifconf));
+    close(sockfd);
+    if (ret < 0)
     {
         free(buffer);
         return;

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

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia0304e5ef5f8a553262a32d78ed21577973ee2e9
Gerrit-Change-Number: 2093
Gerrit-PatchSet: 2
Gerrit-Owner: Răzvan Cojocaru <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-Reviewer: Frank Lichtenheld <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel