Compare commits

..

No commits in common. "7183b22f129f49ded2b8bfffd3c473e15aebca2c" and "68f6c583543eb40a541823cd6d21b5eaaf7dd7f4" have entirely different histories.

13 changed files with 130 additions and 194 deletions

7
TODO
View File

@ -62,13 +62,6 @@ Features:
operate on disk images directly. Specifically: bootctl, firstboot, tmpfiles,
sysusers, systemctl, repart, journalctl, coredumpctl.
* seccomp: by default mask x32 ABI system wide on x86-64. it's on its way out
* seccomp: don't install filters for ABIs that are masked anyway for the
specific service
* seccomp: maybe merge all filters we install into one with that libseccomp API that allows merging.
* per-service credential system. Specifically: add LoadCredential= (for loading
cred from file), AcquireCredential= (for asking user for cred, via
ask-password), PassCredential= (for passing on credential systemd itself

View File

@ -1614,7 +1614,8 @@
<varlistentry>
<term><varname>RouteMetric=</varname></term>
<listitem>
<para>Set the routing metric for routes specified by the DHCP server. Defaults to 1024.</para>
<para>Set the routing metric for routes specified by the
DHCP server.</para>
</listitem>
</varlistentry>
@ -1733,13 +1734,6 @@
</listitem>
</varlistentry>
<varlistentry>
<term><varname>RouteMetric=</varname></term>
<listitem>
<para>Set the routing metric for routes specified by the DHCP server. Defaults to 1024.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>RapidCommit=</varname></term>
<listitem>

View File

@ -25,8 +25,7 @@
#if ENABLE_EFI
/* Reads from efivarfs sometimes fail with EINTR. Retry that many times. */
#define EFI_N_RETRIES_NO_DELAY 20
#define EFI_N_RETRIES_TOTAL 25
#define EFI_N_RETRIES 5
#define EFI_RETRY_DELAY (50 * USEC_PER_MSEC)
char* efi_variable_path(sd_id128_t vendor, const char *name) {
@ -102,10 +101,9 @@ int efi_get_variable(
log_debug_errno(errno, "Reading from \"%s\" failed: %m", p);
if (errno != EINTR)
return -errno;
if (try >= EFI_N_RETRIES_TOTAL)
if (try >= EFI_N_RETRIES)
return -EBUSY;
if (try >= EFI_N_RETRIES_NO_DELAY)
(void) usleep(EFI_RETRY_DELAY);
}

View File

@ -103,16 +103,13 @@ int fclose_nointr(FILE *f) {
/* Same as close_nointr(), but for fclose() */
errno = 0; /* Extra safety: if the FILE* object is not encapsulating an fd, it might not set errno
* correctly. Let's hence initialize it to zero first, so that we aren't confused by any
* prior errno here */
if (fclose(f) == 0)
return 0;
if (errno == EINTR)
return 0;
return errno_or_else(EIO);
return -errno;
}
FILE* safe_fclose(FILE *f) {

View File

@ -9,6 +9,7 @@
#include "parse-util.h"
#include "string-table.h"
#include "strv.h"
#include "web-util.h"
int config_parse_dhcp(
const char* unit,
@ -62,50 +63,6 @@ int config_parse_dhcp(
return 0;
}
int config_parse_dhcp_route_metric(
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;
uint32_t metric;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
r = safe_atou32(rvalue, &metric);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
"Failed to parse RouteMetric=%s, ignoring assignment: %m", rvalue);
return 0;
}
if (streq_ptr(section, "DHCPv4")) {
network->dhcp_route_metric = metric;
network->dhcp_route_metric_set = true;
} else if (streq_ptr(section, "DHCPv6")) {
network->dhcp6_route_metric = metric;
network->dhcp6_route_metric_set = true;
} else { /* [DHCP] section */
if (!network->dhcp_route_metric_set)
network->dhcp_route_metric = metric;
if (!network->dhcp6_route_metric_set)
network->dhcp6_route_metric = metric;
}
return 0;
}
int config_parse_dhcp_use_dns(
const char* unit,
const char *filename,
@ -133,19 +90,41 @@ int config_parse_dhcp_use_dns(
return 0;
}
if (streq_ptr(section, "DHCPv4")) {
network->dhcp_use_dns = r;
network->dhcp_use_dns_set = true;
} else if (streq_ptr(section, "DHCPv6")) {
network->dhcp6_use_dns = r;
network->dhcp6_use_dns_set = true;
} else { /* [DHCP] section */
if (!network->dhcp_use_dns_set)
network->dhcp_use_dns = r;
if (!network->dhcp6_use_dns_set)
network->dhcp6_use_dns = r;
return 0;
}
int config_parse_dhcp_use_sip(
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;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
r = parse_boolean(rvalue);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
"Failed to parse UseSIP=%s, ignoring assignment: %m", rvalue);
return 0;
}
network->dhcp_use_sip = r;
return 0;
}
@ -176,18 +155,8 @@ int config_parse_dhcp_use_ntp(
return 0;
}
if (streq_ptr(section, "DHCPv4")) {
network->dhcp_use_ntp = r;
network->dhcp_use_ntp_set = true;
} else if (streq_ptr(section, "DHCPv6")) {
network->dhcp6_use_ntp = r;
network->dhcp6_use_ntp_set = true;
} else { /* [DHCP] section */
if (!network->dhcp_use_ntp_set)
network->dhcp_use_ntp = r;
if (!network->dhcp6_use_ntp_set)
network->dhcp6_use_ntp = r;
}
return 0;
}
@ -263,6 +232,41 @@ int config_parse_iaid(const char *unit,
return 0;
}
int config_parse_dhcp6_pd_hint(
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;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
r = in_addr_prefix_from_string(rvalue, AF_INET6, (union in_addr_union *) &network->dhcp6_pd_address, &network->dhcp6_pd_length);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse PrefixDelegationHint=%s, ignoring assignment", rvalue);
return 0;
}
if (network->dhcp6_pd_length < 1 || network->dhcp6_pd_length > 128) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid prefix length='%d', ignoring assignment", network->dhcp6_pd_length);
network->dhcp6_pd_length = 0;
return 0;
}
return 0;
}
int config_parse_dhcp_user_class(
const char *unit,
const char *filename,
@ -378,6 +382,47 @@ int config_parse_dhcp_vendor_class(
return 0;
}
int config_parse_dhcp6_mud_url(
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) {
_cleanup_free_ char *unescaped = NULL;
Network *network = data;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
if (isempty(rvalue)) {
network->dhcp6_mudurl = mfree(network->dhcp6_mudurl);
return 0;
}
r = cunescape(rvalue, 0, &unescaped);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
"Failed to Failed to unescape MUD URL, ignoring: %s", rvalue);
return 0;
}
if (!http_url_is_valid(unescaped) || strlen(unescaped) > UINT8_MAX) {
log_syntax(unit, LOG_ERR, filename, line, 0,
"Failed to parse MUD URL '%s', ignoring: %m", rvalue);
return 0;
}
return free_and_replace(network->dhcp6_mudurl, unescaped);
}
int config_parse_dhcp_send_option(
const char *unit,
const char *filename,

View File

@ -42,12 +42,14 @@ const char *dhcp_option_data_type_to_string(DHCPOptionDataType d) _const_;
DHCPOptionDataType dhcp_option_data_type_from_string(const char *d) _pure_;
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_route_metric);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_use_dns);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_use_domains);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_use_ntp);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_use_sip);
CONFIG_PARSER_PROTOTYPE(config_parse_iaid);
CONFIG_PARSER_PROTOTYPE(config_parse_section_route_table);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp6_pd_hint);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp6_mud_url);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_user_class);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_vendor_class);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_send_option);

