Update routing table when default address is reset 89/266789/1 accepted/tizen/6.5/unified/20211124.060337 submit/tizen_6.5/20211119.073159 submit/tizen_6.5/20211123.064148 submit/tizen_6.5/20211123.090823
authorJaehyun Kim <jeik01.kim@samsung.com>
Thu, 18 Nov 2021 15:35:03 +0000 (00:35 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Thu, 18 Nov 2021 15:35:03 +0000 (00:35 +0900)
Restore the default route even when the IP is updated due to external factors.

Change-Id: Id44732f84cac7a26c494fe8f3bcd77a75c7daf19
Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
src/connection.c
src/connman.h
src/ipconfig.c

index 6036db3..c18701a 100755 (executable)
@@ -1114,6 +1114,23 @@ bool __connman_connection_update_gateway(void)
        return updated;
 }
 
+#if defined TIZEN_EXT
+void __connman_connection_update_default_gateway(void)
+{
+       struct gateway_data *default_gateway;
+
+       default_gateway = find_default_gateway();
+       DBG("default %p", default_gateway);
+
+       if (!default_gateway)
+               return;
+
+       if (default_gateway->ipv4_gateway)
+               set_default_gateway(default_gateway,
+                               CONNMAN_IPCONFIG_TYPE_IPV4);
+}
+#endif
+
 int __connman_connection_get_vpn_index(int phy_index)
 {
        GHashTableIter iter;
index e92f2b1..e63eb9d 100755 (executable)
@@ -541,6 +541,9 @@ void __connman_connection_gateway_remove(struct connman_service *service,
 int __connman_connection_get_vpn_index(int phy_index);
 
 bool __connman_connection_update_gateway(void);
+#if defined TIZEN_EXT
+void __connman_connection_update_default_gateway(void);
+#endif
 
 typedef void (*__connman_ntp_cb_t) (bool success, void *user_data);
 int __connman_ntp_start(char *server, __connman_ntp_cb_t callback,
index 8c21db5..ec4c396 100755 (executable)
@@ -785,6 +785,30 @@ int __connman_ipconfig_newaddr(int index, int family, const char *label,
                        ipconfig->ops->ip_bound(ipconfig, ifname);
        }
 
+#if defined TIZEN_EXT
+       const char *local;
+       struct connman_service *service;
+       struct connman_ipconfig *local_ipconfig;
+
+       service = connman_service_get_default();
+       if (!service)
+               goto out;
+
+       local_ipconfig = __connman_service_get_ip4config(service);
+       if (!local_ipconfig)
+               goto out;
+
+       local = __connman_ipconfig_get_local(local_ipconfig);
+       if (!local)
+               goto out;
+
+       DBG("local %s", local);
+
+       if (g_strcmp0(local, address) != 0)
+               goto out;
+
+       __connman_connection_update_default_gateway();
+#endif
 out:
        g_free(ifname);
        return 0;