From: "plaisthos (Code Review)"
Date: Mon, 6 Oct 2025 13:22:11 +0000
In-Reply-To:
References:
Reply-To: arne-openvpn@...1227..., heiko@...515...,
openvpn-devel@lists.sourceforge.net, frank@...2641...,
antonio@...2726...
Message-ID: <35557b67bb72d1502cd87a8cbc12568d7543ed5a-EmailReplacePatchSet-HTML@...2715...>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
Content-Type: multipart/alternative; boundary="+whD+dIsi9o="; charset=UTF-8
Subject: [Openvpn-devel] [S] Change in openvpn[master]: Allow
route_ipv6_match_host to be used outside of route.c
List-Id:
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
To: flichtenheld , d12fk
Cc: openvpn-devel
--+whD+dIsi9o=
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Attention is currently required from: d12fk, flichtenheld, ordex.
Hello d12fk, flichtenheld, ordex,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1191?usp=3Demail
to look at the new patch set (#5).
The following approvals got outdated and were removed:
Code-Review+1 by d12fk
Change subject: Allow route_ipv6_match_host to be used outside of route.c
......................................................................
Allow route_ipv6_match_host to be used outside of route.c
Also adjust style a bit to C99
Change-Id: Ief1495b52ea81cac35d78e40264372d3869423f1
Signed-off-by: Arne Schwabe
---
M src/openvpn/route.c
M src/openvpn/route.h
2 files changed, 23 insertions(+), 14 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/91/1191/5
diff --git a/src/openvpn/route.c b/src/openvpn/route.c
index 05a0c8f..0044794 100644
--- a/src/openvpn/route.c
+++ b/src/openvpn/route.c
@@ -710,25 +710,20 @@
return ret;
}
-/* check whether an IPv6 host address is covered by a given route_ipv6
- * (not the most beautiful implementation in the world, but portable and
- * "good enough")
- */
-static bool
-route_ipv6_match_host(const struct route_ipv6 *r6, const struct in6_addr *=
host)
+bool
+ipv6_net_contains_host(const struct in6_addr *network, unsigned int bits, =
const struct in6_addr *host)
{
- unsigned int bits =3D r6->netbits;
- int i;
- unsigned int mask;
-
+ /* not the most beautiful implementation in the world, but portable and
+ * "good enough" */
if (bits > 128)
{
return false;
}
+ int i;
for (i =3D 0; bits >=3D 8; i++, bits -=3D 8)
{
- if (r6->network.s6_addr[i] !=3D host->s6_addr[i])
+ if (network->s6_addr[i] !=3D host->s6_addr[i])
{
return false;
}
@@ -739,9 +734,9 @@
return true;
}
- mask =3D 0xff << (8 - bits);
+ unsigned int mask =3D 0xff << (8 - bits);
- if ((r6->network.s6_addr[i] & mask) =3D=3D (host->s6_addr[i] & mask))
+ if ((network->s6_addr[i] & mask) =3D=3D (host->s6_addr[i] & mask))
{
return true;
}
@@ -830,7 +825,8 @@
* avoiding routing loops, so ignore this part and let
* need_remote_ipv6_route always evaluate to false
*/
- if (remote_host_ipv6 && route_ipv6_match_host(r6, remote_h=
ost_ipv6))
+ if (remote_host_ipv6
+ && ipv6_net_contains_host(&r6->network, r6->netbits, r=
emote_host_ipv6))
{
need_remote_ipv6_route =3D true;
msg(D_ROUTE,
diff --git a/src/openvpn/route.h b/src/openvpn/route.h
index c5006ae..54fa137 100644
--- a/src/openvpn/route.h
+++ b/src/openvpn/route.h
@@ -426,4 +426,17 @@
return rl && BOOL_CAST(rl->iflags & RL_DID_REDIRECT_DEFAULT_GATEWAY);
}
+
+/**
+ * check whether an IPv6 host address is covered by a given network/bits
+ * @param network the network address
+ * @param bits the network mask
+ * @param host the host address to be checked if it is contained by the ne=
twork
+ *
+ * @return true if the host address is covered by the network with the giv=
en
+ * network mask by bits
+ */
+bool
+ipv6_net_contains_host(const struct in6_addr *network, unsigned int bits, =
const struct in6_addr *host);
+
#endif /* ifndef ROUTE_H */
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1191?usp=3Demail
To unsubscribe, or for help writing mail filters, visit http://gerrit.openv=
pn.net/settings?usp=3Demail
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ief1495b52ea81cac35d78e40264372d3869423f1
Gerrit-Change-Number: 1191
Gerrit-PatchSet: 5
Gerrit-Owner: plaisthos
Gerrit-Reviewer: d12fk
Gerrit-Reviewer: flichtenheld
Gerrit-Reviewer: ordex
Gerrit-CC: openvpn-devel
Gerrit-Attention: flichtenheld
Gerrit-Attention: ordex
Gerrit-Attention: d12fk
--+whD+dIsi9o=
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Attention is cur=
rently required from: d12fk, flichtenheld, ordex.
plaisthos uploaded patch set #5 to this change.
<=
a href=3D"http://gerrit.openvpn.net/c/openvpn/+/1191?usp=3Demail">View Chan=
ge
The following approvals got outdated and were removed:
Code-Review+1 by d12fk
Allow route_ipv6_match_host to be u=
sed outside of route.c
Also adjust style a bit to C99
Change-=
Id: Ief1495b52ea81cac35d78e40264372d3869423f1
Signed-off-by: Arne Schwab=
e <arne@...1227...>
---
M src/openvpn/route.c
M src/openvpn/=
route.h
2 files changed, 23 insertions(+), 14 deletions(-)
=
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/=
91/1191/5
diff --git a/src/openvpn/route.c b/src/openvpn/route.c
index 05a0c8f..0044794 100644
--- a/src/openv=
pn/route.c
+++ b/src/openvpn/route.c
@@ -71=
0,25 +710,20 @@
return ret;
}<=
br>
-/* check wh=
ether an IPv6 host address is covered by a given route_ipv6
- * (not the most beautiful implementa=
tion in the world, but portable and
- * "good enough")
- */
-static bool
-route_ip=
v6_match_host(const struct route_ipv6 *r6, const struct in6_addr *host)
+bool
+ipv6_net_contains_host(const struct in=
6_addr *network, unsigned int bits, const struct in6_addr *host)
=
{
- unsigned =
int bits =3D r6->netbits;
- int i;
- =
unsigned int mask;
-
+ /* not the most be=
autiful implementation in the world, but portable and
+ * "good enough" */<=
br> if (bits > 128)
{
=
return false;
}
+ int i;
fo=
r (i =3D 0; bits >=3D 8; i++, bits -=3D 8)
{=
- if (r6->network.s=
6_addr[i] !=3D host->s6_addr[i])
+ if (network->s6_addr[i] !=3D host->s6_addr[i]=
)
{
return false;
}
@@ -739,9 +734,9 @@
return true;
}
<=
span style=3D"color: hsl(0, 100%, 40%);">- mask =3D 0xff << (8 - b=
its);
+ unsigned i=
nt mask =3D 0xff << (8 - bits);
- if ((r6->network.s6_addr[i] & =
mask) =3D=3D (host->s6_addr[i] & mask))
+ if ((network->s6_addr[i] & mask) =3D=
=3D (host->s6_addr[i] & mask))
{
return true;
}
@@ -830,7 +8=
25,8 @@
* avoiding routing loops, so igno=
re this part and let
* need_remote_ipv6_r=
oute always evaluate to false
*/- if (remote_hos=
t_ipv6 && route_ipv6_match_host(r6, remote_host_ipv6))
+ if (remote_host_=
ipv6
+ =
&& ipv6_net_contains_host(&r6->network, r6->netbits,=
remote_host_ipv6))
{
=
need_remote_ipv6_route =3D true;
=
msg(D_ROUTE,
diff --git a/src/openvpn/route.h b=
/src/openvpn/route.h
index c5006ae..54fa137 100644--- a/src/openvpn/route.h
+++ b/src/openvpn/route.h=
@@ -426,4 +426,17 @@
return rl &&=
amp; BOOL_CAST(rl->iflags & RL_DID_REDIRECT_DEFAULT_GATEWAY);=
}
+
+/**
+ * check whether an IPv6=
host address is covered by a given network/bits
+ * @param network the network address+ * @param bits the network m=
ask
+ * @param host t=
he host address to be checked if it is contained by the network
<=
span style=3D"color: hsl(120, 100%, 40%);">+ *
+ * @return true if the host address is covered b=
y the network with the given
+ * network mask by bits
+ */
+bool
+ipv6_net_c=
ontains_host(const struct in6_addr *network, unsigned int bits, const struc=
t in6_addr *host);
+<=
/span>
#endif /* ifndef ROUTE_H */
To view, visit change 1191. To unsubscribe, or for help writing mail filt=
ers, visit setti=
ngs.
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ief1495b52ea81cac35d78e40264=
372d3869423f1
Gerrit-Change-Number: 1191
Gerrit-PatchSet: 5
Gerrit-Owner: plaisthos <arne-openvpn@...1711...=
27...>
Gerrit-Reviewer: d12fk <heiko@...515...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...=
1...>
Gerrit-Reviewer: ordex <antonio@...2726...&=
gt;
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...=
ts.sourceforge.net>
Gerrit-Attention: flichtenheld <frank@...2375...=
41...>
Gerrit-Attention: ordex <antonio@...2726...=
>
Gerrit-Attention: d12fk <heiko@...515...>=
;
=
--+whD+dIsi9o=--