View File

@ -10,7 +10,6 @@
#include "sd-dhcp6-client.h"
#include "escape.h"
#include "hashmap.h"
#include "hostname-util.h"
#include "missing_network.h"
@ -21,7 +20,6 @@
#include "siphash24.h"
#include "string-util.h"
#include "radv-internal.h"
#include "web-util.h"
static int dhcp6_lease_address_acquired(sd_dhcp6_client *client, Link *link);
static Link *dhcp6_prefix_get(Manager *m, struct in6_addr *addr);
@ -1079,79 +1077,3 @@ static int dhcp6_assign_delegated_prefix(Link *link,
return 0;
}
int config_parse_dhcp6_pd_hint(
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;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
r = in_addr_prefix_from_string(rvalue, AF_INET6, (union in_addr_union *) &network->dhcp6_pd_address, &network->dhcp6_pd_length);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse PrefixDelegationHint=%s, ignoring assignment", rvalue);
return 0;
}
if (network->dhcp6_pd_length < 1 || network->dhcp6_pd_length > 128) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid prefix length='%d', ignoring assignment", network->dhcp6_pd_length);
network->dhcp6_pd_length = 0;
return 0;
}
return 0;
}
int config_parse_dhcp6_mud_url(
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) {
_cleanup_free_ char *unescaped = NULL;
Network *network = data;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
if (isempty(rvalue)) {
network->dhcp6_mudurl = mfree(network->dhcp6_mudurl);
return 0;
}
r = cunescape(rvalue, 0, &unescaped);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
"Failed to Failed to unescape MUD URL, ignoring: %s", rvalue);
return 0;
}
if (!http_url_is_valid(unescaped) || strlen(unescaped) > UINT8_MAX) {
log_syntax(unit, LOG_ERR, filename, line, 0,
"Failed to parse MUD URL '%s', ignoring: %m", rvalue);
return 0;
}
return free_and_replace(network->dhcp6_mudurl, unescaped);
}

