diff options
-rw-r--r-- | src/devices/nm-device.c | 2 | ||||
-rw-r--r-- | src/nm-ip4-config.c | 13 | ||||
-rw-r--r-- | src/nm-ip6-config.c | 13 | ||||
-rw-r--r-- | src/nm-types.h | 9 | ||||
-rw-r--r-- | src/platform/nm-platform.c | 18 | ||||
-rw-r--r-- | src/platform/nm-platform.h | 2 |
6 files changed, 46 insertions, 11 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 298f86f372..96fc6614ac 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -7585,7 +7585,7 @@ ip_config_merge_and_apply (NMDevice *self, nm_ip_config_merge (composite, iter->data, NM_IP_CONFIG_MERGE_DEFAULT, 0); if (priv->ext_ip_config_x[IS_IPv4]) - nm_ip_config_merge (composite, priv->ext_ip_config_x[IS_IPv4], NM_IP_CONFIG_MERGE_DEFAULT, 0); + nm_ip_config_merge (composite, priv->ext_ip_config_x[IS_IPv4], NM_IP_CONFIG_MERGE_EXTERNAL, 0); /* Merge WWAN config *last* to ensure modem-given settings overwrite * any external stuff set by pppd or other scripts. diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c index 6c79c97d1b..1096fb0a23 100644 --- a/src/nm-ip4-config.c +++ b/src/nm-ip4-config.c @@ -1163,8 +1163,17 @@ nm_ip4_config_merge (NMIP4Config *dst, g_object_freeze_notify (G_OBJECT (dst)); /* addresses */ - nm_ip_config_iter_ip4_address_for_each (&ipconf_iter, src, &address) - _add_address (dst, NMP_OBJECT_UP_CAST (address), NULL); + nm_ip_config_iter_ip4_address_for_each (&ipconf_iter, src, &address) { + if ( NM_FLAGS_HAS (merge_flags, NM_IP_CONFIG_MERGE_EXTERNAL) + && !address->external) { + NMPlatformIP4Address a; + + a = *address; + a.external = TRUE; + _add_address (dst, NULL, &a); + } else + _add_address (dst, NMP_OBJECT_UP_CAST (address), NULL); + } /* nameservers */ if (!NM_FLAGS_HAS (merge_flags, NM_IP_CONFIG_MERGE_NO_DNS)) { diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c index e109e42acf..8ed17b95f6 100644 --- a/src/nm-ip6-config.c +++ b/src/nm-ip6-config.c @@ -849,8 +849,17 @@ nm_ip6_config_merge (NMIP6Config *dst, g_object_freeze_notify (G_OBJECT (dst)); /* addresses */ - nm_ip_config_iter_ip6_address_for_each (&ipconf_iter, src, &address) - _add_address (dst, NMP_OBJECT_UP_CAST (address), NULL); + nm_ip_config_iter_ip6_address_for_each (&ipconf_iter, src, &address) { + if ( NM_FLAGS_HAS (merge_flags, NM_IP_CONFIG_MERGE_EXTERNAL) + && !address->external) { + NMPlatformIP6Address a; + + a = *address; + a.external = TRUE; + _add_address (dst, NULL, &a); + } else + _add_address (dst, NMP_OBJECT_UP_CAST (address), NULL); + } /* nameservers */ if (!NM_FLAGS_HAS (merge_flags, NM_IP_CONFIG_MERGE_NO_DNS)) { diff --git a/src/nm-types.h b/src/nm-types.h index 28e2cc9dcf..2f1ac2dcd5 100644 --- a/src/nm-types.h +++ b/src/nm-types.h @@ -204,11 +204,20 @@ typedef enum { NMP_OBJECT_TYPE_MAX = __NMP_OBJECT_TYPE_LAST - 1, } NMPObjectType; +/** + * NMIPConfigMergeFlags: + * @NM_IP_CONFIG_MERGE_DEFAULT: no flags set + * @NM_IP_CONFIG_MERGE_NO_ROUTES: don't merge routes + * @NM_IP_CONFIG_MERGE_NO_DEFAULT_ROUTES: don't merge default routes + * @NM_IP_CONFIG_MERGE_NO_DNS: don't merge DNS information + * @NM_IP_CONFIG_MERGE_EXTERNAL: mark new addresses as external + */ typedef enum { NM_IP_CONFIG_MERGE_DEFAULT = 0, NM_IP_CONFIG_MERGE_NO_ROUTES = (1LL << 0), NM_IP_CONFIG_MERGE_NO_DEFAULT_ROUTES = (1LL << 1), NM_IP_CONFIG_MERGE_NO_DNS = (1LL << 2), + NM_IP_CONFIG_MERGE_EXTERNAL = (1LL << 3), } NMIPConfigMergeFlags; /** diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 8017d3f088..6795dde772 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -6084,13 +6084,14 @@ nm_platform_ip4_address_to_string (const NMPlatformIP4Address *address, char *bu str_time_p = _lifetime_summary_to_string (now, address->timestamp, address->preferred, address->lifetime, str_time, sizeof (str_time)); g_snprintf (buf, len, - "%s/%d lft %s pref %s%s%s%s%s%s src %s", + "%s/%d lft %s pref %s%s%s%s%s%s src %s%s", s_address, address->plen, str_lft_p, str_pref_p, str_time_p, str_peer ?: "", str_dev, _to_string_ifa_flags (address->n_ifa_flags, s_flags, sizeof (s_flags)), str_label, - nmp_utils_ip_config_source_to_string (address->addr_source, s_source, sizeof (s_source))); + nmp_utils_ip_config_source_to_string (address->addr_source, s_source, sizeof (s_source)), + address->external ? " ext" : ""); g_free (str_peer); return buf; } @@ -6191,12 +6192,13 @@ nm_platform_ip6_address_to_string (const NMPlatformIP6Address *address, char *bu str_time_p = _lifetime_summary_to_string (now, address->timestamp, address->preferred, address->lifetime, str_time, sizeof (str_time)); g_snprintf (buf, len, - "%s/%d lft %s pref %s%s%s%s%s src %s", + "%s/%d lft %s pref %s%s%s%s%s src %s%s", s_address, address->plen, str_lft_p, str_pref_p, str_time_p, str_peer ?: "", str_dev, _to_string_ifa_flags (address->n_ifa_flags, s_flags, sizeof (s_flags)), - nmp_utils_ip_config_source_to_string (address->addr_source, s_source, sizeof (s_source))); + nmp_utils_ip_config_source_to_string (address->addr_source, s_source, sizeof (s_source)), + address->external ? " ext" : ""); g_free (str_peer); return buf; } @@ -7302,7 +7304,8 @@ nm_platform_ip4_address_hash_update (const NMPlatformIP4Address *obj, NMHashStat obj->n_ifa_flags, obj->plen, obj->address, - obj->peer_address); + obj->peer_address, + NM_HASH_COMBINE_BOOLS (guint8, obj->external)); nm_hash_update_strarr (h, obj->label); } @@ -7320,6 +7323,7 @@ nm_platform_ip4_address_cmp (const NMPlatformIP4Address *a, const NMPlatformIP4A NM_CMP_FIELD (a, b, preferred); NM_CMP_FIELD (a, b, n_ifa_flags); NM_CMP_FIELD_STR (a, b, label); + NM_CMP_FIELD_UNSAFE (a, b, external); return 0; } @@ -7335,7 +7339,8 @@ nm_platform_ip6_address_hash_update (const NMPlatformIP6Address *obj, NMHashStat obj->n_ifa_flags, obj->plen, obj->address, - obj->peer_address); + obj->peer_address, + NM_HASH_COMBINE_BOOLS (guint8, obj->external)); } int @@ -7355,6 +7360,7 @@ nm_platform_ip6_address_cmp (const NMPlatformIP6Address *a, const NMPlatformIP6A NM_CMP_FIELD (a, b, lifetime); NM_CMP_FIELD (a, b, preferred); NM_CMP_FIELD (a, b, n_ifa_flags); + NM_CMP_FIELD_UNSAFE (a, b, external); return 0; } diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index bdbb256d9f..0340136c86 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -306,6 +306,8 @@ typedef enum { guint32 n_ifa_flags; \ \ guint8 plen; \ + \ + bool external:1; \ ; /** |