All of lore.kernel.org
 help / color / mirror / Atom feed
* [Openvpn-devel] [S] Change in openvpn[master]: route.c: change the signature of get_default_gateway()
       [not found] <gerrit.1738070271000.I58735fb24bc4a94c803b7dfcd6de87af0f75522a@...2715...>
@ 2025-01-28 13:17 ` stipa (Code Review)
  2025-01-28 13:55 ` cron2 (Code Review)
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: stipa (Code Review) @ 2025-01-28 13:17 UTC (permalink / raw)
  To: plaisthos <arne-openvpn@; +Cc: openvpn-devel

[-- Attachment #1: Type: text/plain, Size: 5870 bytes --]

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 <lev@...515...>
---
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;

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/878?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I58735fb24bc4a94c803b7dfcd6de87af0f75522a
Gerrit-Change-Number: 878
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <lstipakov@...277...>
Gerrit-Reviewer: flichtenheld <frank@...2641...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...1227...>
Gerrit-Attention: flichtenheld <frank@...2641...>
Gerrit-MessageType: newchange

[-- Attachment #2: Type: text/html, Size: 9466 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Openvpn-devel] [S] Change in openvpn[master]: route.c: change the signature of get_default_gateway()
       [not found] <gerrit.1738070271000.I58735fb24bc4a94c803b7dfcd6de87af0f75522a@...2715...>
  2025-01-28 13:17 ` [Openvpn-devel] [S] Change in openvpn[master]: route.c: change the signature of get_default_gateway() stipa (Code Review)
@ 2025-01-28 13:55 ` cron2 (Code Review)
  2025-01-29  9:50 ` [Openvpn-devel] [PATCH v1] " Gert Doering
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: cron2 (Code Review) @ 2025-01-28 13:55 UTC (permalink / raw)
  To: stipa <lstipakov@; +Cc: plaisthos <arne-openvpn@

[-- Attachment #1: Type: text/plain, Size: 1213 bytes --]

Attention is currently required from: flichtenheld, plaisthos, stipa.

cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/878?usp=email )

Change subject: route.c: change the signature of get_default_gateway()
......................................................................


Patch Set 1: Code-Review+2


--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/878?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I58735fb24bc4a94c803b7dfcd6de87af0f75522a
Gerrit-Change-Number: 878
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <lstipakov@...277...>
Gerrit-Reviewer: cron2 <gert@...1296...>
Gerrit-Reviewer: flichtenheld <frank@...2641...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...1227...>
Gerrit-Attention: flichtenheld <frank@...2641...>
Gerrit-Attention: stipa <lstipakov@...277...>
Gerrit-Comment-Date: Tue, 28 Jan 2025 13:55:23 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

[-- Attachment #2: Type: text/html, Size: 2204 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Openvpn-devel] [PATCH v1] route.c: change the signature of get_default_gateway()
       [not found] <gerrit.1738070271000.I58735fb24bc4a94c803b7dfcd6de87af0f75522a@...2715...>
  2025-01-28 13:17 ` [Openvpn-devel] [S] Change in openvpn[master]: route.c: change the signature of get_default_gateway() stipa (Code Review)
  2025-01-28 13:55 ` cron2 (Code Review)
@ 2025-01-29  9:50 ` Gert Doering
  2025-01-29  9:56   ` [Openvpn-devel] [PATCH applied] " Gert Doering
  2025-01-29  9:57 ` [Openvpn-devel] [S] Change in openvpn[master]: " cron2 (Code Review)
  2025-01-29  9:57 ` cron2 (Code Review)
  4 siblings, 1 reply; 6+ messages in thread
From: Gert Doering @ 2025-01-29  9:50 UTC (permalink / raw)
  To: openvpn-devel

From: Lev Stipakov <lev@...515...>

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 <lev@...515...>
Acked-by: Gert Doering <gert@...1296...>
---

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 <gert@...1296...>

        
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;


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Openvpn-devel] [PATCH applied] Re: route.c: change the signature of get_default_gateway()
  2025-01-29  9:50 ` [Openvpn-devel] [PATCH v1] " Gert Doering
@ 2025-01-29  9:56   ` Gert Doering
  0 siblings, 0 replies; 6+ messages in thread
From: Gert Doering @ 2025-01-29  9:56 UTC (permalink / raw)
  To: Lev Stipakov <lev@; +Cc: openvpn-devel

As discusssed on IRC, this is the first patch of a series to improve
the IPv4 gateway lookup, aka, "make it as good as the IPv6 implementation".

The problem today is that the IPv4 code only looks for "the default route",
which is not the right answer for "which route and interface is used to
reach the VPN server?" in case of more-specific routes - arguably not the
most common case, but if we can get it right, we should.

This patch does not change anything but add an (unused) "in_addr_t host"
argument to all the get_default_gateway() calls & implementations.  Further
patches will enhance the per-platform implementations to use this info
(if possible).

So the thing to test here is "was any of our platforms overlooked, and
compilation fails" - and the anwswer is "it compiles, ship it!" ;-)

Your patch has been applied to the master branch.

commit 0fcfc8381f60d9f7b4a53afaea223dfee5e18835
Author: Lev Stipakov
Date:   Wed Jan 29 10:50:38 2025 +0100

     route.c: change the signature of get_default_gateway()

     Signed-off-by: Lev Stipakov <lev@...515...>
     Acked-by: Gert Doering <gert@...1296...>
     Message-Id: <20250129095038.19056-1-gert@...1296...>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30685.html
     Signed-off-by: Gert Doering <gert@...1296...>


--
kind regards,

Gert Doering



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Openvpn-devel] [S] Change in openvpn[master]: route.c: change the signature of get_default_gateway()
       [not found] <gerrit.1738070271000.I58735fb24bc4a94c803b7dfcd6de87af0f75522a@...2715...>
                   ` (2 preceding siblings ...)
  2025-01-29  9:50 ` [Openvpn-devel] [PATCH v1] " Gert Doering
@ 2025-01-29  9:57 ` cron2 (Code Review)
  2025-01-29  9:57 ` cron2 (Code Review)
  4 siblings, 0 replies; 6+ messages in thread
From: cron2 (Code Review) @ 2025-01-29  9:57 UTC (permalink / raw)
  To: stipa <lstipakov@; +Cc: openvpn-devel

[-- Attachment #1: Type: text/plain, Size: 6013 bytes --]

cron2 has uploaded a new patch set (#2) to the change originally created by stipa. ( http://gerrit.openvpn.net/c/openvpn/+/878?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2


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 <lev@...515...>
Acked-by: Gert Doering <gert@...1296...>
Message-Id: <20250129095038.19056-1-gert@...1296...>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30685.html
Signed-off-by: Gert Doering <gert@...1296...>
---
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/2

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 12d6c07..3501e35 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 69b06b8..0bbedbb 100644
--- a/src/openvpn/route.h
+++ b/src/openvpn/route.h
@@ -335,6 +335,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;

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/878?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I58735fb24bc4a94c803b7dfcd6de87af0f75522a
Gerrit-Change-Number: 878
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <lstipakov@...277...>
Gerrit-Reviewer: cron2 <gert@...1296...>
Gerrit-Reviewer: flichtenheld <frank@...2641...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net>
Gerrit-MessageType: newpatchset

[-- Attachment #2: Type: text/html, Size: 9619 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Openvpn-devel] [S] Change in openvpn[master]: route.c: change the signature of get_default_gateway()
       [not found] <gerrit.1738070271000.I58735fb24bc4a94c803b7dfcd6de87af0f75522a@...2715...>
                   ` (3 preceding siblings ...)
  2025-01-29  9:57 ` [Openvpn-devel] [S] Change in openvpn[master]: " cron2 (Code Review)
@ 2025-01-29  9:57 ` cron2 (Code Review)
  4 siblings, 0 replies; 6+ messages in thread
From: cron2 (Code Review) @ 2025-01-29  9:57 UTC (permalink / raw)
  To: stipa <lstipakov@; +Cc: plaisthos <arne-openvpn@

[-- Attachment #1: Type: text/plain, Size: 5803 bytes --]

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/878?usp=email )

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 <lev@...515...>
Acked-by: Gert Doering <gert@...1296...>
Message-Id: <20250129095038.19056-1-gert@...1296...>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30685.html
Signed-off-by: Gert Doering <gert@...1296...>
---
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(-)




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 12d6c07..3501e35 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 69b06b8..0bbedbb 100644
--- a/src/openvpn/route.h
+++ b/src/openvpn/route.h
@@ -335,6 +335,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;

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/878?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I58735fb24bc4a94c803b7dfcd6de87af0f75522a
Gerrit-Change-Number: 878
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <lstipakov@...277...>
Gerrit-Reviewer: cron2 <gert@...1296...>
Gerrit-Reviewer: flichtenheld <frank@...2641...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@lists.sourceforge.net>
Gerrit-MessageType: merged

[-- Attachment #2: Type: text/html, Size: 9384 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-01-29  9:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <gerrit.1738070271000.I58735fb24bc4a94c803b7dfcd6de87af0f75522a@...2715...>
2025-01-28 13:17 ` [Openvpn-devel] [S] Change in openvpn[master]: route.c: change the signature of get_default_gateway() stipa (Code Review)
2025-01-28 13:55 ` cron2 (Code Review)
2025-01-29  9:50 ` [Openvpn-devel] [PATCH v1] " Gert Doering
2025-01-29  9:56   ` [Openvpn-devel] [PATCH applied] " Gert Doering
2025-01-29  9:57 ` [Openvpn-devel] [S] Change in openvpn[master]: " cron2 (Code Review)
2025-01-29  9:57 ` cron2 (Code Review)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.