| Message ID | 20241126142639.67446-2-alex@terarocket.io |
|---|---|
| State | Changes Requested |
| Headers |
Return-Path: <openvpn-devel-bounces@lists.sourceforge.net>
Delivered-To: patchwork@openvpn.net
Received: by 2002:a05:7000:8712:b0:5db:5963:ef83 with SMTP id bv18csp92050mab;
Tue, 26 Nov 2024 06:27:44 -0800 (PST)
X-Forwarded-Encrypted: i=2;
AJvYcCVfMt03Y7O3kecivua6miCZ0WMadD+RavEbxldCEx0hYv8h9Nm+NqMD/j5MC5qBjfBX8JhdaqhdrY4=@openvpn.net
X-Google-Smtp-Source:
AGHT+IFOIhXLdSu0mqfiMLelA+V8vvM7KoObgn3+6G4pdBHjHpqSp1LhvSVfzZdFQ4vocNYRS7Zi
X-Received: by 2002:a05:6808:10c6:b0:3e7:ac6a:2137 with SMTP id
5614622812f47-3ea592e7160mr2029194b6e.16.1732631264123;
Tue, 26 Nov 2024 06:27:44 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1732631264; cv=none;
d=google.com; s=arc-20240605;
b=CTWwA1/zQHKelnV76ivB/jWnUL9Muu7LpZGcvik2T7Dh/yS6pO87aARrx6x+6UVaSC
D26EUbEbAJg6JzyX7RLM6P5zNs7IPiBAg2KtUXueR0PmQphIMg0QPCldWSy1/Cun56IV
Mw+jOPoOUW+mwD2MFsNc2JdheiZWY4+dnk8XubZupnRmhRcBEYbEV6qx2jzN6LAZx4Mf
QD7RiK9amhNK62HHcx83rU+Lkmttv997TVIEAQ0bu0KqiY0AOPywsjkbPGDvvGBLl6qt
rp2BGdia9kSNUI/BJZuNiJ+HLHSAZT/RNBAT7D3CWVER+0mF7YmEXKRgO44jJKJA91ye
r1ZA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;
s=arc-20240605;
h=errors-to:reply-to:from:list-subscribe:list-help:list-post
:list-archive:list-unsubscribe:list-id:precedence:subject
:mime-version:feedback-id:references:in-reply-to:message-id:to:date
:dkim-signature:dkim-signature:dkim-signature;
bh=APEDSRVJXOb3KeUpZnwpvwWsDvh3HST+zVv15vO4TC8=;
fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=;
b=jtx++n/Y7AdHvl0uptdct0AndWxohOgKuy6jUzFgSTtJM64/8Bz+3qQn4L1GCPwBW1
TNl+hTrQqs0nZWkfyqAWuamc9rbgnDPaaWMzyHjIEguWrYuhKe/qz3/j1vcRTD97R5sO
9LzoxYphfQY3yTSA/JlGMlDN7ThuOdcGrBKxWioQh6bMAvbK4DNbMuxurZzL7cxwdyzt
Z7UUoLGBE05/qoY4lYyXQjuwJ5U8tv/GcffwETrdc9HLKEoU0Z+tM+2FAhwTrDxuk8Ci
YrhIs3u4D8HiOmwcyWgI9sFjjTYPoN3xNt+1/HbuQm1ZGovYm6h6u2ouWajcHueh3F6a
FZjQ==;
dara=google.com
ARC-Authentication-Results: i=1; mx.google.com;
dkim=neutral (body hash did not verify) header.i=@sourceforge.net
header.s=x header.b="c442wzt/";
dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x
header.b=Vst60yR0;
dkim=neutral (body hash did not verify) header.i=@terarocket.io
header.s=protonmail2 header.b=CN+9c+n2;
spf=pass (google.com: domain of
openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as
permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net;
dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=sourceforge.net
Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7])
by mx.google.com with ESMTPS id
5614622812f47-3ea4af5a9cesi1814301b6e.320.2024.11.26.06.27.43
(version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
Tue, 26 Nov 2024 06:27:44 -0800 (PST)
Received-SPF: pass (google.com: domain of
openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as
permitted sender) client-ip=216.105.38.7;
Authentication-Results: mx.google.com;
dkim=neutral (body hash did not verify) header.i=@sourceforge.net
header.s=x header.b="c442wzt/";
dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x
header.b=Vst60yR0;
dkim=neutral (body hash did not verify) header.i=@terarocket.io
header.s=protonmail2 header.b=CN+9c+n2;
spf=pass (google.com: domain of
openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as
permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net;
dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=sourceforge.net
Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com)
by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95)
(envelope-from <openvpn-devel-bounces@lists.sourceforge.net>)
id 1tFwXQ-0007MV-L3;
Tue, 26 Nov 2024 14:27:36 +0000
Received: from [172.30.29.66] (helo=mx.sourceforge.net)
by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95)
(envelope-from <alex@terarocket.io>) id 1tFwXP-0007M6-0M
for openvpn-devel@lists.sourceforge.net;
Tue, 26 Nov 2024 14:27:35 +0000
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
d=sourceforge.net; s=x; h=Content-Type:MIME-Version:References:In-Reply-To:
Message-ID:Subject:Cc:From:To:Date:Sender:Reply-To:Content-Transfer-Encoding:
Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
List-Subscribe:List-Post:List-Owner:List-Archive;
bh=f3Fu7z3AKIeSgozi8r5ckNFu0veECjzOHBEG+VxMFZQ=; b=c442wzt/tausBJBfBB9cLLsZIK
H7ACP5+e3XzXu3lIpX1F2hZonQ58Yjsc28W6RHZCbMr0flgPjwJwaX2le9+O/sXt8pUF2G122PlMM
8MinLEXJdvUlznr8OHxadBDFypass0+r8yqBX0maAuQjcBa9LEuszdVdxeBg8fpb5Y9E=;
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x
;
h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Subject:Cc:
From:To:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID:
Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
List-Post:List-Owner:List-Archive;
bh=f3Fu7z3AKIeSgozi8r5ckNFu0veECjzOHBEG+VxMFZQ=; b=Vst60yR03Vi+Uu/ri016WyHPg1
Z1Wo+gerAB8rr8neWunW2OL2cUvUSOQ0fTkBK9LVgr2KOjyfT4HCMwjtTlkBYLQrSfVz9P3FHZ8kf
2ePUN8T89HDmROqdYqifUA7DrcjMtp3JVuxrC+mL8h9RZ1AgJaEidQU6RXg1iE2Ewcfk=;
Received: from mail-10626.protonmail.ch ([79.135.106.26])
by sfi-mx-2.v28.lw.sourceforge.com with esmtps
(TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95)
id 1tFwX3-0008H9-SG for openvpn-devel@lists.sourceforge.net;
Tue, 26 Nov 2024 14:27:14 +0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=terarocket.io;
s=protonmail2; t=1732631222; x=1732890422;
bh=f3Fu7z3AKIeSgozi8r5ckNFu0veECjzOHBEG+VxMFZQ=;
h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:
Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:
Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post;
b=CN+9c+n2Gs+6RJrnPDZU6N4mdeA4XUKt5+sYXDrG05xV0rY62BcOcgVM+0E7XoKii
1WbjKy90K3DTWYFroqjFExZc/ODR7ljVncP2VJKTkcgeaj82xGZoScOro0BPdomJIM
ZjzlOS5HKp2TshN1GUr1uSK+z2tcPjEABFtSgjILYa+nphh2Fxor99xWyyVKpu2gP1
dAVmFxF5zmTKfTkyk6tlpMTFjjtFFmgyqmZ2W7A3ZDblUr1HyFxxNw+dpyoJ47Ba5/
CX7nLvkAYAbMNOGWzapSXhR8yhXQd9YKyKudo0A7tybaTaJM/bM+tAWsZGFxuKs5SW
EMvNxfpPQHDFA==
Date: Tue, 26 Nov 2024 14:26:59 +0000
To: openvpn-devel@lists.sourceforge.net
Message-ID: <20241126142639.67446-2-alex@terarocket.io>
In-Reply-To: <20241126142639.67446-1-alex@terarocket.io>
References: <20241126142639.67446-1-alex@terarocket.io>
Feedback-ID: 105812837:user:proton
X-Pm-Message-ID: 2d87c6161d44708be25787b3ff95fd4b5ef127ee
MIME-Version: 1.0
X-Spam-Score: -0.2 (/)
X-Spam-Report: Spam detection software,
running on the system "util-spamd-2.v13.lw.sourceforge.com",
has NOT identified this incoming email as spam. The original
message has been attached to this so you can view it or label
similar future email. If you have any questions, see
the administrator of that system for details.
Content preview: --- src/openvpn/route.c | 109
+++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 107 insertions(+),
2 deletions(-) diff --git a/src/openvpn/route.c
b/src/openvpn/route.c index fa20d08f..8d319123 100644 ---
a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -54, 6 +54,
12 @@ #include <net/route.h> /* RT_ROUNDUP(), RT [...]
Content analysis details: (-0.2 points, 6.0 required)
pts rule name description
---- ----------------------
--------------------------------------------------
-0.0 SPF_PASS SPF: sender matches SPF record
0.0 RCVD_IN_VALIDITY_SAFE_BLOCKED RBL: ADMINISTRATOR NOTICE: The
query to Validity was blocked. See
https://knowledge.validity.com/hc/en-us/articles/20961730681243
for more information.
[79.135.106.26 listed in sa-trusted.bondedsender.org]
0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The
query to Validity was blocked. See
https://knowledge.validity.com/hc/en-us/articles/20961730681243
for more information.
[79.135.106.26 listed in bl.score.senderscore.com]
-0.0 SPF_HELO_PASS SPF: HELO matches SPF record
-0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from
author's domain
-0.1 DKIM_VALID Message has at least one valid DKIM or DK signature
0.1 DKIM_SIGNED Message has a DKIM or DK signature,
not necessarily
valid
-0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from
envelope-from domain
X-Headers-End: 1tFwX3-0008H9-SG
Subject: [Openvpn-devel] [PATCH 2/2] Haiku: Pull in routing table to get
default route
X-BeenThere: openvpn-devel@lists.sourceforge.net
X-Mailman-Version: 2.1.21
Precedence: list
List-Id: <openvpn-devel.lists.sourceforge.net>
List-Unsubscribe: <https://lists.sourceforge.net/lists/options/openvpn-devel>,
<mailto:openvpn-devel-request@lists.sourceforge.net?subject=unsubscribe>
List-Archive:
<http://sourceforge.net/mailarchive/forum.php?forum_name=openvpn-devel>
List-Post: <mailto:openvpn-devel@lists.sourceforge.net>
List-Help: <mailto:openvpn-devel-request@lists.sourceforge.net?subject=help>
List-Subscribe: <https://lists.sourceforge.net/lists/listinfo/openvpn-devel>,
<mailto:openvpn-devel-request@lists.sourceforge.net?subject=subscribe>
From: Alexander von Gluck via Openvpn-devel
<openvpn-devel@lists.sourceforge.net>
Reply-To: Alexander von Gluck <alex@terarocket.io>
Content-Type: multipart/mixed; boundary="===============8372020485981273094=="
Errors-To: openvpn-devel-bounces@lists.sourceforge.net
X-getmail-retrieved-from-mailbox: Inbox
X-GMAIL-THRID: =?utf-8?q?1816795560517654971?=
X-GMAIL-MSGID: =?utf-8?q?1816795560517654971?=
|
| Series |
[Openvpn-devel,1/2] Haiku: Introduce basic platform support
|
|
Commit Message
Alexander von Gluck
Nov. 26, 2024, 2:26 p.m. UTC
---
src/openvpn/route.c | 109 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 107 insertions(+), 2 deletions(-)
@@ -2344,6 +2352,21 @@ delete_route(struct route_ipv4 *r,
openvpn_execve_check(&argv, es, 0, "ERROR: AIX route delete command failed");
}
+#elif defined(TARGET_HAIKU)
+
+ {
+ // route del /dev/net/ipro1000/0 inet 192.168.0.0 gw 192.168.1.1 netmask 255.255.0.0
+ argv_printf(&argv, "%s del %s inet %s gw %s netmask %s",
+ ROUTE_PATH,
+ rgi->iface,
+ network,
+ gateway,
+ netmask);
+
+ argv_msg(D_ROUTE, &argv);
+
openvpn_execve_check(&argv, es, 0, "ERROR: Haiku inet route delete command failed");
+ }
+
#else /* if defined(TARGET_LINUX) */
msg(M_FATAL, "Sorry, but I don't know how to do 'route' commands on this operating system. Try putting your routes in a --route-up script");
#endif /* if defined(TARGET_LINUX) */
@@ -2523,6 +2546,19 @@ delete_route_ipv6(const struct route_ipv6 *r6, const struct tuntap *tt,
msg(D_ROUTE_DEBUG, "Deleting routes on Android is not possible/not "
"needed. The VpnService API allows routes to be set "
"on connect only and will clean up automatically.");
+#elif defined(TARGET_HAIKU)
+ {
+ argv_printf(&argv, "%s del %s inet6 %s gw %s prefixlen %d",
+ ROUTE_PATH,
+ r6->iface,
+ network,
+ gateway,
+ r6->netbits);
+
+ argv_msg(D_ROUTE, &argv);
+ openvpn_execve_check(&argv, es, 0, "ERROR: Haiku inet
6 route delete command failed");
+
+ }
#else /* if defined(TARGET_LINUX) */
msg(M_FATAL, "Sorry, but I don't know how to do 'route ipv6' commands on this operating system. Try putting your routes in a --route-down script");
#endif /* if defined(TARGET_LINUX) */
@@ -3460,6 +3496,75 @@ get_default_gateway_ipv6(struct route_ipv6_gateway_info *rgi6,
}
}
+#elif defined(TARGET_HAIKU)
+
+void
+get_default_gateway(struct route_gateway_info *rgi, openvpn_net_ctx_t *ctx)
+{
+ CLEAR(*rgi);
+
+ int sockfd = -1;
+ sockfd = socket(AF_INET, SOCK_DGRAM, 0);
+ if (sockfd < 0) {
+ msg(M_INFO, "%s: Error opening socket for AF_INET", __func__);
+ return;
+ }
+
+ struct ifconf config;
+ config.ifc_len = sizeof(config.ifc_value);
+ if (ioctl(sockfd, SIOCGRTSIZE, &config, sizeof(struct ifconf)) < 0) {
+ msg(M_INFO, "%s: Error getting routing table size", __func__);
+ return;
+ }
+
+ uint32 size = (uin
t32)config.ifc_value;
+ if (size == 0)
+ return;
+
+ void *buffer = malloc(size);
+ if (buffer == NULL) {
+ fprintf(stderr, "%s: Out of memory.\n", __func__);
+ return;
+ }
+
+ config.ifc_len = size;
+ config.ifc_buf = buffer;
+ if (ioctl(sockfd, SIOCGRTTABLE, &config, sizeof(struct ifconf)) < 0)
+ return;
+
+ struct ifreq *interface = (struct ifreq*)buffer;
+ struct ifreq *end = (struct ifreq*)((uint8*)buffer + size);
+
+ while (interface < end) {
+ struct route_entry route = interface->ifr_route;
+ if ((route.flags & RTF_GATEWAY) != 0 && (route.flags & RTF_DEFAULT) != 0) {
+ //msg(M_INFO, "%s: FOUND DEFAULT GATEWAY ON %s", __func__, interface->ifr_name);
+ rgi->gateway.addr = ntohl(((struct sockaddr_in *)route.gateway)->sin_addr.s_addr);
+ rgi->flags = RGI_ADDR_DEFINED | RGI_IFACE_DEFINED;
+ strcpy(rgi->iface, interface->ifr_name);
+ }
+
+ int32 addressSize = 0;
+ if (route.destination != NULL)
+ addressSize += route.destination->sa_len;
+ if (route.mask != NULL)
+ addressSize += route.mask->sa_len;
+ if (route.gateway != NULL)
+ addressSize += route.gateway->sa_len;
+
+ interface = (struct ifreq*)((addr_t)interface + IF_NAMESIZE
+ + sizeof(struct route_entry) + addressSize);
+ }
+}
+
+void
+get_default_gateway_ipv6(struct route_ipv6_gateway_info *rgi6,
+ const struct in6_addr *dest, openvpn_net_ctx_t *ctx)
+{
+ /* TODO: Same for ipv6 with AF_INET6 */
+ CLEAR(*rgi6);
+}
+
#elif defined(TARGET_DARWIN) || defined(TARGET_SOLARIS) \
|| defined(TARGET_FREEBSD) || defined(TARGET_DRAGONFLY) \
|| defined(TARGET_OPENBSD) || defined(TARGET_NETBSD)
Comments
Hi, On Tue, Nov 26, 2024 at 02:26:59PM +0000, Alexander von Gluck via Openvpn-devel wrote: > diff --git a/src/openvpn/route.c b/src/openvpn/route.c > index fa20d08f..8d319123 100644 > --- a/src/openvpn/route.c > +++ b/src/openvpn/route.c > @@ -54,6 +54,12 @@ > #include <net/route.h> /* RT_ROUNDUP(), RT_ADVANCE() */ > #endif > > +#if defined(TARGET_HAIKU) > +#include <SupportDefs.h> /* uint32, etc */ > +#include <net/if.h> /* ifconf etc */ > +#include <sys/sockio.h> /* SIOCGRTTABLE, etc */ > +#endif /* TARGET_HAIKU */ > + System includes go to "syshead.h". > #ifdef _WIN32 > #include "openvpn-msg.h" > > @@ -1857,14 +1863,16 @@ add_route(struct route_ipv4 *r, > > { > /* ex: route add /dev/net/ipro1000/0 default gw 192.168.1.1 netmask 255.255.255.0 */ > - argv_printf(&argv, "route add %s inet default gw %s netmask %s", > + argv_printf(&argv, "%s add %s inet %s gw %s netmask %s", > + ROUTE_PATH, > rgi- > >iface, > + network, Please squash this part into patch 1/2 - having one patch introduce something new for #ifdef TARGET_HAIKU, only to have the next patch modify the very same line is not helpful. > +#elif defined(TARGET_HAIKU) > + > + { > + // route del /dev/net/ipro1000/0 inet 192.168.0.0 gw 192.168.1.1 netmask 255.255.0.0 No // comments At least adding/deleting of routes should be "in patch 1". The get_default_gateway() part could, technically, go into its own patch ("it adds independent new functionality") - but since this all fairly small, it can just be part of the single patch. A few lines of README would be nice, if anything special is needed to make OpenVPN work on HAIKU, with you patch ("you need to install the tun/tap driver from $url, then reboot twice at midnight, and off you go"). gert
diff --git a/src/openvpn/route.c b/src/openvpn/route.c index fa20d08f..8d319123 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -54,6 +54,12 @@ #include <net/route.h> /* RT_ROUNDUP(), RT_ADVANCE() */ #endif +#if defined(TARGET_HAIKU) +#include <SupportDefs.h> /* uint32, etc */ +#include <net/if.h> /* ifconf etc */ +#include <sys/sockio.h> /* SIOCGRTTABLE, etc */ +#endif /* TARGET_HAIKU */ + #ifdef _WIN32 #include "openvpn-msg.h" @@ -1857,14 +1863,16 @@ add_route(struct route_ipv4 *r, { /* ex: route add /dev/net/ipro1000/0 default gw 192.168.1.1 netmask 255.255.255.0 */ - argv_printf(&argv, "route add %s inet default gw %s netmask %s", + argv_printf(&argv, "%s add %s inet %s gw %s netmask %s", + ROUTE_PATH, rgi- >iface, + network, gateway, netmask); argv_msg(D_ROUTE, &argv); bool ret = openvpn_execve_check(&argv, es, 0, - "ERROR: Haiku route add command failed"); + "ERROR: Haiku inet route add command failed"); status = ret ? RTA_SUCCESS : RTA_ERROR; }