summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2019-10-17 11:36:38 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2019-10-23 21:46:26 +0200
commitea1679aac03f709667d2f89574b2ee1b5af0a361 (patch)
treec34bd4bc05ae9a1a447d347bbf82c5fda567ea14
parent3eb2f435ae4763ca1b8c9afc46642e2d6a4b31e1 (diff)
downloadNetworkManager-ea1679aac03f709667d2f89574b2ee1b5af0a361.tar.gz
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.
-rw-r--r--src/nm-ip4-config.c3
-rw-r--r--src/nm-ip6-config.c2
2 files changed, 5 insertions, 0 deletions
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)