View File

@ -13,6 +13,3 @@ int dhcp6_configure(Link *link);
int dhcp6_request_address(Link *link, int ir);
int dhcp6_lease_pd_prefix_lost(sd_dhcp6_client *client, Link* link);
int dhcp6_prefix_remove(Manager *m, struct in6_addr *addr);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp6_pd_hint);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp6_mud_url);

View File

@ -216,7 +216,7 @@ static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) {
route->family = AF_INET6;
route->table = link_get_ipv6_accept_ra_route_table(link);
route->priority = link->network->dhcp6_route_metric;
route->priority = link->network->dhcp_route_metric;
route->protocol = RTPROT_RA;
route->pref = preference;
route->gw = gateway;
@ -451,7 +451,7 @@ static int ndisc_router_process_onlink_prefix(Link *link, sd_ndisc_router *rt) {
route->family = AF_INET6;
route->table = link_get_ipv6_accept_ra_route_table(link);
route->priority = link->network->dhcp6_route_metric;
route->priority = link->network->dhcp_route_metric;
route->protocol = RTPROT_RA;
route->flags = RTM_F_PREFIX;
route->dst_prefixlen = prefixlen;
@ -512,7 +512,6 @@ static int ndisc_router_process_route(Link *link, sd_ndisc_router *rt) {
route->family = AF_INET6;
route->table = link_get_ipv6_accept_ra_route_table(link);
route->priority = link->network->dhcp6_route_metric;
route->protocol = RTPROT_RA;
route->pref = preference;
route->gw.in6 = gateway;

View File

@ -11,7 +11,6 @@ _Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"")
#include "networkd-dhcp-common.h"
#include "networkd-dhcp-server.h"
#include "networkd-dhcp4.h"
#include "networkd-dhcp6.h"
#include "networkd-ipv4ll.h"
#include "networkd-ndisc.h"
#include "networkd-network.h"
@ -159,9 +158,9 @@ Route.MultiPathRoute, config_parse_multipath_route,
NextHop.Id, config_parse_nexthop_id, 0, 0
NextHop.Gateway, config_parse_nexthop_gateway, 0, 0
DHCPv4.ClientIdentifier, config_parse_dhcp_client_identifier, 0, offsetof(Network, dhcp_client_identifier)
DHCPv4.UseDNS, config_parse_dhcp_use_dns, 0, 0
DHCPv4.UseDNS, config_parse_bool, 0, offsetof(Network, dhcp_use_dns)
DHCPv4.RoutesToDNS, config_parse_bool, 0, offsetof(Network, dhcp_routes_to_dns)
DHCPv4.UseNTP, config_parse_dhcp_use_ntp, 0, 0
DHCPv4.UseNTP, config_parse_bool, 0, offsetof(Network, dhcp_use_ntp)
DHCPv4.UseSIP, config_parse_bool, 0, offsetof(Network, dhcp_use_sip)
DHCPv4.UseMTU, config_parse_bool, 0, offsetof(Network, dhcp_use_mtu)
DHCPv4.UseHostname, config_parse_bool, 0, offsetof(Network, dhcp_use_hostname)
@ -179,7 +178,7 @@ DHCPv4.MaxAttempts, config_parse_dhcp_max_attempts,
DHCPv4.UserClass, config_parse_dhcp_user_class, AF_INET, offsetof(Network, dhcp_user_class)
DHCPv4.DUIDType, config_parse_duid_type, 0, offsetof(Network, duid)
DHCPv4.DUIDRawData, config_parse_duid_rawdata, 0, offsetof(Network, duid)
DHCPv4.RouteMetric, config_parse_dhcp_route_metric, 0, 0
DHCPv4.RouteMetric, config_parse_unsigned, 0, offsetof(Network, dhcp_route_metric)
DHCPv4.RouteTable, config_parse_section_route_table, 0, 0
DHCPv4.UseTimezone, config_parse_bool, 0, offsetof(Network, dhcp_use_timezone)
DHCPv4.IAID, config_parse_iaid, 0, 0
@ -192,8 +191,8 @@ DHCPv4.SendOption, config_parse_dhcp_send_option,
DHCPv4.SendVendorOption, config_parse_dhcp_send_option, 0, offsetof(Network, dhcp_client_send_vendor_options)
DHCPv4.RouteMTUBytes, config_parse_mtu, AF_INET, offsetof(Network, dhcp_route_mtu)
DHCPv4.FallbackLeaseLifetimeSec, config_parse_dhcp_fallback_lease_lifetime, 0, 0
DHCPv6.UseDNS, config_parse_dhcp_use_dns, 0, 0
DHCPv6.UseNTP, config_parse_dhcp_use_ntp, 0, 0
DHCPv6.UseDNS, config_parse_bool, 0, offsetof(Network, dhcp6_use_dns)
DHCPv6.UseNTP, config_parse_bool, 0, offsetof(Network, dhcp6_use_ntp)
DHCPv6.RapidCommit, config_parse_bool, 0, offsetof(Network, rapid_commit)
DHCPv6.MUDURL, config_parse_dhcp6_mud_url, 0, 0
DHCPv6.RequestOptions, config_parse_dhcp_request_options, AF_INET6, 0
@ -205,7 +204,6 @@ DHCPv6.AssignAcquiredDelegatedPrefixAddress, config_parse_bool,
DHCPv6.PrefixDelegationHint, config_parse_dhcp6_pd_hint, 0, 0
DHCPv6.WithoutRA, config_parse_bool, 0, offsetof(Network, dhcp6_without_ra)
DHCPv6.SendOption, config_parse_dhcp_send_option, AF_INET6, offsetof(Network, dhcp6_client_send_options)
DHCPv6.RouteMetric, config_parse_dhcp_route_metric, 0, 0
IPv6AcceptRA.UseAutonomousPrefix, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_autonomous_prefix)
IPv6AcceptRA.UseOnLinkPrefix, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_onlink_prefix)
IPv6AcceptRA.UseDNS, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_dns)
@ -396,7 +394,7 @@ DHCP.VendorClassIdentifier, config_parse_string,
DHCP.UserClass, config_parse_dhcp_user_class, AF_INET, offsetof(Network, dhcp_user_class)
DHCP.DUIDType, config_parse_duid_type, 0, offsetof(Network, duid)
DHCP.DUIDRawData, config_parse_duid_rawdata, 0, offsetof(Network, duid)
DHCP.RouteMetric, config_parse_dhcp_route_metric, 0, 0
DHCP.RouteMetric, config_parse_unsigned, 0, offsetof(Network, dhcp_route_metric)
DHCP.RouteTable, config_parse_section_route_table, 0, 0
DHCP.UseTimezone, config_parse_bool, 0, offsetof(Network, dhcp_use_timezone)
DHCP.IAID, config_parse_iaid, 0, 0

