]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: do not save DNS= entries not match link ifindex
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 3 Jul 2020 09:29:13 +0000 (18:29 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 20 Jul 2020 19:08:22 +0000 (04:08 +0900)
src/network/networkd-link.c

index 7e7713519b3305452fa1138e3c4d32836a284c7a..1d73a3c34fe3ce0bde74cf40a67679240e72c66b 100644 (file)
@@ -4111,10 +4111,13 @@ static void print_link_hashmap(FILE *f, const char *prefix, Hashmap* h) {
         fputc('\n', f);
 }
 
-static void link_save_dns(FILE *f, struct in_addr_full **dns, unsigned n_dns, bool *space) {
+static void link_save_dns(Link *link, FILE *f, struct in_addr_full **dns, unsigned n_dns, bool *space) {
         for (unsigned j = 0; j < n_dns; j++) {
                 const char *str;
 
+                if (dns[j]->ifindex != 0 && dns[j]->ifindex != link->ifindex)
+                        continue;
+
                 str = in_addr_full_to_string(dns[j]);
                 if (!str)
                         continue;
@@ -4251,9 +4254,9 @@ int link_save(Link *link) {
                 fputs("DNS=", f);
                 space = false;
                 if (link->n_dns != (unsigned) -1)
-                        link_save_dns(f, link->dns, link->n_dns, &space);
+                        link_save_dns(link, f, link->dns, link->n_dns, &space);
                 else
-                        link_save_dns(f, link->network->dns, link->network->n_dns, &space);
+                        link_save_dns(link, f, link->network->dns, link->network->n_dns, &space);
 
                 serialize_addresses(f, NULL, &space,
                                     NULL,