From fbde824584266d9f6ac7f14916fdcc9cd179a73a Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 26 Aug 2013 23:06:03 +0200 Subject: [PATCH] core: fail activation when a route cannot be added Before, when a route failed to be added, NM stopped adding further routes. However, the activation still continued and the user was not notified about the error. Adding a route might fail for example if the gateway is not on one of the subnets of the interface. Now, a failure to add a route makes the activaion fail. If the connection has autoconnect=yes, this might result in some unsuccessful reconnection attempts. In the future, we might want to distinguish between manually added routes and routes from RA/DHCP. So that connecting to a wrongly configured DHCP server still works for most parts. https://bugzilla.redhat.com/show_bug.cgi?id=999544 Signed-off-by: Thomas Haller --- src/nm-ip4-config.c | 5 ++++- src/nm-ip6-config.c | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c index 9b9deeaf32..8ba1070913 100644 --- a/src/nm-ip4-config.c +++ b/src/nm-ip4-config.c @@ -137,6 +137,7 @@ nm_ip4_config_commit (NMIP4Config *config, int ifindex, int priority) int count = nm_ip4_config_get_num_routes (config); GArray *routes = g_array_sized_new (FALSE, FALSE, sizeof (NMPlatformIP4Route), count); NMPlatformIP4Route route; + gboolean success; for (i = 0; i < count; i++) { memcpy (&route, nm_ip4_config_get_route (config, i), sizeof (route)); @@ -157,8 +158,10 @@ nm_ip4_config_commit (NMIP4Config *config, int ifindex, int priority) g_array_append_val (routes, route); } - nm_platform_ip4_route_sync (ifindex, routes); + success = nm_platform_ip4_route_sync (ifindex, routes); g_array_unref (routes); + if (!success) + return FALSE; } /* MTU */ diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c index 8c49d95ee6..f6b48cca89 100644 --- a/src/nm-ip6-config.c +++ b/src/nm-ip6-config.c @@ -127,6 +127,7 @@ nm_ip6_config_commit (NMIP6Config *config, int ifindex, int priority) { NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config); int i; + gboolean success; g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (config != NULL, FALSE); @@ -159,11 +160,11 @@ nm_ip6_config_commit (NMIP6Config *config, int ifindex, int priority) g_array_append_val (routes, route); } - nm_platform_ip6_route_sync (ifindex, routes); + success = nm_platform_ip6_route_sync (ifindex, routes); g_array_unref (routes); } - return TRUE; + return success; } static inline gboolean