]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/network/networkd-dhcp-server.c
Merge pull request #29121 from yuwata/network-drop-duplicated
[thirdparty/systemd.git] / src / network / networkd-dhcp-server.c
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 #include <netinet/in.h>
4 #include <net/if.h>
5 #include <linux/if_arp.h> /* Must be included after <net/if.h> */
6 #include <linux/if.h> /* Must be included after <net/if.h> */
7
8 #include "sd-dhcp-server.h"
9
10 #include "fd-util.h"
11 #include "fileio.h"
12 #include "networkd-address.h"
13 #include "networkd-dhcp-server-bus.h"
14 #include "networkd-dhcp-server-static-lease.h"
15 #include "networkd-dhcp-server.h"
16 #include "networkd-link.h"
17 #include "networkd-manager.h"
18 #include "networkd-network.h"
19 #include "networkd-queue.h"
20 #include "networkd-route-util.h"
21 #include "parse-util.h"
22 #include "socket-netlink.h"
23 #include "string-table.h"
24 #include "string-util.h"
25 #include "strv.h"
26
27 static bool link_dhcp4_server_enabled(Link *link) {
28 assert(link);
29
30 if (link->flags & IFF_LOOPBACK)
31 return false;
32
33 if (!link->network)
34 return false;
35
36 if (link->iftype == ARPHRD_CAN)
37 return false;
38
39 return link->network->dhcp_server;
40 }
41
42 void network_adjust_dhcp_server(Network *network) {
43 assert(network);
44
45 if (!network->dhcp_server)
46 return;
47
48 if (network->bond) {
49 log_warning("%s: DHCPServer= is enabled for bond slave. Disabling DHCP server.",
50 network->filename);
51 network->dhcp_server = false;
52 return;
53 }
54
55 if (!in4_addr_is_set(&network->dhcp_server_address)) {
56 Address *address;
57 bool have = false;
58
59 ORDERED_HASHMAP_FOREACH(address, network->addresses_by_section) {
60 if (section_is_invalid(address->section))
61 continue;
62
63 if (address->family != AF_INET)
64 continue;
65
66 if (in4_addr_is_localhost(&address->in_addr.in))
67 continue;
68
69 if (in4_addr_is_link_local(&address->in_addr.in))
70 continue;
71
72 if (in4_addr_is_set(&address->in_addr_peer.in))
73 continue;
74
75 have = true;
76 break;
77 }
78 if (!have) {
79 log_warning("%s: DHCPServer= is enabled, but no static address configured. "
80 "Disabling DHCP server.",
81 network->filename);
82 network->dhcp_server = false;
83 return;
84 }
85 }
86 }
87
88 int link_request_dhcp_server_address(Link *link) {
89 _cleanup_(address_freep) Address *address = NULL;
90 Address *existing;
91 int r;
92
93 assert(link);
94 assert(link->network);
95
96 if (!link_dhcp4_server_enabled(link))
97 return 0;
98
99 if (!in4_addr_is_set(&link->network->dhcp_server_address))
100 return 0;
101
102 r = address_new(&address);
103 if (r < 0)
104 return r;
105
106 address->source = NETWORK_CONFIG_SOURCE_STATIC;
107 address->family = AF_INET;
108 address->in_addr.in = link->network->dhcp_server_address;
109 address->prefixlen = link->network->dhcp_server_address_prefixlen;
110
111 if (address_get_harder(link, address, &existing) >= 0 &&
112 (address_exists(existing) || address_is_requesting(existing)) &&
113 existing->source == NETWORK_CONFIG_SOURCE_STATIC)
114 /* The same address seems explicitly configured in [Address] or [Network] section.
115 * Configure the DHCP server address only when it is not. */
116 return 0;
117
118 return link_request_static_address(link, address);
119 }
120
121 static int link_find_dhcp_server_address(Link *link, Address **ret) {
122 Address *address;
123
124 assert(link);
125 assert(link->network);
126
127 /* If ServerAddress= is specified, then use the address. */
128 if (in4_addr_is_set(&link->network->dhcp_server_address))
129 return link_get_ipv4_address(link, &link->network->dhcp_server_address,
130 link->network->dhcp_server_address_prefixlen, ret);
131
132 /* If not, then select one from static addresses. */
133 SET_FOREACH(address, link->addresses) {
134 if (address->source != NETWORK_CONFIG_SOURCE_STATIC)
135 continue;
136 if (!address_exists(address))
137 continue;
138 if (address->family != AF_INET)
139 continue;
140 if (in4_addr_is_localhost(&address->in_addr.in))
141 continue;
142 if (in4_addr_is_link_local(&address->in_addr.in))
143 continue;
144 if (in4_addr_is_set(&address->in_addr_peer.in))
145 continue;
146
147 *ret = address;
148 return 0;
149 }
150
151 return -ENOENT;
152 }
153
154 static int dhcp_server_find_uplink(Link *link, Link **ret) {
155 assert(link);
156
157 if (link->network->dhcp_server_uplink_name)
158 return link_get_by_name(link->manager, link->network->dhcp_server_uplink_name, ret);
159
160 if (link->network->dhcp_server_uplink_index > 0)
161 return link_get_by_index(link->manager, link->network->dhcp_server_uplink_index, ret);
162
163 if (link->network->dhcp_server_uplink_index == UPLINK_INDEX_AUTO) {
164 /* It is not necessary to propagate error in automatic selection. */
165 if (manager_find_uplink(link->manager, AF_INET, link, ret) < 0)
166 *ret = NULL;
167 return 0;
168 }
169
170 *ret = NULL;
171 return 0;
172 }
173
174 static int link_push_uplink_to_dhcp_server(
175 Link *link,
176 sd_dhcp_lease_server_type_t what,
177 sd_dhcp_server *s) {
178
179 _cleanup_free_ struct in_addr *addresses = NULL;
180 bool use_dhcp_lease_data = true;
181 size_t n_addresses = 0;
182
183 assert(link);
184
185 if (!link->network)
186 return 0;
187 assert(link->network);
188
189 log_link_debug(link, "Copying %s from link", dhcp_lease_server_type_to_string(what));
190
191 switch (what) {
192
193 case SD_DHCP_LEASE_DNS:
194 /* For DNS we have a special case. We the data configured explicitly locally along with the
195 * data from the DHCP lease. */
196
197 for (unsigned i = 0; i < link->network->n_dns; i++) {
198 struct in_addr ia;
199
200 /* Only look for IPv4 addresses */
201 if (link->network->dns[i]->family != AF_INET)
202 continue;
203
204 ia = link->network->dns[i]->address.in;
205
206 /* Never propagate obviously borked data */
207 if (in4_addr_is_null(&ia) || in4_addr_is_localhost(&ia))
208 continue;
209
210 if (!GREEDY_REALLOC(addresses, n_addresses + 1))
211 return log_oom();
212
213 addresses[n_addresses++] = ia;
214 }
215
216 use_dhcp_lease_data = link->network->dhcp_use_dns;
217 break;
218
219 case SD_DHCP_LEASE_NTP: {
220 /* For NTP things are similar, but for NTP hostnames can be configured too, which we cannot
221 * propagate via DHCP. Hence let's only propagate those which are IP addresses. */
222
223 STRV_FOREACH(i, link->network->ntp) {
224 union in_addr_union ia;
225
226 if (in_addr_from_string(AF_INET, *i, &ia) < 0)
227 continue;
228
229 /* Never propagate obviously borked data */
230 if (in4_addr_is_null(&ia.in) || in4_addr_is_localhost(&ia.in))
231 continue;
232
233 if (!GREEDY_REALLOC(addresses, n_addresses + 1))
234 return log_oom();
235
236 addresses[n_addresses++] = ia.in;
237 }
238
239 use_dhcp_lease_data = link->network->dhcp_use_ntp;
240 break;
241 }
242
243 case SD_DHCP_LEASE_SIP:
244
245 /* For SIP we don't allow explicit, local configuration, but there's control whether to use the data */
246 use_dhcp_lease_data = link->network->dhcp_use_sip;
247 break;
248
249 case SD_DHCP_LEASE_POP3:
250 case SD_DHCP_LEASE_SMTP:
251 case SD_DHCP_LEASE_LPR:
252 /* For the other server types we currently do not allow local configuration of server data,
253 * since there are typically no local consumers of the data. */
254 break;
255
256 default:
257 assert_not_reached();
258 }
259
260 if (use_dhcp_lease_data && link->dhcp_lease) {
261 const struct in_addr *da;
262
263 int n = sd_dhcp_lease_get_servers(link->dhcp_lease, what, &da);
264 if (n > 0) {
265 if (!GREEDY_REALLOC(addresses, n_addresses + n))
266 return log_oom();
267
268 for (int j = 0; j < n; j++)
269 if (in4_addr_is_non_local(&da[j]))
270 addresses[n_addresses++] = da[j];
271 }
272 }
273
274 if (n_addresses <= 0)
275 return 0;
276
277 return sd_dhcp_server_set_servers(s, what, addresses, n_addresses);
278 }
279
280 static int dhcp4_server_parse_dns_server_string_and_warn(
281 const char *string,
282 struct in_addr **addresses,
283 size_t *n_addresses) {
284
285 for (;;) {
286 _cleanup_free_ char *word = NULL, *server_name = NULL;
287 union in_addr_union address;
288 int family, r, ifindex = 0;
289
290 r = extract_first_word(&string, &word, NULL, 0);
291 if (r < 0)
292 return r;
293 if (r == 0)
294 break;
295
296 r = in_addr_ifindex_name_from_string_auto(word, &family, &address, &ifindex, &server_name);
297 if (r < 0) {
298 log_warning_errno(r, "Failed to parse DNS server address '%s', ignoring: %m", word);
299 continue;
300 }
301
302 /* Only look for IPv4 addresses */
303 if (family != AF_INET)
304 continue;
305
306 /* Never propagate obviously borked data */
307 if (in4_addr_is_null(&address.in) || in4_addr_is_localhost(&address.in))
308 continue;
309
310 if (!GREEDY_REALLOC(*addresses, *n_addresses + 1))
311 return log_oom();
312
313 (*addresses)[(*n_addresses)++] = address.in;
314 }
315
316 return 0;
317 }
318
319 static int dhcp4_server_set_dns_from_resolve_conf(Link *link) {
320 _cleanup_free_ struct in_addr *addresses = NULL;
321 _cleanup_fclose_ FILE *f = NULL;
322 size_t n_addresses = 0;
323 int r;
324
325 f = fopen(PRIVATE_UPLINK_RESOLV_CONF, "re");
326 if (!f) {
327 if (errno == ENOENT)
328 return 0;
329
330 return log_warning_errno(errno, "Failed to open " PRIVATE_UPLINK_RESOLV_CONF ": %m");
331 }
332
333 for (;;) {
334 _cleanup_free_ char *line = NULL;
335 const char *a;
336 char *l;
337
338 r = read_line(f, LONG_LINE_MAX, &line);
339 if (r < 0)
340 return log_error_errno(r, "Failed to read " PRIVATE_UPLINK_RESOLV_CONF ": %m");
341 if (r == 0)
342 break;
343
344 l = strstrip(line);
345 if (IN_SET(*l, '#', ';', 0))
346 continue;
347
348 a = first_word(l, "nameserver");
349 if (!a)
350 continue;
351
352 r = dhcp4_server_parse_dns_server_string_and_warn(a, &addresses, &n_addresses);
353 if (r < 0)
354 log_warning_errno(r, "Failed to parse DNS server address '%s', ignoring.", a);
355 }
356
357 if (n_addresses <= 0)
358 return 0;
359
360 return sd_dhcp_server_set_dns(link->dhcp_server, addresses, n_addresses);
361 }
362
363 static int dhcp4_server_configure(Link *link) {
364 bool acquired_uplink = false;
365 sd_dhcp_option *p;
366 DHCPStaticLease *static_lease;
367 Link *uplink = NULL;
368 Address *address;
369 bool bind_to_interface;
370 int r;
371
372 assert(link);
373
374 log_link_debug(link, "Configuring DHCP Server.");
375
376 if (link->dhcp_server)
377 return -EBUSY;
378
379 r = sd_dhcp_server_new(&link->dhcp_server, link->ifindex);
380 if (r < 0)
381 return r;
382
383 r = sd_dhcp_server_attach_event(link->dhcp_server, link->manager->event, 0);
384 if (r < 0)
385 return r;
386
387 r = sd_dhcp_server_set_callback(link->dhcp_server, dhcp_server_callback, link);
388 if (r < 0)
389 return log_link_warning_errno(link, r, "Failed to set callback for DHCPv4 server instance: %m");
390
391 r = link_find_dhcp_server_address(link, &address);
392 if (r < 0)
393 return log_link_error_errno(link, r, "Failed to find suitable address for DHCPv4 server instance: %m");
394
395 /* use the server address' subnet as the pool */
396 r = sd_dhcp_server_configure_pool(link->dhcp_server, &address->in_addr.in, address->prefixlen,
397 link->network->dhcp_server_pool_offset, link->network->dhcp_server_pool_size);
398 if (r < 0)
399 return log_link_error_errno(link, r, "Failed to configure address pool for DHCPv4 server instance: %m");
400
401 if (link->network->dhcp_server_max_lease_time_usec > 0) {
402 r = sd_dhcp_server_set_max_lease_time(link->dhcp_server,
403 DIV_ROUND_UP(link->network->dhcp_server_max_lease_time_usec, USEC_PER_SEC));
404 if (r < 0)
405 return log_link_error_errno(link, r, "Failed to set maximum lease time for DHCPv4 server instance: %m");
406 }
407
408 if (link->network->dhcp_server_default_lease_time_usec > 0) {
409 r = sd_dhcp_server_set_default_lease_time(link->dhcp_server,
410 DIV_ROUND_UP(link->network->dhcp_server_default_lease_time_usec, USEC_PER_SEC));
411 if (r < 0)
412 return log_link_error_errno(link, r, "Failed to set default lease time for DHCPv4 server instance: %m");
413 }
414
415 r = sd_dhcp_server_set_boot_server_address(link->dhcp_server, &link->network->dhcp_server_boot_server_address);
416 if (r < 0)
417 return log_link_warning_errno(link, r, "Failed to set boot server address for DHCPv4 server instance: %m");
418
419 r = sd_dhcp_server_set_boot_server_name(link->dhcp_server, link->network->dhcp_server_boot_server_name);
420 if (r < 0)
421 return log_link_warning_errno(link, r, "Failed to set boot server name for DHCPv4 server instance: %m");
422
423 r = sd_dhcp_server_set_boot_filename(link->dhcp_server, link->network->dhcp_server_boot_filename);
424 if (r < 0)
425 return log_link_warning_errno(link, r, "Failed to set boot filename for DHCPv4 server instance: %m");
426
427 for (sd_dhcp_lease_server_type_t type = 0; type < _SD_DHCP_LEASE_SERVER_TYPE_MAX; type ++) {
428
429 if (!link->network->dhcp_server_emit[type].emit)
430 continue;
431
432 if (link->network->dhcp_server_emit[type].n_addresses > 0)
433 /* Explicitly specified servers to emit */
434 r = sd_dhcp_server_set_servers(
435 link->dhcp_server,
436 type,
437 link->network->dhcp_server_emit[type].addresses,
438 link->network->dhcp_server_emit[type].n_addresses);
439 else {
440 /* Emission is requested, but nothing explicitly configured. Let's find a suitable upling */
441 if (!acquired_uplink) {
442 (void) dhcp_server_find_uplink(link, &uplink);
443 acquired_uplink = true;
444 }
445
446 if (uplink && uplink->network)
447 r = link_push_uplink_to_dhcp_server(uplink, type, link->dhcp_server);
448 else if (type == SD_DHCP_LEASE_DNS)
449 r = dhcp4_server_set_dns_from_resolve_conf(link);
450 else {
451 log_link_debug(link,
452 "Not emitting %s on link, couldn't find suitable uplink.",
453 dhcp_lease_server_type_to_string(type));
454 continue;
455 }
456 }
457
458 if (r < 0)
459 log_link_warning_errno(link, r,
460 "Failed to set %s for DHCP server, ignoring: %m",
461 dhcp_lease_server_type_to_string(type));
462 }
463
464 if (link->network->dhcp_server_emit_router) {
465 r = sd_dhcp_server_set_router(link->dhcp_server, &link->network->dhcp_server_router);
466 if (r < 0)
467 return log_link_error_errno(link, r, "Failed to set router address for DHCP server: %m");
468 }
469
470 r = sd_dhcp_server_set_relay_target(link->dhcp_server, &link->network->dhcp_server_relay_target);
471 if (r < 0)
472 return log_link_error_errno(link, r, "Failed to set relay target for DHCP server: %m");
473
474 bind_to_interface = sd_dhcp_server_is_in_relay_mode(link->dhcp_server) ? false : link->network->dhcp_server_bind_to_interface;
475 r = sd_dhcp_server_set_bind_to_interface(link->dhcp_server, bind_to_interface);
476 if (r < 0)
477 return log_link_error_errno(link, r, "Failed to set interface binding for DHCP server: %m");
478
479 r = sd_dhcp_server_set_relay_agent_information(link->dhcp_server, link->network->dhcp_server_relay_agent_circuit_id, link->network->dhcp_server_relay_agent_remote_id);
480 if (r < 0)
481 return log_link_error_errno(link, r, "Failed to set agent circuit/remote id for DHCP server: %m");
482
483 if (link->network->dhcp_server_emit_timezone) {
484 _cleanup_free_ char *buffer = NULL;
485 const char *tz = NULL;
486
487 if (link->network->dhcp_server_timezone)
488 tz = link->network->dhcp_server_timezone;
489 else {
490 r = get_timezone(&buffer);
491 if (r < 0)
492 log_link_warning_errno(link, r, "Failed to determine timezone, not sending timezone: %m");
493 else
494 tz = buffer;
495 }
496
497 if (tz) {
498 r = sd_dhcp_server_set_timezone(link->dhcp_server, tz);
499 if (r < 0)
500 return log_link_error_errno(link, r, "Failed to set timezone for DHCP server: %m");
501 }
502 }
503
504 ORDERED_HASHMAP_FOREACH(p, link->network->dhcp_server_send_options) {
505 r = sd_dhcp_server_add_option(link->dhcp_server, p);
506 if (r == -EEXIST)
507 continue;
508 if (r < 0)
509 return log_link_error_errno(link, r, "Failed to set DHCPv4 option: %m");
510 }
511
512 ORDERED_HASHMAP_FOREACH(p, link->network->dhcp_server_send_vendor_options) {
513 r = sd_dhcp_server_add_vendor_option(link->dhcp_server, p);
514 if (r == -EEXIST)
515 continue;
516 if (r < 0)
517 return log_link_error_errno(link, r, "Failed to set DHCPv4 option: %m");
518 }
519
520 HASHMAP_FOREACH(static_lease, link->network->dhcp_static_leases_by_section) {
521 r = sd_dhcp_server_set_static_lease(link->dhcp_server, &static_lease->address, static_lease->client_id, static_lease->client_id_size);
522 if (r < 0)
523 return log_link_error_errno(link, r, "Failed to set DHCPv4 static lease for DHCP server: %m");
524 }
525
526 r = sd_dhcp_server_start(link->dhcp_server);
527 if (r < 0)
528 return log_link_error_errno(link, r, "Could not start DHCPv4 server instance: %m");
529
530 log_link_debug(link, "Offering DHCPv4 leases");
531 return 0;
532 }
533
534 static bool dhcp_server_is_ready_to_configure(Link *link) {
535 Link *uplink = NULL;
536 Address *a;
537
538 assert(link);
539
540 if (!link_is_ready_to_configure(link, /* allow_unmanaged = */ false))
541 return false;
542
543 if (!link_has_carrier(link))
544 return false;
545
546 if (!link->static_addresses_configured)
547 return false;
548
549 if (link_find_dhcp_server_address(link, &a) < 0)
550 return false;
551
552 if (!address_is_ready(a))
553 return false;
554
555 if (dhcp_server_find_uplink(link, &uplink) < 0)
556 return false;
557
558 if (uplink && !uplink->network)
559 return false;
560
561 return true;
562 }
563
564 static int dhcp_server_process_request(Request *req, Link *link, void *userdata) {
565 int r;
566
567 assert(link);
568
569 if (!dhcp_server_is_ready_to_configure(link))
570 return 0;
571
572 r = dhcp4_server_configure(link);
573 if (r < 0)
574 return log_link_warning_errno(link, r, "Failed to configure DHCP server: %m");
575
576 return 1;
577 }
578
579 int link_request_dhcp_server(Link *link) {
580 int r;
581
582 assert(link);
583
584 if (!link_dhcp4_server_enabled(link))
585 return 0;
586
587 if (link->dhcp_server)
588 return 0;
589
590 log_link_debug(link, "Requesting DHCP server.");
591 r = link_queue_request(link, REQUEST_TYPE_DHCP_SERVER, dhcp_server_process_request, NULL);
592 if (r < 0)
593 return log_link_warning_errno(link, r, "Failed to request configuration of DHCP server: %m");
594
595 return 0;
596 }
597
598 int config_parse_dhcp_server_relay_agent_suboption(
599 const char *unit,
600 const char *filename,
601 unsigned line,
602 const char *section,
603 unsigned section_line,
604 const char *lvalue,
605 int ltype,
606 const char *rvalue,
607 void *data,
608 void *userdata) {
609
610 char **suboption_value = data;
611 char* p;
612
613 assert(filename);
614 assert(lvalue);
615 assert(rvalue);
616
617 if (isempty(rvalue)) {
618 *suboption_value = mfree(*suboption_value);
619 return 0;
620 }
621
622 p = startswith(rvalue, "string:");
623 if (!p) {
624 log_syntax(unit, LOG_WARNING, filename, line, 0,
625 "Failed to parse %s=%s'. Invalid format, ignoring.", lvalue, rvalue);
626 return 0;
627 }
628 return free_and_strdup(suboption_value, empty_to_null(p));
629 }
630
631 int config_parse_dhcp_server_emit(
632 const char *unit,
633 const char *filename,
634 unsigned line,
635 const char *section,
636 unsigned section_line,
637 const char *lvalue,
638 int ltype,
639 const char *rvalue,
640 void *data,
641 void *userdata) {
642
643 NetworkDHCPServerEmitAddress *emit = ASSERT_PTR(data);
644
645 assert(rvalue);
646
647 if (isempty(rvalue)) {
648 emit->addresses = mfree(emit->addresses);
649 emit->n_addresses = 0;
650 return 0;
651 }
652
653 for (const char *p = rvalue;;) {
654 _cleanup_free_ char *w = NULL;
655 union in_addr_union a;
656 int r;
657
658 r = extract_first_word(&p, &w, NULL, 0);
659 if (r == -ENOMEM)
660 return log_oom();
661 if (r < 0) {
662 log_syntax(unit, LOG_WARNING, filename, line, r,
663 "Failed to extract word, ignoring: %s", rvalue);
664 return 0;
665 }
666 if (r == 0)
667 return 0;
668
669 if (streq(w, "_server_address"))
670 a = IN_ADDR_NULL; /* null address will be converted to the server address. */
671 else {
672 r = in_addr_from_string(AF_INET, w, &a);
673 if (r < 0) {
674 log_syntax(unit, LOG_WARNING, filename, line, r,
675 "Failed to parse %s= address '%s', ignoring: %m", lvalue, w);
676 continue;
677 }
678
679 if (in4_addr_is_null(&a.in)) {
680 log_syntax(unit, LOG_WARNING, filename, line, 0,
681 "Found a null address in %s=, ignoring.", lvalue);
682 continue;
683 }
684 }
685
686 if (!GREEDY_REALLOC(emit->addresses, emit->n_addresses + 1))
687 return log_oom();
688
689 emit->addresses[emit->n_addresses++] = a.in;
690 }
691 }
692
693 int config_parse_dhcp_server_address(
694 const char *unit,
695 const char *filename,
696 unsigned line,
697 const char *section,
698 unsigned section_line,
699 const char *lvalue,
700 int ltype,
701 const char *rvalue,
702 void *data,
703 void *userdata) {
704
705 Network *network = ASSERT_PTR(userdata);
706 union in_addr_union a;
707 unsigned char prefixlen;
708 int r;
709
710 assert(filename);
711 assert(lvalue);
712 assert(rvalue);
713
714 if (isempty(rvalue)) {
715 network->dhcp_server_address = (struct in_addr) {};
716 network->dhcp_server_address_prefixlen = 0;
717 return 0;
718 }
719
720 r = in_addr_prefix_from_string(rvalue, AF_INET, &a, &prefixlen);
721 if (r < 0) {
722 log_syntax(unit, LOG_WARNING, filename, line, r,
723 "Failed to parse %s=, ignoring assignment: %s", lvalue, rvalue);
724 return 0;
725 }
726 if (in4_addr_is_null(&a.in) || in4_addr_is_localhost(&a.in)) {
727 log_syntax(unit, LOG_WARNING, filename, line, 0,
728 "DHCP server address cannot be the ANY address or a localhost address, "
729 "ignoring assignment: %s", rvalue);
730 return 0;
731 }
732
733 network->dhcp_server_address = a.in;
734 network->dhcp_server_address_prefixlen = prefixlen;
735 return 0;
736 }