`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.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
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)
set_dnses(netid, dnses);
set_routes(iface, netid);
set_mtu(iface, mtu);
+ set_users(netid);
broadcast_change();
free(cleanup_iface);