From b57461ceb01e591525201a9b8db3bf5107e51f8d Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 31 May 2018 16:38:06 +0200 Subject: wg-quick: android: delay setting users until end `ndc users add` eventually invokes SOCK_DESTROY on user sockets, causing them to reconnect. By delaying this until after routes are set, we ensure that the sockets reconnect using the tunnel, rather than the old route. --- src/tools/wg-quick/android.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/tools') diff --git a/src/tools/wg-quick/android.c b/src/tools/wg-quick/android.c index 25f8f5f..cd43a13 100644 --- a/src/tools/wg-quick/android.c +++ b/src/tools/wg-quick/android.c @@ -280,7 +280,11 @@ static void up_if(unsigned int *netid, const char *iface) cndc("interface setcfg %s up", iface); cndc("network create %u vpn 1 1", *netid); cndc("network interface add %u %s", *netid, iface); - cndc("network users add %u 0-99999", *netid); +} + +static void set_users(unsigned int netid) +{ + cndc("network users add %u 0-99999", netid); } static void set_dnses(unsigned int netid, const char *dnses) @@ -510,6 +514,7 @@ static void cmd_up(const char *iface, const char *config, unsigned int mtu, cons set_dnses(netid, dnses); set_routes(iface, netid); set_mtu(iface, mtu); + set_users(netid); broadcast_change(); free(cleanup_iface); -- cgit v1.2.3-59-g8ed1b