From patchwork Sun Dec 31 17:41:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 3541 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7301:2791:b0:100:d2e5:60d with SMTP id hm17csp1132714dyb; Sun, 31 Dec 2023 10:11:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IG7sqivdlMV25APUeUcdecu53dUtMRAYpSSdVd5tcNYcEGpxJOLArN9ivk7Cxir7fYWPVQL X-Received: by 2002:a17:90a:e0f:b0:28c:5a9:de71 with SMTP id v15-20020a17090a0e0f00b0028c05a9de71mr22129137pje.4.1704046267385; Sun, 31 Dec 2023 10:11:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704046267; cv=none; d=google.com; s=arc-20160816; b=esanJFiS3205g/Upxcnv606vaJ8bdXRSWdF30ezunF04AQUEm5C5phS74Q7uvJXmXA BI2V0Np6NsY8vOxYCKoUHEz6EcIZxBFrNmKzJzNp5K/y2701rPF+6OF0g8DPXu6ApGEc wYAggf7v9A3i8QqvqRvEub01csPpoPdnCwXId6JGmflZNTDHEMFxnZi6XGdJoZv4xoek aclFAMtZPgR8QTuYl+OcC5a9Mm96aE8VbsFvg24RO7uTsMceLikTgJbdWFU3K96LBn35 4p6ljFf+PexLBJb1GMW3Qsd5J6y2h2Z7i3YH0lwwRv8PgFajFZQY2amBmHfOYievR0oU j0AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:message-id:date:to:from:dkim-signature:dkim-signature; bh=wWP6DaPHYCrqaGdGRT5z931DbwQN66e0//3GtXp0H8A=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=AkUOvvbWp6+fegIQUuwSn+qnhw/wyGpnHCD8Yb3ew6fqOV/xUy/Mut9KbRwuBW/FCh 4oYkfr3gfWvAdNuPP0NMdYhrUtD8fh4QxRScGxQK1brzytSiW2ow4lOrj2lXxmXFLIrr O9qZ96amUUL+AdT/+nze6Bq8SHqhKgSYar7fl6eEyMBKFVFolmSaW8PMBVYzzXf9zW5Y SG8zB2AfXFwE/69gReiXt52cr+Mn6a0YRMoo8D2Oh/E2WldaZb2r6QcUo0TylzB7k8OV C189lf86VjNTp0kr9QBN2d0Izn0R+gyYzGVPQEO9FNAkP0iuIgtJLAbIml5kFo8J+keE xEqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=YhOvFjnZ; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=Dgxfyo4w; 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 x10-20020a17090a788a00b0028bbcbe5414si20845460pjk.45.2023.12.31.10.11.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 Dec 2023 10:11:07 -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=YhOvFjnZ; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=Dgxfyo4w; 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-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rK0Gs-0002vG-CK; Sun, 31 Dec 2023 18:10:45 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rK0Gp-0002v9-6q for openvpn-devel@lists.sourceforge.net; Sun, 31 Dec 2023 18:10: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: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=CMxFo2i1urh2Mkfeq2KY6wScptcokvnA68hk8Jk4YPg=; b=YhOvFjnZ6UXzpR6KEbXcWfOD0s esrxULn1n+nHJS3lBRkQMNemou1ozDd4iETQvJOeHbjjt5VI3MNKbm2mtjtL25ORor1WvLsgQhtk/ 224dOfTpIDt8Ali6GjNSeaCRFj1xlobiJYADa9+NSo++DxqyZ0pcB6iMMS7xT5cuxuSI=; 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=CMxFo2i1urh2Mkfeq2KY6wScptcokvnA68hk8Jk4YPg=; b=D gxfyo4wyMAiyZQFBgwIOng+aTDPeomRfnx+geEK/m26B/Wl8SG8BGZoXL/6QO0EZrO0hXeOGJS5d0 6us9XHVIv7hIFZYZMGZu9eJrxCJnrcaRTDyLNuoSwxnbr9HQGIZ8b4RKYihHpq9PthNoCGy/dDKXD NrkvQwyfC0mfMCZ0=; Received: from vmail1.greenie.net ([195.30.8.66]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1rK0Gi-0002n9-EE for openvpn-devel@lists.sourceforge.net; Sun, 31 Dec 2023 18:10:42 +0000 Received: from oi2019.ov.greenie.net (oi2019.ov.greenie.net [IPv6:2001:608:0:814:0:0:f000:20]) by vmail1.greenie.net (8.17.2/8.16.1) with ESMTPS id 3BVHfohs073523 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Sun, 31 Dec 2023 18:41:51 +0100 (CET) Received: from oi2019.ov.greenie.net (oi2019 [127.0.0.1]) by oi2019.ov.greenie.net (8.15.2+Sun/8.15.2) with ESMTP id 3BVHfpCT026825 for ; Sun, 31 Dec 2023 18:41:51 +0100 (CET) Received: (from gert@localhost) by oi2019.ov.greenie.net (8.15.2+Sun/8.15.2/Submit) id 3BVHfpjK026824 for openvpn-devel@lists.sourceforge.net; Sun, 31 Dec 2023 18:41:51 +0100 (CET) From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Sun, 31 Dec 2023 18:41:51 +0100 Message-Id: <20231231174151.26780-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.4 (vmail1.greenie.net [IPv6:2001:608:1:995a:20c:29ff:feb8:10eb]); Sun, 31 Dec 2023 18:41:51 +0100 (CET) X-Spam-Score: -2.1 (--) 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: In the context of gerrit/454 it was uncovered that the existing code never worked on OpenSolaris anyway because no AF_LINK addresses are returned. Debugging this, it was found that SIOCGIFHWADDR exist [...] Content analysis details: (-2.1 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [195.30.8.66 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 T_SCC_BODY_TEXT_LINE No description available. X-Headers-End: 1rK0Gi-0002n9-EE Subject: [Openvpn-devel] [PATCH] OpenSolaris: teach get_default_gateway() to get HWADDR 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?1786822018833121175?= X-GMAIL-MSGID: =?utf-8?q?1786822018833121175?= In the context of gerrit/454 it was uncovered that the existing code never worked on OpenSolaris anyway because no AF_LINK addresses are returned. Debugging this, it was found that SIOCGIFHWADDR exists instead, and "man if_tcp" claims "should behave in a manner compatible with Linux". So, copied and adjusted the linux code, and it works... Signed-off-by: Gert Doering --- src/openvpn/route.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/openvpn/route.c b/src/openvpn/route.c index 0e6667f7..684b6357 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -3643,8 +3643,8 @@ get_default_gateway(struct route_gateway_info *rgi, openvpn_net_ctx_t *ctx) #if !defined(TARGET_SOLARIS) /* Illumos/Solaris does not provide AF_LINK entries when calling the - * SIOCGIFCONF API, so there is little sense to trying to figure out a - * MAC address from an API that does not provide that information */ + * SIOCGIFCONF API, but does have SIOCGIFHWADDR - so ifdef needed + */ /* try to read MAC addr associated with interface that owns default gateway */ if (rgi->flags & RGI_IFACE_DEFINED) @@ -3725,6 +3725,31 @@ get_default_gateway(struct route_gateway_info *rgi, openvpn_net_ctx_t *ctx) cp += len; } } +#else /* if !defined(TARGET_SOLARIS) */ + /* try to read MAC addr associated with interface that owns default gateway */ + if (rgi->flags & RGI_IFACE_DEFINED) + { + sockfd = socket(AF_INET, SOCK_DGRAM, 0); + if (sockfd < 0) + { + msg(M_WARN, "GDG: socket #3 failed"); + goto done; + } + + struct ifreq ifreq = { 0 }; + + /* now get the hardware address. */ + strncpynt(ifreq.ifr_name, rgi->iface, sizeof(ifreq.ifr_name)); + if (ioctl(sockfd, SIOCGIFHWADDR, &ifreq) < 0) + { + msg(M_WARN, "GDG: SIOCGIFHWADDR(%s) failed", ifreq.ifr_name); + } + else + { + memcpy(rgi->hwaddr, &ifreq.ifr_addr.sa_data, 6); + rgi->flags |= RGI_HWADDR_DEFINED; + } + } #endif /* if !defined(TARGET_SOLARIS) */ done: