core: misc fixes for loopback support

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
This commit is contained in:
Beniamino Galvani 2022-09-05 15:21:42 +02:00
parent 68d9bf84fc
commit 85cd932ed9
2 changed files with 28 additions and 7 deletions

View file

@ -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,

View file

@ -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)