2 This file is part of systemd.
4 Copyright 2013 Tom Gundersen <teg@jklm.no>
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
23 #include "alloc-util.h"
24 #include "conf-files.h"
25 #include "conf-parser.h"
26 #include "dns-domain.h"
28 #include "hostname-util.h"
29 #include "network-internal.h"
30 #include "networkd-manager.h"
31 #include "networkd-network.h"
32 #include "parse-util.h"
34 #include "stat-util.h"
35 #include "string-table.h"
36 #include "string-util.h"
39 static int network_load_one(Manager
*manager
, const char *filename
) {
40 _cleanup_network_free_ Network
*network
= NULL
;
41 _cleanup_fclose_
FILE *file
= NULL
;
43 const char *dropin_dirname
;
51 file
= fopen(filename
, "re");
59 if (null_or_empty_fd(fileno(file
))) {
60 log_debug("Skipping empty file: %s", filename
);
64 network
= new0(Network
, 1);
68 network
->manager
= manager
;
70 LIST_HEAD_INIT(network
->static_addresses
);
71 LIST_HEAD_INIT(network
->static_routes
);
72 LIST_HEAD_INIT(network
->static_fdb_entries
);
73 LIST_HEAD_INIT(network
->ipv6_proxy_ndp_addresses
);
75 network
->stacked_netdevs
= hashmap_new(&string_hash_ops
);
76 if (!network
->stacked_netdevs
)
79 network
->addresses_by_section
= hashmap_new(NULL
);
80 if (!network
->addresses_by_section
)
83 network
->routes_by_section
= hashmap_new(NULL
);
84 if (!network
->routes_by_section
)
87 network
->fdb_entries_by_section
= hashmap_new(NULL
);
88 if (!network
->fdb_entries_by_section
)
91 network
->filename
= strdup(filename
);
92 if (!network
->filename
)
95 network
->name
= strdup(basename(filename
));
99 d
= strrchr(network
->name
, '.');
103 assert(streq(d
, ".network"));
107 network
->dhcp
= ADDRESS_FAMILY_NO
;
108 network
->dhcp_use_ntp
= true;
109 network
->dhcp_use_dns
= true;
110 network
->dhcp_use_hostname
= true;
111 network
->dhcp_use_routes
= true;
112 network
->dhcp_send_hostname
= true;
113 network
->dhcp_route_metric
= DHCP_ROUTE_METRIC
;
114 network
->dhcp_client_identifier
= DHCP_CLIENT_ID_DUID
;
115 network
->dhcp_route_table
= RT_TABLE_MAIN
;
117 network
->dhcp_server_emit_dns
= true;
118 network
->dhcp_server_emit_ntp
= true;
119 network
->dhcp_server_emit_router
= true;
120 network
->dhcp_server_emit_timezone
= true;
122 network
->use_bpdu
= true;
123 network
->allow_port_to_be_root
= true;
124 network
->unicast_flood
= true;
126 network
->lldp_mode
= LLDP_MODE_ROUTERS_ONLY
;
128 network
->llmnr
= RESOLVE_SUPPORT_YES
;
129 network
->mdns
= RESOLVE_SUPPORT_NO
;
130 network
->dnssec_mode
= _DNSSEC_MODE_INVALID
;
132 network
->link_local
= ADDRESS_FAMILY_IPV6
;
134 network
->ipv6_privacy_extensions
= IPV6_PRIVACY_EXTENSIONS_NO
;
135 network
->ipv6_accept_ra
= -1;
136 network
->ipv6_dad_transmits
= -1;
137 network
->ipv6_hop_limit
= -1;
138 network
->duid
.type
= _DUID_TYPE_INVALID
;
139 network
->proxy_arp
= -1;
141 network
->ipv6_accept_ra_use_dns
= true;
142 network
->ipv6_accept_ra_route_table
= RT_TABLE_MAIN
;
144 dropin_dirname
= strjoina(network
->name
, ".network.d");
146 r
= config_parse_many(filename
, network_dirs
, dropin_dirname
,
153 "DHCPv4\0" /* compat */
156 "IPv6NDPProxyAddress\0"
160 config_item_perf_lookup
, network_network_gperf_lookup
,
165 /* IPMasquerade=yes implies IPForward=yes */
166 if (network
->ip_masquerade
)
167 network
->ip_forward
|= ADDRESS_FAMILY_IPV4
;
169 LIST_PREPEND(networks
, manager
->networks
, network
);
171 r
= hashmap_ensure_allocated(&manager
->networks_by_name
, &string_hash_ops
);
175 r
= hashmap_put(manager
->networks_by_name
, network
->name
, network
);
179 LIST_FOREACH(routes
, route
, network
->static_routes
) {
180 if (!route
->family
) {
181 log_warning("Route section without Gateway field configured in %s. "
182 "Ignoring", filename
);
187 LIST_FOREACH(addresses
, address
, network
->static_addresses
) {
188 if (!address
->family
) {
189 log_warning("Address section without Address field configured in %s. "
190 "Ignoring", filename
);
200 int network_load(Manager
*manager
) {
202 _cleanup_strv_free_
char **files
= NULL
;
208 while ((network
= manager
->networks
))
209 network_free(network
);
211 r
= conf_files_list_strv(&files
, ".network", NULL
, network_dirs
);
213 return log_error_errno(r
, "Failed to enumerate network files: %m");
215 STRV_FOREACH_BACKWARDS(f
, files
) {
216 r
= network_load_one(manager
, *f
);
224 void network_free(Network
*network
) {
229 IPv6ProxyNDPAddress
*ipv6_proxy_ndp_address
;
235 free(network
->filename
);
237 free(network
->match_mac
);
238 strv_free(network
->match_path
);
239 strv_free(network
->match_driver
);
240 strv_free(network
->match_type
);
241 strv_free(network
->match_name
);
243 free(network
->description
);
244 free(network
->dhcp_vendor_class_identifier
);
245 free(network
->dhcp_hostname
);
249 strv_free(network
->ntp
);
251 strv_free(network
->search_domains
);
252 strv_free(network
->route_domains
);
253 strv_free(network
->bind_carrier
);
255 netdev_unref(network
->bridge
);
256 netdev_unref(network
->bond
);
257 netdev_unref(network
->vrf
);
259 HASHMAP_FOREACH(netdev
, network
->stacked_netdevs
, i
) {
260 hashmap_remove(network
->stacked_netdevs
, netdev
->ifname
);
261 netdev_unref(netdev
);
263 hashmap_free(network
->stacked_netdevs
);
265 while ((route
= network
->static_routes
))
268 while ((address
= network
->static_addresses
))
269 address_free(address
);
271 while ((fdb_entry
= network
->static_fdb_entries
))
272 fdb_entry_free(fdb_entry
);
274 while ((ipv6_proxy_ndp_address
= network
->ipv6_proxy_ndp_addresses
))
275 ipv6_proxy_ndp_address_free(ipv6_proxy_ndp_address
);
277 hashmap_free(network
->addresses_by_section
);
278 hashmap_free(network
->routes_by_section
);
279 hashmap_free(network
->fdb_entries_by_section
);
281 if (network
->manager
) {
282 if (network
->manager
->networks
)
283 LIST_REMOVE(networks
, network
->manager
->networks
, network
);
285 if (network
->manager
->networks_by_name
)
286 hashmap_remove(network
->manager
->networks_by_name
, network
->name
);
291 condition_free_list(network
->match_host
);
292 condition_free_list(network
->match_virt
);
293 condition_free_list(network
->match_kernel
);
294 condition_free_list(network
->match_arch
);
296 free(network
->dhcp_server_timezone
);
297 free(network
->dhcp_server_dns
);
298 free(network
->dhcp_server_ntp
);
300 set_free_free(network
->dnssec_negative_trust_anchors
);
305 int network_get_by_name(Manager
*manager
, const char *name
, Network
**ret
) {
312 network
= hashmap_get(manager
->networks_by_name
, name
);
321 int network_get(Manager
*manager
, struct udev_device
*device
,
322 const char *ifname
, const struct ether_addr
*address
,
325 struct udev_device
*parent
;
326 const char *path
= NULL
, *parent_driver
= NULL
, *driver
= NULL
, *devtype
= NULL
;
332 path
= udev_device_get_property_value(device
, "ID_PATH");
334 parent
= udev_device_get_parent(device
);
336 parent_driver
= udev_device_get_driver(parent
);
338 driver
= udev_device_get_property_value(device
, "ID_NET_DRIVER");
340 devtype
= udev_device_get_devtype(device
);
343 LIST_FOREACH(networks
, network
, manager
->networks
) {
344 if (net_match_config(network
->match_mac
, network
->match_path
,
345 network
->match_driver
, network
->match_type
,
346 network
->match_name
, network
->match_host
,
347 network
->match_virt
, network
->match_kernel
,
349 address
, path
, parent_driver
, driver
,
351 if (network
->match_name
&& device
) {
353 uint8_t name_assign_type
= NET_NAME_UNKNOWN
;
355 attr
= udev_device_get_sysattr_value(device
, "name_assign_type");
357 (void) safe_atou8(attr
, &name_assign_type
);
359 if (name_assign_type
== NET_NAME_ENUM
)
360 log_warning("%s: found matching network '%s', based on potentially unpredictable ifname",
361 ifname
, network
->filename
);
363 log_debug("%s: found matching network '%s'", ifname
, network
->filename
);
365 log_debug("%s: found matching network '%s'", ifname
, network
->filename
);
377 int network_apply(Network
*network
, Link
*link
) {
383 link
->network
= network
;
385 if (network
->ipv4ll_route
) {
388 r
= route_new_static(network
, 0, &route
);
392 r
= inet_pton(AF_INET
, "169.254.0.0", &route
->dst
.in
);
398 route
->family
= AF_INET
;
399 route
->dst_prefixlen
= 16;
400 route
->scope
= RT_SCOPE_LINK
;
401 route
->priority
= IPV4LL_ROUTE_METRIC
;
402 route
->protocol
= RTPROT_STATIC
;
405 if (network
->n_dns
> 0 ||
406 !strv_isempty(network
->ntp
) ||
407 !strv_isempty(network
->search_domains
) ||
408 !strv_isempty(network
->route_domains
))
414 bool network_has_static_ipv6_addresses(Network
*network
) {
419 LIST_FOREACH(addresses
, address
, network
->static_addresses
) {
420 if (address
->family
== AF_INET6
)
427 int config_parse_netdev(const char *unit
,
428 const char *filename
,
431 unsigned section_line
,
437 Network
*network
= userdata
;
438 _cleanup_free_
char *kind_string
= NULL
;
449 kind_string
= strdup(lvalue
);
453 /* the keys are CamelCase versions of the kind */
454 for (p
= kind_string
; *p
; p
++)
457 kind
= netdev_kind_from_string(kind_string
);
458 if (kind
== _NETDEV_KIND_INVALID
) {
459 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Invalid NetDev kind: %s", lvalue
);
463 r
= netdev_get(network
->manager
, rvalue
, &netdev
);
465 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "%s could not be found, ignoring assignment: %s", lvalue
, rvalue
);
469 if (netdev
->kind
!= kind
) {
470 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "NetDev is not a %s, ignoring assignment: %s", lvalue
, rvalue
);
475 case NETDEV_KIND_BRIDGE
:
476 network
->bridge
= netdev
;
479 case NETDEV_KIND_BOND
:
480 network
->bond
= netdev
;
483 case NETDEV_KIND_VRF
:
484 network
->vrf
= netdev
;
487 case NETDEV_KIND_VLAN
:
488 case NETDEV_KIND_MACVLAN
:
489 case NETDEV_KIND_MACVTAP
:
490 case NETDEV_KIND_IPVLAN
:
491 case NETDEV_KIND_VXLAN
:
492 case NETDEV_KIND_VCAN
:
493 r
= hashmap_put(network
->stacked_netdevs
, netdev
->ifname
, netdev
);
495 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Can not add NetDev '%s' to network: %m", rvalue
);
501 assert_not_reached("Can not parse NetDev");
509 int config_parse_domains(
511 const char *filename
,
514 unsigned section_line
,
529 if (isempty(rvalue
)) {
530 n
->search_domains
= strv_free(n
->search_domains
);
531 n
->route_domains
= strv_free(n
->route_domains
);
537 _cleanup_free_
char *w
= NULL
, *normalized
= NULL
;
541 r
= extract_first_word(&p
, &w
, NULL
, 0);
543 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to extract search or route domain, ignoring: %s", rvalue
);
549 is_route
= w
[0] == '~';
550 domain
= is_route
? w
+ 1 : w
;
552 if (dns_name_is_root(domain
) || streq(domain
, "*")) {
553 /* If the root domain appears as is, or the special token "*" is found, we'll consider this as
554 * routing domain, unconditionally. */
556 domain
= "."; /* make sure we don't allow empty strings, thus write the root domain as "." */
559 r
= dns_name_normalize(domain
, &normalized
);
561 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "'%s' is not a valid domain name, ignoring.", domain
);
567 if (is_localhost(domain
)) {
568 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "'localhost' domain names may not be configure as search or route domains, ignoring assignment: %s", domain
);
574 r
= strv_extend(&n
->route_domains
, domain
);
579 r
= strv_extend(&n
->search_domains
, domain
);
585 strv_uniq(n
->route_domains
);
586 strv_uniq(n
->search_domains
);
591 int config_parse_tunnel(const char *unit
,
592 const char *filename
,
595 unsigned section_line
,
601 Network
*network
= userdata
;
610 r
= netdev_get(network
->manager
, rvalue
, &netdev
);
612 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Tunnel is invalid, ignoring assignment: %s", rvalue
);
616 if (netdev
->kind
!= NETDEV_KIND_IPIP
&&
617 netdev
->kind
!= NETDEV_KIND_SIT
&&
618 netdev
->kind
!= NETDEV_KIND_GRE
&&
619 netdev
->kind
!= NETDEV_KIND_GRETAP
&&
620 netdev
->kind
!= NETDEV_KIND_IP6GRE
&&
621 netdev
->kind
!= NETDEV_KIND_IP6GRETAP
&&
622 netdev
->kind
!= NETDEV_KIND_VTI
&&
623 netdev
->kind
!= NETDEV_KIND_VTI6
&&
624 netdev
->kind
!= NETDEV_KIND_IP6TNL
626 log_syntax(unit
, LOG_ERR
, filename
, line
, 0,
627 "NetDev is not a tunnel, ignoring assignment: %s", rvalue
);
631 r
= hashmap_put(network
->stacked_netdevs
, netdev
->ifname
, netdev
);
633 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Cannot add VLAN '%s' to network, ignoring: %m", rvalue
);
642 int config_parse_ipv4ll(
644 const char *filename
,
647 unsigned section_line
,
654 AddressFamilyBoolean
*link_local
= data
;
661 /* Note that this is mostly like
662 * config_parse_address_family_boolean(), except that it
663 * applies only to IPv4 */
665 SET_FLAG(*link_local
, ADDRESS_FAMILY_IPV4
, parse_boolean(rvalue
));
670 int config_parse_dhcp(
672 const char *filename
,
675 unsigned section_line
,
682 AddressFamilyBoolean
*dhcp
= data
, s
;
689 /* Note that this is mostly like
690 * config_parse_address_family_boolean(), except that it
691 * understands some old names for the enum values */
693 s
= address_family_boolean_from_string(rvalue
);
696 /* Previously, we had a slightly different enum here,
697 * support its values for compatbility. */
699 if (streq(rvalue
, "none"))
700 s
= ADDRESS_FAMILY_NO
;
701 else if (streq(rvalue
, "v4"))
702 s
= ADDRESS_FAMILY_IPV4
;
703 else if (streq(rvalue
, "v6"))
704 s
= ADDRESS_FAMILY_IPV6
;
705 else if (streq(rvalue
, "both"))
706 s
= ADDRESS_FAMILY_YES
;
708 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Failed to parse DHCP option, ignoring: %s", rvalue
);
717 static const char* const dhcp_client_identifier_table
[_DHCP_CLIENT_ID_MAX
] = {
718 [DHCP_CLIENT_ID_MAC
] = "mac",
719 [DHCP_CLIENT_ID_DUID
] = "duid"
722 DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(dhcp_client_identifier
, DCHPClientIdentifier
);
723 DEFINE_CONFIG_PARSE_ENUM(config_parse_dhcp_client_identifier
, dhcp_client_identifier
, DCHPClientIdentifier
, "Failed to parse client identifier type");
725 int config_parse_ipv6token(
727 const char *filename
,
730 unsigned section_line
,
737 union in_addr_union buffer
;
738 struct in6_addr
*token
= data
;
746 r
= in_addr_from_string(AF_INET6
, rvalue
, &buffer
);
748 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse IPv6 token, ignoring: %s", rvalue
);
752 r
= in_addr_is_null(AF_INET6
, &buffer
);
754 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "IPv6 token can not be the ANY address, ignoring: %s", rvalue
);
758 if ((buffer
.in6
.s6_addr32
[0] | buffer
.in6
.s6_addr32
[1]) != 0) {
759 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "IPv6 token can not be longer than 64 bits, ignoring: %s", rvalue
);
768 static const char* const ipv6_privacy_extensions_table
[_IPV6_PRIVACY_EXTENSIONS_MAX
] = {
769 [IPV6_PRIVACY_EXTENSIONS_NO
] = "no",
770 [IPV6_PRIVACY_EXTENSIONS_PREFER_PUBLIC
] = "prefer-public",
771 [IPV6_PRIVACY_EXTENSIONS_YES
] = "yes",
774 DEFINE_STRING_TABLE_LOOKUP(ipv6_privacy_extensions
, IPv6PrivacyExtensions
);
776 int config_parse_ipv6_privacy_extensions(
778 const char *filename
,
781 unsigned section_line
,
788 IPv6PrivacyExtensions
*ipv6_privacy_extensions
= data
;
794 assert(ipv6_privacy_extensions
);
796 /* Our enum shall be a superset of booleans, hence first try
797 * to parse as boolean, and then as enum */
799 k
= parse_boolean(rvalue
);
801 *ipv6_privacy_extensions
= IPV6_PRIVACY_EXTENSIONS_YES
;
803 *ipv6_privacy_extensions
= IPV6_PRIVACY_EXTENSIONS_NO
;
805 IPv6PrivacyExtensions s
;
807 s
= ipv6_privacy_extensions_from_string(rvalue
);
810 if (streq(rvalue
, "kernel"))
811 s
= _IPV6_PRIVACY_EXTENSIONS_INVALID
;
813 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Failed to parse IPv6 privacy extensions option, ignoring: %s", rvalue
);
818 *ipv6_privacy_extensions
= s
;
824 int config_parse_hostname(
826 const char *filename
,
829 unsigned section_line
,
836 char **hostname
= data
, *hn
= NULL
;
843 r
= config_parse_string(unit
, filename
, line
, section
, section_line
, lvalue
, ltype
, rvalue
, &hn
, userdata
);
847 if (!hostname_is_valid(hn
, false)) {
848 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Hostname is not valid, ignoring assignment: %s", rvalue
);
854 *hostname
= hostname_cleanup(hn
);
858 int config_parse_timezone(
860 const char *filename
,
863 unsigned section_line
,
870 char **datap
= data
, *tz
= NULL
;
877 r
= config_parse_string(unit
, filename
, line
, section
, section_line
, lvalue
, ltype
, rvalue
, &tz
, userdata
);
881 if (!timezone_is_valid(tz
)) {
882 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Timezone is not valid, ignoring assignment: %s", rvalue
);
893 int config_parse_dhcp_server_dns(
895 const char *filename
,
898 unsigned section_line
,
906 const char *p
= rvalue
;
914 _cleanup_free_
char *w
= NULL
;
915 struct in_addr a
, *m
;
917 r
= extract_first_word(&p
, &w
, NULL
, 0);
921 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to extract word, ignoring: %s", rvalue
);
927 if (inet_pton(AF_INET
, w
, &a
) <= 0) {
928 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Failed to parse DNS server address, ignoring: %s", w
);
932 m
= realloc(n
->dhcp_server_dns
, (n
->n_dhcp_server_dns
+ 1) * sizeof(struct in_addr
));
936 m
[n
->n_dhcp_server_dns
++] = a
;
937 n
->dhcp_server_dns
= m
;
943 int config_parse_dhcp_server_ntp(
945 const char *filename
,
948 unsigned section_line
,
956 const char *p
= rvalue
;
964 _cleanup_free_
char *w
= NULL
;
965 struct in_addr a
, *m
;
967 r
= extract_first_word(&p
, &w
, NULL
, 0);
971 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to extract word, ignoring: %s", rvalue
);
977 if (inet_pton(AF_INET
, w
, &a
) <= 0) {
978 log_syntax(unit
, LOG_ERR
, filename
, line
, 0, "Failed to parse NTP server address, ignoring: %s", w
);
982 m
= realloc(n
->dhcp_server_ntp
, (n
->n_dhcp_server_ntp
+ 1) * sizeof(struct in_addr
));
986 m
[n
->n_dhcp_server_ntp
++] = a
;
987 n
->dhcp_server_ntp
= m
;
991 int config_parse_dns(
993 const char *filename
,
996 unsigned section_line
,
1003 Network
*n
= userdata
;
1011 _cleanup_free_
char *w
= NULL
;
1012 union in_addr_union a
;
1013 struct in_addr_data
*m
;
1016 r
= extract_first_word(&rvalue
, &w
, NULL
, 0);
1020 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Invalid syntax, ignoring: %s", rvalue
);
1026 r
= in_addr_from_string_auto(w
, &family
, &a
);
1028 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to parse dns server address, ignoring: %s", w
);
1032 m
= realloc(n
->dns
, (n
->n_dns
+ 1) * sizeof(struct in_addr_data
));
1036 m
[n
->n_dns
++] = (struct in_addr_data
) {
1047 int config_parse_dnssec_negative_trust_anchors(
1049 const char *filename
,
1051 const char *section
,
1052 unsigned section_line
,
1059 const char *p
= rvalue
;
1067 if (isempty(rvalue
)) {
1068 n
->dnssec_negative_trust_anchors
= set_free_free(n
->dnssec_negative_trust_anchors
);
1073 _cleanup_free_
char *w
= NULL
;
1075 r
= extract_first_word(&p
, &w
, NULL
, 0);
1077 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to extract negative trust anchor domain, ignoring: %s", rvalue
);
1083 r
= dns_name_is_valid(w
);
1085 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "%s is not a valid domain name, ignoring.", w
);
1089 r
= set_ensure_allocated(&n
->dnssec_negative_trust_anchors
, &dns_name_hash_ops
);
1093 r
= set_put(n
->dnssec_negative_trust_anchors
, w
);
1103 int config_parse_ntp(
1105 const char *filename
,
1107 const char *section
,
1108 unsigned section_line
,
1122 if (isempty(rvalue
)) {
1128 _cleanup_free_
char *w
= NULL
;
1130 r
= extract_first_word(&rvalue
, &w
, NULL
, 0);
1134 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "Failed to extract NTP server name, ignoring: %s", rvalue
);
1140 r
= dns_name_is_valid_or_address(w
);
1142 log_syntax(unit
, LOG_ERR
, filename
, line
, r
, "%s is not a valid domain name or IP address, ignoring.", w
);
1146 r
= strv_push(l
, w
);
1156 int config_parse_dhcp_route_table(const char *unit
,
1157 const char *filename
,
1159 const char *section
,
1160 unsigned section_line
,
1174 r
= safe_atou32(rvalue
, &rt
);
1176 log_syntax(unit
, LOG_ERR
, filename
, line
, r
,
1177 "Unable to read RouteTable, ignoring assignment: %s", rvalue
);
1181 *((uint32_t *)data
) = rt
;
1186 DEFINE_CONFIG_PARSE_ENUM(config_parse_dhcp_use_domains
, dhcp_use_domains
, DHCPUseDomains
, "Failed to parse DHCP use domains setting");
1188 static const char* const dhcp_use_domains_table
[_DHCP_USE_DOMAINS_MAX
] = {
1189 [DHCP_USE_DOMAINS_NO
] = "no",
1190 [DHCP_USE_DOMAINS_ROUTE
] = "route",
1191 [DHCP_USE_DOMAINS_YES
] = "yes",
1194 DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(dhcp_use_domains
, DHCPUseDomains
, DHCP_USE_DOMAINS_YES
);
1196 DEFINE_CONFIG_PARSE_ENUM(config_parse_lldp_mode
, lldp_mode
, LLDPMode
, "Failed to parse LLDP= setting.");
1198 static const char* const lldp_mode_table
[_LLDP_MODE_MAX
] = {
1199 [LLDP_MODE_NO
] = "no",
1200 [LLDP_MODE_YES
] = "yes",
1201 [LLDP_MODE_ROUTERS_ONLY
] = "routers-only",
1204 DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(lldp_mode
, LLDPMode
, LLDP_MODE_YES
);