From: Jaehyun Kim Date: Thu, 18 Nov 2021 15:35:03 +0000 (+0900) Subject: Update routing table when default address is reset X-Git-Tag: accepted/tizen/6.5/unified/20211124.060337^0 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fupstream%2Fconnman.git;a=commitdiff_plain;h=3b0014134b2153de07f0c0b953a243a07d9029a9 Update routing table when default address is reset Restore the default route even when the IP is updated due to external factors. Change-Id: Id44732f84cac7a26c494fe8f3bcd77a75c7daf19 Signed-off-by: Jaehyun Kim --- diff --git a/src/connection.c b/src/connection.c index 6036db3..c18701a 100755 --- a/src/connection.c +++ b/src/connection.c @@ -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; diff --git a/src/connman.h b/src/connman.h index e92f2b1..e63eb9d 100755 --- a/src/connman.h +++ b/src/connman.h @@ -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, diff --git a/src/ipconfig.c b/src/ipconfig.c index 8c21db5..ec4c396 100755 --- a/src/ipconfig.c +++ b/src/ipconfig.c @@ -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;