summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-10-21 12:14:08 +0200
committerThomas Haller <thaller@redhat.com>2020-10-23 17:11:54 +0200
commitb38fbb3bf621a45c8a00beb290ae0c29fb226ba3 (patch)
treef2bb388f4bc4c4104028b05c3a413dc1ee6428d6
parent4561b3c114c13f5a8ad52917db89c949e748bb84 (diff)
l3cfg: add nm_l3_acd_addr_info_find_track_info() helper
-rw-r--r--src/nm-l3cfg.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/nm-l3cfg.h b/src/nm-l3cfg.h
index d89e2fa28..0bbe69240 100644
--- a/src/nm-l3cfg.h
+++ b/src/nm-l3cfg.h
@@ -55,6 +55,33 @@ typedef struct {
const NML3AcdAddrTrackInfo *track_infos;
} NML3AcdAddrInfo;
+static inline const NML3AcdAddrTrackInfo *
+nm_l3_acd_addr_info_find_track_info(const NML3AcdAddrInfo *addr_info,
+ gconstpointer tag,
+ const NML3ConfigData * l3cd,
+ const NMPObject * obj)
+{
+ guint i;
+ const NML3AcdAddrTrackInfo *ti;
+
+ nm_assert(addr_info);
+
+ /* we always expect that the number n_track_infos is reasonably small. Hence,
+ * a naive linear search is simplest and fastest (e.g. we don't have a hash table). */
+
+ for (i = 0, ti = addr_info->track_infos; i < addr_info->n_track_infos; i++, ti++) {
+ if (l3cd && ti->l3cd != l3cd)
+ continue;
+ if (tag && ti->tag != tag)
+ continue;
+ if (obj && ti->obj != obj)
+ continue;
+ return ti;
+ }
+
+ return NULL;
+}
+
typedef enum {
NM_L3_CONFIG_NOTIFY_TYPE_ROUTES_TEMPORARY_NOT_AVAILABLE_EXPIRED,