+/*
+ * Return a copy of the .ifa_name field passed as argument where the optional
+ * IP label, if present, is removed.
+ *
+ * example:
+ * - strip_optional_label("eth0") => "eth0"
+ * - strip_optional_label("eth0:label") => "eth0"
+ *
+ * The memory for the returned string is obtained with malloc(3), and can be
+ * freed with free(3).
+ *
+ *
+ */
+static char *strip_optional_label(const char *ifa_name) {
+ char *copy = sstrdup(ifa_name);
+
+ char *ptr = strchr(copy, ':');
+
+ if (ptr) {
+ *ptr = '\0';
+ }
+
+ return copy;
+}
+