View File

@ -410,7 +410,6 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
.dhcp_use_timezone = false,
.rapid_commit = true,
.dhcp6_route_metric = DHCP_ROUTE_METRIC,
.dhcp6_use_ntp = true,
.dhcp6_use_dns = true,

View File

@ -95,8 +95,7 @@ struct Network {
char **dhcp_user_class;
char *dhcp_hostname;
uint64_t dhcp_max_attempts;
uint32_t dhcp_route_metric;
bool dhcp_route_metric_set;
unsigned dhcp_route_metric;
uint32_t dhcp_route_table;
uint32_t dhcp_fallback_lease_lifetime;
uint32_t dhcp_route_mtu;
@ -107,10 +106,8 @@ struct Network {
bool dhcp_send_hostname;
bool dhcp_broadcast;
bool dhcp_use_dns;
bool dhcp_use_dns_set;
bool dhcp_routes_to_dns;
bool dhcp_use_ntp;
bool dhcp_use_ntp_set;
bool dhcp_use_sip;
bool dhcp_use_mtu;
bool dhcp_use_routes;
@ -132,13 +129,9 @@ struct Network {
/* DHCPv6 Client support*/
bool dhcp6_use_dns;
bool dhcp6_use_dns_set;
bool dhcp6_use_ntp;
bool dhcp6_use_ntp_set;
bool dhcp6_without_ra;
uint8_t dhcp6_pd_length;
uint32_t dhcp6_route_metric;
bool dhcp6_route_metric_set;
char *dhcp6_mudurl;
char **dhcp6_user_class;
char **dhcp6_vendor_class;

View File

@ -121,7 +121,6 @@ UserClass=
VendorClass=
AssignAcquiredDelegatedPrefixAddress=
SendVendorOption=
RouteMetric=
[Route]
Destination=
Protocol=