l3cfg: add helper function to fetch all the IPv4 configured addresses

This function would be useful when performing operations related to the
IPv4 addresses configured on the l3cfg. E.g this function will be used
for getting the IPv4 to announce on a GARP on bonding-slb when one of
the ports failover.
This commit is contained in:
Fernando Fernandez Mancera
2024-10-24 03:05:27 +02:00
parent aa91d64606
commit 69f3493670
2 changed files with 26 additions and 0 deletions

View File

@@ -5552,6 +5552,30 @@ nm_l3cfg_get_best_default_route(NML3Cfg *self, int addr_family, gboolean get_com
return nm_l3_config_data_get_best_default_route(l3cd, addr_family);
}
in_addr_t *
nm_l3cfg_get_configured_ip4_addresses(NML3Cfg *self, gsize *out_len)
{
GArray *array = NULL;
NMDedupMultiIter iter;
const NMPObject *obj;
const NML3ConfigData *l3cd;
l3cd = nm_l3cfg_get_combined_l3cd(self, FALSE);
if (!l3cd)
return NULL;
array = g_array_new(FALSE, FALSE, sizeof(in_addr_t));
nm_l3_config_data_iter_obj_for_each (&iter, l3cd, &obj, NMP_OBJECT_TYPE_IP4_ADDRESS) {
in_addr_t tmp = NMP_OBJECT_CAST_IP4_ADDRESS(obj)->address;
nm_g_array_append_simple(array, tmp);
}
*out_len = array->len;
return NM_CAST_ALIGN(in_addr_t, g_array_free(array, FALSE));
}
/*****************************************************************************/
gboolean

View File

@@ -437,6 +437,8 @@ const NML3ConfigData *nm_l3cfg_get_combined_l3cd(NML3Cfg *self, gboolean get_com
const NMPObject *
nm_l3cfg_get_best_default_route(NML3Cfg *self, int addr_family, gboolean get_commited);
in_addr_t *nm_l3cfg_get_configured_ip4_addresses(NML3Cfg *self, gsize *out_len);
/*****************************************************************************/
gboolean nm_l3cfg_has_commited_ip6_addresses_pending_dad(NML3Cfg *self);