From patchwork Sun Sep 13 04:56:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 1443 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director10.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id WMq1GJE4Xl/dMwAAIUCqbw (envelope-from ) for ; Sun, 13 Sep 2020 11:19:45 -0400 Received: from proxy16.mail.iad3b.rsapps.net ([172.31.255.6]) by director10.mail.ord1d.rsapps.net with LMTP id CNmSGJE4Xl8IEQAApN4f7A (envelope-from ) for ; Sun, 13 Sep 2020 11:19:45 -0400 Received: from smtp2.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy16.mail.iad3b.rsapps.net with LMTPS id QBdIEJE4Xl/XTwAAPj+4aA (envelope-from ) for ; Sun, 13 Sep 2020 11:19:45 -0400 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: smtp2.gate.iad3b.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; dmarc=none (p=nil; dis=none) header.from=greenie.muc.de X-Suspicious-Flag: YES X-Classification-ID: 8d482a8a-f5d4-11ea-958e-5254000fbace-1-1 Received: from [216.105.38.7] ([216.105.38.7:54492] helo=lists.sourceforge.net) by smtp2.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id A9/4F-13758-0983E5F5; Sun, 13 Sep 2020 11:19:44 -0400 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.90_1) (envelope-from ) id 1kHTmD-0001dY-9w; Sun, 13 Sep 2020 15:18:49 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kHTm9-0001dO-PI for openvpn-devel@lists.sourceforge.net; Sun, 13 Sep 2020 15:18:45 +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: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:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Z5GUWvVJWGgWizwxoVBdraBICBC/ucMqqdO4LCy7hVE=; b=U3+Gw6E0X9rCmjw1YXfW/inAAK k7NDjL+2uiVH0pGFjfBj4/MRl7hL+xfD+OedFW7Z2Jj9vhNNJkNBlnPbOfQlKu6Uy2q3GlQV2Yu/O VE713u3K8CV7tIVyhMjJM4jxDTESF1wefcmwwld6iwu1TkgMihMv7YX4k2u01Bv2Ni9E=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version: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:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=Z5GUWvVJWGgWizwxoVBdraBICBC/ucMqqdO4LCy7hVE=; b=D a5wT71ldKDAHEx0xa0C0jhxF7TJYDU5SxKIP4R4m0yv4sPmOiUzJTQkMGSKWswV8XwRZPWPIi1pVa gIN5jdiO8reuEOniInnL9p/t8tDjh0ylsLLufLa0qhEWfTO69zmU7O2Qvs/SeI2pQIAZkEueJfEoz Nufat0rbh9Ztz/M4=; Received: from vmail1.greenie.net ([195.30.8.66]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1kHTm1-007E0g-MB for openvpn-devel@lists.sourceforge.net; Sun, 13 Sep 2020 15:18:45 +0000 Received: from nbsd81.ov.greenie.net (nbsd81.ov.greenie.net [IPv6:2001:608:0:814:0:0:f000:17]) by vmail1.greenie.net (8.16.1/8.12.11) with ESMTP id 08DEuL2D016730 for ; Sun, 13 Sep 2020 16:56:22 +0200 (CEST) Received: by nbsd81.ov.greenie.net (Postfix, from userid 1000) id F1E8376A61; Sun, 13 Sep 2020 16:56:21 +0200 (CEST) From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Sun, 13 Sep 2020 16:56:21 +0200 Message-Id: <20200913145621.12125-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (vmail1.greenie.net [IPv6:2001:608:1:995a:20c:29ff:feb8:10eb]); Sun, 13 Sep 2020 16:56:22 +0200 (CEST) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: greenie.net] 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-Headers-End: 1kHTm1-007E0g-MB Subject: [Openvpn-devel] [PATCH] Fix --show-gateway for IPv6 on NetBSD/i386. 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 Our ROUNDUP() macro to achieve the required system-specific alignment for data structures sent to the routing socket was wrong for NetBSD - unlike OpenBSD/FreeBSD, NetBSD is not using "long" (32/64 bit depending on OS architecture), and not "uint32_t" either (32/32) like MacOS, but uint64_t. So our use of "long" always worked on NetBSD/amd64 and stopped working on NetBSD/i386 when this was changed on the OS side... NetBSD conveniently exports a RT_ROUNDUP() macro from - use that, and avoid trying to second-guess OS requirements. While at it, add M_ERRNO to ominous "GDG6: problem writing to routing socket" error message to differenciate between "EINVAL" and other errors. Trac: #734 Signed-off-by: Gert Doering Acked-By: Arne Schwabe --- src/openvpn/route.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/openvpn/route.c b/src/openvpn/route.c index f127a90a..87febf49 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -49,6 +49,10 @@ #include /* RTM_GETROUTE etc. */ #endif +#if defined(TARGET_NETBSD) +#include /* RT_ROUNDUP(), RT_ADVANCE() */ +#endif + #ifdef _WIN32 #include "openvpn-msg.h" @@ -3408,11 +3412,15 @@ struct rtmsg { /* the route socket code is identical for all 4 supported BSDs and for * MacOS X (Darwin), with one crucial difference: when going from - * 32 bit to 64 bit, the BSDs increased the structure size but kept + * 32 bit to 64 bit, FreeBSD/OpenBSD increased the structure size but kept * source code compatibility by keeping the use of "long", while * MacOS X decided to keep binary compatibility by *changing* the API * to use "uint32_t", thus 32 bit on all OS X variants * + * NetBSD does the MacOS way of "fixed number of bits, no matter if + * 32 or 64 bit OS", but chose uint64_t. For maximum portability, we + * just use the OS RT_ROUNDUP() macro, which is guaranteed to be correct. + * * We used to have a large amount of duplicate code here which really * differed only in this (long) vs. (uint32_t) - IMHO, worse than * having a combined block for all BSDs with this single #ifdef inside @@ -3421,6 +3429,8 @@ struct rtmsg { #if defined(TARGET_DARWIN) #define ROUNDUP(a) \ ((a) > 0 ? (1 + (((a) - 1) | (sizeof(uint32_t) - 1))) : sizeof(uint32_t)) +#elif defined(TARGET_NETBSD) +#define ROUNDUP(a) RT_ROUNDUP(a) #else #define ROUNDUP(a) \ ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) @@ -3729,7 +3739,7 @@ get_default_gateway_ipv6(struct route_ipv6_gateway_info *rgi6, } if (write(sockfd, (char *)&m_rtmsg, l) < 0) { - msg(M_WARN, "GDG6: problem writing to routing socket"); + msg(M_WARN|M_ERRNO, "GDG6: problem writing to routing socket"); goto done; }