2017-11-18 17:09:20 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
2013-10-17 03:18:36 +02:00
|
|
|
|
2019-05-09 02:33:45 +02:00
|
|
|
#include <net/if.h>
|
|
|
|
#include <netinet/in.h>
|
2019-04-10 12:55:53 +02:00
|
|
|
#include <linux/netdevice.h>
|
2014-05-08 19:22:53 +02:00
|
|
|
|
2015-10-27 03:01:06 +01:00
|
|
|
#include "alloc-util.h"
|
2013-10-17 03:18:36 +02:00
|
|
|
#include "conf-files.h"
|
|
|
|
#include "conf-parser.h"
|
2015-06-03 01:30:42 +02:00
|
|
|
#include "dns-domain.h"
|
2015-10-25 13:14:12 +01:00
|
|
|
#include "fd-util.h"
|
2015-10-24 22:58:24 +02:00
|
|
|
#include "hostname-util.h"
|
2017-08-14 11:53:10 +02:00
|
|
|
#include "in-addr-util.h"
|
2019-09-20 04:22:17 +02:00
|
|
|
#include "networkd-dhcp-server.h"
|
2015-08-27 13:59:06 +02:00
|
|
|
#include "network-internal.h"
|
2016-11-13 04:59:06 +01:00
|
|
|
#include "networkd-manager.h"
|
2015-10-25 13:14:12 +01:00
|
|
|
#include "networkd-network.h"
|
2015-10-26 16:18:16 +01:00
|
|
|
#include "parse-util.h"
|
2016-01-06 18:36:32 +01:00
|
|
|
#include "set.h"
|
2019-02-21 08:40:34 +01:00
|
|
|
#include "socket-util.h"
|
2015-10-26 22:01:44 +01:00
|
|
|
#include "stat-util.h"
|
2015-10-26 22:31:05 +01:00
|
|
|
#include "string-table.h"
|
2015-10-24 22:58:24 +02:00
|
|
|
#include "string-util.h"
|
2017-08-16 12:29:51 +02:00
|
|
|
#include "strv.h"
|
2020-02-10 12:53:00 +01:00
|
|
|
#include "tc.h"
|
2015-10-24 22:58:24 +02:00
|
|
|
#include "util.h"
|
2013-10-17 03:18:36 +02:00
|
|
|
|
2019-02-27 14:45:29 +01:00
|
|
|
/* Let's assume that anything above this number is a user misconfiguration. */
|
|
|
|
#define MAX_NTP_SERVERS 128
|
|
|
|
|
2017-08-03 01:10:51 +02:00
|
|
|
/* Set defaults following RFC7844 */
|
|
|
|
void network_apply_anonymize_if_set(Network *network) {
|
|
|
|
if (!network->dhcp_anonymize)
|
|
|
|
return;
|
|
|
|
/* RFC7844 3.7
|
|
|
|
SHOULD NOT send the Host Name option */
|
|
|
|
network->dhcp_send_hostname = false;
|
|
|
|
/* RFC7844 section 3.:
|
|
|
|
MAY contain the Client Identifier option
|
|
|
|
Section 3.5:
|
|
|
|
clients MUST use client identifiers based solely
|
|
|
|
on the link-layer address */
|
|
|
|
/* NOTE: Using MAC, as it does not reveal extra information,
|
|
|
|
* and some servers might not answer if this option is not sent */
|
|
|
|
network->dhcp_client_identifier = DHCP_CLIENT_ID_MAC;
|
|
|
|
/* RFC 7844 3.10:
|
|
|
|
SHOULD NOT use the Vendor Class Identifier option */
|
2018-09-27 10:48:11 +02:00
|
|
|
network->dhcp_vendor_class_identifier = mfree(network->dhcp_vendor_class_identifier);
|
2017-08-03 01:10:51 +02:00
|
|
|
/* RFC7844 section 3.6.:
|
|
|
|
The client intending to protect its privacy SHOULD only request a
|
|
|
|
minimal number of options in the PRL and SHOULD also randomly shuffle
|
|
|
|
the ordering of option codes in the PRL. If this random ordering
|
|
|
|
cannot be implemented, the client MAY order the option codes in the
|
|
|
|
PRL by option code number (lowest to highest).
|
|
|
|
*/
|
|
|
|
/* NOTE: dhcp_use_mtu is false by default,
|
|
|
|
* though it was not initiallized to any value in network_load_one.
|
|
|
|
* Maybe there should be another var called *send*?
|
|
|
|
* (to use the MTU sent by the server but to do not send
|
|
|
|
* the option in the PRL). */
|
|
|
|
network->dhcp_use_mtu = false;
|
2017-11-10 16:03:43 +01:00
|
|
|
/* NOTE: when Anonymize=yes, the PRL route options are sent by default,
|
|
|
|
* but this is needed to use them. */
|
|
|
|
network->dhcp_use_routes = true;
|
2017-08-03 01:10:51 +02:00
|
|
|
/* RFC7844 section 3.6.
|
|
|
|
* same comments as previous option */
|
|
|
|
network->dhcp_use_timezone = false;
|
|
|
|
}
|
|
|
|
|
2019-02-21 08:40:34 +01:00
|
|
|
static int network_resolve_netdev_one(Network *network, const char *name, NetDevKind kind, NetDev **ret_netdev) {
|
|
|
|
const char *kind_string;
|
|
|
|
NetDev *netdev;
|
|
|
|
int r;
|
|
|
|
|
2019-03-01 09:39:45 +01:00
|
|
|
/* For test-networkd-conf, the check must be earlier than the assertions. */
|
|
|
|
if (!name)
|
|
|
|
return 0;
|
|
|
|
|
2019-02-21 08:40:34 +01:00
|
|
|
assert(network);
|
|
|
|
assert(network->manager);
|
|
|
|
assert(network->filename);
|
|
|
|
assert(ret_netdev);
|
|
|
|
|
|
|
|
if (kind == _NETDEV_KIND_TUNNEL)
|
|
|
|
kind_string = "tunnel";
|
|
|
|
else {
|
|
|
|
kind_string = netdev_kind_to_string(kind);
|
|
|
|
if (!kind_string)
|
|
|
|
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
|
|
|
"%s: Invalid NetDev kind of %s, ignoring assignment.",
|
|
|
|
network->filename, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
r = netdev_get(network->manager, name, &netdev);
|
|
|
|
if (r < 0)
|
|
|
|
return log_error_errno(r, "%s: %s NetDev could not be found, ignoring assignment.",
|
|
|
|
network->filename, name);
|
|
|
|
|
|
|
|
if (netdev->kind != kind && !(kind == _NETDEV_KIND_TUNNEL &&
|
|
|
|
IN_SET(netdev->kind,
|
|
|
|
NETDEV_KIND_IPIP,
|
|
|
|
NETDEV_KIND_SIT,
|
|
|
|
NETDEV_KIND_GRE,
|
|
|
|
NETDEV_KIND_GRETAP,
|
|
|
|
NETDEV_KIND_IP6GRE,
|
|
|
|
NETDEV_KIND_IP6GRETAP,
|
|
|
|
NETDEV_KIND_VTI,
|
|
|
|
NETDEV_KIND_VTI6,
|
2019-03-29 19:34:03 +01:00
|
|
|
NETDEV_KIND_IP6TNL,
|
|
|
|
NETDEV_KIND_ERSPAN)))
|
2019-02-21 08:40:34 +01:00
|
|
|
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
|
|
|
"%s: NetDev %s is not a %s, ignoring assignment",
|
|
|
|
network->filename, name, kind_string);
|
|
|
|
|
|
|
|
*ret_netdev = netdev_ref(netdev);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int network_resolve_stacked_netdevs(Network *network) {
|
|
|
|
void *name, *kind;
|
|
|
|
Iterator i;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
assert(network);
|
|
|
|
|
|
|
|
HASHMAP_FOREACH_KEY(kind, name, network->stacked_netdev_names, i) {
|
|
|
|
_cleanup_(netdev_unrefp) NetDev *netdev = NULL;
|
|
|
|
|
|
|
|
r = network_resolve_netdev_one(network, name, PTR_TO_INT(kind), &netdev);
|
|
|
|
if (r <= 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
r = hashmap_ensure_allocated(&network->stacked_netdevs, &string_hash_ops);
|
|
|
|
if (r < 0)
|
|
|
|
return log_oom();
|
|
|
|
|
|
|
|
r = hashmap_put(network->stacked_netdevs, netdev->ifname, netdev);
|
|
|
|
if (r < 0)
|
|
|
|
return log_error_errno(r, "%s: Failed to add NetDev '%s' to network: %m",
|
|
|
|
network->filename, (const char *) name);
|
|
|
|
|
|
|
|
netdev = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-03-01 09:39:45 +01:00
|
|
|
int network_verify(Network *network) {
|
2019-11-05 14:31:20 +01:00
|
|
|
RoutePrefix *route_prefix, *route_prefix_next;
|
2019-09-20 04:22:17 +02:00
|
|
|
RoutingPolicyRule *rule, *rule_next;
|
2019-03-01 05:27:47 +01:00
|
|
|
Neighbor *neighbor, *neighbor_next;
|
|
|
|
AddressLabel *label, *label_next;
|
2019-10-04 21:40:51 +02:00
|
|
|
NextHop *nexthop, *nextnop_next;
|
2019-09-20 04:22:17 +02:00
|
|
|
Address *address, *address_next;
|
|
|
|
Prefix *prefix, *prefix_next;
|
|
|
|
Route *route, *route_next;
|
|
|
|
FdbEntry *fdb, *fdb_next;
|
2020-02-10 12:53:00 +01:00
|
|
|
TrafficControl *tc;
|
2019-11-24 12:31:38 +01:00
|
|
|
Iterator i;
|
2019-02-19 04:36:15 +01:00
|
|
|
|
|
|
|
assert(network);
|
|
|
|
assert(network->filename);
|
|
|
|
|
2019-01-07 12:16:19 +01:00
|
|
|
if (set_isempty(network->match_mac) && set_isempty(network->match_permanent_mac) &&
|
|
|
|
strv_isempty(network->match_path) && strv_isempty(network->match_driver) &&
|
|
|
|
strv_isempty(network->match_type) && strv_isempty(network->match_name) &&
|
|
|
|
strv_isempty(network->match_property) && strv_isempty(network->match_ssid) && !network->conditions)
|
2020-02-04 08:42:50 +01:00
|
|
|
return log_warning_errno(SYNTHETIC_ERRNO(EINVAL),
|
|
|
|
"%s: No valid settings found in the [Match] section, ignoring file. "
|
|
|
|
"To match all interfaces, add Name=* in the [Match] section.",
|
|
|
|
network->filename);
|
2019-04-20 14:40:24 +02:00
|
|
|
|
2019-02-21 08:40:34 +01:00
|
|
|
/* skip out early if configuration does not match the environment */
|
2019-03-08 07:20:01 +01:00
|
|
|
if (!condition_test_list(network->conditions, NULL, NULL, NULL))
|
2019-02-21 08:40:34 +01:00
|
|
|
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
|
2019-02-27 13:34:51 +01:00
|
|
|
"%s: Conditions in the file do not match the system environment, skipping.",
|
|
|
|
network->filename);
|
2019-02-21 08:40:34 +01:00
|
|
|
|
|
|
|
(void) network_resolve_netdev_one(network, network->bond_name, NETDEV_KIND_BOND, &network->bond);
|
|
|
|
(void) network_resolve_netdev_one(network, network->bridge_name, NETDEV_KIND_BRIDGE, &network->bridge);
|
|
|
|
(void) network_resolve_netdev_one(network, network->vrf_name, NETDEV_KIND_VRF, &network->vrf);
|
|
|
|
(void) network_resolve_stacked_netdevs(network);
|
|
|
|
|
|
|
|
/* Free unnecessary entries. */
|
|
|
|
network->bond_name = mfree(network->bond_name);
|
|
|
|
network->bridge_name = mfree(network->bridge_name);
|
|
|
|
network->vrf_name = mfree(network->vrf_name);
|
|
|
|
network->stacked_netdev_names = hashmap_free_free_key(network->stacked_netdev_names);
|
|
|
|
|
2019-02-19 04:36:15 +01:00
|
|
|
if (network->bond) {
|
|
|
|
/* Bonding slave does not support addressing. */
|
|
|
|
if (network->ipv6_accept_ra > 0) {
|
2019-02-20 21:30:06 +01:00
|
|
|
log_warning("%s: Cannot enable IPv6AcceptRA= when Bond= is specified, disabling IPv6AcceptRA=.",
|
|
|
|
network->filename);
|
2019-02-19 04:36:15 +01:00
|
|
|
network->ipv6_accept_ra = 0;
|
|
|
|
}
|
|
|
|
if (network->link_local >= 0 && network->link_local != ADDRESS_FAMILY_NO) {
|
2019-02-20 21:30:06 +01:00
|
|
|
log_warning("%s: Cannot enable LinkLocalAddressing= when Bond= is specified, disabling LinkLocalAddressing=.",
|
|
|
|
network->filename);
|
2019-02-19 04:36:15 +01:00
|
|
|
network->link_local = ADDRESS_FAMILY_NO;
|
|
|
|
}
|
|
|
|
if (network->dhcp != ADDRESS_FAMILY_NO) {
|
2019-02-20 21:30:06 +01:00
|
|
|
log_warning("%s: Cannot enable DHCP= when Bond= is specified, disabling DHCP=.",
|
|
|
|
network->filename);
|
2019-02-19 04:36:15 +01:00
|
|
|
network->dhcp = ADDRESS_FAMILY_NO;
|
|
|
|
}
|
|
|
|
if (network->dhcp_server) {
|
2019-02-20 21:30:06 +01:00
|
|
|
log_warning("%s: Cannot enable DHCPServer= when Bond= is specified, disabling DHCPServer=.",
|
|
|
|
network->filename);
|
2019-02-19 04:36:15 +01:00
|
|
|
network->dhcp_server = false;
|
|
|
|
}
|
|
|
|
if (network->n_static_addresses > 0) {
|
2019-02-20 21:30:06 +01:00
|
|
|
log_warning("%s: Cannot set addresses when Bond= is specified, ignoring addresses.",
|
|
|
|
network->filename);
|
2019-02-19 04:36:15 +01:00
|
|
|
while ((address = network->static_addresses))
|
|
|
|
address_free(address);
|
|
|
|
}
|
|
|
|
if (network->n_static_routes > 0) {
|
2019-02-20 21:30:06 +01:00
|
|
|
log_warning("%s: Cannot set routes when Bond= is specified, ignoring routes.",
|
|
|
|
network->filename);
|
2019-02-19 04:36:15 +01:00
|
|
|
while ((route = network->static_routes))
|
|
|
|
route_free(route);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (network->link_local < 0)
|
2019-02-20 02:17:11 +01:00
|
|
|
network->link_local = network->bridge ? ADDRESS_FAMILY_NO : ADDRESS_FAMILY_IPV6;
|
|
|
|
|
2019-08-27 16:45:00 +02:00
|
|
|
if (!FLAGS_SET(network->link_local, ADDRESS_FAMILY_IPV6)) {
|
|
|
|
if (network->ipv6_accept_ra > 0) {
|
|
|
|
log_warning("%s: IPv6AcceptRA= is enabled by the .network file but IPv6 link local addressing is disabled. "
|
|
|
|
"Disabling IPv6AcceptRA=.", network->filename);
|
|
|
|
network->ipv6_accept_ra = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FLAGS_SET(network->dhcp, ADDRESS_FAMILY_IPV6)) {
|
|
|
|
log_warning("%s: DHCPv6 client is enabled by the .network file but IPv6 link local addressing is disabled. "
|
|
|
|
"Disabling DHCPv6 client.", network->filename);
|
|
|
|
SET_FLAG(network->dhcp, ADDRESS_FAMILY_IPV6, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (network->router_prefix_delegation != RADV_PREFIX_DELEGATION_NONE) {
|
|
|
|
log_warning("%s: IPv6PrefixDelegation= is enabled but IPv6 link local addressing is disabled. "
|
|
|
|
"Disabling IPv6PrefixDelegation=.", network->filename);
|
|
|
|
network->router_prefix_delegation = RADV_PREFIX_DELEGATION_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-04 11:16:12 +02:00
|
|
|
if (FLAGS_SET(network->link_local, ADDRESS_FAMILY_FALLBACK_IPV4) &&
|
|
|
|
!FLAGS_SET(network->dhcp, ADDRESS_FAMILY_IPV4)) {
|
|
|
|
log_warning("%s: fallback assignment of IPv4 link local address is enabled but DHCPv4 is disabled. "
|
|
|
|
"Disabling the fallback assignment.", network->filename);
|
|
|
|
SET_FLAG(network->link_local, ADDRESS_FAMILY_FALLBACK_IPV4, false);
|
|
|
|
}
|
|
|
|
|
2019-02-20 02:17:11 +01:00
|
|
|
if (network->ipv6_accept_ra < 0 && network->bridge)
|
|
|
|
network->ipv6_accept_ra = false;
|
2019-02-19 04:36:15 +01:00
|
|
|
|
|
|
|
/* IPMasquerade=yes implies IPForward=yes */
|
|
|
|
if (network->ip_masquerade)
|
|
|
|
network->ip_forward |= ADDRESS_FAMILY_IPV4;
|
|
|
|
|
2019-05-15 09:02:06 +02:00
|
|
|
if (network->mtu > 0 && network->dhcp_use_mtu) {
|
2019-02-19 04:36:15 +01:00
|
|
|
log_warning("%s: MTUBytes= in [Link] section and UseMTU= in [DHCP] section are set. "
|
|
|
|
"Disabling UseMTU=.", network->filename);
|
|
|
|
network->dhcp_use_mtu = false;
|
|
|
|
}
|
|
|
|
|
2019-06-03 05:31:13 +02:00
|
|
|
if (network->dhcp_critical >= 0) {
|
|
|
|
if (network->keep_configuration >= 0)
|
|
|
|
log_warning("%s: Both KeepConfiguration= and deprecated CriticalConnection= are set. "
|
|
|
|
"Ignoring CriticalConnection=.", network->filename);
|
|
|
|
else if (network->dhcp_critical)
|
|
|
|
/* CriticalConnection=yes also preserve foreign static configurations. */
|
|
|
|
network->keep_configuration = KEEP_CONFIGURATION_YES;
|
|
|
|
else
|
2019-10-01 17:12:31 +02:00
|
|
|
network->keep_configuration = KEEP_CONFIGURATION_NO;
|
2019-06-03 05:31:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (network->keep_configuration < 0)
|
2019-10-01 17:12:31 +02:00
|
|
|
network->keep_configuration = KEEP_CONFIGURATION_NO;
|
2019-06-03 05:31:13 +02:00
|
|
|
|
2019-02-27 10:22:40 +01:00
|
|
|
LIST_FOREACH_SAFE(addresses, address, address_next, network->static_addresses)
|
2019-03-01 05:27:47 +01:00
|
|
|
if (address_section_verify(address) < 0)
|
2019-02-27 10:22:40 +01:00
|
|
|
address_free(address);
|
|
|
|
|
2019-03-01 05:27:47 +01:00
|
|
|
LIST_FOREACH_SAFE(routes, route, route_next, network->static_routes)
|
|
|
|
if (route_section_verify(route, network) < 0)
|
2019-02-27 10:22:40 +01:00
|
|
|
route_free(route);
|
2019-02-19 04:36:15 +01:00
|
|
|
|
2019-10-04 21:40:51 +02:00
|
|
|
LIST_FOREACH_SAFE(nexthops, nexthop, nextnop_next, network->static_nexthops)
|
|
|
|
if (nexthop_section_verify(nexthop) < 0)
|
|
|
|
nexthop_free(nexthop);
|
|
|
|
|
2019-03-01 05:27:47 +01:00
|
|
|
LIST_FOREACH_SAFE(static_fdb_entries, fdb, fdb_next, network->static_fdb_entries)
|
|
|
|
if (section_is_invalid(fdb->section))
|
|
|
|
fdb_entry_free(fdb);
|
|
|
|
|
|
|
|
LIST_FOREACH_SAFE(neighbors, neighbor, neighbor_next, network->neighbors)
|
2019-07-10 20:08:31 +02:00
|
|
|
if (neighbor_section_verify(neighbor) < 0)
|
2019-03-01 05:27:47 +01:00
|
|
|
neighbor_free(neighbor);
|
|
|
|
|
|
|
|
LIST_FOREACH_SAFE(labels, label, label_next, network->address_labels)
|
|
|
|
if (section_is_invalid(label->section))
|
|
|
|
address_label_free(label);
|
|
|
|
|
|
|
|
LIST_FOREACH_SAFE(prefixes, prefix, prefix_next, network->static_prefixes)
|
|
|
|
if (section_is_invalid(prefix->section))
|
|
|
|
prefix_free(prefix);
|
|
|
|
|
2019-11-05 14:31:20 +01:00
|
|
|
LIST_FOREACH_SAFE(route_prefixes, route_prefix, route_prefix_next, network->static_route_prefixes)
|
|
|
|
if (section_is_invalid(route_prefix->section))
|
|
|
|
route_prefix_free(route_prefix);
|
2019-09-19 08:20:00 +02:00
|
|
|
|
2019-03-01 05:27:47 +01:00
|
|
|
LIST_FOREACH_SAFE(rules, rule, rule_next, network->rules)
|
2019-08-01 22:07:40 +02:00
|
|
|
if (routing_policy_rule_section_verify(rule) < 0)
|
2019-03-01 05:27:47 +01:00
|
|
|
routing_policy_rule_free(rule);
|
2019-02-27 10:41:49 +01:00
|
|
|
|
2019-11-24 12:31:38 +01:00
|
|
|
bool has_root = false, has_clsact = false;
|
2020-02-10 12:53:00 +01:00
|
|
|
ORDERED_HASHMAP_FOREACH(tc, network->tc_by_section, i)
|
|
|
|
if (traffic_control_section_verify(tc, &has_root, &has_clsact) < 0)
|
|
|
|
traffic_control_free(tc);
|
2019-11-24 12:31:38 +01:00
|
|
|
|
2019-02-19 04:36:15 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-10-23 15:20:48 +02:00
|
|
|
int network_load_one(Manager *manager, OrderedHashmap **networks, const char *filename) {
|
2019-01-18 04:55:15 +01:00
|
|
|
_cleanup_free_ char *fname = NULL, *name = NULL;
|
2019-05-04 07:52:38 +02:00
|
|
|
_cleanup_(network_unrefp) Network *network = NULL;
|
2013-10-17 03:18:36 +02:00
|
|
|
_cleanup_fclose_ FILE *file = NULL;
|
2016-07-09 16:55:26 +02:00
|
|
|
const char *dropin_dirname;
|
2019-01-18 04:55:15 +01:00
|
|
|
char *d;
|
2013-10-17 03:18:36 +02:00
|
|
|
int r;
|
|
|
|
|
2013-12-16 18:55:59 +01:00
|
|
|
assert(manager);
|
|
|
|
assert(filename);
|
|
|
|
|
2013-10-17 03:18:36 +02:00
|
|
|
file = fopen(filename, "re");
|
|
|
|
if (!file) {
|
|
|
|
if (errno == ENOENT)
|
|
|
|
return 0;
|
network: beef up ipv6 RA support considerably
This reworks sd-ndisc and networkd substantially to support IPv6 RA much more
comprehensively. Since the API is extended quite a bit networkd has been ported
over too, and the patch is not as straight-forward as one could wish. The
rework includes:
- Support for DNSSL, RDNSS and RA routing options in sd-ndisc and networkd. Two
new configuration options have been added to networkd to make this
configurable.
- sd-ndisc now exposes an sd_ndisc_router object that encapsulates a full RA
message, and has direct, friendly acessor functions for the singleton RA
properties, as well as an iterative interface to iterate through known and
unsupported options. The router object may either be retrieved from the wire,
or generated from raw data. In many ways the sd-ndisc API now matches the
sd-lldp API, except that no implicit database of seen data is kept. (Note
that sd-ndisc actually had a half-written, but unused implementaiton of such
a store, which is removed now.)
- sd-ndisc will now collect the reception timestamps of RA, which is useful to
make sd_ndisc_router fully descriptive of what it covers.
Fixes: #1079
2016-06-02 20:38:12 +02:00
|
|
|
|
|
|
|
return -errno;
|
2013-10-17 03:18:36 +02:00
|
|
|
}
|
|
|
|
|
2014-07-17 00:59:49 +02:00
|
|
|
if (null_or_empty_fd(fileno(file))) {
|
|
|
|
log_debug("Skipping empty file: %s", filename);
|
2014-04-19 19:05:37 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-18 04:55:15 +01:00
|
|
|
fname = strdup(filename);
|
|
|
|
if (!fname)
|
|
|
|
return log_oom();
|
|
|
|
|
|
|
|
name = strdup(basename(filename));
|
|
|
|
if (!name)
|
|
|
|
return log_oom();
|
|
|
|
|
|
|
|
d = strrchr(name, '.');
|
|
|
|
if (!d)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
*d = '\0';
|
|
|
|
|
|
|
|
dropin_dirname = strjoina(name, ".network.d");
|
|
|
|
|
2018-11-12 06:55:52 +01:00
|
|
|
network = new(Network, 1);
|
2013-10-17 03:18:36 +02:00
|
|
|
if (!network)
|
|
|
|
return log_oom();
|
|
|
|
|
2018-11-12 06:55:52 +01:00
|
|
|
*network = (Network) {
|
2019-01-18 04:55:15 +01:00
|
|
|
.filename = TAKE_PTR(fname),
|
|
|
|
.name = TAKE_PTR(name),
|
2018-11-12 06:55:52 +01:00
|
|
|
|
2019-05-04 13:02:18 +02:00
|
|
|
.manager = manager,
|
2019-05-04 07:52:38 +02:00
|
|
|
.n_ref = 1,
|
|
|
|
|
2018-11-12 06:55:52 +01:00
|
|
|
.required_for_online = true,
|
2020-01-09 21:31:50 +01:00
|
|
|
.required_operstate_for_online = LINK_OPERSTATE_RANGE_DEFAULT,
|
2018-11-12 06:55:52 +01:00
|
|
|
.dhcp = ADDRESS_FAMILY_NO,
|
2019-06-03 05:31:13 +02:00
|
|
|
.dhcp_critical = -1,
|
2018-11-12 06:55:52 +01:00
|
|
|
.dhcp_use_ntp = true,
|
2019-09-18 15:22:47 +02:00
|
|
|
.dhcp_use_sip = true,
|
2018-11-12 06:55:52 +01:00
|
|
|
.dhcp_use_dns = true,
|
|
|
|
.dhcp_use_hostname = true,
|
|
|
|
.dhcp_use_routes = true,
|
2019-04-27 02:22:40 +02:00
|
|
|
/* NOTE: this var might be overwritten by network_apply_anonymize_if_set */
|
2018-11-12 06:55:52 +01:00
|
|
|
.dhcp_send_hostname = true,
|
2019-10-01 17:25:31 +02:00
|
|
|
.dhcp_send_release = true,
|
2018-11-12 06:55:52 +01:00
|
|
|
/* To enable/disable RFC7844 Anonymity Profiles */
|
|
|
|
.dhcp_anonymize = false,
|
|
|
|
.dhcp_route_metric = DHCP_ROUTE_METRIC,
|
2019-05-04 08:05:11 +02:00
|
|
|
/* NOTE: this var might be overwritten by network_apply_anonymize_if_set */
|
2018-11-12 06:55:52 +01:00
|
|
|
.dhcp_client_identifier = DHCP_CLIENT_ID_DUID,
|
|
|
|
.dhcp_route_table = RT_TABLE_MAIN,
|
|
|
|
.dhcp_route_table_set = false,
|
|
|
|
/* NOTE: from man: UseMTU=... Defaults to false*/
|
|
|
|
.dhcp_use_mtu = false,
|
|
|
|
/* NOTE: from man: UseTimezone=... Defaults to "no".*/
|
|
|
|
.dhcp_use_timezone = false,
|
|
|
|
.rapid_commit = true,
|
|
|
|
|
2019-07-09 16:23:28 +02:00
|
|
|
.dhcp6_use_ntp = true,
|
|
|
|
.dhcp6_use_dns = true,
|
|
|
|
|
2018-11-12 06:55:52 +01:00
|
|
|
.dhcp_server_emit_dns = true,
|
|
|
|
.dhcp_server_emit_ntp = true,
|
2019-09-18 15:22:47 +02:00
|
|
|
.dhcp_server_emit_sip = true,
|
2018-11-12 06:55:52 +01:00
|
|
|
.dhcp_server_emit_router = true,
|
|
|
|
.dhcp_server_emit_timezone = true,
|
|
|
|
|
|
|
|
.router_emit_dns = true,
|
|
|
|
.router_emit_domains = true,
|
|
|
|
|
|
|
|
.use_bpdu = -1,
|
|
|
|
.hairpin = -1,
|
|
|
|
.fast_leave = -1,
|
|
|
|
.allow_port_to_be_root = -1,
|
|
|
|
.unicast_flood = -1,
|
2019-03-10 21:25:24 +01:00
|
|
|
.multicast_flood = -1,
|
2018-12-03 11:47:36 +01:00
|
|
|
.multicast_to_unicast = -1,
|
2019-03-10 21:25:24 +01:00
|
|
|
.neighbor_suppression = -1,
|
|
|
|
.learning = -1,
|
2019-05-04 16:51:13 +02:00
|
|
|
.bridge_proxy_arp = -1,
|
|
|
|
.bridge_proxy_arp_wifi = -1,
|
2018-11-12 06:55:52 +01:00
|
|
|
.priority = LINK_BRIDGE_PORT_PRIORITY_INVALID,
|
2019-05-09 02:32:12 +02:00
|
|
|
.multicast_router = _MULTICAST_ROUTER_INVALID,
|
2018-11-12 06:55:52 +01:00
|
|
|
|
|
|
|
.lldp_mode = LLDP_MODE_ROUTERS_ONLY,
|
|
|
|
|
2018-12-04 15:34:04 +01:00
|
|
|
.dns_default_route = -1,
|
2018-11-12 06:55:52 +01:00
|
|
|
.llmnr = RESOLVE_SUPPORT_YES,
|
|
|
|
.mdns = RESOLVE_SUPPORT_NO,
|
|
|
|
.dnssec_mode = _DNSSEC_MODE_INVALID,
|
|
|
|
.dns_over_tls_mode = _DNS_OVER_TLS_MODE_INVALID,
|
|
|
|
|
2019-02-19 04:36:15 +01:00
|
|
|
/* If LinkLocalAddressing= is not set, then set to ADDRESS_FAMILY_IPV6 later. */
|
2019-08-03 22:09:08 +02:00
|
|
|
.link_local = _ADDRESS_FAMILY_INVALID,
|
2018-11-12 06:55:52 +01:00
|
|
|
|
|
|
|
.ipv6_privacy_extensions = IPV6_PRIVACY_EXTENSIONS_NO,
|
|
|
|
.ipv6_accept_ra = -1,
|
|
|
|
.ipv6_dad_transmits = -1,
|
|
|
|
.ipv6_hop_limit = -1,
|
|
|
|
.ipv6_proxy_ndp = -1,
|
|
|
|
.duid.type = _DUID_TYPE_INVALID,
|
|
|
|
.proxy_arp = -1,
|
|
|
|
.arp = -1,
|
|
|
|
.multicast = -1,
|
|
|
|
.allmulticast = -1,
|
|
|
|
.ipv6_accept_ra_use_dns = true,
|
2019-02-14 16:35:17 +01:00
|
|
|
.ipv6_accept_ra_use_autonomous_prefix = true,
|
|
|
|
.ipv6_accept_ra_use_onlink_prefix = true,
|
2018-11-12 06:55:52 +01:00
|
|
|
.ipv6_accept_ra_route_table = RT_TABLE_MAIN,
|
2019-02-12 04:42:10 +01:00
|
|
|
.ipv6_accept_ra_route_table_set = false,
|
2019-03-11 15:25:20 +01:00
|
|
|
|
2019-06-03 05:31:13 +02:00
|
|
|
.keep_configuration = _KEEP_CONFIGURATION_INVALID,
|
|
|
|
|
2019-03-11 15:25:20 +01:00
|
|
|
.can_triple_sampling = -1,
|
2019-09-23 13:25:21 +02:00
|
|
|
.ip_service_type = -1,
|
2018-11-12 06:55:52 +01:00
|
|
|
};
|
2013-10-17 03:18:36 +02:00
|
|
|
|
2019-01-02 14:30:24 +01:00
|
|
|
r = config_parse_many(filename, NETWORK_DIRS, dropin_dirname,
|
2016-09-10 13:19:41 +02:00
|
|
|
"Match\0"
|
|
|
|
"Link\0"
|
|
|
|
"Network\0"
|
|
|
|
"Address\0"
|
2018-11-29 04:00:58 +01:00
|
|
|
"Neighbor\0"
|
2017-04-25 12:36:50 +02:00
|
|
|
"IPv6AddressLabel\0"
|
2017-09-14 21:51:39 +02:00
|
|
|
"RoutingPolicyRule\0"
|
2016-09-10 13:19:41 +02:00
|
|
|
"Route\0"
|
2019-10-04 21:40:51 +02:00
|
|
|
"NextHop\0"
|
2019-10-14 14:19:04 +02:00
|
|
|
"DHCP\0" /* compat */
|
|
|
|
"DHCPv4\0"
|
2019-07-09 16:23:28 +02:00
|
|
|
"DHCPv6\0"
|
2016-09-10 13:19:41 +02:00
|
|
|
"DHCPServer\0"
|
|
|
|
"IPv6AcceptRA\0"
|
2017-02-11 00:47:55 +01:00
|
|
|
"IPv6NDPProxyAddress\0"
|
2016-09-10 13:19:41 +02:00
|
|
|
"Bridge\0"
|
|
|
|
"BridgeFDB\0"
|
2017-05-12 15:48:29 +02:00
|
|
|
"BridgeVLAN\0"
|
2017-05-12 15:48:30 +02:00
|
|
|
"IPv6PrefixDelegation\0"
|
2018-04-10 17:26:20 +02:00
|
|
|
"IPv6Prefix\0"
|
2019-09-14 13:14:22 +02:00
|
|
|
"IPv6RoutePrefix\0"
|
2019-10-07 16:19:00 +02:00
|
|
|
"TrafficControlQueueingDiscipline\0"
|
2020-02-04 13:45:29 +01:00
|
|
|
"CAN\0"
|
2020-02-05 11:10:33 +01:00
|
|
|
"QDisc\0"
|
2020-02-04 13:45:29 +01:00
|
|
|
"ControlledDelay\0"
|
2020-02-10 16:12:21 +01:00
|
|
|
"PFIFO\0"
|
2020-02-04 17:35:12 +01:00
|
|
|
"FairQueueing\0"
|
2020-02-04 13:45:29 +01:00
|
|
|
"FairQueueingControlledDelay\0"
|
2020-02-10 13:24:02 +01:00
|
|
|
"GenericRandomEarlyDetection\0"
|
2020-02-10 11:41:12 +01:00
|
|
|
"HierarchyTokenBucket\0"
|
2020-02-12 01:52:56 +01:00
|
|
|
"HierarchyTokenBucketClass\0"
|
2020-02-04 13:45:29 +01:00
|
|
|
"NetworkEmulator\0"
|
|
|
|
"StochasticFairnessQueueing\0"
|
2020-02-06 09:52:24 +01:00
|
|
|
"TokenBucketFilter\0"
|
|
|
|
"TrivialLinkEqualizer\0",
|
2016-09-10 13:19:41 +02:00
|
|
|
config_item_perf_lookup, network_network_gperf_lookup,
|
2017-11-09 00:26:11 +01:00
|
|
|
CONFIG_PARSE_WARN, network);
|
2019-02-22 01:38:19 +01:00
|
|
|
if (r < 0)
|
2013-10-17 03:18:36 +02:00
|
|
|
return r;
|
|
|
|
|
2017-08-03 01:10:51 +02:00
|
|
|
network_apply_anonymize_if_set(network);
|
|
|
|
|
2019-03-05 02:51:57 +01:00
|
|
|
r = network_add_ipv4ll_route(network);
|
|
|
|
if (r < 0)
|
|
|
|
log_warning_errno(r, "%s: Failed to add IPv4LL route, ignoring: %m", network->filename);
|
|
|
|
|
2019-05-14 09:43:14 +02:00
|
|
|
r = network_add_default_route_on_device(network);
|
|
|
|
if (r < 0)
|
|
|
|
log_warning_errno(r, "%s: Failed to add default route on device, ignoring: %m",
|
|
|
|
network->filename);
|
|
|
|
|
2019-10-23 15:20:48 +02:00
|
|
|
struct stat stats;
|
|
|
|
if (stat(filename, &stats) < 0)
|
|
|
|
return -errno;
|
|
|
|
network->timestamp = timespec_load(&stats.st_mtim);
|
|
|
|
|
|
|
|
if (network_verify(network) < 0)
|
|
|
|
/* Ignore .network files that do not match the conditions. */
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
r = ordered_hashmap_ensure_allocated(networks, &string_hash_ops);
|
2015-02-08 13:29:35 +01:00
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
|
2019-10-23 15:20:48 +02:00
|
|
|
r = ordered_hashmap_put(*networks, network->name, network);
|
2015-02-08 13:29:35 +01:00
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
|
2013-10-17 03:18:36 +02:00
|
|
|
network = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-10-23 15:20:48 +02:00
|
|
|
int network_load(Manager *manager, OrderedHashmap **networks) {
|
2014-01-03 01:49:49 +01:00
|
|
|
_cleanup_strv_free_ char **files = NULL;
|
|
|
|
char **f;
|
2013-10-17 03:18:36 +02:00
|
|
|
int r;
|
|
|
|
|
|
|
|
assert(manager);
|
|
|
|
|
2019-10-23 15:20:48 +02:00
|
|
|
ordered_hashmap_clear_with_destructor(*networks, network_unref);
|
2013-10-17 03:18:36 +02:00
|
|
|
|
2019-01-02 14:30:24 +01:00
|
|
|
r = conf_files_list_strv(&files, ".network", NULL, 0, NETWORK_DIRS);
|
2014-11-28 18:50:43 +01:00
|
|
|
if (r < 0)
|
|
|
|
return log_error_errno(r, "Failed to enumerate network files: %m");
|
2013-10-17 03:18:36 +02:00
|
|
|
|
2019-05-04 13:02:18 +02:00
|
|
|
STRV_FOREACH(f, files) {
|
2019-10-23 15:20:48 +02:00
|
|
|
r = network_load_one(manager, networks, *f);
|
2013-10-17 03:18:36 +02:00
|
|
|
if (r < 0)
|
2019-09-11 11:24:41 +02:00
|
|
|
log_error_errno(r, "Failed to load %s, ignoring: %m", *f);
|
2013-10-17 03:18:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-10-23 15:20:48 +02:00
|
|
|
int network_reload(Manager *manager) {
|
|
|
|
OrderedHashmap *new_networks = NULL;
|
|
|
|
Network *n, *old;
|
|
|
|
Iterator i;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
assert(manager);
|
|
|
|
|
|
|
|
r = network_load(manager, &new_networks);
|
|
|
|
if (r < 0)
|
|
|
|
goto failure;
|
|
|
|
|
|
|
|
ORDERED_HASHMAP_FOREACH(n, new_networks, i) {
|
|
|
|
r = network_get_by_name(manager, n->name, &old);
|
|
|
|
if (r < 0)
|
|
|
|
continue; /* The .network file is new. */
|
|
|
|
|
|
|
|
if (n->timestamp != old->timestamp)
|
|
|
|
continue; /* The .network file is modified. */
|
|
|
|
|
|
|
|
if (!streq(n->filename, old->filename))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
r = ordered_hashmap_replace(new_networks, old->name, old);
|
|
|
|
if (r < 0)
|
|
|
|
goto failure;
|
|
|
|
|
|
|
|
network_ref(old);
|
|
|
|
network_unref(n);
|
|
|
|
}
|
|
|
|
|
|
|
|
ordered_hashmap_free_with_destructor(manager->networks, network_unref);
|
|
|
|
manager->networks = new_networks;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
failure:
|
|
|
|
ordered_hashmap_free_with_destructor(new_networks, network_unref);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2019-05-04 07:52:38 +02:00
|
|
|
static Network *network_free(Network *network) {
|
2017-02-11 00:47:55 +01:00
|
|
|
IPv6ProxyNDPAddress *ipv6_proxy_ndp_address;
|
2019-11-05 14:31:20 +01:00
|
|
|
RoutePrefix *route_prefix;
|
2017-09-14 21:51:39 +02:00
|
|
|
RoutingPolicyRule *rule;
|
2019-11-05 14:31:20 +01:00
|
|
|
AddressLabel *label;
|
2017-09-14 21:51:39 +02:00
|
|
|
FdbEntry *fdb_entry;
|
2018-11-29 04:00:58 +01:00
|
|
|
Neighbor *neighbor;
|
2017-09-14 21:51:39 +02:00
|
|
|
Address *address;
|
2019-10-04 21:40:51 +02:00
|
|
|
NextHop *nexthop;
|
|
|
|
Prefix *prefix;
|
2017-09-14 21:51:39 +02:00
|
|
|
Route *route;
|
2013-10-17 03:18:36 +02:00
|
|
|
|
|
|
|
if (!network)
|
2019-05-04 07:52:38 +02:00
|
|
|
return NULL;
|
2013-10-17 03:18:36 +02:00
|
|
|
|
|
|
|
free(network->filename);
|
|
|
|
|
2018-05-09 04:59:18 +02:00
|
|
|
set_free_free(network->match_mac);
|
2019-01-07 12:16:19 +01:00
|
|
|
set_free_free(network->match_permanent_mac);
|
2015-02-10 18:30:16 +01:00
|
|
|
strv_free(network->match_path);
|
|
|
|
strv_free(network->match_driver);
|
|
|
|
strv_free(network->match_type);
|
|
|
|
strv_free(network->match_name);
|
2019-06-22 18:44:13 +02:00
|
|
|
strv_free(network->match_property);
|
2019-10-25 09:29:23 +02:00
|
|
|
strv_free(network->match_wlan_iftype);
|
2019-07-24 07:46:55 +02:00
|
|
|
strv_free(network->match_ssid);
|
2019-07-24 08:32:24 +02:00
|
|
|
set_free_free(network->match_bssid);
|
2019-03-08 07:20:01 +01:00
|
|
|
condition_free_list(network->conditions);
|
2013-10-17 03:18:36 +02:00
|
|
|
|
|
|
|
free(network->description);
|
2014-07-14 10:04:18 +02:00
|
|
|
free(network->dhcp_vendor_class_identifier);
|
2018-05-07 14:21:02 +02:00
|
|
|
strv_free(network->dhcp_user_class);
|
2016-01-25 21:47:02 +01:00
|
|
|
free(network->dhcp_hostname);
|
2019-05-01 00:47:41 +02:00
|
|
|
set_free(network->dhcp_black_listed_ip);
|
2019-09-17 14:49:22 +02:00
|
|
|
set_free(network->dhcp_request_options);
|
2014-12-04 21:57:13 +01:00
|
|
|
free(network->mac);
|
|
|
|
|
2019-12-20 14:13:18 +01:00
|
|
|
if (network->dhcp_acd)
|
|
|
|
sd_ipv4acd_unref(network->dhcp_acd);
|
|
|
|
|
2014-07-23 13:48:18 +02:00
|
|
|
strv_free(network->ntp);
|
2016-11-18 17:04:26 +01:00
|
|
|
free(network->dns);
|
2019-09-18 15:22:47 +02:00
|
|
|
strv_free(network->sip);
|
2019-02-20 22:50:25 +01:00
|
|
|
ordered_set_free_free(network->search_domains);
|
|
|
|
ordered_set_free_free(network->route_domains);
|
2015-02-17 13:06:57 +01:00
|
|
|
strv_free(network->bind_carrier);
|
2018-11-11 03:20:51 +01:00
|
|
|
|
2019-02-20 22:50:25 +01:00
|
|
|
ordered_set_free_free(network->router_search_domains);
|
2018-11-11 03:20:51 +01:00
|
|
|
free(network->router_dns);
|
2019-05-17 18:21:20 +02:00
|
|
|
set_free_free(network->ndisc_black_listed_prefix);
|
2014-01-05 23:01:10 +01:00
|
|
|
|
2019-02-21 08:40:34 +01:00
|
|
|
free(network->bridge_name);
|
|
|
|
free(network->bond_name);
|
|
|
|
free(network->vrf_name);
|
|
|
|
hashmap_free_free_key(network->stacked_netdev_names);
|
2014-05-08 19:28:17 +02:00
|
|
|
netdev_unref(network->bridge);
|
|
|
|
netdev_unref(network->bond);
|
2016-06-13 01:05:49 +02:00
|
|
|
netdev_unref(network->vrf);
|
2018-11-11 03:21:13 +01:00
|
|
|
hashmap_free_with_destructor(network->stacked_netdevs, netdev_unref);
|
2014-06-16 08:24:33 +02:00
|
|
|
|
2014-01-01 15:16:10 +01:00
|
|
|
while ((route = network->static_routes))
|
2013-10-17 03:18:36 +02:00
|
|
|
route_free(route);
|
|
|
|
|
2019-10-04 21:40:51 +02:00
|
|
|
while ((nexthop = network->static_nexthops))
|
|
|
|
nexthop_free(nexthop);
|
|
|
|
|
2014-01-01 15:16:10 +01:00
|
|
|
while ((address = network->static_addresses))
|
2013-10-17 03:18:36 +02:00
|
|
|
address_free(address);
|
|
|
|
|
2014-12-17 16:35:36 +01:00
|
|
|
while ((fdb_entry = network->static_fdb_entries))
|
|
|
|
fdb_entry_free(fdb_entry);
|
|
|
|
|
2017-02-11 00:47:55 +01:00
|
|
|
while ((ipv6_proxy_ndp_address = network->ipv6_proxy_ndp_addresses))
|
|
|
|
ipv6_proxy_ndp_address_free(ipv6_proxy_ndp_address);
|
|
|
|
|
2018-11-29 04:00:58 +01:00
|
|
|
while ((neighbor = network->neighbors))
|
|
|
|
neighbor_free(neighbor);
|
|
|
|
|
2017-04-25 12:36:50 +02:00
|
|
|
while ((label = network->address_labels))
|
|
|
|
address_label_free(label);
|
|
|
|
|
2017-05-12 15:48:28 +02:00
|
|
|
while ((prefix = network->static_prefixes))
|
|
|
|
prefix_free(prefix);
|
|
|
|
|
2019-11-05 14:31:20 +01:00
|
|
|
while ((route_prefix = network->static_route_prefixes))
|
|
|
|
route_prefix_free(route_prefix);
|
2019-11-05 01:39:44 +01:00
|
|
|
|
2017-09-14 21:51:39 +02:00
|
|
|
while ((rule = network->rules))
|
|
|
|
routing_policy_rule_free(rule);
|
|
|
|
|
2013-11-19 16:54:42 +01:00
|
|
|
hashmap_free(network->addresses_by_section);
|
|
|
|
hashmap_free(network->routes_by_section);
|
2019-10-04 21:40:51 +02:00
|
|
|
hashmap_free(network->nexthops_by_section);
|
2014-12-17 16:35:36 +01:00
|
|
|
hashmap_free(network->fdb_entries_by_section);
|
2018-11-29 04:00:58 +01:00
|
|
|
hashmap_free(network->neighbors_by_section);
|
2017-04-25 12:36:50 +02:00
|
|
|
hashmap_free(network->address_labels_by_section);
|
2017-05-12 15:48:28 +02:00
|
|
|
hashmap_free(network->prefixes_by_section);
|
2019-11-05 01:39:44 +01:00
|
|
|
hashmap_free(network->route_prefixes_by_section);
|
2017-09-14 21:51:39 +02:00
|
|
|
hashmap_free(network->rules_by_section);
|
2020-02-10 12:53:00 +01:00
|
|
|
ordered_hashmap_free_with_destructor(network->tc_by_section, traffic_control_free);
|
2013-11-19 16:54:42 +01:00
|
|
|
|
2019-10-23 15:20:48 +02:00
|
|
|
if (network->manager &&
|
|
|
|
network->manager->duids_requesting_uuid)
|
|
|
|
set_remove(network->manager->duids_requesting_uuid, &network->duid);
|
2015-02-08 13:29:35 +01:00
|
|
|
|
|
|
|
free(network->name);
|
2013-10-17 03:18:36 +02:00
|
|
|
|
2015-08-26 19:19:32 +02:00
|
|
|
free(network->dhcp_server_timezone);
|
2015-08-27 14:48:37 +02:00
|
|
|
free(network->dhcp_server_dns);
|
|
|
|
free(network->dhcp_server_ntp);
|
2019-09-18 15:22:47 +02:00
|
|
|
free(network->dhcp_server_sip);
|
2015-08-26 19:19:32 +02:00
|
|
|
|
2016-01-06 18:36:32 +01:00
|
|
|
set_free_free(network->dnssec_negative_trust_anchors);
|
|
|
|
|
2019-11-18 10:29:29 +01:00
|
|
|
ordered_hashmap_free(network->dhcp_client_send_options);
|
|
|
|
ordered_hashmap_free(network->dhcp_server_send_options);
|
2020-01-09 13:19:53 +01:00
|
|
|
ordered_hashmap_free(network->ipv6_tokens);
|
2019-09-26 20:06:02 +02:00
|
|
|
|
2019-05-04 07:52:38 +02:00
|
|
|
return mfree(network);
|
2013-10-17 03:18:36 +02:00
|
|
|
}
|
|
|
|
|
2019-05-04 07:52:38 +02:00
|
|
|
DEFINE_TRIVIAL_REF_UNREF_FUNC(Network, network, network_free);
|
|
|
|
|
2015-02-08 13:29:35 +01:00
|
|
|
int network_get_by_name(Manager *manager, const char *name, Network **ret) {
|
|
|
|
Network *network;
|
|
|
|
|
|
|
|
assert(manager);
|
|
|
|
assert(name);
|
|
|
|
assert(ret);
|
|
|
|
|
2019-05-04 13:02:18 +02:00
|
|
|
network = ordered_hashmap_get(manager->networks, name);
|
2015-02-08 13:29:35 +01:00
|
|
|
if (!network)
|
|
|
|
return -ENOENT;
|
|
|
|
|
|
|
|
*ret = network;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-08-22 07:30:49 +02:00
|
|
|
int network_get(Manager *manager, sd_device *device,
|
2019-01-07 12:16:19 +01:00
|
|
|
const char *ifname, char * const *alternative_names,
|
|
|
|
const struct ether_addr *address, const struct ether_addr *permanent_address,
|
2019-10-25 09:29:23 +02:00
|
|
|
enum nl80211_iftype wlan_iftype, const char *ssid, const struct ether_addr *bssid,
|
|
|
|
Network **ret) {
|
2018-08-22 07:30:49 +02:00
|
|
|
Network *network;
|
2019-05-04 13:02:18 +02:00
|
|
|
Iterator i;
|
2013-10-17 03:18:36 +02:00
|
|
|
|
|
|
|
assert(manager);
|
|
|
|
assert(ret);
|
2015-03-26 21:53:38 +01:00
|
|
|
|
2019-05-04 13:02:18 +02:00
|
|
|
ORDERED_HASHMAP_FOREACH(network, manager->networks, i)
|
2019-01-07 12:16:19 +01:00
|
|
|
if (net_match_config(network->match_mac, network->match_permanent_mac,
|
|
|
|
network->match_path, network->match_driver,
|
2019-06-22 18:44:13 +02:00
|
|
|
network->match_type, network->match_name, network->match_property,
|
2019-10-25 09:29:23 +02:00
|
|
|
network->match_wlan_iftype, network->match_ssid, network->match_bssid,
|
2019-01-07 12:16:19 +01:00
|
|
|
device, address, permanent_address,
|
|
|
|
ifname, alternative_names, wlan_iftype, ssid, bssid)) {
|
2015-05-12 00:22:29 +02:00
|
|
|
if (network->match_name && device) {
|
2014-12-07 13:00:01 +01:00
|
|
|
const char *attr;
|
|
|
|
uint8_t name_assign_type = NET_NAME_UNKNOWN;
|
|
|
|
|
2018-08-22 07:30:49 +02:00
|
|
|
if (sd_device_get_sysattr_value(device, "name_assign_type", &attr) >= 0)
|
2015-03-14 03:20:01 +01:00
|
|
|
(void) safe_atou8(attr, &name_assign_type);
|
2014-12-05 15:56:10 +01:00
|
|
|
|
|
|
|
if (name_assign_type == NET_NAME_ENUM)
|
2015-09-30 19:37:52 +02:00
|
|
|
log_warning("%s: found matching network '%s', based on potentially unpredictable ifname",
|
|
|
|
ifname, network->filename);
|
2014-12-05 15:56:10 +01:00
|
|
|
else
|
2015-09-30 19:37:52 +02:00
|
|
|
log_debug("%s: found matching network '%s'", ifname, network->filename);
|
2014-12-05 15:56:10 +01:00
|
|
|
} else
|
2015-09-30 19:37:52 +02:00
|
|
|
log_debug("%s: found matching network '%s'", ifname, network->filename);
|
2014-12-05 15:56:10 +01:00
|
|
|
|
2013-10-17 03:18:36 +02:00
|
|
|
*ret = network;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ret = NULL;
|
|
|
|
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
2016-09-28 12:32:31 +02:00
|
|
|
int network_apply(Network *network, Link *link) {
|
2015-10-01 21:14:06 +02:00
|
|
|
assert(network);
|
|
|
|
assert(link);
|
|
|
|
|
2019-05-04 08:05:11 +02:00
|
|
|
link->network = network_ref(network);
|
2013-10-17 03:18:36 +02:00
|
|
|
|
2016-11-18 17:04:26 +01:00
|
|
|
if (network->n_dns > 0 ||
|
networkd: rework Domains= setting
Previously, .network files only knew a vaguely defined "Domains=" concept, for which the documentation declared it was
the "DNS domain" for the network connection, without specifying what that means.
With this the Domains setting is reworked, so that there are now "routing" domains and "search" domains. The former are
to be used by resolved to route DNS request to specific network interfaces, the latter is to be used for searching
single-label hostnames with (in addition to being used for routing). Both settings are configured in the "Domains="
setting. Normal domain names listed in it are now considered search domains (for compatibility with existing setups),
while those prefixed with "~" are considered routing domains only. To route all lookups to a specific interface the
routing domain "." may be used, referring to the root domain. An alternative syntax for this is the "*", as was already
implemented before using the "wildcard" domain concept.
This commit adds proper parsers for this new logic, and exposes this via the sd-network API. This information is not
used by resolved yet, this will be added in a later commit.
2016-01-25 19:46:00 +01:00
|
|
|
!strv_isempty(network->ntp) ||
|
2019-02-20 22:50:25 +01:00
|
|
|
!ordered_set_isempty(network->search_domains) ||
|
|
|
|
!ordered_set_isempty(network->route_domains))
|
2015-09-30 18:17:43 +02:00
|
|
|
link_dirty(link);
|
2014-01-05 23:01:10 +01:00
|
|
|
|
2013-10-17 03:18:36 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2013-11-24 23:37:56 +01:00
|
|
|
|
2019-08-27 16:15:24 +02:00
|
|
|
bool network_has_static_ipv6_configurations(Network *network) {
|
2016-04-21 02:34:13 +02:00
|
|
|
Address *address;
|
2019-08-27 16:15:24 +02:00
|
|
|
Route *route;
|
|
|
|
FdbEntry *fdb;
|
|
|
|
Neighbor *neighbor;
|
2016-04-21 02:34:13 +02:00
|
|
|
|
|
|
|
assert(network);
|
|
|
|
|
2019-08-27 16:15:24 +02:00
|
|
|
LIST_FOREACH(addresses, address, network->static_addresses)
|
2016-04-21 02:34:13 +02:00
|
|
|
if (address->family == AF_INET6)
|
|
|
|
return true;
|
2019-08-27 16:15:24 +02:00
|
|
|
|
|
|
|
LIST_FOREACH(routes, route, network->static_routes)
|
|
|
|
if (route->family == AF_INET6)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
LIST_FOREACH(static_fdb_entries, fdb, network->static_fdb_entries)
|
|
|
|
if (fdb->family == AF_INET6)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
LIST_FOREACH(neighbors, neighbor, network->neighbors)
|
|
|
|
if (neighbor->family == AF_INET6)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (!LIST_IS_EMPTY(network->address_labels))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (!LIST_IS_EMPTY(network->static_prefixes))
|
|
|
|
return true;
|
2016-04-21 02:34:13 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-02-21 08:40:34 +01:00
|
|
|
int config_parse_stacked_netdev(const char *unit,
|
2013-11-24 23:37:56 +01:00
|
|
|
const char *filename,
|
|
|
|
unsigned line,
|
|
|
|
const char *section,
|
|
|
|
unsigned section_line,
|
|
|
|
const char *lvalue,
|
|
|
|
int ltype,
|
|
|
|
const char *rvalue,
|
|
|
|
void *data,
|
|
|
|
void *userdata) {
|
2019-02-28 08:18:57 +01:00
|
|
|
_cleanup_free_ char *name = NULL;
|
|
|
|
NetDevKind kind = ltype;
|
2019-02-21 08:40:34 +01:00
|
|
|
Hashmap **h = data;
|
2013-11-24 23:37:56 +01:00
|
|
|
int r;
|
|
|
|
|
|
|
|
assert(filename);
|
|
|
|
assert(lvalue);
|
|
|
|
assert(rvalue);
|
|
|
|
assert(data);
|
2019-02-28 08:18:57 +01:00
|
|
|
assert(IN_SET(kind,
|
|
|
|
NETDEV_KIND_VLAN, NETDEV_KIND_MACVLAN, NETDEV_KIND_MACVTAP,
|
2019-05-15 12:12:30 +02:00
|
|
|
NETDEV_KIND_IPVLAN, NETDEV_KIND_IPVTAP, NETDEV_KIND_VXLAN,
|
2019-07-08 17:09:46 +02:00
|
|
|
NETDEV_KIND_L2TP, NETDEV_KIND_MACSEC, _NETDEV_KIND_TUNNEL,
|
|
|
|
NETDEV_KIND_XFRM));
|
2014-01-22 14:49:24 +01:00
|
|
|
|
2019-02-21 08:40:34 +01:00
|
|
|
if (!ifname_valid(rvalue)) {
|
2019-02-27 13:34:51 +01:00
|
|
|
log_syntax(unit, LOG_ERR, filename, line, 0,
|
|
|
|
"Invalid netdev name in %s=, ignoring assignment: %s", lvalue, rvalue);
|
2014-01-22 14:49:24 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-02-21 08:40:34 +01:00
|
|
|
name = strdup(rvalue);
|
|
|
|
if (!name)
|
|
|
|
return log_oom();
|
2018-11-12 07:24:11 +01:00
|
|
|
|
2019-02-21 08:40:34 +01:00
|
|
|
r = hashmap_ensure_allocated(h, &string_hash_ops);
|
|
|
|
if (r < 0)
|
|
|
|
return log_oom();
|
2014-06-16 08:24:33 +02:00
|
|
|
|
2019-02-21 08:40:34 +01:00
|
|
|
r = hashmap_put(*h, name, INT_TO_PTR(kind));
|
2019-02-27 14:15:29 +01:00
|
|
|
if (r < 0)
|
2019-02-27 13:34:51 +01:00
|
|
|
log_syntax(unit, LOG_ERR, filename, line, r,
|
2019-02-27 14:15:29 +01:00
|
|
|
"Cannot add NetDev '%s' to network, ignoring assignment: %m", name);
|
|
|
|
else if (r == 0)
|
|
|
|
log_syntax(unit, LOG_DEBUG, filename, line, r,
|
|
|
|
"NetDev '%s' specified twice, ignoring.", name);
|
|
|
|
else
|
|
|
|
name = NULL;
|
2014-05-08 19:28:17 +02:00
|
|
|
|
2014-02-25 21:16:17 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2014-05-12 07:18:24 +02:00
|
|
|
|
networkd: rework Domains= setting
Previously, .network files only knew a vaguely defined "Domains=" concept, for which the documentation declared it was
the "DNS domain" for the network connection, without specifying what that means.
With this the Domains setting is reworked, so that there are now "routing" domains and "search" domains. The former are
to be used by resolved to route DNS request to specific network interfaces, the latter is to be used for searching
single-label hostnames with (in addition to being used for routing). Both settings are configured in the "Domains="
setting. Normal domain names listed in it are now considered search domains (for compatibility with existing setups),
while those prefixed with "~" are considered routing domains only. To route all lookups to a specific interface the
routing domain "." may be used, referring to the root domain. An alternative syntax for this is the "*", as was already
implemented before using the "wildcard" domain concept.
This commit adds proper parsers for this new logic, and exposes this via the sd-network API. This information is not
used by resolved yet, this will be added in a later commit.
2016-01-25 19:46:00 +01:00
|
|
|
int config_parse_domains(
|
|
|
|
const char *unit,
|
|
|
|
const char *filename,
|
|
|
|
unsigned line,
|
|
|
|
const char *section,
|
|
|
|
unsigned section_line,
|
|
|
|
const char *lvalue,
|
|
|
|
int ltype,
|
|
|
|
const char *rvalue,
|
|
|
|
void *data,
|
|
|
|
void *userdata) {
|
|
|
|
|
|
|
|
const char *p;
|
|
|
|
Network *n = data;
|
2014-08-15 14:21:08 +02:00
|
|
|
int r;
|
|
|
|
|
networkd: rework Domains= setting
Previously, .network files only knew a vaguely defined "Domains=" concept, for which the documentation declared it was
the "DNS domain" for the network connection, without specifying what that means.
With this the Domains setting is reworked, so that there are now "routing" domains and "search" domains. The former are
to be used by resolved to route DNS request to specific network interfaces, the latter is to be used for searching
single-label hostnames with (in addition to being used for routing). Both settings are configured in the "Domains="
setting. Normal domain names listed in it are now considered search domains (for compatibility with existing setups),
while those prefixed with "~" are considered routing domains only. To route all lookups to a specific interface the
routing domain "." may be used, referring to the root domain. An alternative syntax for this is the "*", as was already
implemented before using the "wildcard" domain concept.
This commit adds proper parsers for this new logic, and exposes this via the sd-network API. This information is not
used by resolved yet, this will be added in a later commit.
2016-01-25 19:46:00 +01:00
|
|
|
assert(n);
|
|
|
|
assert(lvalue);
|
|
|
|
assert(rvalue);
|
2014-08-15 14:21:08 +02:00
|
|
|
|
networkd: rework Domains= setting
Previously, .network files only knew a vaguely defined "Domains=" concept, for which the documentation declared it was
the "DNS domain" for the network connection, without specifying what that means.
With this the Domains setting is reworked, so that there are now "routing" domains and "search" domains. The former are
to be used by resolved to route DNS request to specific network interfaces, the latter is to be used for searching
single-label hostnames with (in addition to being used for routing). Both settings are configured in the "Domains="
setting. Normal domain names listed in it are now considered search domains (for compatibility with existing setups),
while those prefixed with "~" are considered routing domains only. To route all lookups to a specific interface the
routing domain "." may be used, referring to the root domain. An alternative syntax for this is the "*", as was already
implemented before using the "wildcard" domain concept.
This commit adds proper parsers for this new logic, and exposes this via the sd-network API. This information is not
used by resolved yet, this will be added in a later commit.
2016-01-25 19:46:00 +01:00
|
|
|
if (isempty(rvalue)) {
|
2019-02-20 22:50:25 +01:00
|
|
|
n->search_domains = ordered_set_free_free(n->search_domains);
|
|
|
|
n->route_domains = ordered_set_free_free(n->route_domains);
|
networkd: rework Domains= setting
Previously, .network files only knew a vaguely defined "Domains=" concept, for which the documentation declared it was
the "DNS domain" for the network connection, without specifying what that means.
With this the Domains setting is reworked, so that there are now "routing" domains and "search" domains. The former are
to be used by resolved to route DNS request to specific network interfaces, the latter is to be used for searching
single-label hostnames with (in addition to being used for routing). Both settings are configured in the "Domains="
setting. Normal domain names listed in it are now considered search domains (for compatibility with existing setups),
while those prefixed with "~" are considered routing domains only. To route all lookups to a specific interface the
routing domain "." may be used, referring to the root domain. An alternative syntax for this is the "*", as was already
implemented before using the "wildcard" domain concept.
This commit adds proper parsers for this new logic, and exposes this via the sd-network API. This information is not
used by resolved yet, this will be added in a later commit.
2016-01-25 19:46:00 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2014-08-15 14:49:31 +02:00
|
|
|
|
networkd: rework Domains= setting
Previously, .network files only knew a vaguely defined "Domains=" concept, for which the documentation declared it was
the "DNS domain" for the network connection, without specifying what that means.
With this the Domains setting is reworked, so that there are now "routing" domains and "search" domains. The former are
to be used by resolved to route DNS request to specific network interfaces, the latter is to be used for searching
single-label hostnames with (in addition to being used for routing). Both settings are configured in the "Domains="
setting. Normal domain names listed in it are now considered search domains (for compatibility with existing setups),
while those prefixed with "~" are considered routing domains only. To route all lookups to a specific interface the
routing domain "." may be used, referring to the root domain. An alternative syntax for this is the "*", as was already
implemented before using the "wildcard" domain concept.
This commit adds proper parsers for this new logic, and exposes this via the sd-network API. This information is not
used by resolved yet, this will be added in a later commit.
2016-01-25 19:46:00 +01:00
|
|
|
p = rvalue;
|
|
|
|
for (;;) {
|
|
|
|
_cleanup_free_ char *w = NULL, *normalized = NULL;
|
|
|
|
const char *domain;
|
|
|
|
bool is_route;
|
|
|
|
|
|
|
|
r = extract_first_word(&p, &w, NULL, 0);
|
|
|
|
if (r < 0) {
|
2019-02-20 21:30:06 +01:00
|
|
|
log_syntax(unit, LOG_ERR, filename, line, r,
|
|
|
|
"Failed to extract search or route domain, ignoring: %s", rvalue);
|
networkd: rework Domains= setting
Previously, .network files only knew a vaguely defined "Domains=" concept, for which the documentation declared it was
the "DNS domain" for the network connection, without specifying what that means.
With this the Domains setting is reworked, so that there are now "routing" domains and "search" domains. The former are
to be used by resolved to route DNS request to specific network interfaces, the latter is to be used for searching
single-label hostnames with (in addition to being used for routing). Both settings are configured in the "Domains="
setting. Normal domain names listed in it are now considered search domains (for compatibility with existing setups),
while those prefixed with "~" are considered routing domains only. To route all lookups to a specific interface the
routing domain "." may be used, referring to the root domain. An alternative syntax for this is the "*", as was already
implemented before using the "wildcard" domain concept.
This commit adds proper parsers for this new logic, and exposes this via the sd-network API. This information is not
used by resolved yet, this will be added in a later commit.
2016-01-25 19:46:00 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (r == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
is_route = w[0] == '~';
|
|
|
|
domain = is_route ? w + 1 : w;
|
|
|
|
|
|
|
|
if (dns_name_is_root(domain) || streq(domain, "*")) {
|
2019-02-20 21:30:06 +01:00
|
|
|
/* If the root domain appears as is, or the special token "*" is found, we'll
|
|
|
|
* consider this as routing domain, unconditionally. */
|
networkd: rework Domains= setting
Previously, .network files only knew a vaguely defined "Domains=" concept, for which the documentation declared it was
the "DNS domain" for the network connection, without specifying what that means.
With this the Domains setting is reworked, so that there are now "routing" domains and "search" domains. The former are
to be used by resolved to route DNS request to specific network interfaces, the latter is to be used for searching
single-label hostnames with (in addition to being used for routing). Both settings are configured in the "Domains="
setting. Normal domain names listed in it are now considered search domains (for compatibility with existing setups),
while those prefixed with "~" are considered routing domains only. To route all lookups to a specific interface the
routing domain "." may be used, referring to the root domain. An alternative syntax for this is the "*", as was already
implemented before using the "wildcard" domain concept.
This commit adds proper parsers for this new logic, and exposes this via the sd-network API. This information is not
used by resolved yet, this will be added in a later commit.
2016-01-25 19:46:00 +01:00
|
|
|
is_route = true;
|
2019-02-20 21:30:06 +01:00
|
|
|
domain = "."; /* make sure we don't allow empty strings, thus write the root
|
|
|
|
* domain as "." */
|
networkd: rework Domains= setting
Previously, .network files only knew a vaguely defined "Domains=" concept, for which the documentation declared it was
the "DNS domain" for the network connection, without specifying what that means.
With this the Domains setting is reworked, so that there are now "routing" domains and "search" domains. The former are
to be used by resolved to route DNS request to specific network interfaces, the latter is to be used for searching
single-label hostnames with (in addition to being used for routing). Both settings are configured in the "Domains="
setting. Normal domain names listed in it are now considered search domains (for compatibility with existing setups),
while those prefixed with "~" are considered routing domains only. To route all lookups to a specific interface the
routing domain "." may be used, referring to the root domain. An alternative syntax for this is the "*", as was already
implemented before using the "wildcard" domain concept.
This commit adds proper parsers for this new logic, and exposes this via the sd-network API. This information is not
used by resolved yet, this will be added in a later commit.
2016-01-25 19:46:00 +01:00
|
|
|
} else {
|
resolve: reject host names with leading or trailing dashes in /etc/hosts
https://tools.ietf.org/html/rfc1035#section-2.3.1 says (approximately)
that only letters, numbers, and non-leading non-trailing dashes are allowed
(for entries with A/AAAA records). We set no restrictions.
hosts(5) says:
> Host names may contain only alphanumeric characters, minus signs ("-"), and
> periods ("."). They must begin with an alphabetic character and end with an
> alphanumeric character.
nss-files follows those rules, and will ignore names in /etc/hosts that do not
follow this rule.
Let's follow the documented rules for /etc/hosts. In particular, this makes us
consitent with nss-files, reducing surprises for the user.
I'm pretty sure we should apply stricter filtering to names received over DNS
and LLMNR and MDNS, but it's a bigger project, because the rules differ
depepending on which level the label appears (rules for top-level names are
stricter), and this patch takes the minimalistic approach and only changes
behaviour for /etc/hosts.
Escape syntax is also disallowed in /etc/hosts, even if the resulting character
would be allowed. Other tools that parse /etc/hosts do not support this, and
there is no need to use it because no allowed characters benefit from escaping.
2018-11-21 22:58:13 +01:00
|
|
|
r = dns_name_normalize(domain, 0, &normalized);
|
networkd: rework Domains= setting
Previously, .network files only knew a vaguely defined "Domains=" concept, for which the documentation declared it was
the "DNS domain" for the network connection, without specifying what that means.
With this the Domains setting is reworked, so that there are now "routing" domains and "search" domains. The former are
to be used by resolved to route DNS request to specific network interfaces, the latter is to be used for searching
single-label hostnames with (in addition to being used for routing). Both settings are configured in the "Domains="
setting. Normal domain names listed in it are now considered search domains (for compatibility with existing setups),
while those prefixed with "~" are considered routing domains only. To route all lookups to a specific interface the
routing domain "." may be used, referring to the root domain. An alternative syntax for this is the "*", as was already
implemented before using the "wildcard" domain concept.
This commit adds proper parsers for this new logic, and exposes this via the sd-network API. This information is not
used by resolved yet, this will be added in a later commit.
2016-01-25 19:46:00 +01:00
|
|
|
if (r < 0) {
|
2019-02-20 21:30:06 +01:00
|
|
|
log_syntax(unit, LOG_ERR, filename, line, r,
|
|
|
|
"'%s' is not a valid domain name, ignoring.", domain);
|
networkd: rework Domains= setting
Previously, .network files only knew a vaguely defined "Domains=" concept, for which the documentation declared it was
the "DNS domain" for the network connection, without specifying what that means.
With this the Domains setting is reworked, so that there are now "routing" domains and "search" domains. The former are
to be used by resolved to route DNS request to specific network interfaces, the latter is to be used for searching
single-label hostnames with (in addition to being used for routing). Both settings are configured in the "Domains="
setting. Normal domain names listed in it are now considered search domains (for compatibility with existing setups),
while those prefixed with "~" are considered routing domains only. To route all lookups to a specific interface the
routing domain "." may be used, referring to the root domain. An alternative syntax for this is the "*", as was already
implemented before using the "wildcard" domain concept.
This commit adds proper parsers for this new logic, and exposes this via the sd-network API. This information is not
used by resolved yet, this will be added in a later commit.
2016-01-25 19:46:00 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
domain = normalized;
|
|
|
|
|
|
|
|
if (is_localhost(domain)) {
|
2019-02-20 21:30:06 +01:00
|
|
|
log_syntax(unit, LOG_ERR, filename, line, 0,
|
|
|
|
"'localhost' domain may not be configured as search or route domain, ignoring assignment: %s",
|
|
|
|
domain);
|
2015-06-03 01:30:42 +02:00
|
|
|
continue;
|
networkd: rework Domains= setting
Previously, .network files only knew a vaguely defined "Domains=" concept, for which the documentation declared it was
the "DNS domain" for the network connection, without specifying what that means.
With this the Domains setting is reworked, so that there are now "routing" domains and "search" domains. The former are
to be used by resolved to route DNS request to specific network interfaces, the latter is to be used for searching
single-label hostnames with (in addition to being used for routing). Both settings are configured in the "Domains="
setting. Normal domain names listed in it are now considered search domains (for compatibility with existing setups),
while those prefixed with "~" are considered routing domains only. To route all lookups to a specific interface the
routing domain "." may be used, referring to the root domain. An alternative syntax for this is the "*", as was already
implemented before using the "wildcard" domain concept.
This commit adds proper parsers for this new logic, and exposes this via the sd-network API. This information is not
used by resolved yet, this will be added in a later commit.
2016-01-25 19:46:00 +01:00
|
|
|
}
|
2015-06-03 01:30:42 +02:00
|
|
|
}
|
2014-08-15 16:21:19 +02:00
|
|
|
|
2019-02-20 22:50:25 +01:00
|
|
|
OrderedSet **set = is_route ? &n->route_domains : &n->search_domains;
|
|
|
|
r = ordered_set_ensure_allocated(set, &string_hash_ops);
|
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
|
|
|
|
r = ordered_set_put_strdup(*set, domain);
|
2018-12-04 15:34:37 +01:00
|
|
|
if (r < 0)
|
|
|
|
return log_oom();
|
2014-08-15 16:21:19 +02:00
|
|
|
}
|
2014-08-15 15:36:17 +02:00
|
|
|
|
2014-08-15 14:21:08 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-02-14 00:32:56 +01:00
|
|
|
int config_parse_ipv6token(
|
2015-02-08 23:20:56 +01:00
|
|
|
const char* unit,
|
|
|
|
const char *filename,
|
|
|
|
unsigned line,
|
|
|
|
const char *section,
|
|
|
|
unsigned section_line,
|
|
|
|
const char *lvalue,
|
|
|
|
int ltype,
|
|
|
|
const char *rvalue,
|
|
|
|
void *data,
|
|
|
|
void *userdata) {
|
|
|
|
|
|
|
|
union in_addr_union buffer;
|
|
|
|
struct in6_addr *token = data;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
assert(filename);
|
|
|
|
assert(lvalue);
|
|
|
|
assert(rvalue);
|
|
|
|
assert(token);
|
|
|
|
|
|
|
|
r = in_addr_from_string(AF_INET6, rvalue, &buffer);
|
|
|
|
if (r < 0) {
|
2019-02-20 21:30:06 +01:00
|
|
|
log_syntax(unit, LOG_ERR, filename, line, r,
|
|
|
|
"Failed to parse IPv6 token, ignoring: %s", rvalue);
|
2015-02-08 23:20:56 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-02-02 23:08:10 +01:00
|
|
|
if (in_addr_is_null(AF_INET6, &buffer)) {
|
2019-02-20 21:30:06 +01:00
|
|
|
log_syntax(unit, LOG_ERR, filename, line, 0,
|
|
|
|
"IPv6 token cannot be the ANY address, ignoring: %s", rvalue);
|
2015-02-08 23:20:56 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((buffer.in6.s6_addr32[0] | buffer.in6.s6_addr32[1]) != 0) {
|
2019-02-20 21:30:06 +01:00
|
|
|
log_syntax(unit, LOG_ERR, filename, line, 0,
|
|
|
|
"IPv6 token cannot be longer than 64 bits, ignoring: %s", rvalue);
|
2015-02-08 23:20:56 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
*token = buffer.in6;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2015-05-01 20:48:08 +02:00
|
|
|
|
2015-07-05 07:54:31 +02:00
|
|
|
static const char* const ipv6_privacy_extensions_table[_IPV6_PRIVACY_EXTENSIONS_MAX] = {
|
2015-07-06 20:29:33 +02:00
|
|
|
[IPV6_PRIVACY_EXTENSIONS_NO] = "no",
|
|
|
|
[IPV6_PRIVACY_EXTENSIONS_PREFER_PUBLIC] = "prefer-public",
|
|
|
|
[IPV6_PRIVACY_EXTENSIONS_YES] = "yes",
|
2015-07-05 07:54:31 +02:00
|
|
|
};
|
|
|
|
|
2019-08-26 09:18:40 +02:00
|
|
|
DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(ipv6_privacy_extensions, IPv6PrivacyExtensions,
|
|
|
|
IPV6_PRIVACY_EXTENSIONS_YES);
|
2015-07-05 07:54:31 +02:00
|
|
|
|
|
|
|
int config_parse_ipv6_privacy_extensions(
|
|
|
|
const char* unit,
|
|
|
|
const char *filename,
|
|
|
|
unsigned line,
|
|
|
|
const char *section,
|
|
|
|
unsigned section_line,
|
|
|
|
const char *lvalue,
|
|
|
|
int ltype,
|
|
|
|
const char *rvalue,
|
|
|
|
void *data,
|
|
|
|
void *userdata) {
|
|
|
|
|
2019-08-26 09:18:40 +02:00
|
|
|
IPv6PrivacyExtensions s, *ipv6_privacy_extensions = data;
|
2015-07-05 07:54:31 +02:00
|
|
|
|
|
|
|
assert(filename);
|
|
|
|
assert(lvalue);
|
|
|
|
assert(rvalue);
|
|
|
|
assert(ipv6_privacy_extensions);
|
|
|
|
|
2019-08-26 09:18:40 +02:00
|
|
|
s = ipv6_privacy_extensions_from_string(rvalue);
|
|
|
|
if (s < 0) {
|
|
|
|
if (streq(rvalue, "kernel"))
|
|
|
|
s = _IPV6_PRIVACY_EXTENSIONS_INVALID;
|
|
|
|
else {
|
|
|
|
log_syntax(unit, LOG_ERR, filename, line, 0,
|
|
|
|
"Failed to parse IPv6 privacy extensions option, ignoring: %s", rvalue);
|
|
|
|
return 0;
|
2015-07-05 07:54:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-26 09:18:40 +02:00
|
|
|
*ipv6_privacy_extensions = s;
|
|
|
|
|
2015-07-05 07:54:31 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2015-07-10 12:12:27 +02:00
|
|
|
|
2015-08-26 19:16:52 +02:00
|
|
|
int config_parse_hostname(
|
|
|
|
const char *unit,
|
|
|
|
const char *filename,
|
|
|
|
unsigned line,
|
|
|
|
const char *section,
|
|
|
|
unsigned section_line,
|
|
|
|
const char *lvalue,
|
|
|
|
int ltype,
|
|
|
|
const char *rvalue,
|
|
|
|
void *data,
|
|
|
|
void *userdata) {
|
|
|
|
|
2018-08-02 09:28:23 +02:00
|
|
|
_cleanup_free_ char *hn = NULL;
|
|
|
|
char **hostname = data;
|
2015-07-10 12:12:27 +02:00
|
|
|
int r;
|
|
|
|
|
|
|
|
assert(filename);
|
|
|
|
assert(lvalue);
|
|
|
|
assert(rvalue);
|
|
|
|
|
2015-08-26 19:16:52 +02:00
|
|
|
r = config_parse_string(unit, filename, line, section, section_line, lvalue, ltype, rvalue, &hn, userdata);
|
2015-07-10 12:12:27 +02:00
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
|
2015-08-26 19:16:52 +02:00
|
|
|
if (!hostname_is_valid(hn, false)) {
|
2019-02-20 21:30:06 +01:00
|
|
|
log_syntax(unit, LOG_ERR, filename, line, 0,
|
|
|
|
"Hostname is not valid, ignoring assignment: %s", rvalue);
|
2015-07-10 12:12:27 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-08-02 09:28:23 +02:00
|
|
|
r = dns_name_is_valid(hn);
|
|
|
|
if (r < 0) {
|
2019-02-20 21:30:06 +01:00
|
|
|
log_syntax(unit, LOG_ERR, filename, line, r,
|
|
|
|
"Failed to check validity of hostname '%s', ignoring assignment: %m", rvalue);
|
2018-08-02 09:28:23 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (r == 0) {
|
2019-02-20 21:30:06 +01:00
|
|
|
log_syntax(unit, LOG_ERR, filename, line, 0,
|
|
|
|
"Hostname is not a valid DNS domain name, ignoring assignment: %s", rvalue);
|
2018-08-02 09:28:23 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return free_and_replace(*hostname, hn);
|
2015-07-10 12:12:27 +02:00
|
|
|
}
|
2015-08-26 19:19:32 +02:00
|
|
|
|
|
|
|
int config_parse_timezone(
|
|
|
|
const char *unit,
|
|
|
|
const char *filename,
|
|
|
|
unsigned line,
|
|
|
|
const char *section,
|
|
|
|
unsigned section_line,
|
|
|
|
const char *lvalue,
|
|
|
|
int ltype,
|
|
|
|
const char *rvalue,
|
|
|
|
void *data,
|
|
|
|
void *userdata) {
|
|
|
|
|
2018-08-02 09:28:44 +02:00
|
|
|
_cleanup_free_ char *tz = NULL;
|
|
|
|
char **datap = data;
|
2015-08-26 19:19:32 +02:00
|
|
|
int r;
|
|
|
|
|
|
|
|
assert(filename);
|
|
|
|
assert(lvalue);
|
|
|
|
assert(rvalue);
|
|
|
|
|
|
|
|
r = config_parse_string(unit, filename, line, section, section_line, lvalue, ltype, rvalue, &tz, userdata);
|
|
|
|
if (r < 0)
|
|
|
|
return r;
|
|
|
|
|
2018-05-12 21:20:13 +02:00
|
|
|
if (!timezone_is_valid(tz, LOG_ERR)) {
|
2019-02-20 21:30:06 +01:00
|
|
|
log_syntax(unit, LOG_ERR, filename, line, 0,
|
|
|
|
"Timezone is not valid, ignoring assignment: %s", rvalue);
|
2015-08-26 19:19:32 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-08-02 09:28:44 +02:00
|
|
|
return free_and_replace(*datap, tz);
|
2015-08-26 19:19:32 +02:00
|
|
|
}
|
2015-08-27 14:48:37 +02:00
|
|
|
|
2016-10-27 01:31:04 +02:00
|
|
|
int config_parse_dns(
|
|
|
|
const char *unit,
|
|
|
|
const char *filename,
|
|
|
|
unsigned line,
|
|
|
|
const char *section,
|
|
|
|
unsigned section_line,
|
|
|
|
const char *lvalue,
|
|
|
|
int ltype,
|
|
|
|
const char *rvalue,
|
|
|
|
void *data,
|
|
|
|
void *userdata) {
|
|
|
|
|
|
|
|
Network *n = userdata;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
assert(filename);
|
|
|
|
assert(lvalue);
|
|
|
|
assert(rvalue);
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
_cleanup_free_ char *w = NULL;
|
|
|
|
union in_addr_union a;
|
2016-11-18 17:04:26 +01:00
|
|
|
struct in_addr_data *m;
|
2016-10-27 01:31:04 +02:00
|
|
|
int family;
|
|
|
|
|
2016-11-18 17:04:26 +01:00
|
|
|
r = extract_first_word(&rvalue, &w, NULL, 0);
|
2016-10-27 01:31:04 +02:00
|
|
|
if (r == -ENOMEM)
|
|
|
|
return log_oom();
|
|
|
|
if (r < 0) {
|
2019-02-20 21:30:06 +01:00
|
|
|
log_syntax(unit, LOG_ERR, filename, line, r,
|
|
|
|
"Invalid syntax, ignoring: %s", rvalue);
|
2016-10-27 01:31:04 +02:00
|
|
|
break;
|
|
|
|
}
|
2016-11-18 17:04:26 +01:00
|
|
|
if (r == 0)
|
|
|
|
break;
|
2016-10-27 01:31:04 +02:00
|
|
|
|
|
|
|
r = in_addr_from_string_auto(w, &family, &a);
|
|
|
|
if (r < 0) {
|
2019-02-20 21:30:06 +01:00
|
|
|
log_syntax(unit, LOG_ERR, filename, line, r,
|
|
|
|
"Failed to parse dns server address, ignoring: %s", w);
|
2016-10-27 01:31:04 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-02-27 19:09:22 +01:00
|
|
|
m = reallocarray(n->dns, n->n_dns + 1, sizeof(struct in_addr_data));
|
2016-11-18 17:04:26 +01:00
|
|
|
if (!m)
|
2016-10-27 01:31:04 +02:00
|
|
|
return log_oom();
|
|
|
|
|
2016-11-18 17:04:26 +01:00
|
|
|
m[n->n_dns++] = (struct in_addr_data) {
|
|
|
|
.family = family,
|
|
|
|
.address = a,
|
|
|
|
};
|
|
|
|
|
|
|
|
n->dns = m;
|
2016-10-27 01:31:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-01-06 18:36:32 +01:00
|
|
|
int config_parse_dnssec_negative_trust_anchors(
|
|
|
|
const char *unit,
|
|
|
|
const char *filename,
|
|
|
|
unsigned line,
|
|
|
|
const char *section,
|
|
|
|
unsigned section_line,
|
|
|
|
const char *lvalue,
|
|
|
|
int ltype,
|
|
|
|
const char *rvalue,
|
|
|
|
void *data,
|
|
|
|
void *userdata) {
|
|
|
|
|
|
|
|
const char *p = rvalue;
|
|
|
|
Network *n = data;
|
|
|
|
int r;
|
|
|
|
|
networkd: rework Domains= setting
Previously, .network files only knew a vaguely defined "Domains=" concept, for which the documentation declared it was
the "DNS domain" for the network connection, without specifying what that means.
With this the Domains setting is reworked, so that there are now "routing" domains and "search" domains. The former are
to be used by resolved to route DNS request to specific network interfaces, the latter is to be used for searching
single-label hostnames with (in addition to being used for routing). Both settings are configured in the "Domains="
setting. Normal domain names listed in it are now considered search domains (for compatibility with existing setups),
while those prefixed with "~" are considered routing domains only. To route all lookups to a specific interface the
routing domain "." may be used, referring to the root domain. An alternative syntax for this is the "*", as was already
implemented before using the "wildcard" domain concept.
This commit adds proper parsers for this new logic, and exposes this via the sd-network API. This information is not
used by resolved yet, this will be added in a later commit.
2016-01-25 19:46:00 +01:00
|
|
|
assert(n);
|
2016-01-06 18:36:32 +01:00
|
|
|
assert(lvalue);
|
|
|
|
assert(rvalue);
|
|
|
|
|
|
|
|
if (isempty(rvalue)) {
|
|
|
|
n->dnssec_negative_trust_anchors = set_free_free(n->dnssec_negative_trust_anchors);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
_cleanup_free_ char *w = NULL;
|
|
|
|
|
|
|
|
r = extract_first_word(&p, &w, NULL, 0);
|
|
|
|
if (r < 0) {
|
2019-02-20 21:30:06 +01:00
|
|
|
log_syntax(unit, LOG_ERR, filename, line, r,
|
|
|
|
"Failed to extract negative trust anchor domain, ignoring: %s", rvalue);
|
2016-01-06 18:36:32 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (r == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
r = dns_name_is_valid(w);
|
|
|
|
if (r <= 0) {
|
2019-02-20 21:30:06 +01:00
|
|
|
log_syntax(unit, LOG_ERR, filename, line, r,
|
|
|
|
"%s is not a valid domain name, ignoring.", w);
|
2016-01-06 18:36:32 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-02-21 22:27:01 +01:00
|
|
|
r = set_ensure_allocated(&n->dnssec_negative_trust_anchors, &dns_name_hash_ops);
|
|
|
|
if (r < 0)
|
|
|
|
return log_oom();
|
|
|
|
|
2016-01-06 18:36:32 +01:00
|
|
|
r = set_put(n->dnssec_negative_trust_anchors, w);
|
|
|
|
if (r < 0)
|
|
|
|
return log_oom();
|
|
|
|
if (r > 0)
|
|
|
|
w = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2016-01-25 22:27:01 +01:00
|
|
|
|
2016-11-18 17:00:25 +01:00
|
|
|
int config_parse_ntp(
|
|
|
|
const char *unit,
|
|
|
|
const char *filename,
|
|
|
|
unsigned line,
|
|
|
|
const char *section,
|
|
|
|
unsigned section_line,
|
|
|
|
const char *lvalue,
|
|
|
|
int ltype,
|
|
|
|
const char *rvalue,
|
|
|
|
void *data,
|
|
|
|
void *userdata) {
|
|
|
|
|
|
|
|
char ***l = data;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
assert(l);
|
|
|
|
assert(lvalue);
|
|
|
|
assert(rvalue);
|
|
|
|
|
|
|
|
if (isempty(rvalue)) {
|
|
|
|
*l = strv_free(*l);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
_cleanup_free_ char *w = NULL;
|
|
|
|
|
|
|
|
r = extract_first_word(&rvalue, &w, NULL, 0);
|
|
|
|
if (r == -ENOMEM)
|
|
|
|
return log_oom();
|
|
|
|
if (r < 0) {
|
2019-02-20 21:30:06 +01:00
|
|
|
log_syntax(unit, LOG_ERR, filename, line, r,
|
|
|
|
"Failed to extract NTP server name, ignoring: %s", rvalue);
|
2016-11-18 17:00:25 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (r == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
r = dns_name_is_valid_or_address(w);
|
|
|
|
if (r <= 0) {
|
2019-02-20 21:30:06 +01:00
|
|
|
log_syntax(unit, LOG_ERR, filename, line, r,
|
|
|
|
"%s is not a valid domain name or IP address, ignoring.", w);
|
2016-11-18 17:00:25 +01:00
|
|
|
continue;
|
2018-05-07 14:21:02 +02:00
|
|
|
}
|
|
|
|
|
2019-02-27 14:45:29 +01:00
|
|
|
if (strv_length(*l) > MAX_NTP_SERVERS) {
|
|
|
|
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
|
|
|
"More than %u NTP servers specified, ignoring \"%s\" and any subsequent entries.",
|
|
|
|
MAX_NTP_SERVERS, w);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = strv_consume(l, TAKE_PTR(w));
|
2018-05-07 14:21:02 +02:00
|
|
|
if (r < 0)
|
|
|
|
return log_oom();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-03-06 06:29:49 +01:00
|
|
|
int config_parse_required_for_online(
|
|
|
|
const char *unit,
|
|
|
|
const char *filename,
|
|
|
|
unsigned line,
|
|
|
|
const char *section,
|
|
|
|
unsigned section_line,
|
|
|
|
const char *lvalue,
|
|
|
|
int ltype,
|
|
|
|
const char *rvalue,
|
|
|
|
void *data,
|
|
|
|
void *userdata) {
|
|
|
|
|
|
|
|
Network *network = data;
|
2020-01-09 21:31:50 +01:00
|
|
|
LinkOperationalStateRange range;
|
2019-03-06 06:29:49 +01:00
|
|
|
bool required = true;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
if (isempty(rvalue)) {
|
|
|
|
network->required_for_online = true;
|
2020-01-09 21:31:50 +01:00
|
|
|
network->required_operstate_for_online = LINK_OPERSTATE_RANGE_DEFAULT;
|
2019-03-06 06:29:49 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-01-09 21:31:50 +01:00
|
|
|
r = parse_operational_state_range(rvalue, &range);
|
|
|
|
if (r < 0) {
|
2019-03-06 06:29:49 +01:00
|
|
|
r = parse_boolean(rvalue);
|
|
|
|
if (r < 0) {
|
|
|
|
log_syntax(unit, LOG_ERR, filename, line, r,
|
|
|
|
"Failed to parse %s= setting, ignoring assignment: %s",
|
|
|
|
lvalue, rvalue);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
required = r;
|
2020-01-09 21:31:50 +01:00
|
|
|
range = LINK_OPERSTATE_RANGE_DEFAULT;
|
2019-03-06 06:29:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
network->required_for_online = required;
|
2020-01-09 21:31:50 +01:00
|
|
|
network->required_operstate_for_online = range;
|
2019-03-06 06:29:49 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2019-06-03 05:31:13 +02:00
|
|
|
|
|
|
|
DEFINE_CONFIG_PARSE_ENUM(config_parse_keep_configuration, keep_configuration, KeepConfiguration,
|
|
|
|
"Failed to parse KeepConfiguration= setting");
|
|
|
|
|
|
|
|
static const char* const keep_configuration_table[_KEEP_CONFIGURATION_MAX] = {
|
2019-06-03 19:05:26 +02:00
|
|
|
[KEEP_CONFIGURATION_NO] = "no",
|
|
|
|
[KEEP_CONFIGURATION_DHCP_ON_STOP] = "dhcp-on-stop",
|
|
|
|
[KEEP_CONFIGURATION_DHCP] = "dhcp",
|
|
|
|
[KEEP_CONFIGURATION_STATIC] = "static",
|
|
|
|
[KEEP_CONFIGURATION_YES] = "yes",
|
2019-06-03 05:31:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(keep_configuration, KeepConfiguration, KEEP_CONFIGURATION_YES);
|