[Openvpn-devel] Remove workaround for Android 4.4

Message ID 20220504111802.1050648-1-arne@rfc2549.org
State Accepted
Headers show
Series [Openvpn-devel] Remove workaround for Android 4.4 | expand

Commit Message

Arne Schwabe May 4, 2022, 1:18 a.m. UTC
Android 4.4 is now 9 years old and the main user of this API (OpenVPN
for Android) does not support this OS anymore. This workaround
is now safe to remove.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
---
 src/openvpn/manage.c | 6 +-----
 src/openvpn/manage.h | 3 +--
 src/openvpn/tun.c    | 9 +--------
 3 files changed, 3 insertions(+), 15 deletions(-)

Comments

Gert Doering May 5, 2022, 4:09 a.m. UTC | #1
Acked-by: Gert Doering <gert@greenie.muc.de>

I have not actually investigated this in more detail - but this is 
something the Android GUI controls, so if you say "it will never send
this message anymore" we can remove the code from openvpn core.

I did wonder (on IRC) if we can get rid of ANDROID_OPEN_BEFORE_CLOSE at
the same time - but looking more close, I see that we still have two
variants, ANDROID_KEEP_OLD_TUN and ANDROID_OPEN_BEFORE_CLOSE.  So, yes, 
as long as the GUI can send both, we need both in the core...

Your patch has been applied to the master branch.

commit 44517fd7694012502318975173b1d0c05045d388
Author: Arne Schwabe
Date:   Wed May 4 13:18:02 2022 +0200

     Remove workaround for Android 4.4

     Signed-off-by: Arne Schwabe <arne@rfc2549.org>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Message-Id: <20220504111802.1050648-1-arne@rfc2549.org>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24276.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering
Penn Thitsar May 5, 2022, 4:19 a.m. UTC | #2
Re: Remove workaround for Android 4.4

On Thu, 5 May 2022, 21:11 Gert Doering, <gert@greenie.muc.de> wrote:

> Acked-by: Gert Doering <gert@greenie.muc.de>
>
> I have not actually investigated this in more detail - but this is
> something the Android GUI controls, so if you say "it will never send
> this message anymore" we can remove the code from openvpn core.
>
> I did wonder (on IRC) if we can get rid of ANDROID_OPEN_BEFORE_CLOSE at
> the same time - but looking more close, I see that we still have two
> variants, ANDROID_KEEP_OLD_TUN and ANDROID_OPEN_BEFORE_CLOSE.  So, yes,
> as long as the GUI can send both, we need both in the core...
>
> Your patch has been applied to the master branch.
>
> commit 44517fd7694012502318975173b1d0c05045d388
> Author: Arne Schwabe
> Date:   Wed May 4 13:18:02 2022 +0200
>
>      Remove workaround for Android 4.4
>
>      Signed-off-by: Arne Schwabe <arne@rfc2549.org>
>      Acked-by: Gert Doering <gert@greenie.muc.de>
>      Message-Id: <20220504111802.1050648-1-arne@rfc2549.org>
>      URL:
> https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24276.html
>      Signed-off-by: Gert Doering <gert@greenie.muc.de>
>
>
> --
> kind regards,
>
> Gert Doering
>
>
>
> _______________________________________________
> Openvpn-devel mailing list
> Openvpn-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openvpn-devel
>
<div dir="auto">Re: Remove workaround for Android 4.4</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 5 May 2022, 21:11 Gert Doering, &lt;<a href="mailto:gert@greenie.muc.de">gert@greenie.muc.de</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Acked-by: Gert Doering &lt;<a href="mailto:gert@greenie.muc.de" target="_blank" rel="noreferrer">gert@greenie.muc.de</a>&gt;<br>
<br>
I have not actually investigated this in more detail - but this is <br>
something the Android GUI controls, so if you say &quot;it will never send<br>
this message anymore&quot; we can remove the code from openvpn core.<br>
<br>
I did wonder (on IRC) if we can get rid of ANDROID_OPEN_BEFORE_CLOSE at<br>
the same time - but looking more close, I see that we still have two<br>
variants, ANDROID_KEEP_OLD_TUN and ANDROID_OPEN_BEFORE_CLOSE.  So, yes, <br>
as long as the GUI can send both, we need both in the core...<br>
<br>
Your patch has been applied to the master branch.<br>
<br>
commit 44517fd7694012502318975173b1d0c05045d388<br>
Author: Arne Schwabe<br>
Date:   Wed May 4 13:18:02 2022 +0200<br>
<br>
     Remove workaround for Android 4.4<br>
