From patchwork Sat Nov 26 09:08:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kristof Provost X-Patchwork-Id: 2855 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director15.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id yIIUMu7XgWPGdAAAIUCqbw (envelope-from ) for ; Sat, 26 Nov 2022 04:10:06 -0500 Received: from proxy19.mail.ord1d.rsapps.net ([172.30.191.6]) by director15.mail.ord1d.rsapps.net with LMTP id 8Lj8Me7XgWMidgAAIcMcQg (envelope-from ) for ; Sat, 26 Nov 2022 04:10:06 -0500 Received: from smtp27.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy19.mail.ord1d.rsapps.net with LMTPS id CIjFMe7XgWPHfwAAyH2SIw (envelope-from ) for ; Sat, 26 Nov 2022 04:10:06 -0500 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp27.gate.ord1d.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dkim=fail (signature verification failed) header.d=netgate.com; dmarc=pass (p=none; dis=none) header.from=lists.sourceforge.net X-Suspicious-Flag: YES X-Classification-ID: 1e3a21e2-6d6a-11ed-b45d-5254003773d7-1-1 Received: from [216.105.38.7] ([216.105.38.7:48322] helo=lists.sourceforge.net) by smtp27.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 0C/68-05938-EE7D1836; Sat, 26 Nov 2022 04:10:06 -0500 Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1oyrBI-0000jT-RM; Sat, 26 Nov 2022 09:09:04 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1oyrBG-0000jJ-0T for openvpn-devel@lists.sourceforge.net; Sat, 26 Nov 2022 09:09:02 +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=doWNL7zSmVDJ3ZZj1htAKvqksExmitfm73fqfhqDA1U=; b=ccv3mtuc0ChWQpfMd7JPFRj/Qn SKZYYzX9gyofIuXNm/hOkUYkabTbHADn2hFLouxd47FCVxzjclT5SSv3e7zoQtNfGjWdAMGLOJrfP eSmESnTos4IHqwXUDdGmNjMYAOXWaubeZkybKqSrFR1+wqJ8sdHdiN88nKtadefboMLM=; 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=doWNL7zSmVDJ3ZZj1htAKvqksExmitfm73fqfhqDA1U=; b=IBtRLI9X+j55wSsQDWfYih6Dmz qzgEYgq6A1YNJ+QCvZmqQeEMZvX2yaE1IYHTC3PJEqT/1J+syth2Gnq+a8CxKhJXsSxgd9s/mxUWv 5NHBh0hvl0XL5+gfAaKicUfIVs9DcW6nu9huyGpnxrA1gAbECyTyHhVtyvljMBQTok6Q=; Received: from mail-ej1-f45.google.com ([209.85.218.45]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1oyrBD-00ESiV-Hr for openvpn-devel@lists.sourceforge.net; Sat, 26 Nov 2022 09:09:01 +0000 Received: by mail-ej1-f45.google.com with SMTP id bj12so14838773ejb.13 for ; Sat, 26 Nov 2022 01:08:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netgate.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=doWNL7zSmVDJ3ZZj1htAKvqksExmitfm73fqfhqDA1U=; b=UY03B5Wpojechm3ELoUNCfe2WczdcnWficBJHsW9+/UAqEmmjdc6wpT561bTFdwl1q Cgx5UqJ1dFxXPcLpvU/Iva5Ix7KabxtBHLFD6pqU363ucK808sRg/2M0Ug4UuyuDWQ/f qi08BeILXnce7cnJGsIyUmcfBuUYnkX2+2leM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=doWNL7zSmVDJ3ZZj1htAKvqksExmitfm73fqfhqDA1U=; b=aCDGTudPfDVScSDQdB11YKPkOErDiPLH4W4jyEBCDNPxb1a9h1HLBK89zczkkXtFoN MKqa63maTAo1qV/GfIh21/rJ+kcvRUBRpSQcQw/N3d+yff6mENAhLPw/xMvD/GbBlIJP CLCtos6dj6TX1rQ0TcjDFX1uyXFvDwWw5X9cZUbr3rliGFOsY5nL9UKI072DFOGJE9Jj S4gC/o4NHF71EA+eo+kyHVXZkbGvHaXpEZ9NTMhU5dDPaKOCIH0BEsPWAtT26cytI4f7 6/pMNEbeztyUc38KBxfe9wYPDYxdxtIz8kkKOrtb9D+VE80UZQ/TIuBEIb9rgrYxxch0 9bvA== X-Gm-Message-State: ANoB5pmLAztvNNMh2OxdPXCHp3cQ0/GduzuG0DDgbRuSt6Qy4EE7yZBx SjJmcGP7yNv+qGN191r5JqBtbIr2i8DsO9dJ X-Google-Smtp-Source: AA0mqf5gH4WTmv/BSAUqS+mgX/it+gleWka4RFnS0Bh0MX4pe0iaEcb6zpjwGt2QEaUcBkiqfu9YaQ== X-Received: by 2002:a17:906:7ac8:b0:7ad:c8d6:bc7f with SMTP id k8-20020a1709067ac800b007adc8d6bc7fmr35256091ejo.118.1669453732870; Sat, 26 Nov 2022 01:08:52 -0800 (PST) Received: from nut.jupiter.sigsegv.be (ptr-8rfalzsse26o3oo9imw.18120a2.ip6.access.telenet.be. [2a02:1811:2402:bf00:f602:70ff:feae:6e98]) by smtp.googlemail.com with ESMTPSA id l16-20020aa7c3d0000000b00468f7bb4895sm2798054edr.43.2022.11.26.01.08.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Nov 2022 01:08:52 -0800 (PST) To: openvpn-devel Date: Sat, 26 Nov 2022 10:08:51 +0100 Message-Id: <20221126090851.8656-1-kprovost@netgate.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221125155341.19456-1-kprovost@netgate.com> References: <20221125155341.19456-1-kprovost@netgate.com> MIME-Version: 1.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: Kristof Provost FreeBSD allows packets to be sent through the socket even when the if_dco driver is active, so prefer that path. Also remove the FreeBSD dco_do_write() implementation, as this function will never be called any more on FreeBSD. Assert this. Content analysis details: (-0.2 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.218.45 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.218.45 listed in wl.mailspike.net] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-Headers-End: 1oyrBD-00ESiV-Hr Subject: [Openvpn-devel] [PATCH] dco: pass control packets through the socket on FreeBSD 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: , X-Patchwork-Original-From: Kristof Provost via Openvpn-devel From: Kristof Provost Reply-To: Kristof Provost Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox From: Kristof Provost FreeBSD allows packets to be sent through the socket even when the if_dco driver is active, so prefer that path. Also remove the FreeBSD dco_do_write() implementation, as this function will never be called any more on FreeBSD. Assert this. Signed-off-by: Kristof Provost Acked-by: Gert Doering --- src/openvpn/dco_freebsd.c | 33 ++++----------------------------- src/openvpn/forward.c | 7 +++++-- 2 files changed, 9 insertions(+), 31 deletions(-) diff --git a/src/openvpn/dco_freebsd.c b/src/openvpn/dco_freebsd.c index 8e5ee436..4e03f52e 100644 --- a/src/openvpn/dco_freebsd.c +++ b/src/openvpn/dco_freebsd.c @@ -536,35 +536,10 @@ dco_do_read(dco_context_t *dco) int dco_do_write(dco_context_t *dco, int peer_id, struct buffer *buf) { - struct ifdrv drv; - nvlist_t *nvl; - int ret; - - nvl = nvlist_create(0); - - nvlist_add_binary(nvl, "packet", BSTR(buf), BLEN(buf)); - nvlist_add_number(nvl, "peerid", peer_id); - - CLEAR(drv); - snprintf(drv.ifd_name, IFNAMSIZ, "%s", dco->ifname); - drv.ifd_cmd = OVPN_SEND_PKT; - drv.ifd_data = nvlist_pack(nvl, &drv.ifd_len); - - ret = ioctl(dco->fd, SIOCSDRVSPEC, &drv); - if (ret) - { - msg(M_WARN | M_ERRNO, "Failed to send control packet"); - ret = -errno; - } - else - { - ret = BLEN(buf); - } - - free(drv.ifd_data); - nvlist_destroy(nvl); - - return ret; + /* Control packets are passed through the socket, so this should never get + * called. See should_use_dco_socket(). */ + ASSERT(0); + return -EINVAL; } bool diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 622be841..1dcaabd8 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -1635,20 +1635,23 @@ process_ip_header(struct context *c, unsigned int flags, struct buffer *buf) } } -/* Linux-like DCO implementations pass the socket to the kernel and +/* Linux DCO implementations pass the socket to the kernel and * disallow usage of it from userland, so (control) packets sent and * received by OpenVPN need to go through the DCO interface. * * Windows DCO needs control packets to be sent via the normal * standard Overlapped I/O. * + * FreeBSD DCO allows control packets to pass through the socket in both + * directions. + * * Hide that complexity (...especially if more platforms show up * in the future...) in a small inline function. */ static inline bool should_use_dco_socket(struct link_socket_actual *actual) { -#if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) +#if defined(TARGET_LINUX) return actual->dco_installed; #else return false;