diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2022-09-05 15:21:42 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2022-09-05 15:25:38 +0200 |
commit | 85cd932ed98cc89435ea5574739894bf7de4a9ef (patch) | |
tree | 1029dc7b70c62df226e099f130be57e6a55aaf1c | |
parent | 68d9bf84fc81d334b815aa6e58ff70d3fcb1b4a1 (diff) |
core: misc fixes for loopback supportbg/loopback
1) when a IPv4 address has an empty .peer_address, it means the peer
address is 0.0.0.0. To have the peer unset, we must set .peer_address
= .address.
2) don't add address 127.0.0.1/8 to the prune list. This prevents the
deletion of the address on reactivation.
3) add "src 127.0.0.1" to the local route
-rw-r--r-- | src/core/nm-l3cfg.c | 15 | ||||
-rw-r--r-- | src/libnm-platform/nm-platform.c | 20 |
2 files changed, 28 insertions, 7 deletions
diff --git a/src/core/nm-l3cfg.c b/src/core/nm-l3cfg.c index 731c4c5928..2d46ea5b60 100644 --- a/src/core/nm-l3cfg.c +++ b/src/core/nm-l3cfg.c @@ -3731,9 +3731,10 @@ _l3cfg_update_combined_config(NML3Cfg *self, 8, NM_IPV4LO_NETWORK)) { const NMPlatformIP4Address ip4_address = (NMPlatformIP4Address){ - .address = NM_IPV4LO_NETWORK, - .ifindex = 1, - .plen = 8, + .address = NM_IPV4LO_NETWORK, + .peer_address = NM_IPV4LO_NETWORK, + .ifindex = 1, + .plen = 8, }; nm_l3_config_data_add_address_4(l3cd, &ip4_address); } @@ -3754,6 +3755,7 @@ _l3cfg_update_combined_config(NML3Cfg *self, .table_coerced = nm_platform_route_table_coerce(RT_TABLE_LOCAL), .scope_inv = nm_platform_route_scope_inv(RT_SCOPE_HOST), .type_coerced = nm_platform_route_type_coerce(RTN_LOCAL), + .pref_src = NM_IPV4LO_NETWORK, }; nm_platform_ip_route_normalize(AF_INET, &rx.rx); if (!nm_l3_config_data_lookup_route(l3cd, AF_INET, &rx.rx)) { @@ -4607,9 +4609,10 @@ _l3_commit_one(NML3Cfg *self, g_ptr_array_add(addresses, nmp_object_new(NMP_OBJECT_TYPE_IP4_ADDRESS, &((const NMPlatformIP4Address){ - .address = NM_IPV4LO_NETWORK, - .ifindex = 1, - .plen = 8, + .address = NM_IPV4LO_NETWORK, + .peer_address = NM_IPV4LO_NETWORK, + .ifindex = 1, + .plen = 8, }))); } else { g_ptr_array_add(addresses, diff --git a/src/libnm-platform/nm-platform.c b/src/libnm-platform/nm-platform.c index d5620446da..c6e6c544de 100644 --- a/src/libnm-platform/nm-platform.c +++ b/src/libnm-platform/nm-platform.c @@ -4662,7 +4662,25 @@ nm_platform_ip_address_get_prune_list(NMPlatform *self, c_list_for_each (iter, &head_entry->lst_entries_head) { const NMPObject *obj = c_list_entry(iter, NMDedupMultiEntry, lst_entries)->obj; - if (!IS_IPv4) { + if (IS_IPv4) { + const NMPlatformIP4Address *a4 = NMP_OBJECT_CAST_IP4_ADDRESS(obj); + + if (a4->address == NM_IPV4LO_NETWORK && a4->plen == 8) { + NMPlatformIP4Address addr = (NMPlatformIP4Address){ + .address = NM_IPV4LO_NETWORK, + .peer_address = NM_IPV4LO_NETWORK, + .use_ip4_broadcast_address = TRUE, + .ifindex = 1, + .plen = 8, + }; + if (nm_platform_ip4_address_cmp(a4, + &addr, + NM_PLATFORM_IP_ADDRESS_CMP_TYPE_SEMANTICALLY) + == 0) { + continue; + } + } + } else { const NMPlatformIP6Address *a6 = NMP_OBJECT_CAST_IP6_ADDRESS(obj); if (NM_FLAGS_HAS(a6->n_ifa_flags, IFA_F_SECONDARY) |