From patchwork Tue Jan 28 13:17:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "cron2 (Code Review)" X-Patchwork-Id: 4093 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:6a49:b0:5e7:b9eb:58e8 with SMTP id v9csp422206mat; Tue, 28 Jan 2025 05:18:16 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWad5S1z61xBu1uUHbveLlVufgICK47Qm+Xhegli/MyAnNVqI7hgnG9zKZWeiysIHNVLF4sE08lYT8=@openvpn.net X-Google-Smtp-Source: AGHT+IF+zmbTARmVuNw7lQprrDzsb/arYitEh/kzHX/O3oWV4BDtFex/nAgg88NvIvhyRhnuPhXP X-Received: by 2002:a05:6871:10b:b0:29d:c832:7ef6 with SMTP id 586e51a60fabf-2b1c0cddb72mr24099176fac.39.1738070295804; Tue, 28 Jan 2025 05:18:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1738070295; cv=none; d=google.com; s=arc-20240605; b=gjKztgWHgT7Xt8nbZ2Ny0NaVbkXD0sIXT+s946kT0xMTtKrvEEs4roi1ECZ3ucS1Og XjCbXNqWqsS2kiNp0XOMAt9veyHUyNIpN/NuJUG87Ng5dMnvFhhIOJbaMQZu4EKd/l4j fPwpFnHdNl3YXM6FZ9RqiP/t5SJd7yYMOl4s4xZpWqQtVRWy1TQ5oAuf/XWTKdhy8QO9 eoxn46xVaw2pfS9CJ32YlLyIPaE7hK22AiN1DT9Ao4mhqSBSA5ncdTOmeTdFwqZYulAq ZBjyzNxFHIkeQ+wc51Bs9wFZXtzpy+s9jkgYwYEmIy0PRAw42wUZxGxijrAW8yRh8bHQ jkpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:cc:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:user-agent :mime-version:message-id:references:auto-submitted:to:date:from :dkim-signature:dkim-signature:dkim-signature; bh=4Xlwh5ZwDXmvPqXWuYyIZeU8b0rguQ+9wZbf1NS7r/I=; fh=U7wEyxtwz2o5+UdevFSA47vNeG9knhWH0KV//QhD5a0=; b=WknlFnBiu9vZ2sYyjJ5Ka4Kf8/OTbtfiwFLqyWZRBp+EhQ8QqBgsHZpAzh9hw3SL5p dzL2hgE7WXfjEwdzEKI5oyHuNUWUJEUrEOV7mVUxIIiy0SoY8JpmwD45B2IId5OrWJ0f 06i12kAFmoFf/zdr+e+yEHAslwmN53lXIVFAvkNYGhcEvNU+6mqXHCk0XN8OVzzRMZPO gjlG3cS14fgnQKx/D57e7+7VBI4Co8Rg0cTOnEYn1TmWmsQk7qZLQgCX9Vri3g8ol2zi qwUbyjg5ndvq/Enx/82lcJ9uBry1QfJKCBfgxZeTmInxAyECpa/vzS/fbBIYefzW1+0B J2AQ==; 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=hSP9AiM6; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=hoVuD8RB; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=LgwCsaNF; 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=openvpn.net; dara=fail header.i=@openvpn.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 586e51a60fabf-2b28f4a6242si8478085fac.160.2025.01.28.05.18.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jan 2025 05:18:15 -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=hSP9AiM6; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=hoVuD8RB; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=LgwCsaNF; 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=openvpn.net; dara=fail header.i=@openvpn.net 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 1tclTm-0005wQ-Qc; Tue, 28 Jan 2025 13:18:10 +0000 Received: from [172.30.29.66] (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 1tclTm-0005wK-39 for openvpn-devel@lists.sourceforge.net; Tue, 28 Jan 2025 13:18:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Content-Transfer-Encoding:MIME-Version :Message-ID:Reply-To:References:Subject:List-Unsubscribe:List-Id:Cc:To:Date: From:Sender:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help: List-Subscribe:List-Post:List-Owner:List-Archive; bh=oN+rRcPR3MvQPkaUkGb77NPDGYxmJcIEz7HZJMYwF4w=; b=hSP9AiM677T4VSCUNAE2R5a8n9 VA/7pMp+C5e527VZy4ovNA01pixkJN6+HFn7DrKMsk/pyUJbAJO6V+okwAt2p64aTUV/BnNhQCHK+ SRHKSD29c1ajcKzDGE7eVNcuHCo26uknzWGm7IEUO0Xh/hoUoGHpWbxgCMhEOWv0RIbM=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Reply-To: References:Subject:List-Unsubscribe:List-Id:Cc:To:Date:From:Sender:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help:List-Subscribe:List-Post: List-Owner:List-Archive; bh=oN+rRcPR3MvQPkaUkGb77NPDGYxmJcIEz7HZJMYwF4w=; b=h oVuD8RBz2nZ4vtNHlG5iwAYFGj1CT+TJzyZ62AB1eXf4ds9IaHeV6hzuNsQ4xZIGXTpjwpDr51PVN MWAK6BSWB+gDcQ/v4Flw74xW1ONt2jbyq2g3ly8xE1auZp3+ZV0pVql7BUksgbTsBCdGZMULLfhIV 7fNtSxGHGLxGbe0U=; Received: from mail-wr1-f43.google.com ([209.85.221.43]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1tclTk-0003HI-5d for openvpn-devel@lists.sourceforge.net; Tue, 28 Jan 2025 13:18:09 +0000 Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-385eed29d17so2934911f8f.0 for ; Tue, 28 Jan 2025 05:18:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvpn.net; s=google; t=1738070276; x=1738675076; darn=lists.sourceforge.net; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:to:date:from:from:to:cc :subject:date:message-id:reply-to; bh=oN+rRcPR3MvQPkaUkGb77NPDGYxmJcIEz7HZJMYwF4w=; b=LgwCsaNFRtTC1OklvnCtYpOwmYbRzS9yxgHx+BQ7oFTxv2bk8ziMMIlkDc/O0JAUnG rG9/8dgBjrIpWPIMa4YUu8SpHXo9aTOJzGDJ/XEWWeAYC++5n1RWAMA9m8avlINmznfC NCDJtFTdD0WeXS/9tc3JpIgoDuNLBqqlLTf6Zxru+1loAB8u3HjMVJlDG6Z8a8pRmKXM QZi7oZ1d+a4E4LtnTd4VkEPC9E71QDEO0T+hYPof14DurOh539SYHeEMd0/Pim2lcWev Ps4yQqfKVan2gO2ufChCrGHtGMoBKZje8Za7dtzrdqyQuHVNbXfwjc0hR8wtLFaF+l/R t4QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738070277; x=1738675077; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:to:date:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oN+rRcPR3MvQPkaUkGb77NPDGYxmJcIEz7HZJMYwF4w=; b=uA01yoST7gE1GBm0+Zv5LuShl99EmzOxbNdnXphVdeOQPMM0ubQ4pBtWSwPWr9as+i QI657t7pVPIxOmvAZt9WqNhU0Kid+kCCfMQ7d1skDZJWoxfcP3fj8NgQ+gc2SSoebmQT YyuLl3+MC6/bQ+rMmTEPjXJTX/mYDuZdHoue8aXHXA0IN1MBNEGF08lD8Xeh92WhWveY ZPbHZsuOZy1XHNZpOn0RaB3zJd3Pf/EdKIXoRxZw8X+6o3ILS/v+KyqbEUHw7Hg121hi sWhDeYats0JwrtGXgbQIyo/OPgy4cOFLzoniVRoSOXiKDCfUiK7FgoSJwA/X/t2Iw0r7 S+ew== X-Gm-Message-State: AOJu0YzhRMw4+2iBeLK+afiXWD7U9rfMahX2YkyYVximo7GB2u1dT75f 1SR+E2TFVUHFxqcyWv39hSNdL5Ign4Txww5O6mZZSvKfKJq5wJ4+qRIXOxgy/g8= X-Gm-Gg: ASbGncsrR+EZ44rA9qkHpPSKxT1ohcTCA+TojXOEnLgsJDILwvvU0b/03G1y/oYYyA8 R+swiwXAXAsoHgzjMqG6YkQHSZCaILF7Og1tORMSBAy8DZkK1LGlRGKSszoUpPznpcq2fqPJTWI qFwXeNYtXzLlLBWLHPK3dVUyF/GTHCkJSlxN0n1gYWHnLcQszhmrIKw4cC2JQHNCsPtgmL3cw+a zVtaX3iP+F1LH2L0nJHbRVTXE3522SJFOVAKbMAoQYk6T+3zA/0QCiCwT6R0OIVKRtMxq5Hb3O1 w/LqINW0xO/q5N86HuYumvlC07LphT9plvbSUaNLMM5gZzhl9s44SBqkfuR7cqwoTIItU2E3H58 ZgWZJSbk= X-Received: by 2002:a5d:4f8f:0:b0:386:4a24:18f2 with SMTP id ffacd0b85a97d-38bf566f3d7mr34514564f8f.25.1738070276519; Tue, 28 Jan 2025 05:17:56 -0800 (PST) Received: from gerrit.openvpn.in (ec2-18-159-0-78.eu-central-1.compute.amazonaws.com. [18.159.0.78]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38c2a1885besm13883433f8f.49.2025.01.28.05.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jan 2025 05:17:56 -0800 (PST) From: "stipa (Code Review)" X-Google-Original-From: "stipa (Code Review)" X-Gerrit-PatchSet: 1 Date: Tue, 28 Jan 2025 13:17:55 +0000 To: plaisthos , flichtenheld Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange X-Gerrit-Change-Id: I58735fb24bc4a94c803b7dfcd6de87af0f75522a X-Gerrit-Change-Number: 878 X-Gerrit-Project: openvpn X-Gerrit-ChangeURL: X-Gerrit-Commit: 54c7d5f4d9f3860eb7343b59458d743767cda380 References: Message-ID: <6222a0f11e804a0dfba1dec768b2c0864dc5ea71-HTML@gerrit.openvpn.net> MIME-Version: 1.0 User-Agent: Gerrit/3.8.2 X-Spam-Score: -0.2 (/) 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: Attention is currently required from: flichtenheld, plaisthos. Hello plaisthos, flichtenheld, I'd like you to do a code review. Please visit 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.221.43 listed in list.dnswl.org] 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. [209.85.221.43 listed in sa-accredit.habeas.com] 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. [209.85.221.43 listed in bl.score.senderscore.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.221.43 listed in wl.mailspike.net] 0.0 WEIRD_PORT URI: Uses non-standard port number for HTTP 0.0 HTML_MESSAGE BODY: HTML included in message -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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_AU Message has a valid DKIM or DK signature from author's domain -0.0 T_SCC_BODY_TEXT_LINE No description available. 0.0 T_KAM_HTML_FONT_INVALID Test for Invalidly Named or Formatted Colors in HTML X-Headers-End: 1tclTk-0003HI-5d Subject: [Openvpn-devel] [S] Change in openvpn[master]: 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: , Reply-To: lstipakov@gmail.com, arne-openvpn@rfc2549.org, openvpn-devel@lists.sourceforge.net, frank@lichtenheld.com Cc: openvpn-devel Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1822498798441403420?= X-GMAIL-MSGID: =?utf-8?q?1822498798441403420?= X-getmail-filter-classifier: gerrit message type newchange Attention is currently required from: flichtenheld, plaisthos. Hello plaisthos, flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/878?usp=email to review the following change. Change subject: route.c: change the signature of get_default_gateway() ...................................................................... route.c: change the signature of get_default_gateway() 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 --- M src/openvpn/options.c M src/openvpn/route.c M src/openvpn/route.h M src/openvpn/ssl.c M src/openvpn/tun.c 5 files changed, 11 insertions(+), 10 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/78/878/1 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;