diff options
author | Thomas Haller <thaller@redhat.com> | 2017-09-12 13:24:52 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-09-13 08:17:31 +0200 |
commit | 4b4efac3ab8a7b84e25a2dea4eadbaa789c15f9c (patch) | |
tree | db5f8347ee633e545eb2fb80818d435af390652f | |
parent | aee48dfd44c9e469303573fb6d02b0d0113658c5 (diff) | |
download | NetworkManager-4b4efac3ab8a7b84e25a2dea4eadbaa789c15f9c.tar.gz |
core: fix merging IP addresses in NMIP4Config/NMIP6Config
When merging IP addresses, we keep the best addr_source and the internally
configured timestamps. Since the check for the timestamp considers addr_source,
we must move the check before merging addr_source.
-rw-r--r-- | src/nm-ip4-config.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c index c21343510d..07e2f2e080 100644 --- a/src/nm-ip4-config.c +++ b/src/nm-ip4-config.c @@ -143,17 +143,6 @@ _nm_ip_config_add_obj (NMDedupMultiIndex *multi_idx, switch (idx_type->obj_type) { case NMP_OBJECT_TYPE_IP4_ADDRESS: case NMP_OBJECT_TYPE_IP6_ADDRESS: - /* we want to keep the maximum addr_source. But since we expect - * that usually we already add the maxiumum right away, we first try to - * add the new address (replacing the old one). Only if we later - * find out that addr_source is now lower, we fix it. - */ - if (obj_new->ip_address.addr_source < obj_old->ip_address.addr_source) { - obj_new = nmp_object_stackinit_obj (&obj_new_stackinit, obj_new); - obj_new_stackinit.ip_address.addr_source = obj_old->ip_address.addr_source; - modified = TRUE; - } - /* for addresses that we read from the kernel, we keep the timestamps as defined * by the previous source (item_old). The reason is, that the other source configured the lifetimes * with "what should be" and the kernel values are "what turned out after configuring it". @@ -168,14 +157,17 @@ _nm_ip_config_add_obj (NMDedupMultiIndex *multi_idx, obj_new_stackinit.ip_address.preferred = NMP_OBJECT_CAST_IP_ADDRESS (obj_old)->preferred; modified = TRUE; } + + /* keep the maximum addr_source. */ + if (obj_new->ip_address.addr_source < obj_old->ip_address.addr_source) { + obj_new = nmp_object_stackinit_obj (&obj_new_stackinit, obj_new); + obj_new_stackinit.ip_address.addr_source = obj_old->ip_address.addr_source; + modified = TRUE; + } break; case NMP_OBJECT_TYPE_IP4_ROUTE: case NMP_OBJECT_TYPE_IP6_ROUTE: - /* we want to keep the maximum rt_source. But since we expect - * that usually we already add the maxiumum right away, we first try to - * add the new route (replacing the old one). Only if we later - * find out that rt_source is now lower, we fix it. - */ + /* keep the maximum rt_source. */ if (obj_new->ip_route.rt_source < obj_old->ip_route.rt_source) { obj_new = nmp_object_stackinit_obj (&obj_new_stackinit, obj_new); obj_new_stackinit.ip_route.rt_source = obj_old->ip_route.rt_source; |