From: "cron2 (Code Review)"
Date: Wed, 29 Jan 2025 09:57:03 +0000
In-Reply-To:
References:
Reply-To: gert@...1296..., arne-openvpn@...1227...,
openvpn-devel@lists.sourceforge.net, frank@...2641...,
lstipakov@...277...
Message-ID:
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
Content-Type: multipart/alternative; boundary="PYJY7eRNsV0="; charset=UTF-8
Subject: [Openvpn-devel] [S] Change in openvpn[master]: route.c: change the
signature of get_default_gateway()
List-Id:
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
To: stipa , plaisthos , flichtenheld
Cc: openvpn-devel
--PYJY7eRNsV0=
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
cron2 has uploaded a new patch set (#2) to the change originally created by=
stipa. ( http://gerrit.openvpn.net/c/openvpn/+/878?usp=3Demail )
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
Acked-by: Gert Doering
Message-Id: <20250129095038.19056-1-gert@...1296...>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30=
685.html
Signed-off-by: Gert Doering
---
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 |=3D 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, openvp=
n_net_ctx_t *ctx)
{
struct gc_arena gc =3D 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, openvp=
n_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, openvp=
n_net_ctx_t *ctx)
{
struct gc_arena gc =3D gc_new();
int sd =3D -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, openvp=
n_net_ctx_t *ctx)
{
struct gc_arena gc =3D 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, openvp=
n_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, openvp=
n_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=3D%s\n", format_hex_ex(rgi.hwa=
ddr, 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 =3D (RGI_ADDR_DEFINED|RGI_NETMASK_DEFINED);
- get_default_gateway(&rgi, ctx);
+ get_default_gateway(&rgi, 0, ctx);
if ((rgi.flags & needed) =3D=3D needed)
{
const in_addr_t lan_network =3D rgi.gateway.addr & rgi.gateway.net=
mask;
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/878?usp=3Demail
To unsubscribe, or for help writing mail filters, visit http://gerrit.openv=
pn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I58735fb24bc4a94c803b7dfcd6de87af0f75522a
Gerrit-Change-Number: 878
Gerrit-PatchSet: 2
Gerrit-Owner: stipa
Gerrit-Reviewer: cron2
Gerrit-Reviewer: flichtenheld
Gerrit-Reviewer: plaisthos
Gerrit-CC: openvpn-devel
Gerrit-MessageType: newpatchset
--PYJY7eRNsV0=
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
cron2 uploaded patch set #2 to the change originally cr=
eated by stipa.
View Change
The following approvals got outdated and=
were removed:
Code-Review+2 by cron2
route.c: change the signature of get_default_gateway=
()
As a preparation of an upcoming refactoring of
get_default_gat=
eway(), add `dest` parameter to
specify destination address to which we =
are looking
the best route.
Change-Id: I58735fb24bc4a94c803b7dfcd=
6de87af0f75522a
Signed-off-by: Lev Stipakov <lev@...515...>
Ack=
ed-by: Gert Doering <gert@...1296...>
Message-Id: <202501290950=
38.19056-1-gert@...1296...>
URL: https://www.mail-archive.com/openvpn=
-devel@lists.sourceforge.net/msg30685.html
Signed-off-by: Gert Doering &=
lt;gert@...1296...>
---
M src/openvpn/options.c
M src/openvpn/r=
oute.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, &=
amp;net_ctx);
- =
get_default_gateway(&rgi, &net_ctx);
+ get_default_gateway(&rgi, 0, &net_=
ctx);
get_default_gateway_ipv6(&rgi6, &rem=
ote, &net_ctx);
print_default_gateway(M_INFO, =
&rgi, &rgi6);
openvpn_exit(OPENVPN_EXIT_ST=
ATUS_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/rou=
te.c
@@ -655,7 +655,7 @@
rl->sp=
ec.flags |=3D RTSA_DEFAULT_METRIC;
}
=
- get_default_gatew=
ay(&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_in=
fo *rgi, openvpn_net_ctx_t *ctx)
+get_default_gateway(struct route_gateway_info *rgi, in_addr_t =
dest, openvpn_net_ctx_t *ctx)
{
struc=
t gc_arena gc =3D gc_new();
@@ -3282,7 +3=
282,7 @@
#elif defined(TARGET_ANDROID)
=
span>
void
-g=
et_default_gateway(struct route_gateway_info *rgi, openvpn_net_ctx_t *ctx)<=
/span>
+get_default_gateway(=
struct route_gateway_info *rgi, in_addr_t dest, openvpn_net_ctx_t *ctx)
{
/* Android, set some pseudo GW, addr i=
s in host byte order,
* Determining the default GW on=
Android 5.0+ is non trivial
@@ -3323,7 +3323,7 @@ #elif defined(TARGET_LINUX)
voi=
d
-get_default_gateway(=
struct route_gateway_info *rgi, openvpn_net_ctx_t *ctx)
+get_default_gateway(struct route_gatewa=
y_info *rgi, in_addr_t dest, openvpn_net_ctx_t *ctx)
{
struct gc_arena gc =3D gc_new();
int=
sd =3D -1;
@@ -3561,7 +3561,7 @@
#define =
max(a, b) ((a) > (b) ? (a) : (b))
voi=
d
-get_default_gateway(=
struct route_gateway_info *rgi, openvpn_net_ctx_t *ctx)
+get_default_gateway(struct route_gatewa=
y_info *rgi, in_addr_t dest, openvpn_net_ctx_t *ctx)
{
struct gc_arena gc =3D gc_new();
str=
uct rtmsg m_rtmsg;
@@ -3943,7 +3943,7 @@
#=
elif defined(TARGET_HAIKU)
void-get_default_gateway(struct rou=
te_gateway_info *rgi, openvpn_net_ctx_t *ctx)
+get_default_gateway(struct route_gateway_info *rg=
i, 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 *ct=
x)
+get_default_gatew=
ay(struct route_gateway_info *rgi, in_addr_t dest, openvpn_net_ctx_t *ctx)<=
/span>
{
CLEAR(*rgi);
}
diff --git a/src/openvpn/route.h b/src/openvpn/route.h<=
br>index 69b06b8..0bbedbb 100644
--- a/src/openvpn/ro=
ute.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_defaul=
t_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);=
span>
if (rgi.flags & RGI_HWADDR_DEFINED)<=
br> {
buf_printf(&ou=
t, "IV_HWADDR=3D%s\n", format_hex_ex(rgi.hwaddr, 6, 0, 1, ":=
", &gc));
diff --git a/src/openvpn/tun.c b/src/ope=
nvpn/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;<=
/span>
const unsigned int needed =3D (RGI_ADDR_DEFINED|RGI_NE=
TMASK_DEFINED);
- get_default_gateway(&rgi, ctx);
+ get_default_gateway(&rgi, 0, ctx)=
;
if ((rgi.flags & needed) =3D=3D needed) {
const in_addr_t lan_network =3D rgi=
.gateway.addr & rgi.gateway.netmask;
<=
p>To view, visit change 878. To unsubscribe, or for help writing mail filters,=
visit settings.
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I58735fb24bc4a94c803b7dfcd6d=
e87af0f75522a
Gerrit-Change-Number: 878
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <lstipakov@...277...>=
;
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...=
1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...=
.1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...=
ts.sourceforge.net>
Gerrit-MessageType: newpatchset
--PYJY7eRNsV0=--