<br>
     Signed-off-by: Arne Schwabe &lt;<a href="mailto:arne@rfc2549.org" target="_blank" rel="noreferrer">arne@rfc2549.org</a>&gt;<br>
     Acked-by: Gert Doering &lt;<a href="mailto:gert@greenie.muc.de" target="_blank" rel="noreferrer">gert@greenie.muc.de</a>&gt;<br>
     Message-Id: &lt;<a href="mailto:20220504111802.1050648-1-arne@rfc2549.org" target="_blank" rel="noreferrer">20220504111802.1050648-1-arne@rfc2549.org</a>&gt;<br>
     URL: <a href="https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24276.html" rel="noreferrer noreferrer" target="_blank">https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24276.html</a><br>
     Signed-off-by: Gert Doering &lt;<a href="mailto:gert@greenie.muc.de" target="_blank" rel="noreferrer">gert@greenie.muc.de</a>&gt;<br>
<br>
<br>
--<br>
kind regards,<br>
<br>
Gert Doering<br>
<br>
<br>
<br>
_______________________________________________<br>
Openvpn-devel mailing list<br>
<a href="mailto:Openvpn-devel@lists.sourceforge.net" target="_blank" rel="noreferrer">Openvpn-devel@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/openvpn-devel" rel="noreferrer noreferrer" target="_blank">https://lists.sourceforge.net/lists/listinfo/openvpn-devel</a><br>
</blockquote></div>

Patch

diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c
index 1f408f0b..6e27d14e 100644
--- a/src/openvpn/manage.c
+++ b/src/openvpn/manage.c
@@ -2140,10 +2140,6 @@  managment_android_persisttun_action(struct management *man)
     {
         return ANDROID_KEEP_OLD_TUN;
     }
-    else if (!strcmp("OPEN_AFTER_CLOSE", up.password))
-    {
-        return ANDROID_OPEN_AFTER_CLOSE;
-    }
     else if (!strcmp("OPEN_BEFORE_CLOSE", up.password))
     {
         return ANDROID_OPEN_BEFORE_CLOSE;
@@ -2154,7 +2150,7 @@  managment_android_persisttun_action(struct management *man)
     }
 
     ASSERT(0);
-    return ANDROID_OPEN_AFTER_CLOSE;
+    return ANDROID_OPEN_BEFORE_CLOSE;
 }
 
 
diff --git a/src/openvpn/manage.h b/src/openvpn/manage.h
index 9621f479..2e497d67 100644
--- a/src/openvpn/manage.h
+++ b/src/openvpn/manage.h
@@ -383,8 +383,7 @@  bool management_query_user_pass(struct management *man,
 bool management_android_control(struct management *man, const char *command, const char *msg);
 
 #define ANDROID_KEEP_OLD_TUN 1
-#define ANDROID_OPEN_AFTER_CLOSE 2
-#define ANDROID_OPEN_BEFORE_CLOSE 3
+#define ANDROID_OPEN_BEFORE_CLOSE 2
 int managment_android_persisttun_action(struct management *man);
 
 #endif
diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
index 12bdd200..93259ec5 100644
--- a/src/openvpn/tun.c
+++ b/src/openvpn/tun.c
@@ -1879,13 +1879,6 @@  open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun
 
     int android_method = managment_android_persisttun_action(management);
 
-    /* Android 4.4 workaround */
-    if (oldtunfd >=0 && android_method == ANDROID_OPEN_AFTER_CLOSE)
-    {
-        close(oldtunfd);
-        management_sleep(2);
-    }
-
     if (oldtunfd >=0  && android_method == ANDROID_KEEP_OLD_TUN)
     {
         /* keep the old fd */
@@ -1900,7 +1893,7 @@  open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun
         management->connection.lastfdreceived = -1;
     }
 
-    if (oldtunfd>=0 && android_method == ANDROID_OPEN_BEFORE_CLOSE)
+    if (oldtunfd >= 0 && android_method == ANDROID_OPEN_BEFORE_CLOSE)
     {
         close(oldtunfd);
     }