summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-09-16 13:18:54 +0200
committerThomas Haller <thaller@redhat.com>2020-09-24 09:43:55 +0200
commit000ad171e32877e558ade79c8bb478c4225cd67d (patch)
treeb9176ed8393e17251052b51e3530398b5331906e
parentdbfb7fe2d79c9421518c5350a0c3a1cb42b51110 (diff)
downloadNetworkManager-000ad171e32877e558ade79c8bb478c4225cd67d.tar.gz
l3cfg: add nm_l3cfg_has_commited_ipv6_pending_dad() function
This will be used for tracking IPv6 addresses that still have DAD pending. Currently, NMDevice does it differently (see "dad6").
-rw-r--r--src/nm-l3cfg.c50
-rw-r--r--src/nm-l3cfg.h4
2 files changed, 54 insertions, 0 deletions
diff --git a/src/nm-l3cfg.c b/src/nm-l3cfg.c
index eedee51a0d..9b71713d82 100644
--- a/src/nm-l3cfg.c
+++ b/src/nm-l3cfg.c
@@ -5,6 +5,7 @@
#include "nm-l3cfg.h"
#include <net/if.h>
+#include <linux/if_addr.h>
#include "platform/nm-platform.h"
#include "platform/nmp-object.h"
@@ -3080,6 +3081,55 @@ nm_l3cfg_get_best_default_route (NML3Cfg *self,
/*****************************************************************************/
+gboolean
+nm_l3cfg_has_commited_ip6_addresses_pending_dad (NML3Cfg *self)
+{
+ const NML3ConfigData *l3cd;
+ const NMPObject *plat_obj;
+ NMPLookup plat_lookup;
+ NMDedupMultiIter iter;
+
+ nm_assert (NM_IS_L3CFG (self));
+
+ l3cd = nm_l3cfg_get_combined_l3cd (self, TRUE);
+ if (!l3cd)
+ return FALSE;
+
+ /* we iterate over all addresses in platform, and check whether the tentative
+ * addresses are tracked by our l3cd. Not the other way around, because we assume
+ * that there are few addresses in platform that are still tentative, so
+ * we only need to lookup few platform addresses in l3cd.
+ *
+ * Of course, all lookups are O(1) anyway, so in any case the operation is
+ * O(n) (once "n" being the addresses in platform, and once in l3cd). */
+
+ nmp_lookup_init_object (&plat_lookup, NMP_OBJECT_TYPE_IP6_ADDRESS, self->priv.ifindex);
+
+ nm_platform_iter_obj_for_each (&iter,
+ self->priv.platform,
+ &plat_lookup,
+ &plat_obj) {
+ const NMPlatformIP6Address *plat_addr = NMP_OBJECT_CAST_IP6_ADDRESS (plat_obj);
+ const NMDedupMultiEntry *l3cd_entry;
+
+ if ( !NM_FLAGS_HAS (plat_addr->n_ifa_flags, IFA_F_TENTATIVE)
+ || NM_FLAGS_ANY (plat_addr->n_ifa_flags, IFA_F_DADFAILED
+ | IFA_F_OPTIMISTIC))
+ continue;
+
+ l3cd_entry = nm_l3_config_data_lookup_obj (l3cd, plat_obj);
+
+ nm_assert (NMP_OBJECT_CAST_IP6_ADDRESS (nm_dedup_multi_entry_get_obj (l3cd_entry)) == nm_l3_config_data_lookup_address_6 (l3cd, &plat_addr->address));
+
+ if (l3cd_entry)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/*****************************************************************************/
+
static void
set_property (GObject *object,
guint prop_id,
diff --git a/src/nm-l3cfg.h b/src/nm-l3cfg.h
index dfe8530ab6..4da85babde 100644
--- a/src/nm-l3cfg.h
+++ b/src/nm-l3cfg.h
@@ -229,4 +229,8 @@ const NMPObject *nm_l3cfg_get_best_default_route (NML3Cfg *self,
/*****************************************************************************/
+gboolean nm_l3cfg_has_commited_ip6_addresses_pending_dad (NML3Cfg *self);
+
+/*****************************************************************************/
+
#endif /* __NM_L3CFG_H__ */