Get the active gateway pointer only after the gateway hash
has been manipulated by add_gateway(). It is possible that
we are accessing stale pointer otherwise.
DBG("service %p index %d gateway %s vpn ip %s type %d",
service, index, gateway, peer, type);
DBG("service %p index %d gateway %s vpn ip %s type %d",
service, index, gateway, peer, type);
- active_gateway = find_active_gateway();
new_gateway = add_gateway(service, index, gateway, type);
if (new_gateway == NULL)
return -EINVAL;
new_gateway = add_gateway(service, index, gateway, type);
if (new_gateway == NULL)
return -EINVAL;
+ active_gateway = find_active_gateway();
+
DBG("active %p index %d new %p", active_gateway,
active_gateway ? active_gateway->index : -1, new_gateway);
DBG("active %p index %d new %p", active_gateway,
active_gateway ? active_gateway->index : -1, new_gateway);