From patchwork Thu Nov 28 10:15:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 3966 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:57cb:b0:5db:cfa9:4424 with SMTP id v11csp1120637mau; Thu, 28 Nov 2024 02:16:54 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXhUCr8l08miEOX0Zf4pO0Chf7UzBrUHo0J2J6l57YAYYO5Nr5Qk5KADhdQLYkqXwqBO90qqWs9NFk=@openvpn.net X-Google-Smtp-Source: AGHT+IFAc62P3EPM+GliO5nOmbT5CKqpwXDShfdcJkkNSjICPf/YJAvtUh3MHbNQ0vb4EFB0cn5r X-Received: by 2002:a05:6870:c69c:b0:297:2201:84cd with SMTP id 586e51a60fabf-29dc3f9bedamr5936913fac.5.1732789013712; Thu, 28 Nov 2024 02:16:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732789013; cv=none; d=google.com; s=arc-20240605; b=cYP8nl4WuropulCZTgC30gkVRsVaieYc+ds5s26fUg8BL4eMh5UNRW9efoF9f4Ykw8 SURFvjDK1MNynTmGNEFyPN+1pjjCbv3s9C49eZqGcapo/+ajVRIMTdJgNaP0zdwYOR5/ 6IkLV9d15LaqxHckohb5sJfW/thQV54RkYbkWuCkzliskpHoZbqzmTZR5NcK8jNxk3BU GGqEEG56u0NrD3GGVACWkMzv/x+hJEcqqT/lZogEY0r7NTBNwBi0S4CXxIlccQHeGh8U EiBTQVeKgYrNXrwBH5ZFwZVgkZ3s1SkpAbGZAzbqiMyzOG2GWHy5pDlzBiOXizE5c6of taKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature; bh=+MegsxUYsiZEhqPu2cVwoS5FLpETfULZGIcqqslqha0=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=du5QOaLWck7A8SQT1inj6pNB6/fc325qgx9SokY9fnSa9f4tvk/8WQDEnr5sFf7ZUi RH+54PCMgTU2y28Z/QbHiDXDb3sUcB05FGCrdJhZr6mV3JJaz+GW7qeSKKDcWBu9Q00O AFqlm6M8/8Kg11nSprLOjWf16fAz5kTqxH84KbX5SFpnHiE1F0gDoMr+gte+elTqrulx W/gZzhUJwOSk8zJmzwmiS3f1CgZ715RmBmH30DI5ZrcvA85AA9RbcWZfKWbuL3/XHJoU 8T9CIiL+oUkjlhy7Q7ytDfoMF9Qug4NZWyopTb1/79CjYSsAIRAO+td2L9Kd1kCaZ503 grbQ==; 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=lrQYsc80; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=EINx5PG8; 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=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 586e51a60fabf-29de9babb33si518076fac.185.2024.11.28.02.16.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Nov 2024 02:16:53 -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=lrQYsc80; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=EINx5PG8; 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=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1tGbZk-00035D-SO; Thu, 28 Nov 2024 10:16:45 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1tGbZi-00034h-SC for openvpn-devel@lists.sourceforge.net; Thu, 28 Nov 2024 10:16:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: 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=/yuwQVM7qqGDCZMmZqwjXsX7BxVXoVItgWJSqTMVK4U=; b=lrQYsc80bfPQiX/RCNDIoG2lpC c7GKIaGfhHyml8FEX+mjaQ3r6Si27AGk7Osu8NsxabZFJPoUCWSSV/R1ffyEURXCLG+FbTTU1tyZO BfMBY4P/vprkwgaIgsQ/VqXO/7nh19cosDCFsRngubsM6CNSfldm610sNSn5MZRjoPvQ=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: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=/yuwQVM7qqGDCZMmZqwjXsX7BxVXoVItgWJSqTMVK4U=; b=EINx5PG8hOX6peSpn6hO8ksGym V5gr+aEtktmBaPD6mpwwBlEJKQchIc6PeKz/0YwBBorJp7ZUqaIONzgmtTaoDY4oqKbEFFpMQF8su BAOfs1Xme+AgK4jJltDKBVR5C/PqtNTOUUAGafi8jOiiRinoCS2XaLDrW1LqHdft3VXQ=; Received: from dhcp-174.greenie.muc.de ([193.149.48.174] helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1tGbZh-0007wH-D2 for openvpn-devel@lists.sourceforge.net; Thu, 28 Nov 2024 10:16:43 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.17.1.9/8.17.1.9) with ESMTP id 4ASAGT61013274 for ; Thu, 28 Nov 2024 11:16:29 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.17.1.9/8.17.1.9/Submit) id 4ASAGTD8013273 for openvpn-devel@lists.sourceforge.net; Thu, 28 Nov 2024 11:16:29 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Thu, 28 Nov 2024 11:15:38 +0100 Message-ID: <20241128101538.12810-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-1.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: From: Alexander von Gluck * Special thanks to Sean Brady's hard work in GSoC 2023 towards creating a TUN/TAP driver for Haiku! * More kudos to Augustin Cavalier for making it functional :-) Content analysis details: (0.0 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 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. [193.149.48.174 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. [193.149.48.174 listed in bl.score.senderscore.com] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record X-Headers-End: 1tGbZh-0007wH-D2 Subject: [Openvpn-devel] [PATCH v6] Haiku: Introduce basic platform / tun support X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1816960972703229004?= X-GMAIL-MSGID: =?utf-8?q?1816960972703229004?= From: Alexander von Gluck * Special thanks to Sean Brady's hard work in GSoC 2023 towards creating a TUN/TAP driver for Haiku! * More kudos to Augustin Cavalier for making it functional :-) Signed-off-by: Alexander von Gluck Acked-by: Gert Doering Change-Id: I9a278374f492a538f0c174ced1746c3b1f82b8c9 --- 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/+/687 This mail reflects revision 6 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering diff --git a/INSTALL b/INSTALL index 6007338..9739272 100644 --- a/INSTALL +++ b/INSTALL @@ -263,6 +263,16 @@ http://www.whiteboard.ne.jp/~admin2/tuntap/ +* Haiku: + + Haiku can't yet dynamically create TUN/TAP devices, so you need to manually + create one before running openvpn: + + # ifconfig tun/0 up + + A standard reference the dev as "tun" in your config is all that's needed + to use the tunnel device. + * Windows OpenVPN on Windows needs a TUN/TAP kernel driver to work. OpenVPN installers diff --git a/configure.ac b/configure.ac index 0876a6a..7f6e43d 100644 --- a/configure.ac +++ b/configure.ac @@ -368,6 +368,11 @@ have_tap_header="yes" ac_cv_header_net_if_h="no" # exists, but breaks things ;; + *-*-haiku*) + AC_DEFINE([TARGET_HAIKU], [1], [Are we running Haiku?]) + AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["H"], [Target prefix]) + LIBS="${LIBS} -lnetwork" + ;; *) AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["X"], [Target prefix]) have_tap_header="yes" diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 85fe01a..3355508 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -1631,6 +1631,15 @@ { windows_set_mtu(tt->adapter_index, AF_INET, tun_mtu); } +#elif defined(TARGET_HAIKU) + { + /* example: ifconfig tun/0 inet 1.1.1.1 255.255.255.0 mtu 1450 up */ + argv_printf(&argv, "%s %s inet %s %s mtu %d up", IFCONFIG_PATH, + ifname, ifconfig_local, ifconfig_remote_netmask, tun_mtu); + + argv_msg(M_INFO, &argv); + openvpn_execve_check(&argv, es, S_FATAL, "Haiku ifconfig failed"); + } #else /* if defined(TARGET_LINUX) */ msg(M_FATAL, "Sorry, but I don't know how to do 'ifconfig' commands on this operating system. You should ifconfig your TUN/TAP device manually or use an --up script."); #endif /* if defined(TARGET_LINUX) */ @@ -1909,10 +1918,15 @@ { for (int i = 0; i < 256; ++i) { + /* some platforms have a dedicated directory per driver */ + char* sep = ""; +#if defined(TARGET_HAIKU) + sep = "/"; +#endif snprintf(tunname, sizeof(tunname), - "/dev/%s%d", dev, i); + "/dev/%s%s%d", dev, sep, i); snprintf(dynamic_name, sizeof(dynamic_name), - "%s%d", dev, i); + "%s%s%d", dev, sep, i); if ((tt->fd = open(tunname, O_RDWR)) > 0) { dynamic_opened = true;