diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2017-07-31 17:28:08 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2017-07-31 17:53:52 +0200 |
commit | 5df3a1899183045da88e5462f95ea134015b1208 (patch) | |
tree | 9797ee228b7fdab24191f2a336d183bfdc07ebfa | |
parent | 5543bbc0e640af124716c50226f2ac134d42a8b5 (diff) | |
download | NetworkManager-bg/default-route-update-rh1470930.tar.gz |
default-route: skip addition when the route already existsbg/default-route-update-rh1470930
Re-adding the default route has side-effects, as it also prunes the
cloned routes from the kernel FIB.
https://bugzilla.redhat.com/show_bug.cgi?id=1470930
-rw-r--r-- | src/nm-default-route-manager.c | 61 |
1 files changed, 53 insertions, 8 deletions
diff --git a/src/nm-default-route-manager.c b/src/nm-default-route-manager.c index acfe30c17c..cd823db3f3 100644 --- a/src/nm-default-route-manager.c +++ b/src/nm-default-route-manager.c @@ -28,6 +28,7 @@ #include "devices/nm-device.h" #include "vpn/nm-vpn-connection.h" #include "platform/nm-platform.h" +#include "platform/nm-platform-utils.h" #include "platform/nmp-object.h" #include "nm-manager.h" #include "nm-ip4-config.h" @@ -290,20 +291,64 @@ _platform_route_sync_add (const VTableIP *vtable, NMDefaultRouteManager *self, g if (vtable->vt->is_ip4) { NMPlatformIP4Route rt = entry->route.r4; + const NMPlatformIP4Route *plat_rt; + + rt.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (rt.rt_source); + + plat_rt = nm_platform_ip4_route_get (priv->platform, + entry->route.r4.ifindex, + 0, + 0, + entry->effective_metric); + if (plat_rt && nm_platform_ip4_route_cmp (plat_rt, &rt) == 0) { + _LOGt (AF_INET, "already exists: %s", + nm_platform_ip4_route_to_string (&rt, NULL, 0)); + success = TRUE; + } else { + if (plat_rt) { + _LOGt (AF_INET, "update platform route: %s", + nm_platform_ip4_route_to_string (&rt, NULL, 0)); + _LOGt (AF_INET, " with: %s", + nm_platform_ip4_route_to_string (plat_rt, NULL, 0)); + } - rt.network = 0; - rt.plen = 0; - rt.metric = entry->effective_metric; + rt.network = 0; + rt.plen = 0; + rt.metric = entry->effective_metric; + rt.rt_source = entry->route.r4.rt_source; - success = nm_platform_ip4_route_add (priv->platform, &rt); + success = nm_platform_ip4_route_add (priv->platform, &rt); + } } else { NMPlatformIP6Route rt = entry->route.r6; + const NMPlatformIP6Route *plat_rt; + + rt.rt_source = nmp_utils_ip_config_source_round_trip_rtprot (rt.rt_source); + + plat_rt = nm_platform_ip6_route_get (priv->platform, + entry->route.r6.ifindex, + in6addr_any, + 0, + entry->effective_metric); + if (plat_rt && nm_platform_ip6_route_cmp (plat_rt, &rt) == 0) { + _LOGt (AF_INET6, "already exists: %s", + nm_platform_ip6_route_to_string (&rt, NULL, 0)); + success = TRUE; + } else { + if (plat_rt) { + _LOGt (AF_INET6, "update platform route: %s", + nm_platform_ip6_route_to_string (&rt, NULL, 0)); + _LOGt (AF_INET6, " with: %s", + nm_platform_ip6_route_to_string (plat_rt, NULL, 0)); + } - rt.network = in6addr_any; - rt.plen = 0; - rt.metric = entry->effective_metric; + rt.network = in6addr_any; + rt.plen = 0; + rt.metric = entry->effective_metric; + rt.rt_source = entry->route.r6.rt_source; - success = nm_platform_ip6_route_add (priv->platform, &rt); + success = nm_platform_ip6_route_add (priv->platform, &rt); + } } if (!success) { _LOGW (vtable->vt->addr_family, "failed to add default route %s with effective metric %u", |