1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
3 #include <netinet/in.h>
4 #include <linux/if_arp.h>
7 #include "sd-dhcp-server.h"
9 #include "dhcp-protocol.h"
10 #include "dhcp-server-lease-internal.h"
13 #include "network-common.h"
14 #include "networkd-address.h"
15 #include "networkd-dhcp-server-bus.h"
16 #include "networkd-dhcp-server-static-lease.h"
17 #include "networkd-dhcp-server.h"
18 #include "networkd-link.h"
19 #include "networkd-manager.h"
20 #include "networkd-network.h"
21 #include "networkd-queue.h"
22 #include "networkd-route-util.h"
23 #include "parse-util.h"
24 #include "path-util.h"
25 #include "socket-netlink.h"
26 #include "string-table.h"
27 #include "string-util.h"
30 static bool link_dhcp4_server_enabled(Link
*link
) {
33 if (link
->flags
& IFF_LOOPBACK
)
39 if (link
->iftype
== ARPHRD_CAN
)
42 return link
->network
->dhcp_server
;
45 int network_adjust_dhcp_server(Network
*network
, Set
**addresses
) {
51 if (!network
->dhcp_server
)
55 log_warning("%s: DHCPServer= is enabled for bond slave. Disabling DHCP server.",
57 network
->dhcp_server
= false;
61 assert(network
->dhcp_server_address_prefixlen
<= 32);
63 if (network
->dhcp_server_address_prefixlen
== 0) {
66 /* If the server address is not specified, then find suitable static address. */
68 ORDERED_HASHMAP_FOREACH(address
, network
->addresses_by_section
) {
69 assert(!section_is_invalid(address
->section
));
71 if (address
->family
!= AF_INET
)
74 if (in4_addr_is_localhost(&address
->in_addr
.in
))
77 if (in4_addr_is_link_local(&address
->in_addr
.in
))
80 if (in4_addr_is_set(&address
->in_addr_peer
.in
))
83 /* TODO: check if the prefix length is small enough for the pool. */
85 network
->dhcp_server_address
= address
;
86 address
->used_by_dhcp_server
= true;
89 if (!network
->dhcp_server_address
) {
90 log_warning("%s: DHCPServer= is enabled, but no suitable static address configured. "
91 "Disabling DHCP server.",
93 network
->dhcp_server
= false;
98 _cleanup_(address_unrefp
) Address
*a
= NULL
;
102 /* TODO: check if the prefix length is small enough for the pool. */
104 /* If an address is explicitly specified, then check if the corresponding [Address] section
105 * is configured, and add one if not. */
107 existing
= set_get(*addresses
,
110 .in_addr
.in
= network
->dhcp_server_address_in_addr
,
111 .prefixlen
= network
->dhcp_server_address_prefixlen
,
114 /* Corresponding [Address] section already exists. */
115 network
->dhcp_server_address
= existing
;
119 r
= ordered_hashmap_by_section_find_unused_line(network
->addresses_by_section
, network
->filename
, &line
);
121 return log_warning_errno(r
, "%s: Failed to find unused line number for DHCP server address: %m",
124 r
= address_new_static(network
, network
->filename
, line
, &a
);
126 return log_warning_errno(r
, "%s: Failed to add new static address object for DHCP server: %m",
130 a
->prefixlen
= network
->dhcp_server_address_prefixlen
;
131 a
->in_addr
.in
= network
->dhcp_server_address_in_addr
;
132 a
->requested_as_null
= !in4_addr_is_set(&network
->dhcp_server_address_in_addr
);
133 a
->used_by_dhcp_server
= true;
135 r
= address_section_verify(a
);
139 r
= set_ensure_put(addresses
, &address_hash_ops
, a
);
144 network
->dhcp_server_address
= TAKE_PTR(a
);
150 static bool dhcp_server_persist_leases(Link
*link
) {
152 assert(link
->manager
);
153 assert(link
->network
);
155 if (in4_addr_is_set(&link
->network
->dhcp_server_relay_target
))
156 return false; /* On relay mode. Nothing saved in the persistent storage. */
158 if (link
->network
->dhcp_server_persist_leases
>= 0)
159 return link
->network
->dhcp_server_persist_leases
;
161 return link
->manager
->dhcp_server_persist_leases
;
164 int address_acquire_from_dhcp_server_leases_file(Link
*link
, const Address
*address
, union in_addr_union
*ret
) {
170 assert(link
->manager
);
174 /* If the DHCP server address is configured as a null address, reuse the server address of the
175 * previous instance. */
176 if (address
->family
!= AF_INET
)
179 if (!address
->used_by_dhcp_server
)
182 if (!link_dhcp4_server_enabled(link
))
185 if (!dhcp_server_persist_leases(link
))
188 if (link
->manager
->persistent_storage_fd
< 0)
189 return -EBUSY
; /* The persistent storage is not ready, try later again. */
191 _cleanup_free_
char *lease_file
= path_join("dhcp-server-lease", link
->ifname
);
195 r
= dhcp_server_leases_file_get_server_address(
196 link
->manager
->persistent_storage_fd
,
203 if (prefixlen
!= address
->prefixlen
)
210 int link_start_dhcp4_server(Link
*link
) {
214 assert(link
->manager
);
216 if (!link
->dhcp_server
)
217 return 0; /* Not configured yet. */
219 if (!link_has_carrier(link
))
222 if (sd_dhcp_server_is_running(link
->dhcp_server
))
223 return 0; /* already started. */
225 /* TODO: Maybe, also check the system time is synced. If the system does not have RTC battery, then
226 * the realtime clock in not usable in the early boot stage, and all saved leases may be wrongly
227 * handled as expired and dropped. */
228 if (dhcp_server_persist_leases(link
)) {
230 if (link
->manager
->persistent_storage_fd
< 0)
231 return 0; /* persistent storage is not ready. */
233 _cleanup_free_
char *lease_file
= path_join("dhcp-server-lease", link
->ifname
);
237 r
= sd_dhcp_server_set_lease_file(link
->dhcp_server
, link
->manager
->persistent_storage_fd
, lease_file
);
242 r
= sd_dhcp_server_start(link
->dhcp_server
);
246 log_link_debug(link
, "Offering DHCPv4 leases");
250 void manager_toggle_dhcp4_server_state(Manager
*manager
, bool start
) {
256 HASHMAP_FOREACH(link
, manager
->links_by_index
) {
257 if (!link
->dhcp_server
)
259 if (!dhcp_server_persist_leases(link
))
262 /* Even if 'start' is true, first we need to stop the server. Otherwise, we cannot (re)set
263 * the lease file in link_start_dhcp4_server(). */
264 r
= sd_dhcp_server_stop(link
->dhcp_server
);
266 log_link_debug_errno(link
, r
, "Failed to stop DHCP server, ignoring: %m");
271 r
= link_start_dhcp4_server(link
);
273 log_link_debug_errno(link
, r
, "Failed to start DHCP server, ignoring: %m");
277 static int dhcp_server_find_uplink(Link
*link
, Link
**ret
) {
280 if (link
->network
->dhcp_server_uplink_name
)
281 return link_get_by_name(link
->manager
, link
->network
->dhcp_server_uplink_name
, ret
);
283 if (link
->network
->dhcp_server_uplink_index
> 0)
284 return link_get_by_index(link
->manager
, link
->network
->dhcp_server_uplink_index
, ret
);
286 if (link
->network
->dhcp_server_uplink_index
== UPLINK_INDEX_AUTO
) {
287 /* It is not necessary to propagate error in automatic selection. */
288 if (manager_find_uplink(link
->manager
, AF_INET
, link
, ret
) < 0)
297 static int link_push_uplink_to_dhcp_server(
299 sd_dhcp_lease_server_type_t what
,
302 _cleanup_free_
struct in_addr
*addresses
= NULL
;
303 bool use_dhcp_lease_data
= true;
304 size_t n_addresses
= 0;
310 assert(link
->network
);
312 log_link_debug(link
, "Copying %s from link", dhcp_lease_server_type_to_string(what
));
316 case SD_DHCP_LEASE_DNS
:
317 /* For DNS we have a special case. We the data configured explicitly locally along with the
318 * data from the DHCP lease. */
320 for (unsigned i
= 0; i
< link
->network
->n_dns
; i
++) {
323 /* Only look for IPv4 addresses */
324 if (link
->network
->dns
[i
]->family
!= AF_INET
)
327 ia
= link
->network
->dns
[i
]->address
.in
;
329 /* Never propagate obviously borked data */
330 if (in4_addr_is_null(&ia
) || in4_addr_is_localhost(&ia
))
333 if (!GREEDY_REALLOC(addresses
, n_addresses
+ 1))
336 addresses
[n_addresses
++] = ia
;
339 use_dhcp_lease_data
= link
->network
->dhcp_use_dns
;
342 case SD_DHCP_LEASE_NTP
: {
343 /* For NTP things are similar, but for NTP hostnames can be configured too, which we cannot
344 * propagate via DHCP. Hence let's only propagate those which are IP addresses. */
346 STRV_FOREACH(i
, link
->network
->ntp
) {
347 union in_addr_union ia
;
349 if (in_addr_from_string(AF_INET
, *i
, &ia
) < 0)
352 /* Never propagate obviously borked data */
353 if (in4_addr_is_null(&ia
.in
) || in4_addr_is_localhost(&ia
.in
))
356 if (!GREEDY_REALLOC(addresses
, n_addresses
+ 1))
359 addresses
[n_addresses
++] = ia
.in
;
362 use_dhcp_lease_data
= link
->network
->dhcp_use_ntp
;
366 case SD_DHCP_LEASE_SIP
:
368 /* For SIP we don't allow explicit, local configuration, but there's control whether to use the data */
369 use_dhcp_lease_data
= link
->network
->dhcp_use_sip
;
372 case SD_DHCP_LEASE_POP3
:
373 case SD_DHCP_LEASE_SMTP
:
374 case SD_DHCP_LEASE_LPR
:
375 /* For the other server types we currently do not allow local configuration of server data,
376 * since there are typically no local consumers of the data. */
380 assert_not_reached();
383 if (use_dhcp_lease_data
&& link
->dhcp_lease
) {
384 const struct in_addr
*da
;
386 int n
= sd_dhcp_lease_get_servers(link
->dhcp_lease
, what
, &da
);
388 if (!GREEDY_REALLOC(addresses
, n_addresses
+ n
))
391 for (int j
= 0; j
< n
; j
++)
392 if (in4_addr_is_non_local(&da
[j
]))
393 addresses
[n_addresses
++] = da
[j
];
397 if (n_addresses
<= 0)
400 return sd_dhcp_server_set_servers(s
, what
, addresses
, n_addresses
);
403 static int dhcp4_server_parse_dns_server_string_and_warn(
405 struct in_addr
**addresses
,
406 size_t *n_addresses
) {
409 _cleanup_free_
char *word
= NULL
, *server_name
= NULL
;
410 union in_addr_union address
;
411 int family
, r
, ifindex
= 0;
413 r
= extract_first_word(&string
, &word
, NULL
, 0);
419 r
= in_addr_ifindex_name_from_string_auto(word
, &family
, &address
, &ifindex
, &server_name
);
421 log_warning_errno(r
, "Failed to parse DNS server address '%s', ignoring: %m", word
);
425 /* Only look for IPv4 addresses */
426 if (family
!= AF_INET
)
429 /* Never propagate obviously borked data */
430 if (in4_addr_is_null(&address
.in
) || in4_addr_is_localhost(&address
.in
))
433 if (!GREEDY_REALLOC(*addresses
, *n_addresses
+ 1))
436 (*addresses
)[(*n_addresses
)++] = address
.in
;
442 static int dhcp4_server_set_dns_from_resolve_conf(Link
*link
) {
443 _cleanup_free_
struct in_addr
*addresses
= NULL
;
444 _cleanup_fclose_
FILE *f
= NULL
;
445 size_t n_addresses
= 0;
448 f
= fopen(PRIVATE_UPLINK_RESOLV_CONF
, "re");
453 return log_warning_errno(errno
, "Failed to open " PRIVATE_UPLINK_RESOLV_CONF
": %m");
457 _cleanup_free_
char *line
= NULL
;
460 r
= read_stripped_line(f
, LONG_LINE_MAX
, &line
);
462 return log_error_errno(r
, "Failed to read " PRIVATE_UPLINK_RESOLV_CONF
": %m");
466 if (IN_SET(*line
, '#', ';', 0))
469 a
= first_word(line
, "nameserver");
473 r
= dhcp4_server_parse_dns_server_string_and_warn(a
, &addresses
, &n_addresses
);
475 log_warning_errno(r
, "Failed to parse DNS server address '%s', ignoring.", a
);
478 if (n_addresses
<= 0)
481 return sd_dhcp_server_set_dns(link
->dhcp_server
, addresses
, n_addresses
);
484 static int dhcp4_server_configure(Link
*link
) {
485 bool acquired_uplink
= false;
487 DHCPStaticLease
*static_lease
;
490 bool bind_to_interface
;
494 assert(link
->network
);
495 assert(link
->network
->dhcp_server_address
);
497 log_link_debug(link
, "Configuring DHCP Server.");
499 if (link
->dhcp_server
)
502 r
= sd_dhcp_server_new(&link
->dhcp_server
, link
->ifindex
);
506 r
= sd_dhcp_server_attach_event(link
->dhcp_server
, link
->manager
->event
, 0);
510 r
= sd_dhcp_server_set_callback(link
->dhcp_server
, dhcp_server_callback
, link
);
512 return log_link_warning_errno(link
, r
, "Failed to set callback for DHCPv4 server instance: %m");
514 r
= address_get(link
, link
->network
->dhcp_server_address
, &address
);
516 return log_link_error_errno(link
, r
, "Failed to find suitable address for DHCPv4 server instance: %m");
518 /* use the server address' subnet as the pool */
519 r
= sd_dhcp_server_configure_pool(link
->dhcp_server
, &address
->in_addr
.in
, address
->prefixlen
,
520 link
->network
->dhcp_server_pool_offset
, link
->network
->dhcp_server_pool_size
);
522 return log_link_error_errno(link
, r
, "Failed to configure address pool for DHCPv4 server instance: %m");
524 if (link
->network
->dhcp_server_max_lease_time_usec
> 0) {
525 r
= sd_dhcp_server_set_max_lease_time(link
->dhcp_server
, link
->network
->dhcp_server_max_lease_time_usec
);
527 return log_link_error_errno(link
, r
, "Failed to set maximum lease time for DHCPv4 server instance: %m");
530 if (link
->network
->dhcp_server_default_lease_time_usec
> 0) {
531 r
= sd_dhcp_server_set_default_lease_time(link
->dhcp_server
, link
->network
->dhcp_server_default_lease_time_usec
);
533 return log_link_error_errno(link
, r
, "Failed to set default lease time for DHCPv4 server instance: %m");
536 r
= sd_dhcp_server_set_ipv6_only_preferred_usec(link
->dhcp_server
, link
->network
->dhcp_server_ipv6_only_preferred_usec
);
538 return log_link_error_errno(link
, r
, "Failed to set IPv6 only preferred time for DHCPv4 server instance: %m");
540 r
= sd_dhcp_server_set_boot_server_address(link
->dhcp_server
, &link
->network
->dhcp_server_boot_server_address
);
542 return log_link_warning_errno(link
, r
, "Failed to set boot server address for DHCPv4 server instance: %m");
544 r
= sd_dhcp_server_set_boot_server_name(link
->dhcp_server
, link
->network
->dhcp_server_boot_server_name
);
546 return log_link_warning_errno(link
, r
, "Failed to set boot server name for DHCPv4 server instance: %m");
548 r
= sd_dhcp_server_set_boot_filename(link
->dhcp_server
, link
->network
->dhcp_server_boot_filename
);
550 return log_link_warning_errno(link
, r
, "Failed to set boot filename for DHCPv4 server instance: %m");
552 r
= sd_dhcp_server_set_rapid_commit(link
->dhcp_server
, link
->network
->dhcp_server_rapid_commit
);
554 return log_link_warning_errno(link
, r
, "Failed to %s Rapid Commit support for DHCPv4 server instance: %m",
555 enable_disable(link
->network
->dhcp_server_rapid_commit
));
557 for (sd_dhcp_lease_server_type_t type
= 0; type
< _SD_DHCP_LEASE_SERVER_TYPE_MAX
; type
++) {
559 if (!link
->network
->dhcp_server_emit
[type
].emit
)
562 if (link
->network
->dhcp_server_emit
[type
].n_addresses
> 0)
563 /* Explicitly specified servers to emit */
564 r
= sd_dhcp_server_set_servers(
567 link
->network
->dhcp_server_emit
[type
].addresses
,
568 link
->network
->dhcp_server_emit
[type
].n_addresses
);
570 /* Emission is requested, but nothing explicitly configured. Let's find a suitable upling */
571 if (!acquired_uplink
) {
572 (void) dhcp_server_find_uplink(link
, &uplink
);
573 acquired_uplink
= true;
576 if (uplink
&& uplink
->network
)
577 r
= link_push_uplink_to_dhcp_server(uplink
, type
, link
->dhcp_server
);
578 else if (type
== SD_DHCP_LEASE_DNS
)
579 r
= dhcp4_server_set_dns_from_resolve_conf(link
);
582 "Not emitting %s on link, couldn't find suitable uplink.",
583 dhcp_lease_server_type_to_string(type
));
589 log_link_warning_errno(link
, r
,
590 "Failed to set %s for DHCP server, ignoring: %m",
591 dhcp_lease_server_type_to_string(type
));
594 if (link
->network
->dhcp_server_emit_router
) {
595 r
= sd_dhcp_server_set_router(link
->dhcp_server
, &link
->network
->dhcp_server_router
);
597 return log_link_error_errno(link
, r
, "Failed to set router address for DHCP server: %m");
600 r
= sd_dhcp_server_set_relay_target(link
->dhcp_server
, &link
->network
->dhcp_server_relay_target
);
602 return log_link_error_errno(link
, r
, "Failed to set relay target for DHCP server: %m");
604 bind_to_interface
= sd_dhcp_server_is_in_relay_mode(link
->dhcp_server
) ? false : link
->network
->dhcp_server_bind_to_interface
;
605 r
= sd_dhcp_server_set_bind_to_interface(link
->dhcp_server
, bind_to_interface
);
607 return log_link_error_errno(link
, r
, "Failed to set interface binding for DHCP server: %m");
609 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
);
611 return log_link_error_errno(link
, r
, "Failed to set agent circuit/remote id for DHCP server: %m");
613 if (link
->network
->dhcp_server_emit_timezone
) {
614 _cleanup_free_
char *buffer
= NULL
;
615 const char *tz
= NULL
;
617 if (link
->network
->dhcp_server_timezone
)
618 tz
= link
->network
->dhcp_server_timezone
;
620 r
= get_timezone(&buffer
);
622 log_link_warning_errno(link
, r
, "Failed to determine timezone, not sending timezone: %m");
628 r
= sd_dhcp_server_set_timezone(link
->dhcp_server
, tz
);
630 return log_link_error_errno(link
, r
, "Failed to set timezone for DHCP server: %m");
634 ORDERED_HASHMAP_FOREACH(p
, link
->network
->dhcp_server_send_options
) {
635 r
= sd_dhcp_server_add_option(link
->dhcp_server
, p
);
639 return log_link_error_errno(link
, r
, "Failed to set DHCPv4 option: %m");
642 ORDERED_HASHMAP_FOREACH(p
, link
->network
->dhcp_server_send_vendor_options
) {
643 r
= sd_dhcp_server_add_vendor_option(link
->dhcp_server
, p
);
647 return log_link_error_errno(link
, r
, "Failed to set DHCPv4 option: %m");
650 HASHMAP_FOREACH(static_lease
, link
->network
->dhcp_static_leases_by_section
) {
651 r
= sd_dhcp_server_set_static_lease(link
->dhcp_server
, &static_lease
->address
, static_lease
->client_id
, static_lease
->client_id_size
);
653 return log_link_error_errno(link
, r
, "Failed to set DHCPv4 static lease for DHCP server: %m");
656 r
= link_start_dhcp4_server(link
);
658 return log_link_error_errno(link
, r
, "Could not start DHCPv4 server instance: %m");
663 static bool dhcp_server_is_ready_to_configure(Link
*link
) {
668 assert(link
->network
);
669 assert(link
->network
->dhcp_server_address
);
671 if (!link_is_ready_to_configure(link
, /* allow_unmanaged = */ false))
674 if (!link_has_carrier(link
))
677 if (!link
->static_addresses_configured
)
680 if (address_get(link
, link
->network
->dhcp_server_address
, &a
) < 0)
683 if (!address_is_ready(a
))
686 if (dhcp_server_find_uplink(link
, &uplink
) < 0)
689 if (uplink
&& !uplink
->network
)
695 static int dhcp_server_process_request(Request
*req
, Link
*link
, void *userdata
) {
700 if (!dhcp_server_is_ready_to_configure(link
))
703 r
= dhcp4_server_configure(link
);
705 return log_link_warning_errno(link
, r
, "Failed to configure DHCP server: %m");
710 int link_request_dhcp_server(Link
*link
) {
715 if (!link_dhcp4_server_enabled(link
))
718 if (link
->dhcp_server
)
721 log_link_debug(link
, "Requesting DHCP server.");
722 r
= link_queue_request(link
, REQUEST_TYPE_DHCP_SERVER
, dhcp_server_process_request
, NULL
);
724 return log_link_warning_errno(link
, r
, "Failed to request configuration of DHCP server: %m");
729 int config_parse_dhcp_server_relay_agent_suboption(
731 const char *filename
,
734 unsigned section_line
,
741 char **suboption_value
= data
;
748 if (isempty(rvalue
)) {
749 *suboption_value
= mfree(*suboption_value
);
753 p
= startswith(rvalue
, "string:");
755 log_syntax(unit
, LOG_WARNING
, filename
, line
, 0,
756 "Failed to parse %s=%s'. Invalid format, ignoring.", lvalue
, rvalue
);
759 return free_and_strdup(suboption_value
, empty_to_null(p
));
762 int config_parse_dhcp_server_emit(
764 const char *filename
,
767 unsigned section_line
,
774 NetworkDHCPServerEmitAddress
*emit
= ASSERT_PTR(data
);
778 if (isempty(rvalue
)) {
779 emit
->addresses
= mfree(emit
->addresses
);
780 emit
->n_addresses
= 0;
784 for (const char *p
= rvalue
;;) {
785 _cleanup_free_
char *w
= NULL
;
786 union in_addr_union a
;
789 r
= extract_first_word(&p
, &w
, NULL
, 0);
793 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
794 "Failed to extract word, ignoring: %s", rvalue
);
800 if (streq(w
, "_server_address"))
801 a
= IN_ADDR_NULL
; /* null address will be converted to the server address. */
803 r
= in_addr_from_string(AF_INET
, w
, &a
);
805 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
806 "Failed to parse %s= address '%s', ignoring: %m", lvalue
, w
);
810 if (in4_addr_is_null(&a
.in
)) {
811 log_syntax(unit
, LOG_WARNING
, filename
, line
, 0,
812 "Found a null address in %s=, ignoring.", lvalue
);
817 if (!GREEDY_REALLOC(emit
->addresses
, emit
->n_addresses
+ 1))
820 emit
->addresses
[emit
->n_addresses
++] = a
.in
;
824 int config_parse_dhcp_server_address(
826 const char *filename
,
829 unsigned section_line
,
836 Network
*network
= ASSERT_PTR(userdata
);
837 union in_addr_union a
;
838 unsigned char prefixlen
;
845 if (isempty(rvalue
)) {
846 network
->dhcp_server_address_in_addr
= (struct in_addr
) {};
847 network
->dhcp_server_address_prefixlen
= 0;
851 r
= in_addr_prefix_from_string(rvalue
, AF_INET
, &a
, &prefixlen
);
853 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
854 "Failed to parse %s=, ignoring assignment: %s", lvalue
, rvalue
);
857 if (in4_addr_is_localhost(&a
.in
) || in4_addr_is_link_local(&a
.in
)) {
858 log_syntax(unit
, LOG_WARNING
, filename
, line
, 0,
859 "DHCP server address cannot be a localhost or link-local address, "
860 "ignoring assignment: %s", rvalue
);
864 network
->dhcp_server_address_in_addr
= a
.in
;
865 network
->dhcp_server_address_prefixlen
= prefixlen
;
869 int config_parse_dhcp_server_ipv6_only_preferred(
871 const char *filename
,
874 unsigned section_line
,
881 usec_t t
, *usec
= ASSERT_PTR(data
);
889 if (isempty(rvalue
)) {
894 r
= parse_sec(rvalue
, &t
);
896 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
897 "Failed to parse [%s] %s=, ignoring assignment: %s", section
, lvalue
, rvalue
);
901 if (t
< MIN_V6ONLY_WAIT_USEC
&& !network_test_mode_enabled()) {
902 log_syntax(unit
, LOG_WARNING
, filename
, line
, 0,
903 "Invalid [%s] %s=, ignoring assignment: %s", section
, lvalue
, rvalue
);