From ea1679aac03f709667d2f89574b2ee1b5af0a361 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 17 Oct 2019 11:36:38 +0200 Subject: [PATCH] core: don't add prefix route for external addresses If the user adds an address manually, kernel automatically adds a prefix route for it unless the address has the NOPREFIXROUTE flag. When ip_config_merge_and_apply() gets called, NM also adds its prefix route and so we end up with two routes that differ only for the metric. This is a problem because the route added by NM is not removed if the user removes the previously added address. Also, it seems confusing to have multiple instances of the same routes. This commit skips the addition of a prefix route for addresses added manually outside of NetworkManager. --- src/nm-ip4-config.c | 3 +++ src/nm-ip6-config.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c index 1096fb0a23..f132e50754 100644 --- a/src/nm-ip4-config.c +++ b/src/nm-ip4-config.c @@ -704,6 +704,9 @@ nm_ip4_config_add_dependent_routes (NMIP4Config *self, /* The destination network depends on the peer-address. */ network = nm_utils_ip4_address_clear_host_address (my_addr->peer_address, my_addr->plen); + if (my_addr->external) + continue; + if (_ipv4_is_zeronet (network)) { /* Kernel doesn't add device-routes for destinations that * start with 0.x.y.z. Skip them. */ diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c index 8ed17b95f6..1255365745 100644 --- a/src/nm-ip6-config.c +++ b/src/nm-ip6-config.c @@ -480,6 +480,8 @@ nm_ip6_config_add_dependent_routes (NMIP6Config *self, gboolean has_peer; int routes_n, routes_i; + if (my_addr->external) + continue; if (NM_FLAGS_HAS (my_addr->n_ifa_flags, IFA_F_NOPREFIXROUTE)) continue; if (my_addr->plen == 0)