Skip to contentSkip to conversation

Change in openvpn[master]: Route: remove uncorrect routes on exit.

Openvpn-devel In review its_Giaan (Code Review) 3 participants 9 messages Feb 15, 2024 – Sep 17, 2024 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1707986932000.I8a67b82eb4afdc8d82c5a879c18457b41e77cbe7@...2715...

#1 lore raw

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/+/522?usp=email

to review the following change.

Change subject: Route: remove uncorrect routes on exit.
......................................................................

Route: remove uncorrect routes on exit.

Implemented a safeguard to verify the returned value from add_route3() when the default gateway is not a local remote host.

Prior to this implementation, RT_DID_LOCAL flag was erroneously set even in case of add_route3() failure. This problem typically occurs when there's no default route and the --redirect-gateway def1 option is specified, and in case of reconnection makes it impossible for the client to reobtain the route to the server.
This fix ensures OpenVPN accurately deletes the appropriate route on exit by properly handling add_route3() return value.

Fixes Trac #1457
Change-Id I8a67b82eb4afdc8d82c5a879c18457b41e77cbe7

---
M src/openvpn/route.c

1 file changed, 4 insertions(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/22/522/1

src/openvpn/route.c +4 -1
index 6c027d9..6ab4392 100644
@@ -1055,7 +1055,10 @@
                     ret = add_route3(rl->spec.remote_host, IPV4_NETMASK_HOST,
                                      rl->rgi.gateway.addr, tt, flags | ROUTE_REF_GW,
                                      &rl->rgi, es, ctx);
-                    rl->iflags |= RL_DID_LOCAL;
+                    if (ret)
+                    {
+                        rl->iflags |= RL_DID_LOCAL;
+                    }
                 }
                 else
                 {

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/522?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: I8a67b82eb4afdc8d82c5a879c18457b41e77cbe7
Gerrit-Change-Number: 522
Gerrit-PatchSet: 1
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: its_Giaan, plaisthos.

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

Change subject: Route: remove uncorrect routes on exit.
......................................................................

Patch Set 1: Code-Review+2

(1 comment)

Commit Message:

http://gerrit.openvpn.net/c/openvpn/+/522/comment/1ee852a4_4c084f6c :
PS1, Line 7: Route: remove uncorrect routes on exit. "incorrect"
remove full stop at end of summary line

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/522?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: I8a67b82eb4afdc8d82c5a879c18457b41e77cbe7
Gerrit-Change-Number: 522
Gerrit-PatchSet: 1
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Comment-Date: Fri, 16 Feb 2024 15:32:14 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#3 lore raw

[Openvpn-devel] [XS] Change in openvpn[master]: Route: remove incorrect routes on exit

In reply to a message not in the archive

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

Hello flichtenheld, plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/522?usp=email

to look at the new patch set (#2).

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

The change is no longer submittable: Code-Review and checks~ChecksSubmitRule are unsatisfied now.

Change subject: Route: remove incorrect routes on exit
......................................................................

Route: remove incorrect routes on exit

Implemented a safeguard to verify the returned value from add_route3() when the default gateway is not a local remote host.

Prior to this implementation, RT_DID_LOCAL flag was erroneously set even in case of add_route3() failure. This problem typically occurs when there's no default route and the --redirect-gateway def1 option is specified, and in case of reconnection makes it impossible for the client to reobtain the route to the server.
This fix ensures OpenVPN accurately deletes the appropriate route on exit by properly handling add_route3() return value.

Fixes Trac #1457
Change-Id I8a67b82eb4afdc8d82c5a879c18457b41e77cbe7

---
M src/openvpn/route.c

1 file changed, 4 insertions(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/22/522/2

src/openvpn/route.c +4 -1
index 6c027d9..6ab4392 100644
@@ -1055,7 +1055,10 @@
                     ret = add_route3(rl->spec.remote_host, IPV4_NETMASK_HOST,
                                      rl->rgi.gateway.addr, tt, flags | ROUTE_REF_GW,
                                      &rl->rgi, es, ctx);
-                    rl->iflags |= RL_DID_LOCAL;
+                    if (ret)
+                    {
+                        rl->iflags |= RL_DID_LOCAL;
+                    }
                 }
                 else
                 {

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/522?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: I8a67b82eb4afdc8d82c5a879c18457b41e77cbe7
Gerrit-Change-Number: 522
Gerrit-PatchSet: 2
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset

#4 lore raw

[Openvpn-devel] [XS] Change in openvpn[master]: Route: remove incorrect routes on exit

In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

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

Change subject: Route: remove incorrect routes on exit
......................................................................

Patch Set 2:

(1 comment)

Commit Message:

http://gerrit.openvpn.net/c/openvpn/+/522/comment/acf3689c_dd1d77a7 :
PS1, Line 7: Route: remove uncorrect routes on exit.

Quoted 1 line

"incorrect" […]

Done

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/522?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: I8a67b82eb4afdc8d82c5a879c18457b41e77cbe7
Gerrit-Change-Number: 522
Gerrit-PatchSet: 2
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Tue, 20 Feb 2024 09:20:46 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>
Gerrit-MessageType: comment

#5 lore raw

[Openvpn-devel] [XS] Change in openvpn[master]: Route: remove incorrect routes on exit

In reply to a message not in the archive

Attention is currently required from: its_Giaan, plaisthos.

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

Change subject: Route: remove incorrect routes on exit
......................................................................

Patch Set 2: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/522?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: I8a67b82eb4afdc8d82c5a879c18457b41e77cbe7
Gerrit-Change-Number: 522
Gerrit-PatchSet: 2
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Comment-Date: Tue, 20 Feb 2024 13:32:23 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#6 lore raw

PATCH v2 1/1 Route: remove incorrect routes on exit

In reply to a message not in the archive

From: Gianmarco De Gregori <[email protected]...>

Implemented a safeguard to verify the returned value from add_route3() when the default gateway is not a local remote host.

Prior to this implementation, RT_DID_LOCAL flag was erroneously set even in case of add_route3() failure. This problem typically occurs when there's no default route and the --redirect-gateway def1 option is specified, and in case of reconnection makes it impossible for the client to reobtain the route to the server.
This fix ensures OpenVPN accurately deletes the appropriate route on exit by properly handling add_route3() return value.

Fixes Trac #1457
Change-Id I8a67b82eb4afdc8d82c5a879c18457b41e77cbe7

---

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/+/522
This mail reflects revision 2 of this Change. Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <[email protected]...>

src/openvpn/route.c +4 -1
index 6c027d9..6ab4392 100644
@@ -1055,7 +1055,10 @@
                     ret = add_route3(rl->spec.remote_host, IPV4_NETMASK_HOST,
                                      rl->rgi.gateway.addr, tt, flags | ROUTE_REF_GW,
                                      &rl->rgi, es, ctx);
-                    rl->iflags |= RL_DID_LOCAL;
+                    if (ret)
+                    {
+                        rl->iflags |= RL_DID_LOCAL;
+                    }
                 }
                 else
                 {
#7 lore raw

[Openvpn-devel] [PATCH applied] Re: Route: remove incorrect routes on exit

This is a good find, and a somewhat stupid oversight - even if not easy to trigger. What you need so this has an effect is a pre-existing host route to the VPN server and then a "route add" fail (easy to trigger on the BSDs, EEXIST because "only 1 route can exist") - and because we do not remember, we try "route delete" later on and delete the *other* route, messing up our routing table. Which is something t_client even checks for ("is 'route print' the same as before?") but you need a host route to begin with - added t_client tests, breaks without the patch, works with the patch. Thanks :-)

I've changed the commit message slightly ("Trac: #1457" is the standard format).

Your patch has been applied to the master and release/2.6 branch (bugfix).

commit 14d2db6cd41fb6414992869caf109972d7a8275e (master) commit 4ad3aa5a2b6838650ca98fd92994eab7108c1e8b (release/2.6)

Author: Gianmarco De Gregori
Date:   Wed Feb 21 12:18:14 2024 +0100
     Route: remove incorrect routes on exit

     Signed-off-by: Gianmarco De Gregori <[email protected]...>
     Acked-by: Frank Lichtenheld <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg28290.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#8 lore raw

[Openvpn-devel] [XS] Change in openvpn[master]: Route: remove incorrect routes on exit

In reply to a message not in the archive

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

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

Change subject: Route: remove incorrect routes on exit
......................................................................

Route: remove incorrect routes on exit

Implemented a safeguard to verify the returned value from add_route3() when the default gateway is not a local remote host.

Prior to this implementation, RT_DID_LOCAL flag was erroneously set even in case of add_route3() failure. This problem typically occurs when there's no default route and the --redirect-gateway def1 option is specified, and in case of reconnection makes it impossible for the client to reobtain the route to the server.
This fix ensures OpenVPN accurately deletes the appropriate route on exit by properly handling add_route3() return value.

Trac: #1457

Change-Id I8a67b82eb4afdc8d82c5a879c18457b41e77cbe7

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg28290.html

---
M src/openvpn/route.c

1 file changed, 4 insertions(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/22/522/3

src/openvpn/route.c +4 -1
index 91f2032..2e584c7 100644
@@ -1060,7 +1060,10 @@
                     ret = add_route3(rl->spec.remote_host, IPV4_NETMASK_HOST,
                                      rl->rgi.gateway.addr, tt, flags | ROUTE_REF_GW,
                                      &rl->rgi, es, ctx);
-                    rl->iflags |= RL_DID_LOCAL;
+                    if (ret)
+                    {
+                        rl->iflags |= RL_DID_LOCAL;
+                    }
                 }
                 else
                 {

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/522?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: I8a67b82eb4afdc8d82c5a879c18457b41e77cbe7
Gerrit-Change-Number: 522
Gerrit-PatchSet: 3
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset

#9 lore raw

[Openvpn-devel] [XS] Change in openvpn[master]: Route: remove incorrect routes on exit

In reply to a message not in the archive

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

Change subject: Route: remove incorrect routes on exit
......................................................................

Route: remove incorrect routes on exit

Implemented a safeguard to verify the returned value from add_route3() when the default gateway is not a local remote host.

Prior to this implementation, RT_DID_LOCAL flag was erroneously set even in case of add_route3() failure. This problem typically occurs when there's no default route and the --redirect-gateway def1 option is specified, and in case of reconnection makes it impossible for the client to reobtain the route to the server.
This fix ensures OpenVPN accurately deletes the appropriate route on exit by properly handling add_route3() return value.

Trac: #1457

Change-Id I8a67b82eb4afdc8d82c5a879c18457b41e77cbe7

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg28290.html

---
M src/openvpn/route.c

1 file changed, 4 insertions(+), 1 deletion(-)
src/openvpn/route.c +4 -1
index 91f2032..2e584c7 100644
@@ -1060,7 +1060,10 @@
                     ret = add_route3(rl->spec.remote_host, IPV4_NETMASK_HOST,
                                      rl->rgi.gateway.addr, tt, flags | ROUTE_REF_GW,
                                      &rl->rgi, es, ctx);
-                    rl->iflags |= RL_DID_LOCAL;
+                    if (ret)
+                    {
+                        rl->iflags |= RL_DID_LOCAL;
+                    }
                 }
                 else
                 {

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/522?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: I8a67b82eb4afdc8d82c5a879c18457b41e77cbe7
Gerrit-Change-Number: 522
Gerrit-PatchSet: 3
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged