Skip to content

Commit

Permalink
network: Support ipconfig changes for IPv6 force toggle
Browse files Browse the repository at this point in the history
[network] Support ipconfig changes for IPv6 force toggle. JB#48769

Add "false" to all functions using
__connman_ipconfig_{enable,disable}_ipv6() except with
__connman_network_enable_ipconfig(), in which the parameter is set by
the caller. This is passed to autoconf_ipv6_set() to get IPv6 properly
enabled again, when requested. Utilize the input force value with
FIXED, MANUAL, DHCP and AUTO ipconfig method types when enabling
ipconfig via network.c.
  • Loading branch information
LaakkonenJussi committed Mar 17, 2021
1 parent 8471ac6 commit 2031f66
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
3 changes: 2 additions & 1 deletion connman/src/connman.h
Expand Up @@ -708,7 +708,8 @@ int __connman_network_disconnect(struct connman_network *network);
int __connman_network_clear_ipconfig(struct connman_network *network,
struct connman_ipconfig *ipconfig);
int __connman_network_enable_ipconfig(struct connman_network *network,
struct connman_ipconfig *ipconfig);
struct connman_ipconfig *ipconfig,
bool force);

const char *__connman_network_get_type(struct connman_network *network);
const char *__connman_network_get_group(struct connman_network *network);
Expand Down
35 changes: 20 additions & 15 deletions connman/src/network.c
Expand Up @@ -282,7 +282,8 @@ static int set_connected_dhcp(struct connman_network *network)
}

static int manual_ipv6_set(struct connman_network *network,
struct connman_ipconfig *ipconfig_ipv6)
struct connman_ipconfig *ipconfig_ipv6,
bool force)
{
struct connman_service *service;
int err;
Expand All @@ -296,7 +297,9 @@ static int manual_ipv6_set(struct connman_network *network,
if (!__connman_ipconfig_get_local(ipconfig_ipv6))
__connman_service_read_ip6config(service);

__connman_ipconfig_enable_ipv6(ipconfig_ipv6);
err = __connman_ipconfig_enable_ipv6(ipconfig_ipv6, force);
if (err)
return err;

err = __connman_ipconfig_address_add(ipconfig_ipv6);
if (err < 0) {
Expand Down Expand Up @@ -374,7 +377,7 @@ static int dhcpv6_set_addresses(struct connman_network *network)
return err;
}

static void autoconf_ipv6_set(struct connman_network *network);
static void autoconf_ipv6_set(struct connman_network *network, bool force);
static void dhcpv6_callback(struct connman_network *network,
enum __connman_dhcpv6_status status, gpointer data);

Expand All @@ -396,7 +399,7 @@ static void dhcpv6_renew_callback(struct connman_network *network,
stop_dhcpv6(network);

/* restart and do solicit again. */
autoconf_ipv6_set(network);
autoconf_ipv6_set(network, false);
break;
}
}
Expand All @@ -422,7 +425,7 @@ static void dhcpv6_callback(struct connman_network *network,

} else if (status == CONNMAN_DHCPV6_STATUS_RESTART) {
stop_dhcpv6(network);
autoconf_ipv6_set(network);
autoconf_ipv6_set(network, false);
} else
stop_dhcpv6(network);
}
Expand Down Expand Up @@ -558,7 +561,7 @@ int __connman_network_refresh_rs_ipv6(struct connman_network *network,
return ret;
}

static void autoconf_ipv6_set(struct connman_network *network)
static void autoconf_ipv6_set(struct connman_network *network, bool force)
{
struct connman_service *service;
struct connman_ipconfig *ipconfig;
Expand Down Expand Up @@ -588,7 +591,8 @@ static void autoconf_ipv6_set(struct connman_network *network)

__connman_ipconfig_enable(ipconfig);

__connman_ipconfig_enable_ipv6(ipconfig);
if (__connman_ipconfig_enable_ipv6(ipconfig, force))
return;

__connman_ipconfig_address_remove(ipconfig);

Expand Down Expand Up @@ -622,8 +626,8 @@ static void set_connected(struct connman_network *network)
DBG("service %p ipv4 %p ipv6 %p", service, ipconfig_ipv4,
ipconfig_ipv6);

__connman_network_enable_ipconfig(network, ipconfig_ipv4);
__connman_network_enable_ipconfig(network, ipconfig_ipv6);
__connman_network_enable_ipconfig(network, ipconfig_ipv4, false);
__connman_network_enable_ipconfig(network, ipconfig_ipv6, false);
}

static void set_disconnected(struct connman_network *network)
Expand Down Expand Up @@ -730,8 +734,8 @@ static void set_disconnected(struct connman_network *network)
* automagically.
*/
if (ipv6_method == CONNMAN_IPCONFIG_METHOD_AUTO) {
__connman_ipconfig_disable_ipv6(ipconfig_ipv6);
__connman_ipconfig_enable_ipv6(ipconfig_ipv6);
__connman_ipconfig_disable_ipv6(ipconfig_ipv6, false);
__connman_ipconfig_enable_ipv6(ipconfig_ipv6, false);
}
}

Expand Down Expand Up @@ -1575,7 +1579,7 @@ int __connman_network_clear_ipconfig(struct connman_network *network,
}

int __connman_network_enable_ipconfig(struct connman_network *network,
struct connman_ipconfig *ipconfig)
struct connman_ipconfig *ipconfig, bool force)
{
int r = 0;
enum connman_ipconfig_type type;
Expand Down Expand Up @@ -1603,19 +1607,20 @@ int __connman_network_enable_ipconfig(struct connman_network *network,
break;

case CONNMAN_IPCONFIG_METHOD_OFF:
__connman_ipconfig_disable_ipv6(ipconfig);
__connman_ipconfig_disable_ipv6(ipconfig, force);
break;

case CONNMAN_IPCONFIG_METHOD_AUTO:
autoconf_ipv6_set(network);
autoconf_ipv6_set(network, force);
break;

case CONNMAN_IPCONFIG_METHOD_FIXED:
case CONNMAN_IPCONFIG_METHOD_MANUAL:
r = manual_ipv6_set(network, ipconfig);
r = manual_ipv6_set(network, ipconfig, force);
break;

case CONNMAN_IPCONFIG_METHOD_DHCP:
__connman_ipconfig_enable_ipv6(ipconfig, force);
r = -ENOSYS;
break;
}
Expand Down

0 comments on commit 2031f66

Please sign in to comment.