]> git.ipfire.org Git - thirdparty/strongswan.git/commit
Merge branch 'android-scheduler'
authorTobias Brunner <tobias@strongswan.org>
Tue, 2 Jun 2020 12:18:42 +0000 (14:18 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 2 Jun 2020 12:34:31 +0000 (14:34 +0200)
commita22a1493c34da864871129250d75788ec3861712
tree165a0ee1f9ed8c4fbaf5b1dc065acd67ad30f12c
parent0ff939585ec7e24c36af77615255d1dc8ca8609a
parent04f4bef2354dbc94b89af30206acbe3d473263d2
Merge branch 'android-scheduler'

Starting with Android 6, the system will aggressively suspend apps when
the device is idle (Doze mode).  With Android 10 on a Pixel 4 this seems
to happen after about 70 minutes.  Then the scheduler thread in our
default scheduler is only woken rarely, combined with our previous use
of the monotonic clock it meant that events were executed with severe
delays and noticing that there was such a delay.  This was particularly
bad in regards to NAT keepalives as it usually meant that the device was
not reachable anymore from the outside.

Some changes here try to improve that situation, e.g. the clock is switched
to CLOCK_REALTIME (Bionic doesn't support CLOCK_BOOTTIME for condvars) so we
can measure the actual difference e.g. since the last outbound message,
other changes try to ensure that connectivity is restored after being asleep
for a while (send DPD instead of keepalive after a long delay, send DPD even
if path to peer stays the same).

However, the most significant change is the replacement of the default
scheduler with one specifically designed for Android.  It schedules
long-term events via AlarmManager, which allows waking up the app even
if the system put it to sleep.  The latter requires adding the app to the
system's battery optimization whitelist, which is requested from the
user automatically if necessary.  With this, NAT keepalives and rekeyings
are now scheduled accurately, with little changes to the battery usage.
If the app is not whitelisted (there is a setting to ignore this), events
are delayed by up to 15 minutes after about 70 minutes, so behind a NAT
the device won't be reachable from the outside afterwards (connectivity
should be restored as soon as the device is woken from deep sleep by the
user).

Fixes #3364.