Preserve addresses

This commit is contained in:
Wen Liang 2022-07-18 11:19:44 -04:00
parent eeb9d320ea
commit 63b43dfd23
2 changed files with 25 additions and 0 deletions

View file

@ -4277,6 +4277,30 @@ _l3_commit_one(NML3Cfg *self,
}
}
if (self->priv.ifindex == 1) {
if (!addresses)
addresses = g_ptr_array_new_with_free_func((GDestroyNotify) nmp_object_unref);
if (IS_IPv4) {
g_ptr_array_add(addresses,
nmp_object_new(NMP_OBJECT_TYPE_IP4_ADDRESS,
&((const NMPlatformIP4Address){
.address = NM_IPV4LO_NETWORK,
.a_no_auto_noprefixroute = FALSE,
.ifindex = 1,
.plen = 8,
})));
} else {
g_ptr_array_add(addresses,
nmp_object_new(NMP_OBJECT_TYPE_IP6_ADDRESS,
&((const NMPlatformIP6Address){
.address = IN6ADDR_LOOPBACK_INIT,
.a_no_auto_noprefixroute = FALSE,
.ifindex = 1,
.plen = 128,
})));
}
}
/* FIXME(l3cfg): need to honor and set nm_l3_config_data_get_ndisc_*(). */
/* FIXME(l3cfg): need to honor and set nm_l3_config_data_get_mtu(). */

View file

@ -501,6 +501,7 @@ gboolean nm_utils_ip_is_site_local(int addr_family, const void *address);
#define NM_IPV4LL_NETWORK ((in_addr_t) (htonl(0xA9FE0000lu)))
#define NM_IPV4LL_NETMASK ((in_addr_t) (htonl(0xFFFF0000lu)))
#define NM_IPV4LO_NETWORK ((in_addr_t) (htonl(0x7F000001u)))
static inline gboolean
nm_utils_ip4_address_is_link_local(in_addr_t addr)