In Dual Network where both IPv4 and IPv6 networks are available,
gateway address should be set for both network types.
Currently in following scenario:
- Gateway Address for IPv6 is already available
- IPv4 gateway address is obtained using DHCP.
active_gateway is not NULL as IPv6 gateway was set previously and was
made active so IPv4 Gateway Address is never set. So we should set
active_gateway only if gateway address of type given in
__connman_connection_gateway_add() is active, if gateway address
of other type is active then also active_gateway should be NULL
and we should set gateway address for that type.
---
 src/connection.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/connection.c b/src/connection.c
index 8fe9725..5abb143 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -733,7 +733,7 @@ static struct connman_rtnl connection_rtnl = {
        .delgateway     = connection_delgateway,
 };
 
-static struct gateway_data *find_active_gateway(void)
+static struct gateway_data *find_active_gateway(enum connman_ipconfig_type 
type)
 {
        GHashTableIter iter;
        gpointer value, key;
@@ -745,11 +745,13 @@ static struct gateway_data *find_active_gateway(void)
        while (g_hash_table_iter_next(&iter, &key, &value)) {
                struct gateway_data *data = value;
 
-               if (data->ipv4_gateway &&
+               if (type == CONNMAN_IPCONFIG_TYPE_IPV4 &&
+                               data->ipv4_gateway &&
                                data->ipv4_gateway->active)
                        return data;
 
-               if (data->ipv6_gateway &&
+               if (type == CONNMAN_IPCONFIG_TYPE_IPV6 &&
+                               data->ipv6_gateway &&
                                data->ipv6_gateway->active)
                        return data;
        }
@@ -872,7 +874,7 @@ int __connman_connection_gateway_add(struct connman_service 
*service,
        if (!new_gateway)
                return -EINVAL;
 
-       active_gateway = find_active_gateway();
+       active_gateway = find_active_gateway(type);
 
        DBG("active %p index %d new %p", active_gateway,
                active_gateway ? active_gateway->index : -1, new_gateway);
-- 
1.9.1

_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to