void connman_network_set_index(struct connman_network *network, int index)
{
struct connman_service *service;
+ struct connman_ipconfig *ipconfig;
service = __connman_service_lookup_from_network(network);
if (service == NULL)
goto done;
- if (network->element.index < 0)
+ ipconfig = __connman_service_get_ipconfig(service);
+
+ if (network->element.index < 0 && ipconfig == NULL)
/*
* This is needed for plugins that havent set their ipconfig
* layer yet, due to not being able to get a network index
*/
__connman_service_create_ipconfig(service, index);
else {
- struct connman_ipconfig *ipconfig;
-
/* If index changed, the index of ipconfig must be reset. */
- ipconfig = __connman_service_get_ipconfig(service);
if (ipconfig == NULL)
goto done;