diff options
-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", |