+ /* Add the full list to a set, to filter out duplicates */
+ dns = set_new(dns_server_hash_func, dns_server_compare_func);
+ if (!dns)
+ return -ENOMEM;
+
+ /* First add the system-wide servers */
+ LIST_FOREACH(servers, s, m->dns_servers) {
+ r = set_put(dns, s);
+ if (r == -EEXIST)
+ continue;
+ if (r < 0)
+ return r;
+ }
+
+ /* Then, add the per-link servers */
+ HASHMAP_FOREACH(l, m->links, i)
+ LIST_FOREACH(servers, s, l->dns_servers) {
+ r = set_put(dns, s);
+ if (r == -EEXIST)
+ continue;
+ if (r < 0)
+ return r;
+ }
+
+ /* If we found nothing, add the fallback servers */
+ if (set_isempty(dns)) {
+ LIST_FOREACH(servers, s, m->fallback_dns_servers) {
+ r = set_put(dns, s);
+ if (r == -EEXIST)
+ continue;
+ if (r < 0)
+ return r;
+ }
+ }
+