diff options
-rw-r--r-- | include/rtnl.h | 2 | ||||
-rw-r--r-- | src/connection.c | 2 | ||||
-rw-r--r-- | src/connman.h | 1 | ||||
-rw-r--r-- | src/ipconfig.c | 19 | ||||
-rw-r--r-- | src/rtnl.c | 15 |
5 files changed, 30 insertions, 9 deletions
diff --git a/include/rtnl.h b/include/rtnl.h index 6c40f41e..01f4d2f8 100644 --- a/include/rtnl.h +++ b/include/rtnl.h @@ -57,8 +57,6 @@ struct connman_rtnl { int connman_rtnl_register(struct connman_rtnl *rtnl); void connman_rtnl_unregister(struct connman_rtnl *rtnl); -int connman_rtnl_send_getroute(void); - #ifdef __cplusplus } #endif diff --git a/src/connection.c b/src/connection.c index f722cc36..cfe4828f 100644 --- a/src/connection.c +++ b/src/connection.c @@ -614,8 +614,6 @@ int __connman_connection_init(void) if (connman_rtnl_register(&connection_rtnl) < 0) connman_error("Failed to setup RTNL gateway driver"); - connman_rtnl_send_getroute(); - return connman_driver_register(&connection_driver); } diff --git a/src/connman.h b/src/connman.h index f8709d7a..1ba327f3 100644 --- a/src/connman.h +++ b/src/connman.h @@ -94,6 +94,7 @@ int __connman_security_check_privilege(DBusMessage *message, int __connman_ipconfig_get_index(struct connman_ipconfig *ipconfig); unsigned short __connman_ipconfig_get_type(struct connman_ipconfig *ipconfig); unsigned int __connman_ipconfig_get_flags(struct connman_ipconfig *ipconfig); +const char *__connman_ipconfig_get_gateway(struct connman_ipconfig *ipconfig); void __connman_ipconfig_update_link(struct connman_ipconfig *ipconfig, unsigned flags, unsigned change); diff --git a/src/ipconfig.c b/src/ipconfig.c index c149cc61..013a14f0 100644 --- a/src/ipconfig.c +++ b/src/ipconfig.c @@ -46,6 +46,7 @@ struct connman_ipconfig { unsigned int flags; enum connman_ipconfig_method method; GSList *address_list; + char *gateway; }; static void free_address_list(struct connman_ipconfig *ipconfig) @@ -57,7 +58,6 @@ static void free_address_list(struct connman_ipconfig *ipconfig) g_free(ipaddress->address); g_free(ipaddress); - list->data = NULL; } @@ -136,6 +136,8 @@ void connman_ipconfig_unref(struct connman_ipconfig *ipconfig) connman_info("%s {remove} index %d", ipconfig->interface, ipconfig->index); + g_free(ipconfig->gateway); + free_address_list(ipconfig); g_free(ipconfig->interface); @@ -173,6 +175,11 @@ unsigned int __connman_ipconfig_get_flags(struct connman_ipconfig *ipconfig) return ipconfig->flags; } +const char *__connman_ipconfig_get_gateway(struct connman_ipconfig *ipconfig) +{ + return ipconfig->gateway; +} + void __connman_ipconfig_update_link(struct connman_ipconfig *ipconfig, unsigned flags, unsigned change) { @@ -260,6 +267,11 @@ void __connman_ipconfig_add_route(struct connman_ipconfig *ipconfig, unsigned char scope, const char *destination, const char *gateway) { + if (scope == 0 && g_strcmp0(destination, "0.0.0.0") == 0) { + g_free(ipconfig->gateway); + ipconfig->gateway = g_strdup(gateway); + } + connman_info("%s {add} route %s gw %s scope %u <%s>", ipconfig->interface, destination, gateway, scope, scope2str(scope)); @@ -269,6 +281,11 @@ void __connman_ipconfig_del_route(struct connman_ipconfig *ipconfig, unsigned char scope, const char *destination, const char *gateway) { + if (scope == 0 && g_strcmp0(destination, "0.0.0.0") == 0) { + g_free(ipconfig->gateway); + ipconfig->gateway = NULL; + } + connman_info("%s {del} route %s gw %s scope %u <%s>", ipconfig->interface, destination, gateway, scope, scope2str(scope)); @@ -139,7 +139,7 @@ void connman_rtnl_remove_watch(unsigned int id) } } -static void trigger_newlink(gpointer key, gpointer value, gpointer user_data) +static void trigger_rtnl(gpointer key, gpointer value, gpointer user_data) { struct connman_rtnl *rtnl = user_data; struct connman_ipconfig *ipconfig = value; @@ -154,6 +154,13 @@ static void trigger_newlink(gpointer key, gpointer value, gpointer user_data) rtnl->newlink(type, index, flags, 0); } + + if (rtnl->newgateway) { + const char *gateway = __connman_ipconfig_get_gateway(ipconfig); + + if (gateway != NULL) + rtnl->newgateway(index, gateway); + } } static GSList *rtnl_list = NULL; @@ -181,7 +188,7 @@ int connman_rtnl_register(struct connman_rtnl *rtnl) rtnl_list = g_slist_insert_sorted(rtnl_list, rtnl, compare_priority); - g_hash_table_foreach(ipconfig_hash, trigger_newlink, rtnl); + g_hash_table_foreach(ipconfig_hash, trigger_rtnl, rtnl); return 0; } @@ -934,7 +941,7 @@ static int send_getaddr(void) return queue_request(req); } -int connman_rtnl_send_getroute(void) +static int send_getroute(void) { struct rtnl_request *req; @@ -992,7 +999,7 @@ void __connman_rtnl_start(void) send_getlink(); send_getaddr(); - connman_rtnl_send_getroute(); + send_getroute(); } void __connman_rtnl_cleanup(void) |