From patchwork Wed Jan 29 09:50:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4100 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:6a49:b0:5e7:b9eb:58e8 with SMTP id v9csp936968mat; Wed, 29 Jan 2025 01:50:56 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX0c0e4YRlYWhE0cE7a9ZoKYnptvA/60wti+1VI87CEX4Uj6+2Jv0xLA0YgS9Nfzl+GRrTuW2VBt8Y=@openvpn.net X-Google-Smtp-Source: AGHT+IFVI2Xi8n7Vn9QuCk6wpG1bih0mx7bPdR0JF56vcM1y45aNde1vXOugnY/mKs1cswSUh3Vh X-Received: by 2002:a05:6870:2c89:b0:28c:8476:dd76 with SMTP id 586e51a60fabf-2b32f28406bmr1571018fac.29.1738144256552; Wed, 29 Jan 2025 01:50:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1738144256; cv=none; d=google.com; s=arc-20240605; b=SVomRzb7qSs6pSjwYl/PcvMObvv5VihPWaqd/YQxNtoEVXgcOl+gd6G50iAabuboWp 0w3pCRGUG1MJp+zsaHxU6qWzbIErSghxu0Td6QwkVfGUekLNy5Ps6SCluZsbuSCfGKK7 e95yOgsFM3lbX6TYUm20JNfEhiTW1K7k5LjQMIj1kEoI/ozajBzYpWHxRQSCkSRk2ebU pEE1IWZnnAwZTpVEJtSHe4mG7RCejCN+QrWvDQ3XvHt7ghw1GnDHB9Kb5tZU6nQlurOk CgDVNDuNu7t5fGHHLO+9SdQt6Pohs51Xmh9IsTn1ZpyQz8WS2NDkFGnPdbQ9qiOmrvNZ 7saQ== 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=HRSA2k3pWD3yePFTdaWU+TNiabH/H3WUorBo6i+TcOE=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=hX7jxsDDrdV/WaQ2dxBvvnYj0W6ZMwMHkKiTI50yuFJnnFfYIgsiR6b0Z02HmV+vU6 DtI9IMRATzU7LFYIpkuQf0cO0FzRw31GjZK/Qo65134K6iVf1kGBaN2vNqLjZqKbyCMI lBQoclQ9ZQPfzk6p6koxcpKZ02seakgCg9irjfqNldAJ0gwBbD7t2ilwlrgVblaqw4Il BhXOWpymkLndbNrANr1ahz64GeK89b1MrOXRMV3desYfow3nXL9a+DxqNiGxSDDfYxcC poB7Xeox2P4kYDbySLJxwxoF9LLOpKIyaUinrJDfZGSLdduys9/ogmPmJZl0UtR6hgsa LOFA==; 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=KMQtBmiG; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=HDetfNi1; 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-2b2b0963394si6944136fac.127.2025.01.29.01.50.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Jan 2025 01:50:56 -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=KMQtBmiG; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=HDetfNi1; 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-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1td4ii-0005NQ-IX; Wed, 29 Jan 2025 09:50:52 +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 ) id 1td4ih-0005NJ-Ns for openvpn-devel@lists.sourceforge.net; Wed, 29 Jan 2025 09:50:51 +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=W5X7lNB3gRzMV4XQ6K1CkFRSLqUQspKucRnh4/6HPYI=; b=KMQtBmiG1LSTIxTkO8QzooepC2 kPqVt4nl2crVzZ7V2BSGL3S2zjPieQQ0pSMDx1uY250lMFvH3IJMWCNaP7VjBR+Igo5DL/9YecSZn Sql0BzfDgdgOU0pdW28A+uMxoa3CrLk1OvqA42nQMCsmYK+3XbMtpQX4X6Wzuyj21qBs=; 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=W5X7lNB3gRzMV4XQ6K1CkFRSLqUQspKucRnh4/6HPYI=; b=HDetfNi1Dk0LYSw8I88WHrNLcn QeoHXf91wrHVfG2h4OYV/kBvGn6+SSB9irwElO6RLS+yEbjuPQlcuBLqPwvN7It8aG9RXbfvsBANn AKPEw+lRE+RufUhkwZ1SjAgaA2oE5JQcHy/z+uCtY7buy7Q8+OHvkfU4QCVpkQYUuRQk=; 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 1td4ig-0004h9-HR for openvpn-devel@lists.sourceforge.net; Wed, 29 Jan 2025 09:50:51 +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 50T9odob019066 for ; Wed, 29 Jan 2025 10:50:39 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.17.1.9/8.17.1.9/Submit) id 50T9ocCs019065 for openvpn-devel@lists.sourceforge.net; Wed, 29 Jan 2025 10:50:38 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Wed, 29 Jan 2025 10:50:38 +0100 Message-ID: <20250129095038.19056-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-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: From: Lev Stipakov As a preparation of an upcoming refactoring of get_default_gateway(), add `dest` parameter to specify destination address to which we are looking the best route. Change-Id: I58735fb24bc4a94c803b7dfcd6de87af0f75522a Signed-off-by: Lev Stipakov Acked-by: Gert Doering --- Content analysis details: (0.0 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 RCVD_IN_VALIDITY_CERTIFIED_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] X-Headers-End: 1td4ig-0004h9-HR Subject: [Openvpn-devel] [PATCH v1] route.c: change the signature of get_default_gateway() 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?1822576351937525335?= X-GMAIL-MSGID: =?utf-8?q?1822576351937525335?= From: Lev Stipakov As a preparation of an upcoming refactoring of get_default_gateway(), add `dest` parameter to specify destination address to which we are looking the best route. Change-Id: I58735fb24bc4a94c803b7dfcd6de87af0f75522a Signed-off-by: Lev Stipakov Acked-by: Gert Doering --- 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/+/878 This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 4510bea..5a80e6b 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -5866,7 +5866,7 @@ get_ipv6_addr(p[1], &remote, NULL, M_WARN); } net_ctx_init(NULL, &net_ctx); - get_default_gateway(&rgi, &net_ctx); + get_default_gateway(&rgi, 0, &net_ctx); get_default_gateway_ipv6(&rgi6, &remote, &net_ctx); print_default_gateway(M_INFO, &rgi, &rgi6); openvpn_exit(OPENVPN_EXIT_STATUS_GOOD); /* exit point */ diff --git a/src/openvpn/route.c b/src/openvpn/route.c index d17b285..640b0dc 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -655,7 +655,7 @@ rl->spec.flags |= RTSA_DEFAULT_METRIC; } - get_default_gateway(&rl->rgi, ctx); + get_default_gateway(&rl->rgi, remote_host, ctx); if (rl->rgi.flags & RGI_ADDR_DEFINED) { setenv_route_addr(es, "net_gateway", rl->rgi.gateway.addr, -1); @@ -2733,7 +2733,7 @@ } void -get_default_gateway(struct route_gateway_info *rgi, openvpn_net_ctx_t *ctx) +get_default_gateway(struct route_gateway_info *rgi, in_addr_t dest, openvpn_net_ctx_t *ctx) { struct gc_arena gc = gc_new(); @@ -3282,7 +3282,7 @@ #elif defined(TARGET_ANDROID) void -get_default_gateway(struct route_gateway_info *rgi, openvpn_net_ctx_t *ctx) +get_default_gateway(struct route_gateway_info *rgi, in_addr_t dest, openvpn_net_ctx_t *ctx) { /* Android, set some pseudo GW, addr is in host byte order, * Determining the default GW on Android 5.0+ is non trivial @@ -3323,7 +3323,7 @@ #elif defined(TARGET_LINUX) void -get_default_gateway(struct route_gateway_info *rgi, openvpn_net_ctx_t *ctx) +get_default_gateway(struct route_gateway_info *rgi, in_addr_t dest, openvpn_net_ctx_t *ctx) { struct gc_arena gc = gc_new(); int sd = -1; @@ -3561,7 +3561,7 @@ #define max(a, b) ((a) > (b) ? (a) : (b)) void -get_default_gateway(struct route_gateway_info *rgi, openvpn_net_ctx_t *ctx) +get_default_gateway(struct route_gateway_info *rgi, in_addr_t dest, openvpn_net_ctx_t *ctx) { struct gc_arena gc = gc_new(); struct rtmsg m_rtmsg; @@ -3943,7 +3943,7 @@ #elif defined(TARGET_HAIKU) void -get_default_gateway(struct route_gateway_info *rgi, openvpn_net_ctx_t *ctx) +get_default_gateway(struct route_gateway_info *rgi, in_addr_t dest, openvpn_net_ctx_t *ctx) { CLEAR(*rgi); @@ -4047,7 +4047,7 @@ * may be disabled by missing items. */ void -get_default_gateway(struct route_gateway_info *rgi, openvpn_net_ctx_t *ctx) +get_default_gateway(struct route_gateway_info *rgi, in_addr_t dest, openvpn_net_ctx_t *ctx) { CLEAR(*rgi); } diff --git a/src/openvpn/route.h b/src/openvpn/route.h index 421e7d2..23603bc 100644 --- a/src/openvpn/route.h +++ b/src/openvpn/route.h @@ -328,6 +328,7 @@ bool is_special_addr(const char *addr_str); void get_default_gateway(struct route_gateway_info *rgi, + in_addr_t dest, openvpn_net_ctx_t *ctx); void get_default_gateway_ipv6(struct route_ipv6_gateway_info *rgi, diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c index e4a7b57..6f78a76 100644 --- a/src/openvpn/ssl.c +++ b/src/openvpn/ssl.c @@ -1990,7 +1990,7 @@ { /* push mac addr */ struct route_gateway_info rgi; - get_default_gateway(&rgi, session->opt->net_ctx); + get_default_gateway(&rgi, 0, session->opt->net_ctx); if (rgi.flags & RGI_HWADDR_DEFINED) { buf_printf(&out, "IV_HWADDR=%s\n", format_hex_ex(rgi.hwaddr, 6, 0, 1, ":", &gc)); diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 33830fc..80f5dff 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -671,7 +671,7 @@ struct route_gateway_info rgi; const unsigned int needed = (RGI_ADDR_DEFINED|RGI_NETMASK_DEFINED); - get_default_gateway(&rgi, ctx); + get_default_gateway(&rgi, 0, ctx); if ((rgi.flags & needed) == needed) { const in_addr_t lan_network = rgi.gateway.addr & rgi.gateway.netmask;