Compare commits

..

17 Commits

Author SHA1 Message Date
Yu Watanabe d96edb2c6e network: downgrade log level in conf parsers 2020-07-17 00:40:09 +09:00
Lennart Poettering 4d939d2c84
Merge pull request #16485 from bluca/nspawn_os_release_mounts
Follow-up for comments on #15891
2020-07-16 15:09:35 +02:00
Yu Watanabe 9e54462cd5
Merge pull request #16482 from poettering/coverity-246
two coverity fixes
2020-07-16 20:23:23 +09:00
Luca Boccassi 14f1c47a0c nspawn: mount os-release in two steps to make it read-only
The kernel interface requires setting up read-only bind-mounts in
two steps, the bind first and then a read-only remount.
Fix nspawn-mount, and cover this case in the integration test.

Fixes #16484
2020-07-16 09:59:59 +01:00
Luca Boccassi eafc7d6056 nspawn: use access/F_OK instead of stat to check for file existence 2020-07-16 09:59:59 +01:00
Luca Boccassi 2094cd49c4 shared/os-util: fix comment style to follow guidelines 2020-07-16 09:59:59 +01:00
Luca Boccassi cc76bf01e3 basic/mkdir: use uid_is_valid instead of manual check 2020-07-16 09:59:59 +01:00
Zbigniew Jędrzejewski-Szmek 40282752a2
Merge pull request #16483 from poettering/man-env-d-no-session
man: three minor fixes to environment.d/ man page
2020-07-16 10:06:35 +02:00
Zbigniew Jędrzejewski-Szmek 27806670ef
Merge pull request #16480 from yuwata/network-fix-dhcp4-races
network: fix two minor races in DHCP4 handling
2020-07-16 10:04:05 +02:00
Lennart Poettering 3f13f9159f man: configuration files contain assignments, no directories 2020-07-16 09:26:55 +02:00
Lennart Poettering d320bfa558 man: GNOME is usually capitalized 2020-07-16 09:26:38 +02:00
Lennart Poettering a449b7198c man: don't claim environment.d/ was about sessions
This only sets the environment for user *services*, it has no effect on
sessions, as those get an env block set up by whatever program sets them
up and not systemd.
2020-07-16 09:25:24 +02:00
Lennart Poettering 8e32ad9557 machine: fix if check
Fixes: coverity 1430462
2020-07-16 08:35:26 +02:00
Lennart Poettering f63ef93703 execute: fix if check
Fixes: coverity 1430459
2020-07-16 08:35:18 +02:00
Yu Watanabe f766d9af38 network: dhcp4: add two warnings 2020-07-16 10:54:16 +09:00
Yu Watanabe 153cf04139 network: dhcp4: fix another race with SendDecline=yes
If the SD_IPV4ACD_EVENT_BIND event happens before all routes are
assigned, then the link stuck in configuring state.
2020-07-16 10:54:08 +09:00
Yu Watanabe 75be72d139 network: dhcp4: also release old lease in dhcp_lease_lost()
The lease lost may happen during renewing address. If it happens,
assertion hits in dhcp4_release_old_lease().
2020-07-16 10:51:46 +09:00
65 changed files with 961 additions and 818 deletions

View File

@ -22,7 +22,7 @@
<refnamediv> <refnamediv>
<refname>environment.d</refname> <refname>environment.d</refname>
<refpurpose>Definition of user session environment</refpurpose> <refpurpose>Definition of user service environment</refpurpose>
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
@ -36,8 +36,8 @@
<refsect1> <refsect1>
<title>Description</title> <title>Description</title>
<para>The <filename>environment.d</filename> directories contain a list of environment variable <para>Configuration files in the <filename>environment.d/</filename> directories contain lists of
assignments for services started by the systemd user instance. environment variable assignments for services started by the systemd user instance.
<citerefentry><refentrytitle>systemd-environment-d-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry> <citerefentry><refentrytitle>systemd-environment-d-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>
parses them and updates the environment exported by the systemd user instance. See below for an parses them and updates the environment exported by the systemd user instance. See below for an
discussion of which processes inherit those variables.</para> discussion of which processes inherit those variables.</para>
@ -58,7 +58,6 @@
variable assignments, separated by newlines. The right hand side of these assignments may variable assignments, separated by newlines. The right hand side of these assignments may
reference previously defined environment variables, using the <literal>${OTHER_KEY}</literal> reference previously defined environment variables, using the <literal>${OTHER_KEY}</literal>
and <literal>$OTHER_KEY</literal> format. It is also possible to use and <literal>$OTHER_KEY</literal> format. It is also possible to use
<literal>${<replaceable>FOO</replaceable>:-<replaceable>DEFAULT_VALUE</replaceable>}</literal> <literal>${<replaceable>FOO</replaceable>:-<replaceable>DEFAULT_VALUE</replaceable>}</literal>
to expand in the same way as <literal>${<replaceable>FOO</replaceable>}</literal> unless the to expand in the same way as <literal>${<replaceable>FOO</replaceable>}</literal> unless the
expansion would be empty, in which case it expands to <replaceable>DEFAULT_VALUE</replaceable>, expansion would be empty, in which case it expands to <replaceable>DEFAULT_VALUE</replaceable>,
@ -95,7 +94,7 @@
<para>Environment variables exported by the user manager (<command>systemd --user</command> instance <para>Environment variables exported by the user manager (<command>systemd --user</command> instance
started in the <filename>user@<replaceable>uid</replaceable>.service</filename> system service) apply to started in the <filename>user@<replaceable>uid</replaceable>.service</filename> system service) apply to
any services started by that manager. In particular, this may include services which run user shells. For any services started by that manager. In particular, this may include services which run user shells. For
example in the Gnome environment, the graphical terminal emulator runs as the example in the GNOME environment, the graphical terminal emulator runs as the
<filename>gnome-terminal-server.service</filename> user unit, which in turn runs the user shell, so that <filename>gnome-terminal-server.service</filename> user unit, which in turn runs the user shell, so that
shell will inherit environment variables exported by the user manager. For other instances of the shell, shell will inherit environment variables exported by the user manager. For other instances of the shell,
not launched by the user manager, the environment they inherit is defined by the program that starts not launched by the user manager, the environment they inherit is defined by the program that starts

View File

@ -136,7 +136,7 @@ int mkdir_parents_internal(const char *prefix, const char *path, mode_t mode, ui
if (prefix && path_startswith(prefix, t)) if (prefix && path_startswith(prefix, t))
continue; continue;
if (uid == UID_INVALID && gid == UID_INVALID && flags == 0) { if (!uid_is_valid(uid) && !gid_is_valid(gid) && flags == 0) {
r = _mkdir(t, mode); r = _mkdir(t, mode);
if (r < 0 && r != -EEXIST) if (r < 0 && r != -EEXIST)
return r; return r;
@ -167,7 +167,7 @@ int mkdir_p_internal(const char *prefix, const char *path, mode_t mode, uid_t ui
if (r < 0) if (r < 0)
return r; return r;
if (uid == UID_INVALID && gid == UID_INVALID && flags == 0) { if (!uid_is_valid(uid) && !gid_is_valid(gid) && flags == 0) {
r = _mkdir(path, mode); r = _mkdir(path, mode);
if (r < 0 && (r != -EEXIST || is_dir(path, true) <= 0)) if (r < 0 && (r != -EEXIST || is_dir(path, true) <= 0))
return r; return r;

View File

@ -2630,7 +2630,7 @@ static int apply_mount_namespace(
if (streq_ptr(runtime->var_tmp_dir, RUN_SYSTEMD_EMPTY)) if (streq_ptr(runtime->var_tmp_dir, RUN_SYSTEMD_EMPTY))
var_tmp_dir = runtime->var_tmp_dir; var_tmp_dir = runtime->var_tmp_dir;
else if (runtime->tmp_dir) else if (runtime->var_tmp_dir)
var_tmp_dir = strjoina(runtime->var_tmp_dir, "/tmp"); var_tmp_dir = strjoina(runtime->var_tmp_dir, "/tmp");
} }

View File

@ -268,7 +268,7 @@ static int group_lookup_name(Manager *m, const char *name, gid_t *ret_gid) {
return -ENOMEM; return -ENOMEM;
machine = hashmap_get(m->machines, mn); machine = hashmap_get(m->machines, mn);
if (!mn) if (!machine)
return -ESRCH; return -ESRCH;
if (machine->class != MACHINE_CONTAINER) if (machine->class != MACHINE_CONTAINER)

View File

@ -320,13 +320,15 @@ int config_parse_arp_ip_target_address(
return 0; return 0;
} }
for (;;) { for (const char *p = rvalue;;) {
_cleanup_free_ char *n = NULL; _cleanup_free_ char *n = NULL;
union in_addr_union ip; union in_addr_union ip;
r = extract_first_word(&rvalue, &n, NULL, 0); r = extract_first_word(&p, &n, NULL, 0);
if (r == -ENOMEM)
return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse Bond ARP IP target address, ignoring assignment: %s", "Failed to parse Bond ARP IP target address, ignoring assignment: %s",
rvalue); rvalue);
return 0; return 0;
@ -336,7 +338,7 @@ int config_parse_arp_ip_target_address(
r = in_addr_from_string(AF_INET, n, &ip); r = in_addr_from_string(AF_INET, n, &ip);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Bond ARP IP target address is invalid, ignoring assignment: %s", n); "Bond ARP IP target address is invalid, ignoring assignment: %s", n);
continue; continue;
} }
@ -357,7 +359,7 @@ int config_parse_arp_ip_target_address(
log_syntax(unit, LOG_WARNING, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Bond ARP IP target address is duplicated, ignoring assignment: %s", n); "Bond ARP IP target address is duplicated, ignoring assignment: %s", n);
if (r < 0) if (r < 0)
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to store bond ARP IP target address '%s', ignoring assignment: %m", n); "Failed to store bond ARP IP target address '%s', ignoring assignment: %m", n);
} }
} }
@ -384,13 +386,13 @@ int config_parse_ad_actor_sys_prio(
r = safe_atou16(rvalue, &v); r = safe_atou16(rvalue, &v);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse actor system priority '%s', ignoring: %m", rvalue); "Failed to parse actor system priority '%s', ignoring: %m", rvalue);
return 0; return 0;
} }
if (v == 0) { if (v == 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Failed to parse actor system priority '%s'. Range is [1,65535], ignoring.", "Failed to parse actor system priority '%s'. Range is [1,65535], ignoring.",
rvalue); rvalue);
return 0; return 0;
@ -423,13 +425,13 @@ int config_parse_ad_user_port_key(
r = safe_atou16(rvalue, &v); r = safe_atou16(rvalue, &v);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse user port key '%s', ignoring: %m", rvalue); "Failed to parse user port key '%s', ignoring: %m", rvalue);
return 0; return 0;
} }
if (v > 1023) { if (v > 1023) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Failed to parse user port key '%s'. Range is [0…1023], ignoring.", rvalue); "Failed to parse user port key '%s'. Range is [0…1023], ignoring.", rvalue);
return 0; return 0;
} }
@ -461,13 +463,13 @@ int config_parse_ad_actor_system(
r = ether_addr_from_string(rvalue, &n); r = ether_addr_from_string(rvalue, &n);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Not a valid MAC address %s. Ignoring assignment: %m", "Not a valid MAC address %s. Ignoring assignment: %m",
rvalue); rvalue);
return 0; return 0;
} }
if (ether_addr_is_null(&n) || (n.ether_addr_octet[0] & 0x01)) { if (ether_addr_is_null(&n) || (n.ether_addr_octet[0] & 0x01)) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Not a valid MAC address %s, can not be null or multicast. Ignoring assignment.", "Not a valid MAC address %s, can not be null or multicast. Ignoring assignment.",
rvalue); rvalue);
return 0; return 0;

View File

@ -326,13 +326,13 @@ int config_parse_bridge_igmp_version(
r = safe_atou8(rvalue, &u); r = safe_atou8(rvalue, &u);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse bridge's multicast IGMP version number '%s', ignoring assignment: %m", "Failed to parse bridge's multicast IGMP version number '%s', ignoring assignment: %m",
rvalue); rvalue);
return 0; return 0;
} }
if (!IN_SET(u, 2, 3)) { if (!IN_SET(u, 2, 3)) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid bridge's multicast IGMP version number '%s', ignoring assignment.", rvalue); "Invalid bridge's multicast IGMP version number '%s', ignoring assignment.", rvalue);
return 0; return 0;
} }

View File

@ -167,14 +167,14 @@ int config_parse_ip_protocol(
else { else {
r = safe_atou(rvalue, &protocol); r = safe_atou(rvalue, &protocol);
if (r < 0) if (r < 0)
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse IP protocol '%s' for FooOverUDP tunnel, " "Failed to parse IP protocol '%s' for FooOverUDP tunnel, "
"ignoring assignment: %m", rvalue); "ignoring assignment: %m", rvalue);
return 0; return 0;
} }
if (protocol > UINT8_MAX) { if (protocol > UINT8_MAX) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"IP protocol '%s' for FooOverUDP tunnel out of range, " "IP protocol '%s' for FooOverUDP tunnel out of range, "
"ignoring assignment: %m", rvalue); "ignoring assignment: %m", rvalue);
return 0; return 0;
@ -212,7 +212,7 @@ int config_parse_fou_tunnel_address(
r = in_addr_from_string_auto(rvalue, f, addr); r = in_addr_from_string_auto(rvalue, f, addr);
if (r < 0) if (r < 0)
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"FooOverUDP tunnel '%s' address is invalid, ignoring assignment: %s", "FooOverUDP tunnel '%s' address is invalid, ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);

View File

@ -185,12 +185,12 @@ int config_parse_geneve_vni(const char *unit,
r = safe_atou32(rvalue, &f); r = safe_atou32(rvalue, &f);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse Geneve VNI '%s'.", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse Geneve VNI '%s'.", rvalue);
return 0; return 0;
} }
if (f > GENEVE_VID_MAX){ if (f > GENEVE_VID_MAX){
log_syntax(unit, LOG_ERR, filename, line, r, "Geneve VNI out is of range '%s'.", rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "Geneve VNI out is of range '%s'.", rvalue);
return 0; return 0;
} }
@ -220,13 +220,13 @@ int config_parse_geneve_address(const char *unit,
r = in_addr_from_string_auto(rvalue, &f, &buffer); r = in_addr_from_string_auto(rvalue, &f, &buffer);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "geneve '%s' address is invalid, ignoring assignment: %s", lvalue, rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "geneve '%s' address is invalid, ignoring assignment: %s", lvalue, rvalue);
return 0; return 0;
} }
r = in_addr_is_multicast(f, &buffer); r = in_addr_is_multicast(f, &buffer);
if (r > 0) { if (r > 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, "geneve invalid multicast '%s' address, ignoring assignment: %s", lvalue, rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "geneve invalid multicast '%s' address, ignoring assignment: %s", lvalue, rvalue);
return 0; return 0;
} }
@ -257,12 +257,12 @@ int config_parse_geneve_flow_label(const char *unit,
r = safe_atou32(rvalue, &f); r = safe_atou32(rvalue, &f);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse Geneve flow label '%s'.", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse Geneve flow label '%s'.", rvalue);
return 0; return 0;
} }
if (f & ~GENEVE_FLOW_LABEL_MAX_MASK) { if (f & ~GENEVE_FLOW_LABEL_MAX_MASK) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Geneve flow label '%s' not valid. Flow label range should be [0-1048575].", rvalue); "Geneve flow label '%s' not valid. Flow label range should be [0-1048575].", rvalue);
return 0; return 0;
} }
@ -296,13 +296,13 @@ int config_parse_geneve_ttl(const char *unit,
else { else {
r = safe_atou(rvalue, &f); r = safe_atou(rvalue, &f);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse Geneve TTL '%s', ignoring assignment: %m", rvalue); "Failed to parse Geneve TTL '%s', ignoring assignment: %m", rvalue);
return 0; return 0;
} }
if (f > 255) { if (f > 255) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid Geneve TTL '%s'. TTL must be <= 255. Ignoring assignment.", rvalue); "Invalid Geneve TTL '%s'. TTL must be <= 255. Ignoring assignment.", rvalue);
return 0; return 0;
} }

View File

@ -459,7 +459,7 @@ int config_parse_l2tp_tunnel_address(
else else
r = in_addr_from_string(t->family, rvalue, addr); r = in_addr_from_string(t->family, rvalue, addr);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid L2TP Tunnel address specified in %s='%s', ignoring assignment: %m", lvalue, rvalue); "Invalid L2TP Tunnel address specified in %s='%s', ignoring assignment: %m", lvalue, rvalue);
return 0; return 0;
} }
@ -489,13 +489,13 @@ int config_parse_l2tp_tunnel_id(
r = safe_atou32(rvalue, &k); r = safe_atou32(rvalue, &k);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse L2TP tunnel id. Ignoring assignment: %s", rvalue); "Failed to parse L2TP tunnel id. Ignoring assignment: %s", rvalue);
return 0; return 0;
} }
if (k == 0) { if (k == 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid L2TP tunnel id. Ignoring assignment: %s", rvalue); "Invalid L2TP tunnel id. Ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -530,17 +530,17 @@ int config_parse_l2tp_session_id(
r = l2tp_session_new_static(t, filename, section_line, &session); r = l2tp_session_new_static(t, filename, section_line, &session);
if (r < 0) if (r < 0)
return r; return log_oom();
r = safe_atou32(rvalue, &k); r = safe_atou32(rvalue, &k);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse L2TP session id. Ignoring assignment: %s", rvalue); "Failed to parse L2TP session id. Ignoring assignment: %s", rvalue);
return 0; return 0;
} }
if (k == 0) { if (k == 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid L2TP session id. Ignoring assignment: %s", rvalue); "Invalid L2TP session id. Ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -579,11 +579,11 @@ int config_parse_l2tp_session_l2spec(
r = l2tp_session_new_static(t, filename, section_line, &session); r = l2tp_session_new_static(t, filename, section_line, &session);
if (r < 0) if (r < 0)
return r; return log_oom();
spec = l2tp_l2spec_type_from_string(rvalue); spec = l2tp_l2spec_type_from_string(rvalue);
if (spec < 0) { if (spec < 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Failed to parse layer2 specific header type. Ignoring assignment: %s", rvalue); "Failed to parse layer2 specific header type. Ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -618,10 +618,10 @@ int config_parse_l2tp_session_name(
r = l2tp_session_new_static(t, filename, section_line, &session); r = l2tp_session_new_static(t, filename, section_line, &session);
if (r < 0) if (r < 0)
return r; return log_oom();
if (!ifname_valid(rvalue)) { if (!ifname_valid(rvalue)) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Failed to parse L2TP tunnel session name. Ignoring assignment: %s", rvalue); "Failed to parse L2TP tunnel session name. Ignoring assignment: %s", rvalue);
return 0; return 0;
} }

View File

@ -577,7 +577,7 @@ int config_parse_macsec_port(
else if (streq(section, "MACsecReceiveChannel")) { else if (streq(section, "MACsecReceiveChannel")) {
r = macsec_receive_channel_new_static(s, filename, section_line, &c); r = macsec_receive_channel_new_static(s, filename, section_line, &c);
if (r < 0) if (r < 0)
return r; return log_oom();
dest = &c->sci.port; dest = &c->sci.port;
} else { } else {
@ -585,14 +585,14 @@ int config_parse_macsec_port(
r = macsec_receive_association_new_static(s, filename, section_line, &b); r = macsec_receive_association_new_static(s, filename, section_line, &b);
if (r < 0) if (r < 0)
return r; return log_oom();
dest = &b->sci.port; dest = &b->sci.port;
} }
r = parse_ip_port(rvalue, &port); r = parse_ip_port(rvalue, &port);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse port '%s' for secure channel identifier. Ignoring assignment: %m", "Failed to parse port '%s' for secure channel identifier. Ignoring assignment: %m",
rvalue); rvalue);
return 0; return 0;
@ -634,11 +634,11 @@ int config_parse_macsec_hw_address(
else else
r = macsec_receive_association_new_static(s, filename, section_line, &b); r = macsec_receive_association_new_static(s, filename, section_line, &b);
if (r < 0) if (r < 0)
return r; return log_oom();
r = ether_addr_from_string(rvalue, b ? &b->sci.mac : &c->sci.mac); r = ether_addr_from_string(rvalue, b ? &b->sci.mac : &c->sci.mac);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse MAC address for secure channel identifier. " "Failed to parse MAC address for secure channel identifier. "
"Ignoring assignment: %s", rvalue); "Ignoring assignment: %s", rvalue);
return 0; return 0;
@ -679,18 +679,18 @@ int config_parse_macsec_packet_number(
else else
r = macsec_receive_association_new_static(s, filename, section_line, &b); r = macsec_receive_association_new_static(s, filename, section_line, &b);
if (r < 0) if (r < 0)
return r; return log_oom();
dest = a ? &a->sa.packet_number : &b->sa.packet_number; dest = a ? &a->sa.packet_number : &b->sa.packet_number;
r = safe_atou32(rvalue, &val); r = safe_atou32(rvalue, &val);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse packet number. Ignoring assignment: %s", rvalue); "Failed to parse packet number. Ignoring assignment: %s", rvalue);
return 0; return 0;
} }
if (streq(section, "MACsecTransmitAssociation") && val == 0) { if (streq(section, "MACsecTransmitAssociation") && val == 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid packet number. Ignoring assignment: %s", rvalue); "Invalid packet number. Ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -735,19 +735,19 @@ int config_parse_macsec_key(
else else
r = macsec_receive_association_new_static(s, filename, section_line, &b); r = macsec_receive_association_new_static(s, filename, section_line, &b);
if (r < 0) if (r < 0)
return r; return log_oom();
dest = a ? &a->sa : &b->sa; dest = a ? &a->sa : &b->sa;
r = unhexmem_full(rvalue, strlen(rvalue), true, &p, &l); r = unhexmem_full(rvalue, strlen(rvalue), true, &p, &l);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse key. Ignoring assignment: %m"); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse key. Ignoring assignment: %m");
return 0; return 0;
} }
if (l != 16) { if (l != 16) {
/* See DEFAULT_SAK_LEN in drivers/net/macsec.c */ /* See DEFAULT_SAK_LEN in drivers/net/macsec.c */
log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid key length (%zu). Ignoring assignment", l); log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid key length (%zu). Ignoring assignment", l);
return 0; return 0;
} }
@ -791,7 +791,7 @@ int config_parse_macsec_key_file(
else else
r = macsec_receive_association_new_static(s, filename, section_line, &b); r = macsec_receive_association_new_static(s, filename, section_line, &b);
if (r < 0) if (r < 0)
return r; return log_oom();
dest = a ? &a->sa.key_file : &b->sa.key_file; dest = a ? &a->sa.key_file : &b->sa.key_file;
@ -845,15 +845,15 @@ int config_parse_macsec_key_id(
else else
r = macsec_receive_association_new_static(s, filename, section_line, &b); r = macsec_receive_association_new_static(s, filename, section_line, &b);
if (r < 0) if (r < 0)
return r; return log_oom();
r = unhexmem(rvalue, strlen(rvalue), &p, &l); r = unhexmem(rvalue, strlen(rvalue), &p, &l);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse KeyId \"%s\": %m", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse KeyId \"%s\": %m", rvalue);
return 0; return 0;
} }
if (l > MACSEC_KEYID_LEN) if (l > MACSEC_KEYID_LEN)
return log_syntax(unit, LOG_ERR, filename, line, 0, return log_syntax(unit, LOG_WARNING, filename, line, 0,
"Specified KeyId is larger then the allowed maximum (%zu > %u), ignoring: %s", "Specified KeyId is larger then the allowed maximum (%zu > %u), ignoring: %s",
l, MACSEC_KEYID_LEN, rvalue); l, MACSEC_KEYID_LEN, rvalue);
@ -896,7 +896,7 @@ int config_parse_macsec_sa_activate(
else else
r = macsec_receive_association_new_static(s, filename, section_line, &b); r = macsec_receive_association_new_static(s, filename, section_line, &b);
if (r < 0) if (r < 0)
return r; return log_oom();
dest = a ? &a->sa.activate : &b->sa.activate; dest = a ? &a->sa.activate : &b->sa.activate;
@ -905,7 +905,7 @@ int config_parse_macsec_sa_activate(
else { else {
r = parse_boolean(rvalue); r = parse_boolean(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse activation mode of %s security association. " "Failed to parse activation mode of %s security association. "
"Ignoring assignment: %s", "Ignoring assignment: %s",
streq(section, "MACsecTransmitAssociation") ? "transmit" : "receive", streq(section, "MACsecTransmitAssociation") ? "transmit" : "receive",
@ -945,19 +945,21 @@ int config_parse_macsec_use_for_encoding(
r = macsec_transmit_association_new_static(s, filename, section_line, &a); r = macsec_transmit_association_new_static(s, filename, section_line, &a);
if (r < 0) if (r < 0)
return r; return log_oom();
if (isempty(rvalue)) {
a->sa.use_for_encoding = -1;
TAKE_PTR(a);
return 0;
}
if (isempty(rvalue))
r = -1;
else {
r = parse_boolean(rvalue); r = parse_boolean(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse %s= setting. Ignoring assignment: %s", "Failed to parse %s= setting. Ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
} }
}
a->sa.use_for_encoding = r; a->sa.use_for_encoding = r;
if (a->sa.use_for_encoding > 0) if (a->sa.use_for_encoding > 0)

View File

@ -137,12 +137,12 @@ int config_parse_netdev_kind(
k = netdev_kind_from_string(rvalue); k = netdev_kind_from_string(rvalue);
if (k < 0) { if (k < 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse netdev kind, ignoring assignment: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse netdev kind, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
if (*kind != _NETDEV_KIND_INVALID && *kind != k) { if (*kind != _NETDEV_KIND_INVALID && *kind != k) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Specified netdev kind is different from the previous value '%s', ignoring assignment: %s", "Specified netdev kind is different from the previous value '%s', ignoring assignment: %s",
netdev_kind_to_string(*kind), rvalue); netdev_kind_to_string(*kind), rvalue);
return 0; return 0;

View File

@ -541,13 +541,13 @@ int config_parse_tunnel_address(const char *unit,
r = in_addr_from_string_auto(rvalue, &f, &buffer); r = in_addr_from_string_auto(rvalue, &f, &buffer);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Tunnel address \"%s\" invalid, ignoring assignment: %m", rvalue); "Tunnel address \"%s\" invalid, ignoring assignment: %m", rvalue);
return 0; return 0;
} }
if (t->family != AF_UNSPEC && t->family != f) { if (t->family != AF_UNSPEC && t->family != f) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Tunnel addresses incompatible, ignoring assignment: %s", rvalue); "Tunnel addresses incompatible, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -581,7 +581,7 @@ int config_parse_tunnel_key(const char *unit,
if (r < 0) { if (r < 0) {
r = safe_atou32(rvalue, &k); r = safe_atou32(rvalue, &k);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse tunnel key ignoring assignment: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse tunnel key ignoring assignment: %s", rvalue);
return 0; return 0;
} }
} else } else
@ -626,7 +626,7 @@ int config_parse_ipv6_flowlabel(const char* unit,
return r; return r;
if (k > 0xFFFFF) if (k > 0xFFFFF)
log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse IPv6 flowlabel option, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse IPv6 flowlabel option, ignoring: %s", rvalue);
else { else {
*ipv6_flowlabel = htobe32(k) & IP6_FLOWINFO_FLOWLABEL; *ipv6_flowlabel = htobe32(k) & IP6_FLOWINFO_FLOWLABEL;
t->flags &= ~IP6_TNL_F_USE_ORIG_FLOWLABEL; t->flags &= ~IP6_TNL_F_USE_ORIG_FLOWLABEL;
@ -659,12 +659,12 @@ int config_parse_encap_limit(const char* unit,
else { else {
r = safe_atoi(rvalue, &k); r = safe_atoi(rvalue, &k);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse Tunnel Encapsulation Limit option, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse Tunnel Encapsulation Limit option, ignoring: %s", rvalue);
return 0; return 0;
} }
if (k > 255 || k < 0) if (k > 255 || k < 0)
log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid Tunnel Encapsulation value, ignoring: %d", k); log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid Tunnel Encapsulation value, ignoring: %d", k);
else { else {
t->encap_limit = k; t->encap_limit = k;
t->flags &= ~IP6_TNL_F_IGN_ENCAP_LIMIT; t->flags &= ~IP6_TNL_F_IGN_ENCAP_LIMIT;
@ -696,11 +696,11 @@ int config_parse_6rd_prefix(const char* unit,
r = in_addr_prefix_from_string(rvalue, AF_INET6, &p, &l); r = in_addr_prefix_from_string(rvalue, AF_INET6, &p, &l);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse 6rd prefix \"%s\", ignoring: %m", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse 6rd prefix \"%s\", ignoring: %m", rvalue);
return 0; return 0;
} }
if (l == 0) { if (l == 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, "6rd prefix length of \"%s\" must be greater than zero, ignoring", rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "6rd prefix length of \"%s\" must be greater than zero, ignoring", rvalue);
return 0; return 0;
} }

View File

@ -196,7 +196,7 @@ int config_parse_vxlan_address(const char *unit,
r = in_addr_from_string_auto(rvalue, &f, &buffer); r = in_addr_from_string_auto(rvalue, &f, &buffer);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "vxlan '%s' address is invalid, ignoring assignment: %s", lvalue, rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "vxlan '%s' address is invalid, ignoring assignment: %s", lvalue, rvalue);
return 0; return 0;
} }
@ -204,14 +204,14 @@ int config_parse_vxlan_address(const char *unit,
if (streq(lvalue, "Group")) { if (streq(lvalue, "Group")) {
if (r <= 0) { if (r <= 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, "vxlan %s invalid multicast address, ignoring assignment: %s", lvalue, rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "vxlan %s invalid multicast address, ignoring assignment: %s", lvalue, rvalue);
return 0; return 0;
} }
v->group_family = f; v->group_family = f;
} else { } else {
if (r > 0) { if (r > 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, "vxlan %s cannot be a multicast address, ignoring assignment: %s", lvalue, rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "vxlan %s cannot be a multicast address, ignoring assignment: %s", lvalue, rvalue);
return 0; return 0;
} }
@ -247,7 +247,7 @@ int config_parse_port_range(const char *unit,
r = parse_ip_port_range(rvalue, &low, &high); r = parse_ip_port_range(rvalue, &low, &high);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse VXLAN port range '%s'. Port should be greater than 0 and less than 65535.", rvalue); "Failed to parse VXLAN port range '%s'. Port should be greater than 0 and less than 65535.", rvalue);
return 0; return 0;
} }
@ -279,12 +279,12 @@ int config_parse_flow_label(const char *unit,
r = safe_atou(rvalue, &f); r = safe_atou(rvalue, &f);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse VXLAN flow label '%s'.", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse VXLAN flow label '%s'.", rvalue);
return 0; return 0;
} }
if (f & ~VXLAN_FLOW_LABEL_MAX_MASK) { if (f & ~VXLAN_FLOW_LABEL_MAX_MASK) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"VXLAN flow label '%s' not valid. Flow label range should be [0-1048575].", rvalue); "VXLAN flow label '%s' not valid. Flow label range should be [0-1048575].", rvalue);
return 0; return 0;
} }
@ -318,13 +318,13 @@ int config_parse_vxlan_ttl(const char *unit,
else { else {
r = safe_atou(rvalue, &f); r = safe_atou(rvalue, &f);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse VXLAN TTL '%s', ignoring assignment: %m", rvalue); "Failed to parse VXLAN TTL '%s', ignoring assignment: %m", rvalue);
return 0; return 0;
} }
if (f > 255) { if (f > 255) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid VXLAN TTL '%s'. TTL must be <= 255. Ignoring assignment.", rvalue); "Invalid VXLAN TTL '%s'. TTL must be <= 255. Ignoring assignment.", rvalue);
return 0; return 0;
} }

View File

@ -459,7 +459,7 @@ int config_parse_wireguard_listen_port(
r = parse_ip_port(rvalue, s); r = parse_ip_port(rvalue, s);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid port specification, ignoring assignment: %s", rvalue); "Invalid port specification, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -494,10 +494,10 @@ static int wireguard_decode_key_and_warn(
r = unbase64mem_full(rvalue, strlen(rvalue), true, &key, &len); r = unbase64mem_full(rvalue, strlen(rvalue), true, &key, &len);
if (r < 0) if (r < 0)
return log_syntax(unit, LOG_ERR, filename, line, r, return log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to decode wireguard key provided by %s=, ignoring assignment: %m", lvalue); "Failed to decode wireguard key provided by %s=, ignoring assignment: %m", lvalue);
if (len != WG_KEY_LEN) if (len != WG_KEY_LEN)
return log_syntax(unit, LOG_ERR, filename, line, 0, return log_syntax(unit, LOG_WARNING, filename, line, SYNTHETIC_ERRNO(EINVAL),
"Wireguard key provided by %s= has invalid length (%zu bytes), ignoring assignment.", "Wireguard key provided by %s= has invalid length (%zu bytes), ignoring assignment.",
lvalue, len); lvalue, len);
@ -583,9 +583,10 @@ int config_parse_wireguard_preshared_key(
r = wireguard_peer_new_static(w, filename, section_line, &peer); r = wireguard_peer_new_static(w, filename, section_line, &peer);
if (r < 0) if (r < 0)
return r; return log_oom();
return wireguard_decode_key_and_warn(rvalue, peer->preshared_key, unit, filename, line, lvalue); (void) wireguard_decode_key_and_warn(rvalue, peer->preshared_key, unit, filename, line, lvalue);
return 0;
} }
int config_parse_wireguard_preshared_key_file( int config_parse_wireguard_preshared_key_file(
@ -611,7 +612,7 @@ int config_parse_wireguard_preshared_key_file(
r = wireguard_peer_new_static(w, filename, section_line, &peer); r = wireguard_peer_new_static(w, filename, section_line, &peer);
if (r < 0) if (r < 0)
return r; return log_oom();
if (isempty(rvalue)) { if (isempty(rvalue)) {
peer->preshared_key_file = mfree(peer->preshared_key_file); peer->preshared_key_file = mfree(peer->preshared_key_file);
@ -653,11 +654,11 @@ int config_parse_wireguard_public_key(
r = wireguard_peer_new_static(w, filename, section_line, &peer); r = wireguard_peer_new_static(w, filename, section_line, &peer);
if (r < 0) if (r < 0)
return r; return log_oom();
r = wireguard_decode_key_and_warn(rvalue, peer->public_key, unit, filename, line, lvalue); r = wireguard_decode_key_and_warn(rvalue, peer->public_key, unit, filename, line, lvalue);
if (r < 0) if (r < 0)
return r; return 0;
TAKE_PTR(peer); TAKE_PTR(peer);
return 0; return 0;
@ -690,25 +691,25 @@ int config_parse_wireguard_allowed_ips(
r = wireguard_peer_new_static(w, filename, section_line, &peer); r = wireguard_peer_new_static(w, filename, section_line, &peer);
if (r < 0) if (r < 0)
return r; return log_oom();
for (;;) { for (const char *p = rvalue;;) {
_cleanup_free_ char *word = NULL; _cleanup_free_ char *word = NULL;
r = extract_first_word(&rvalue, &word, "," WHITESPACE, 0); r = extract_first_word(&p, &word, "," WHITESPACE, 0);
if (r == 0) if (r == 0)
break; break;
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to split allowed ips \"%s\" option: %m", rvalue); "Failed to split allowed ips \"%s\" option: %m", rvalue);
break; break;
} }
r = in_addr_prefix_from_string_auto(word, &family, &addr, &prefixlen); r = in_addr_prefix_from_string_auto(word, &family, &addr, &prefixlen);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Network address is invalid, ignoring assignment: %s", word); "Network address is invalid, ignoring assignment: %s", word);
continue; continue;
} }
@ -758,7 +759,7 @@ int config_parse_wireguard_endpoint(
begin = &rvalue[1]; begin = &rvalue[1];
end = strchr(rvalue, ']'); end = strchr(rvalue, ']');
if (!end) { if (!end) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Unable to find matching brace of endpoint, ignoring assignment: %s", "Unable to find matching brace of endpoint, ignoring assignment: %s",
rvalue); rvalue);
return 0; return 0;
@ -766,7 +767,7 @@ int config_parse_wireguard_endpoint(
len = end - begin; len = end - begin;
++end; ++end;
if (*end != ':' || !*(end + 1)) { if (*end != ':' || !*(end + 1)) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Unable to find port of endpoint, ignoring assignment: %s", "Unable to find port of endpoint, ignoring assignment: %s",
rvalue); rvalue);
return 0; return 0;
@ -776,7 +777,7 @@ int config_parse_wireguard_endpoint(
begin = rvalue; begin = rvalue;
end = strrchr(rvalue, ':'); end = strrchr(rvalue, ':');
if (!end || !*(end + 1)) { if (!end || !*(end + 1)) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Unable to find port of endpoint, ignoring assignment: %s", "Unable to find port of endpoint, ignoring assignment: %s",
rvalue); rvalue);
return 0; return 0;
@ -787,7 +788,7 @@ int config_parse_wireguard_endpoint(
r = wireguard_peer_new_static(w, filename, section_line, &peer); r = wireguard_peer_new_static(w, filename, section_line, &peer);
if (r < 0) if (r < 0)
return r; return log_oom();
r = free_and_strndup(&peer->endpoint_host, begin, len); r = free_and_strndup(&peer->endpoint_host, begin, len);
if (r < 0) if (r < 0)
@ -830,14 +831,14 @@ int config_parse_wireguard_keepalive(
r = wireguard_peer_new_static(w, filename, section_line, &peer); r = wireguard_peer_new_static(w, filename, section_line, &peer);
if (r < 0) if (r < 0)
return r; return log_oom();
if (streq(rvalue, "off")) if (streq(rvalue, "off"))
keepalive = 0; keepalive = 0;
else { else {
r = safe_atou16(rvalue, &keepalive); r = safe_atou16(rvalue, &keepalive);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse \"%s\" as keepalive interval (range 065535), ignoring assignment: %m", "Failed to parse \"%s\" as keepalive interval (range 065535), ignoring assignment: %m",
rvalue); rvalue);
return 0; return 0;

View File

@ -173,11 +173,11 @@ int config_parse_address_label_prefix(const char *unit,
r = address_label_new_static(network, filename, section_line, &n); r = address_label_new_static(network, filename, section_line, &n);
if (r < 0) if (r < 0)
return r; return log_oom();
r = in_addr_prefix_from_string(rvalue, AF_INET6, &n->in_addr, &n->prefixlen); r = in_addr_prefix_from_string(rvalue, AF_INET6, &n->in_addr, &n->prefixlen);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Address label is invalid, ignoring assignment: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Address label is invalid, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -211,16 +211,16 @@ int config_parse_address_label(
r = address_label_new_static(network, filename, section_line, &n); r = address_label_new_static(network, filename, section_line, &n);
if (r < 0) if (r < 0)
return r; return log_oom();
r = safe_atou32(rvalue, &k); r = safe_atou32(rvalue, &k);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse address label, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse address label, ignoring: %s", rvalue);
return 0; return 0;
} }
if (k == 0xffffffffUL) { if (k == 0xffffffffUL) {
log_syntax(unit, LOG_ERR, filename, line, r, "Address label is invalid, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "Address label is invalid, ignoring: %s", rvalue);
return 0; return 0;
} }

View File

@ -790,18 +790,23 @@ int config_parse_broadcast(
assert(data); assert(data);
r = address_new_static(network, filename, section_line, &n); r = address_new_static(network, filename, section_line, &n);
if (r < 0) if (r == -ENOMEM)
return r; return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to allocate new address, ignoring assignment: %m");
return 0;
}
if (n->family == AF_INET6) { if (n->family == AF_INET6) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Broadcast is not valid for IPv6 addresses, ignoring assignment: %s", rvalue); "Broadcast is not valid for IPv6 addresses, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
r = in_addr_from_string(AF_INET, rvalue, (union in_addr_union*) &n->broadcast); r = in_addr_from_string(AF_INET, rvalue, (union in_addr_union*) &n->broadcast);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Broadcast is invalid, ignoring assignment: %s", rvalue); "Broadcast is invalid, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -841,14 +846,18 @@ int config_parse_address(const char *unit,
r = address_new_static(network, NULL, 0, &n); r = address_new_static(network, NULL, 0, &n);
} else } else
r = address_new_static(network, filename, section_line, &n); r = address_new_static(network, filename, section_line, &n);
if (r == -ENOMEM)
if (r < 0) return log_oom();
return r; if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to allocate new address, ignoring assignment: %m");
return 0;
}
/* Address=address/prefixlen */ /* Address=address/prefixlen */
r = in_addr_prefix_from_string_auto_internal(rvalue, PREFIXLEN_REFUSE, &f, &buffer, &prefixlen); r = in_addr_prefix_from_string_auto_internal(rvalue, PREFIXLEN_REFUSE, &f, &buffer, &prefixlen);
if (r == -ENOANO) { if (r == -ENOANO) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"An address '%s' is specified without prefix length. " "An address '%s' is specified without prefix length. "
"The behavior of parsing addresses without prefix length will be changed in the future release. " "The behavior of parsing addresses without prefix length will be changed in the future release. "
"Please specify prefix length explicitly.", rvalue); "Please specify prefix length explicitly.", rvalue);
@ -856,12 +865,12 @@ int config_parse_address(const char *unit,
r = in_addr_prefix_from_string_auto_internal(rvalue, PREFIXLEN_LEGACY, &f, &buffer, &prefixlen); r = in_addr_prefix_from_string_auto_internal(rvalue, PREFIXLEN_LEGACY, &f, &buffer, &prefixlen);
} }
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Invalid address '%s', ignoring assignment: %m", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid address '%s', ignoring assignment: %m", rvalue);
return 0; return 0;
} }
if (n->family != AF_UNSPEC && f != n->family) { if (n->family != AF_UNSPEC && f != n->family) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Address is incompatible, ignoring assignment: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "Address is incompatible, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -871,7 +880,7 @@ int config_parse_address(const char *unit,
* let's limit the prefix length to 64 or larger. See RFC4193. */ * let's limit the prefix length to 64 or larger. See RFC4193. */
if ((f == AF_INET && prefixlen < 8) || if ((f == AF_INET && prefixlen < 8) ||
(f == AF_INET6 && prefixlen < 64)) { (f == AF_INET6 && prefixlen < 64)) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Null address with invalid prefixlen='%u', ignoring assignment: %s", "Null address with invalid prefixlen='%u', ignoring assignment: %s",
prefixlen, rvalue); prefixlen, rvalue);
return 0; return 0;
@ -917,11 +926,16 @@ int config_parse_label(
assert(data); assert(data);
r = address_new_static(network, filename, section_line, &n); r = address_new_static(network, filename, section_line, &n);
if (r < 0) if (r == -ENOMEM)
return r; return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to allocate new address, ignoring assignment: %m");
return 0;
}
if (!address_label_valid(rvalue)) { if (!address_label_valid(rvalue)) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Interface label is too long or invalid, ignoring assignment: %s", rvalue); "Interface label is too long or invalid, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -956,8 +970,13 @@ int config_parse_lifetime(const char *unit,
assert(data); assert(data);
r = address_new_static(network, filename, section_line, &n); r = address_new_static(network, filename, section_line, &n);
if (r < 0) if (r == -ENOMEM)
return r; return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to allocate new address, ignoring assignment: %m");
return 0;
}
/* We accept only "forever", "infinity", empty, or "0". */ /* We accept only "forever", "infinity", empty, or "0". */
if (STR_IN_SET(rvalue, "forever", "infinity", "")) if (STR_IN_SET(rvalue, "forever", "infinity", ""))
@ -965,7 +984,7 @@ int config_parse_lifetime(const char *unit,
else if (streq(rvalue, "0")) else if (streq(rvalue, "0"))
k = 0; k = 0;
else { else {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid PreferredLifetime= value, ignoring: %s", rvalue); "Invalid PreferredLifetime= value, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -997,12 +1016,17 @@ int config_parse_address_flags(const char *unit,
assert(data); assert(data);
r = address_new_static(network, filename, section_line, &n); r = address_new_static(network, filename, section_line, &n);
if (r < 0) if (r == -ENOMEM)
return r; return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to allocate new address, ignoring assignment: %m");
return 0;
}
r = parse_boolean(rvalue); r = parse_boolean(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse %s=, ignoring: %s", lvalue, rvalue); "Failed to parse %s=, ignoring: %s", lvalue, rvalue);
return 0; return 0;
} }
@ -1045,8 +1069,13 @@ int config_parse_address_scope(const char *unit,
assert(data); assert(data);
r = address_new_static(network, filename, section_line, &n); r = address_new_static(network, filename, section_line, &n);
if (r < 0) if (r == -ENOMEM)
return r; return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to allocate new address, ignoring assignment: %m");
return 0;
}
if (streq(rvalue, "host")) if (streq(rvalue, "host"))
n->scope = RT_SCOPE_HOST; n->scope = RT_SCOPE_HOST;
@ -1057,7 +1086,7 @@ int config_parse_address_scope(const char *unit,
else { else {
r = safe_atou8(rvalue , &n->scope); r = safe_atou8(rvalue , &n->scope);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Could not parse address scope \"%s\", ignoring assignment: %m", rvalue); "Could not parse address scope \"%s\", ignoring assignment: %m", rvalue);
return 0; return 0;
} }
@ -1091,8 +1120,13 @@ int config_parse_duplicate_address_detection(
assert(data); assert(data);
r = address_new_static(network, filename, section_line, &n); r = address_new_static(network, filename, section_line, &n);
if (r < 0) if (r == -ENOMEM)
return r; return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to allocate new address, ignoring assignment: %m");
return 0;
}
r = parse_boolean(rvalue); r = parse_boolean(rvalue);
if (r >= 0) { if (r >= 0) {
@ -1107,7 +1141,7 @@ int config_parse_duplicate_address_detection(
a = duplicate_address_detection_address_family_from_string(rvalue); a = duplicate_address_detection_address_family_from_string(rvalue);
if (a < 0) { if (a < 0) {
log_syntax(unit, LOG_ERR, filename, line, SYNTHETIC_ERRNO(EINVAL), log_syntax(unit, LOG_WARNING, filename, line, SYNTHETIC_ERRNO(EINVAL),
"Failed to parse %s=, ignoring: %s", lvalue, rvalue); "Failed to parse %s=, ignoring: %s", lvalue, rvalue);
return 0; return 0;
} }

View File

@ -241,7 +241,7 @@ int config_parse_brvlan_vlan(const char *unit, const char *filename,
r = parse_vid_range(rvalue, &vid, &vid_end); r = parse_vid_range(rvalue, &vid, &vid_end);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse VLAN, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse VLAN, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -269,7 +269,7 @@ int config_parse_brvlan_untagged(const char *unit, const char *filename,
r = parse_vid_range(rvalue, &vid, &vid_end); r = parse_vid_range(rvalue, &vid, &vid_end);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Could not parse VLAN: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Could not parse VLAN: %s", rvalue);
return 0; return 0;
} }

View File

@ -35,14 +35,14 @@ int config_parse_can_bitrate(
r = parse_size(rvalue, 1000, &sz); r = parse_size(rvalue, 1000, &sz);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse can bitrate '%s', ignoring: %m", rvalue); "Failed to parse can bitrate '%s', ignoring: %m", rvalue);
return 0; return 0;
} }
/* Linux uses __u32 for bitrates, so the value should not exceed that. */ /* Linux uses __u32 for bitrates, so the value should not exceed that. */
if (sz <= 0 || sz > UINT32_MAX) { if (sz <= 0 || sz > UINT32_MAX) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Bit rate out of permitted range 1...4294967295"); "Bit rate out of permitted range 1...4294967295");
return 0; return 0;
} }

View File

@ -144,26 +144,29 @@ int config_parse_duid_rawdata(
assert(ret); assert(ret);
/* RawData contains DUID in format "NN:NN:NN..." */ /* RawData contains DUID in format "NN:NN:NN..." */
for (;;) { for (const char *p = rvalue;;) {
int n1, n2, len, r; int n1, n2, len, r;
uint32_t byte; uint32_t byte;
_cleanup_free_ char *cbyte = NULL; _cleanup_free_ char *cbyte = NULL;
r = extract_first_word(&rvalue, &cbyte, ":", 0); r = extract_first_word(&p, &cbyte, ":", 0);
if (r == -ENOMEM)
return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to read DUID, ignoring assignment: %s.", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to read DUID, ignoring assignment: %s.", rvalue);
return 0; return 0;
} }
if (r == 0) if (r == 0)
break; break;
if (count >= MAX_DUID_LEN) { if (count >= MAX_DUID_LEN) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Max DUID length exceeded, ignoring assignment: %s.", rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "Max DUID length exceeded, ignoring assignment: %s.", rvalue);
return 0; return 0;
} }
len = strlen(cbyte); len = strlen(cbyte);
if (!IN_SET(len, 1, 2)) { if (!IN_SET(len, 1, 2)) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid length - DUID byte: %s, ignoring assignment: %s.", cbyte, rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid length - DUID byte: %s, ignoring assignment: %s.", cbyte, rvalue);
return 0; return 0;
} }
n1 = unhexchar(cbyte[0]); n1 = unhexchar(cbyte[0]);
@ -173,7 +176,7 @@ int config_parse_duid_rawdata(
n2 = 0; n2 = 0;
if (n1 < 0 || n2 < 0) { if (n1 < 0 || n2 < 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid DUID byte: %s. Ignoring assignment: %s.", cbyte, rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid DUID byte: %s. Ignoring assignment: %s.", cbyte, rvalue);
return 0; return 0;
} }

View File

@ -48,7 +48,7 @@ int config_parse_dhcp(
else if (streq(rvalue, "both")) else if (streq(rvalue, "both"))
s = ADDRESS_FAMILY_YES; s = ADDRESS_FAMILY_YES;
else { else {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Failed to parse DHCP option, ignoring: %s", rvalue); "Failed to parse DHCP option, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -85,7 +85,7 @@ int config_parse_dhcp_route_metric(
r = safe_atou32(rvalue, &metric); r = safe_atou32(rvalue, &metric);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse RouteMetric=%s, ignoring assignment: %m", rvalue); "Failed to parse RouteMetric=%s, ignoring assignment: %m", rvalue);
return 0; return 0;
} }
@ -128,7 +128,7 @@ int config_parse_dhcp_use_dns(
r = parse_boolean(rvalue); r = parse_boolean(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse UseDNS=%s, ignoring assignment: %m", rvalue); "Failed to parse UseDNS=%s, ignoring assignment: %m", rvalue);
return 0; return 0;
} }
@ -171,7 +171,7 @@ int config_parse_dhcp_use_ntp(
r = parse_boolean(rvalue); r = parse_boolean(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse UseNTP=%s, ignoring assignment: %m", rvalue); "Failed to parse UseNTP=%s, ignoring assignment: %m", rvalue);
return 0; return 0;
} }
@ -215,7 +215,7 @@ int config_parse_section_route_table(
r = safe_atou32(rvalue, &rt); r = safe_atou32(rvalue, &rt);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse RouteTable=%s, ignoring assignment: %m", rvalue); "Failed to parse RouteTable=%s, ignoring assignment: %m", rvalue);
return 0; return 0;
} }
@ -252,7 +252,7 @@ int config_parse_iaid(const char *unit,
r = safe_atou32(rvalue, &iaid); r = safe_atou32(rvalue, &iaid);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Unable to read IAID, ignoring assignment: %s", rvalue); "Unable to read IAID, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -287,29 +287,29 @@ int config_parse_dhcp_user_class(
return 0; return 0;
} }
for (;;) { for (const char *p = rvalue;;) {
_cleanup_free_ char *w = NULL; _cleanup_free_ char *w = NULL;
r = extract_first_word(&rvalue, &w, NULL, EXTRACT_CUNESCAPE|EXTRACT_UNQUOTE); r = extract_first_word(&p, &w, NULL, EXTRACT_CUNESCAPE|EXTRACT_UNQUOTE);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to split user classes option, ignoring: %s", rvalue); "Failed to split user classes option, ignoring: %s", rvalue);
break; return 0;
} }
if (r == 0) if (r == 0)
break; return 0;
if (ltype == AF_INET) { if (ltype == AF_INET) {
if (strlen(w) > UINT8_MAX) { if (strlen(w) > UINT8_MAX) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"%s length is not in the range 1-255, ignoring.", w); "%s length is not in the range 1-255, ignoring.", w);
continue; continue;
} }
} else { } else {
if (strlen(w) > UINT16_MAX) { if (strlen(w) > UINT16_MAX) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"%s length is not in the range 1-65535, ignoring.", w); "%s length is not in the range 1-65535, ignoring.", w);
continue; continue;
} }
@ -321,8 +321,6 @@ int config_parse_dhcp_user_class(
w = NULL; w = NULL;
} }
return 0;
} }
int config_parse_dhcp_vendor_class( int config_parse_dhcp_vendor_class(
@ -348,22 +346,22 @@ int config_parse_dhcp_vendor_class(
return 0; return 0;
} }
for (;;) { for (const char *p = rvalue;;) {
_cleanup_free_ char *w = NULL; _cleanup_free_ char *w = NULL;
r = extract_first_word(&rvalue, &w, NULL, EXTRACT_CUNESCAPE|EXTRACT_UNQUOTE); r = extract_first_word(&p, &w, NULL, EXTRACT_CUNESCAPE|EXTRACT_UNQUOTE);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to split vendor classes option, ignoring: %s", rvalue); "Failed to split vendor classes option, ignoring: %s", rvalue);
break; return 0;
} }
if (r == 0) if (r == 0)
break; return 0;
if (strlen(w) > UINT8_MAX) { if (strlen(w) > UINT8_MAX) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"%s length is not in the range 1-255, ignoring.", w); "%s length is not in the range 1-255, ignoring.", w);
continue; continue;
} }
@ -374,8 +372,6 @@ int config_parse_dhcp_vendor_class(
w = NULL; w = NULL;
} }
return 0;
} }
int config_parse_dhcp_send_option( int config_parse_dhcp_send_option(
@ -420,14 +416,14 @@ int config_parse_dhcp_send_option(
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r <= 0 || isempty(p)) { if (r <= 0 || isempty(p)) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid DHCP option, ignoring assignment: %s", rvalue); "Invalid DHCP option, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
r = safe_atou32(word, &enterprise_identifier); r = safe_atou32(word, &enterprise_identifier);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse DHCPv6 enterprise identifier data, ignoring assignment: %s", p); "Failed to parse DHCPv6 enterprise identifier data, ignoring assignment: %s", p);
return 0; return 0;
} }
@ -438,7 +434,7 @@ int config_parse_dhcp_send_option(
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r <= 0 || isempty(p)) { if (r <= 0 || isempty(p)) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid DHCP option, ignoring assignment: %s", rvalue); "Invalid DHCP option, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -446,24 +442,24 @@ int config_parse_dhcp_send_option(
if (ltype == AF_INET6) { if (ltype == AF_INET6) {
r = safe_atou16(word, &u16); r = safe_atou16(word, &u16);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid DHCP option, ignoring assignment: %s", rvalue); "Invalid DHCP option, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
if (u16 < 1 || u16 >= UINT16_MAX) { if (u16 < 1 || u16 >= UINT16_MAX) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid DHCP option, valid range is 1-65535, ignoring assignment: %s", rvalue); "Invalid DHCP option, valid range is 1-65535, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
} else { } else {
r = safe_atou8(word, &u8); r = safe_atou8(word, &u8);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid DHCP option, ignoring assignment: %s", rvalue); "Invalid DHCP option, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
if (u8 < 1 || u8 >= UINT8_MAX) { if (u8 < 1 || u8 >= UINT8_MAX) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid DHCP option, valid range is 1-254, ignoring assignment: %s", rvalue); "Invalid DHCP option, valid range is 1-254, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -474,14 +470,14 @@ int config_parse_dhcp_send_option(
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r <= 0 || isempty(p)) { if (r <= 0 || isempty(p)) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid DHCP option, ignoring assignment: %s", rvalue); "Invalid DHCP option, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
type = dhcp_option_data_type_from_string(word); type = dhcp_option_data_type_from_string(word);
if (type < 0) { if (type < 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid DHCP option data type, ignoring assignment: %s", p); "Invalid DHCP option data type, ignoring assignment: %s", p);
return 0; return 0;
} }
@ -490,7 +486,7 @@ int config_parse_dhcp_send_option(
case DHCP_OPTION_DATA_UINT8:{ case DHCP_OPTION_DATA_UINT8:{
r = safe_atou8(p, &uint8_data); r = safe_atou8(p, &uint8_data);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse DHCP uint8 data, ignoring assignment: %s", p); "Failed to parse DHCP uint8 data, ignoring assignment: %s", p);
return 0; return 0;
} }
@ -502,7 +498,7 @@ int config_parse_dhcp_send_option(
case DHCP_OPTION_DATA_UINT16:{ case DHCP_OPTION_DATA_UINT16:{
r = safe_atou16(p, &uint16_data); r = safe_atou16(p, &uint16_data);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse DHCP uint16 data, ignoring assignment: %s", p); "Failed to parse DHCP uint16 data, ignoring assignment: %s", p);
return 0; return 0;
} }
@ -514,7 +510,7 @@ int config_parse_dhcp_send_option(
case DHCP_OPTION_DATA_UINT32: { case DHCP_OPTION_DATA_UINT32: {
r = safe_atou32(p, &uint32_data); r = safe_atou32(p, &uint32_data);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse DHCP uint32 data, ignoring assignment: %s", p); "Failed to parse DHCP uint32 data, ignoring assignment: %s", p);
return 0; return 0;
} }
@ -527,7 +523,7 @@ int config_parse_dhcp_send_option(
case DHCP_OPTION_DATA_IPV4ADDRESS: { case DHCP_OPTION_DATA_IPV4ADDRESS: {
r = in_addr_from_string(AF_INET, p, &addr); r = in_addr_from_string(AF_INET, p, &addr);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse DHCP ipv4address data, ignoring assignment: %s", p); "Failed to parse DHCP ipv4address data, ignoring assignment: %s", p);
return 0; return 0;
} }
@ -539,7 +535,7 @@ int config_parse_dhcp_send_option(
case DHCP_OPTION_DATA_IPV6ADDRESS: { case DHCP_OPTION_DATA_IPV6ADDRESS: {
r = in_addr_from_string(AF_INET6, p, &addr); r = in_addr_from_string(AF_INET6, p, &addr);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse DHCP ipv6address data, ignoring assignment: %s", p); "Failed to parse DHCP ipv6address data, ignoring assignment: %s", p);
return 0; return 0;
} }
@ -551,7 +547,7 @@ int config_parse_dhcp_send_option(
case DHCP_OPTION_DATA_STRING: case DHCP_OPTION_DATA_STRING:
sz = cunescape(p, UNESCAPE_ACCEPT_NUL, &q); sz = cunescape(p, UNESCAPE_ACCEPT_NUL, &q);
if (sz < 0) { if (sz < 0) {
log_syntax(unit, LOG_ERR, filename, line, sz, log_syntax(unit, LOG_WARNING, filename, line, sz,
"Failed to decode DHCP option data, ignoring assignment: %s", p); "Failed to decode DHCP option data, ignoring assignment: %s", p);
} }
@ -564,7 +560,7 @@ int config_parse_dhcp_send_option(
if (ltype == AF_INET6) { if (ltype == AF_INET6) {
r = sd_dhcp6_option_new(u16, udata, sz, enterprise_identifier, &opt6); r = sd_dhcp6_option_new(u16, udata, sz, enterprise_identifier, &opt6);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to store DHCP option '%s', ignoring assignment: %m", rvalue); "Failed to store DHCP option '%s', ignoring assignment: %m", rvalue);
return 0; return 0;
} }
@ -577,7 +573,7 @@ int config_parse_dhcp_send_option(
old6 = ordered_hashmap_get(*options, UINT_TO_PTR(u16)); old6 = ordered_hashmap_get(*options, UINT_TO_PTR(u16));
r = ordered_hashmap_replace(*options, UINT_TO_PTR(u16), opt6); r = ordered_hashmap_replace(*options, UINT_TO_PTR(u16), opt6);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to store DHCP option '%s', ignoring assignment: %m", rvalue); "Failed to store DHCP option '%s', ignoring assignment: %m", rvalue);
return 0; return 0;
} }
@ -585,7 +581,7 @@ int config_parse_dhcp_send_option(
} else { } else {
r = sd_dhcp_option_new(u8, udata, sz, &opt4); r = sd_dhcp_option_new(u8, udata, sz, &opt4);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to store DHCP option '%s', ignoring assignment: %m", rvalue); "Failed to store DHCP option '%s', ignoring assignment: %m", rvalue);
return 0; return 0;
} }
@ -598,7 +594,7 @@ int config_parse_dhcp_send_option(
old4 = ordered_hashmap_get(*options, UINT_TO_PTR(u8)); old4 = ordered_hashmap_get(*options, UINT_TO_PTR(u8));
r = ordered_hashmap_replace(*options, UINT_TO_PTR(u8), opt4); r = ordered_hashmap_replace(*options, UINT_TO_PTR(u8), opt4);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to store DHCP option '%s', ignoring assignment: %m", rvalue); "Failed to store DHCP option '%s', ignoring assignment: %m", rvalue);
return 0; return 0;
} }
@ -642,8 +638,10 @@ int config_parse_dhcp_request_options(
uint32_t i; uint32_t i;
r = extract_first_word(&p, &n, NULL, 0); r = extract_first_word(&p, &n, NULL, 0);
if (r == -ENOMEM)
return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse DHCP request option, ignoring assignment: %s", "Failed to parse DHCP request option, ignoring assignment: %s",
rvalue); rvalue);
return 0; return 0;
@ -653,13 +651,13 @@ int config_parse_dhcp_request_options(
r = safe_atou32(n, &i); r = safe_atou32(n, &i);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"DHCP request option is invalid, ignoring assignment: %s", n); "DHCP request option is invalid, ignoring assignment: %s", n);
continue; continue;
} }
if (i < 1 || i >= UINT8_MAX) { if (i < 1 || i >= UINT8_MAX) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, 0,
"DHCP request option is invalid, valid range is 1-254, ignoring assignment: %s", n); "DHCP request option is invalid, valid range is 1-254, ignoring assignment: %s", n);
continue; continue;
} }
@ -667,11 +665,9 @@ int config_parse_dhcp_request_options(
r = set_ensure_put(ltype == AF_INET ? &network->dhcp_request_options : &network->dhcp6_request_options, r = set_ensure_put(ltype == AF_INET ? &network->dhcp_request_options : &network->dhcp6_request_options,
NULL, UINT32_TO_PTR(i)); NULL, UINT32_TO_PTR(i));
if (r < 0) if (r < 0)
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to store DHCP request option '%s', ignoring assignment: %m", n); "Failed to store DHCP request option '%s', ignoring assignment: %m", n);
} }
return 0;
} }
DEFINE_CONFIG_PARSE_ENUM(config_parse_dhcp_use_domains, dhcp_use_domains, DHCPUseDomains, DEFINE_CONFIG_PARSE_ENUM(config_parse_dhcp_use_domains, dhcp_use_domains, DHCPUseDomains,

View File

@ -373,7 +373,7 @@ int config_parse_dhcp_server_emit(
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to extract word, ignoring: %s", rvalue); "Failed to extract word, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -382,7 +382,7 @@ int config_parse_dhcp_server_emit(
r = in_addr_from_string(AF_INET, w, &a); r = in_addr_from_string(AF_INET, w, &a);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse %s= address '%s', ignoring: %m", lvalue, w); "Failed to parse %s= address '%s', ignoring: %m", lvalue, w);
continue; continue;
} }

View File

@ -27,7 +27,7 @@ static int dhcp_remove_address(Link *link, sd_dhcp_lease *lease, const struct in
static int dhcp4_update_address(Link *link, bool announce); static int dhcp4_update_address(Link *link, bool announce);
static int dhcp4_remove_all(Link *link); static int dhcp4_remove_all(Link *link);
void dhcp4_release_old_lease(Link *link) { static void dhcp4_release_old_lease(Link *link) {
struct in_addr address = {}, address_old = {}; struct in_addr address = {}, address_old = {};
assert(link); assert(link);
@ -52,12 +52,16 @@ void dhcp4_release_old_lease(Link *link) {
} }
static void dhcp4_check_ready(Link *link) { static void dhcp4_check_ready(Link *link) {
if (link->dhcp4_messages == 0) { if (link->network->dhcp_send_decline && !link->dhcp4_address_bind)
return;
if (link->dhcp4_messages > 0)
return;
link->dhcp4_configured = true; link->dhcp4_configured = true;
/* New address and routes are configured now. Let's release old lease. */ /* New address and routes are configured now. Let's release old lease. */
dhcp4_release_old_lease(link); dhcp4_release_old_lease(link);
link_check_ready(link); link_check_ready(link);
}
} }
static int dhcp4_route_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) { static int dhcp4_route_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
@ -86,8 +90,7 @@ static int dhcp4_route_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *li
return 1; return 1;
} }
if (link->dhcp4_messages == 0) { if (link->dhcp4_messages == 0 && link->dhcp4_route_failed) {
if (link->dhcp4_route_failed) {
link->dhcp4_route_failed = false; link->dhcp4_route_failed = false;
link->dhcp4_route_retrying = true; link->dhcp4_route_retrying = true;
@ -96,9 +99,8 @@ static int dhcp4_route_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *li
link_enter_failed(link); link_enter_failed(link);
return 1; return 1;
} }
if (!link->network->dhcp_send_decline)
dhcp4_check_ready(link); dhcp4_check_ready(link);
}
return 1; return 1;
} }
@ -793,6 +795,9 @@ static int dhcp_lease_lost(Link *link) {
link->dhcp4_configured = false; link->dhcp4_configured = false;
/* dhcp_lease_lost() may be called during renewing IP address. */
dhcp4_release_old_lease(link);
r = dhcp4_remove_all(link); r = dhcp4_remove_all(link);
if (r < 0) if (r < 0)
return r; return r;
@ -833,6 +838,7 @@ static void dhcp_address_on_acd(sd_ipv4acd *acd, int event, void *userdata) {
(void) in_addr_to_string(AF_INET, &address, &pretty); (void) in_addr_to_string(AF_INET, &address, &pretty);
log_link_debug(link, "Successfully claimed DHCP4 address %s", strna(pretty)); log_link_debug(link, "Successfully claimed DHCP4 address %s", strna(pretty));
} }
link->dhcp4_address_bind = true;
dhcp4_check_ready(link); dhcp4_check_ready(link);
break; break;
@ -841,7 +847,9 @@ static void dhcp_address_on_acd(sd_ipv4acd *acd, int event, void *userdata) {
(void) in_addr_to_string(AF_INET, &address, &pretty); (void) in_addr_to_string(AF_INET, &address, &pretty);
log_link_warning(link, "DAD conflict. Dropping DHCP4 address %s", strna(pretty)); log_link_warning(link, "DAD conflict. Dropping DHCP4 address %s", strna(pretty));
(void) sd_dhcp_client_send_decline(link->dhcp_client); r = sd_dhcp_client_send_decline(link->dhcp_client);
if (r < 0)
log_link_warning_errno(link, r, "Failed to send DHCP DECLINE, ignoring: %m");
if (link->dhcp_lease) { if (link->dhcp_lease) {
r = dhcp_lease_lost(link); r = dhcp_lease_lost(link);
@ -883,6 +891,44 @@ static int configure_dhcpv4_duplicate_address_detection(Link *link) {
return 0; return 0;
} }
static int dhcp4_start_acd(Link *link) {
union in_addr_union addr;
int r;
if (!link->network->dhcp_send_decline)
return 0;
if (!link->dhcp_lease)
return 0;
link->dhcp4_address_bind = false;
r = sd_dhcp_lease_get_address(link->dhcp_lease, &addr.in);
if (r < 0)
return r;
r = sd_ipv4acd_set_address(link->network->dhcp_acd, &addr.in);
if (r < 0)
return r;
r = sd_ipv4acd_set_callback(link->network->dhcp_acd, dhcp_address_on_acd, link);
if (r < 0)
return r;
if (DEBUG_LOGGING) {
_cleanup_free_ char *pretty = NULL;
(void) in_addr_to_string(AF_INET, &addr, &pretty);
log_link_debug(link, "Starting IPv4ACD client. Probing DHCPv4 address %s", strna(pretty));
}
r = sd_ipv4acd_start(link->network->dhcp_acd, true);
if (r < 0)
return r;
return 1;
}
static int dhcp4_address_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) { static int dhcp4_address_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
int r; int r;
@ -912,30 +958,13 @@ static int dhcp4_address_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *
return 1; return 1;
} }
if (link->network->dhcp_send_decline) { r = dhcp4_start_acd(link);
union in_addr_union addr; if (r < 0) {
log_link_error_errno(link, r, "Failed to start IPv4ACD for DHCP4 adddress: %m");
(void) sd_dhcp_lease_get_address(link->dhcp_lease, &addr.in); link_enter_failed(link);
return 1;
r = sd_ipv4acd_set_address(link->network->dhcp_acd, &addr.in);
if (r < 0)
return r;
r = sd_ipv4acd_set_callback(link->network->dhcp_acd, dhcp_address_on_acd, link);
if (r < 0)
return r;
if (DEBUG_LOGGING) {
_cleanup_free_ char *pretty = NULL;
(void) in_addr_to_string(AF_INET, &addr, &pretty);
log_link_debug(link, "Starting IPv4ACD client. Probing DHCPv4 address %s", strna(pretty));
} }
r = sd_ipv4acd_start(link->network->dhcp_acd, true);
if (r < 0)
log_link_warning_errno(link, r, "Failed to start IPv4ACD client, ignoring: %m");
} else
dhcp4_check_ready(link); dhcp4_check_ready(link);
return 1; return 1;
@ -1236,8 +1265,11 @@ static int dhcp4_handler(sd_dhcp_client *client, int event, void *userdata) {
} }
if (link->dhcp_lease) { if (link->dhcp_lease) {
if (link->network->dhcp_send_release) if (link->network->dhcp_send_release) {
(void) sd_dhcp_client_send_release(client); r = sd_dhcp_client_send_release(client);
if (r < 0)
log_link_warning_errno(link, r, "Failed to send DHCP RELEASE, ignoring: %m");
}
r = dhcp_lease_lost(link); r = dhcp_lease_lost(link);
if (r < 0) { if (r < 0) {
@ -1559,7 +1591,6 @@ int dhcp4_configure(Link *link) {
log_link_debug(link, "DHCP4 CLIENT: Failed to set request flag for '%u' already exists, ignoring.", option); log_link_debug(link, "DHCP4 CLIENT: Failed to set request flag for '%u' already exists, ignoring.", option);
continue; continue;
} }
if (r < 0) if (r < 0)
return log_link_error_errno(link, r, "DHCP4 CLIENT: Failed to set request flag for '%u': %m", option); return log_link_error_errno(link, r, "DHCP4 CLIENT: Failed to set request flag for '%u': %m", option);
} }
@ -1669,13 +1700,13 @@ int config_parse_dhcp_max_attempts(
r = safe_atou64(rvalue, &a); r = safe_atou64(rvalue, &a);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse DHCP maximum attempts, ignoring: %s", rvalue); "Failed to parse DHCP maximum attempts, ignoring: %s", rvalue);
return 0; return 0;
} }
if (a == 0) { if (a == 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"%s= must be positive integer or 'infinity', ignoring: %s", lvalue, rvalue); "%s= must be positive integer or 'infinity', ignoring: %s", lvalue, rvalue);
return 0; return 0;
} }
@ -1718,8 +1749,10 @@ int config_parse_dhcp_acl_ip_address(
union in_addr_union ip; union in_addr_union ip;
r = extract_first_word(&p, &n, NULL, 0); r = extract_first_word(&p, &n, NULL, 0);
if (r == -ENOMEM)
return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse DHCP '%s=' IP address, ignoring assignment: %s", "Failed to parse DHCP '%s=' IP address, ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
@ -1729,18 +1762,16 @@ int config_parse_dhcp_acl_ip_address(
r = in_addr_from_string(AF_INET, n, &ip); r = in_addr_from_string(AF_INET, n, &ip);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"DHCP '%s=' IP address is invalid, ignoring assignment: %s", lvalue, n); "DHCP '%s=' IP address is invalid, ignoring assignment: %s", lvalue, n);
continue; continue;
} }
r = set_ensure_put(acl, NULL, UINT32_TO_PTR(ip.in.s_addr)); r = set_ensure_put(acl, NULL, UINT32_TO_PTR(ip.in.s_addr));
if (r < 0) if (r < 0)
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to store DHCP '%s=' IP address '%s', ignoring assignment: %m", lvalue, n); "Failed to store DHCP '%s=' IP address '%s', ignoring assignment: %m", lvalue, n);
} }
return 0;
} }
int config_parse_dhcp_ip_service_type( int config_parse_dhcp_ip_service_type(
@ -1797,13 +1828,13 @@ int config_parse_dhcp_mud_url(
r = cunescape(rvalue, 0, &unescaped); r = cunescape(rvalue, 0, &unescaped);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to Failed to unescape MUD URL, ignoring: %s", rvalue); "Failed to Failed to unescape MUD URL, ignoring: %s", rvalue);
return 0; return 0;
} }
if (!http_url_is_valid(unescaped) || strlen(unescaped) > 255) { if (!http_url_is_valid(unescaped) || strlen(unescaped) > 255) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Failed to parse MUD URL '%s', ignoring: %m", rvalue); "Failed to parse MUD URL '%s', ignoring: %m", rvalue);
return 0; return 0;
@ -1840,7 +1871,7 @@ int config_parse_dhcp_fallback_lease_lifetime(const char *unit,
if (STR_IN_SET(rvalue, "forever", "infinity")) if (STR_IN_SET(rvalue, "forever", "infinity"))
k = CACHE_INFO_INFINITY_LIFE_TIME; k = CACHE_INFO_INFINITY_LIFE_TIME;
else { else {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid LeaseLifetime= value, ignoring: %s", rvalue); "Invalid LeaseLifetime= value, ignoring: %s", rvalue);
return 0; return 0;
} }

View File

@ -17,7 +17,6 @@ typedef enum DHCPClientIdentifier {
_DHCP_CLIENT_ID_INVALID = -1, _DHCP_CLIENT_ID_INVALID = -1,
} DHCPClientIdentifier; } DHCPClientIdentifier;
void dhcp4_release_old_lease(Link *link);
int dhcp4_configure(Link *link); int dhcp4_configure(Link *link);
int dhcp4_set_client_identifier(Link *link); int dhcp4_set_client_identifier(Link *link);
int dhcp4_set_promote_secondaries(Link *link); int dhcp4_set_promote_secondaries(Link *link);

View File

@ -1161,12 +1161,12 @@ int config_parse_dhcp6_pd_hint(
r = in_addr_prefix_from_string(rvalue, AF_INET6, (union in_addr_union *) &network->dhcp6_pd_address, &network->dhcp6_pd_length); r = in_addr_prefix_from_string(rvalue, AF_INET6, (union in_addr_union *) &network->dhcp6_pd_address, &network->dhcp6_pd_length);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse PrefixDelegationHint=%s, ignoring assignment", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse PrefixDelegationHint=%s, ignoring assignment", rvalue);
return 0; return 0;
} }
if (network->dhcp6_pd_length < 1 || network->dhcp6_pd_length > 128) { 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); log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid prefix length='%d', ignoring assignment", network->dhcp6_pd_length);
network->dhcp6_pd_length = 0; network->dhcp6_pd_length = 0;
return 0; return 0;
} }
@ -1201,13 +1201,13 @@ int config_parse_dhcp6_mud_url(
r = cunescape(rvalue, 0, &unescaped); r = cunescape(rvalue, 0, &unescaped);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to Failed to unescape MUD URL, ignoring: %s", rvalue); "Failed to Failed to unescape MUD URL, ignoring: %s", rvalue);
return 0; return 0;
} }
if (!http_url_is_valid(unescaped) || strlen(unescaped) > UINT8_MAX) { if (!http_url_is_valid(unescaped) || strlen(unescaped) > UINT8_MAX) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Failed to parse MUD URL '%s', ignoring: %m", rvalue); "Failed to parse MUD URL '%s', ignoring: %m", rvalue);
return 0; return 0;
@ -1243,13 +1243,13 @@ int config_parse_dhcp6_delegated_prefix_token(
r = in_addr_from_string(AF_INET6, rvalue, &network->dhcp6_delegation_prefix_token); r = in_addr_from_string(AF_INET6, rvalue, &network->dhcp6_delegation_prefix_token);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse DHCPv6 %s, ignoring: %s", lvalue, rvalue); "Failed to parse DHCPv6 %s, ignoring: %s", lvalue, rvalue);
return 0; return 0;
} }
if (in_addr_is_null(AF_INET6, &network->dhcp6_delegation_prefix_token)) { if (in_addr_is_null(AF_INET6, &network->dhcp6_delegation_prefix_token)) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"DHCPv6 %s cannot be the ANY address, ignoring: %s", lvalue, rvalue); "DHCPv6 %s cannot be the ANY address, ignoring: %s", lvalue, rvalue);
return 0; return 0;
} }

View File

@ -218,7 +218,7 @@ int config_parse_fdb_hwaddr(
r = ether_addr_from_string(rvalue, &fdb_entry->mac_addr); r = ether_addr_from_string(rvalue, &fdb_entry->mac_addr);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Not a valid MAC address, ignoring assignment: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Not a valid MAC address, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -293,7 +293,7 @@ int config_parse_fdb_destination(
r = in_addr_from_string_auto(rvalue, &fdb_entry->family, &fdb_entry->destination_addr); r = in_addr_from_string_auto(rvalue, &fdb_entry->family, &fdb_entry->destination_addr);
if (r < 0) if (r < 0)
return log_syntax(unit, LOG_ERR, filename, line, r, return log_syntax(unit, LOG_WARNING, filename, line, r,
"FDB destination IP address is invalid, ignoring assignment: %s", "FDB destination IP address is invalid, ignoring assignment: %s",
rvalue); rvalue);
@ -331,14 +331,14 @@ int config_parse_fdb_vxlan_vni(
r = safe_atou32(rvalue, &vni); r = safe_atou32(rvalue, &vni);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse VXLAN Network Identifier (VNI), ignoring assignment: %s", "Failed to parse VXLAN Network Identifier (VNI), ignoring assignment: %s",
rvalue); rvalue);
return 0; return 0;
} }
if (vni > VXLAN_VID_MAX) { if (vni > VXLAN_VID_MAX) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"FDB invalid VXLAN Network Identifier (VNI), ignoring assignment: %s", "FDB invalid VXLAN Network Identifier (VNI), ignoring assignment: %s",
rvalue); rvalue);
return 0; return 0;
@ -379,7 +379,7 @@ int config_parse_fdb_ntf_flags(
f = fdb_ntf_flags_from_string(rvalue); f = fdb_ntf_flags_from_string(rvalue);
if (f < 0) { if (f < 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, SYNTHETIC_ERRNO(EINVAL),
"FDB failed to parse AssociatedWith=, ignoring assignment: %s", "FDB failed to parse AssociatedWith=, ignoring assignment: %s",
rvalue); rvalue);
return 0; return 0;

View File

@ -208,7 +208,7 @@ int config_parse_ipv4ll(
r = parse_boolean(rvalue); r = parse_boolean(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse %s=%s, ignoring assignment. " "Failed to parse %s=%s, ignoring assignment. "
"Note that the setting %s= is deprecated, please use LinkLocalAddressing= instead.", "Note that the setting %s= is deprecated, please use LinkLocalAddressing= instead.",
lvalue, rvalue, lvalue); lvalue, rvalue, lvalue);

View File

@ -113,17 +113,18 @@ int config_parse_ipv6_proxy_ndp_address(
r = ipv6_proxy_ndp_address_new_static(network, &ipv6_proxy_ndp_address); r = ipv6_proxy_ndp_address_new_static(network, &ipv6_proxy_ndp_address);
if (r < 0) if (r < 0)
return r; return log_oom();
r = in_addr_from_string(AF_INET6, rvalue, &buffer); r = in_addr_from_string(AF_INET6, rvalue, &buffer);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse IPv6 proxy NDP address, ignoring: %s", log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse IPv6 proxy NDP address, ignoring: %s",
rvalue); rvalue);
return 0; return 0;
} }
if (in_addr_is_null(AF_INET6, &buffer)) { if (in_addr_is_null(AF_INET6, &buffer)) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"IPv6 proxy NDP address cannot be the ANY address, ignoring: %s", rvalue); "IPv6 proxy NDP address cannot be the ANY address, ignoring: %s", rvalue);
return 0; return 0;
} }

View File

@ -800,8 +800,6 @@ int link_stop_clients(Link *link, bool may_keep_dhcp) {
assert(link->manager); assert(link->manager);
assert(link->manager->event); assert(link->manager->event);
dhcp4_release_old_lease(link);
bool keep_dhcp = may_keep_dhcp && bool keep_dhcp = may_keep_dhcp &&
link->network && link->network &&
(link->manager->restarting || (link->manager->restarting ||

View File

@ -108,6 +108,7 @@ typedef struct Link {
bool dhcp4_route_failed:1; bool dhcp4_route_failed:1;
bool dhcp4_route_retrying:1; bool dhcp4_route_retrying:1;
bool dhcp4_configured:1; bool dhcp4_configured:1;
bool dhcp4_address_bind:1;
bool dhcp6_address_configured:1; bool dhcp6_address_configured:1;
bool dhcp6_route_configured:1; bool dhcp6_route_configured:1;
bool dhcp6_pd_address_configured:1; bool dhcp6_pd_address_configured:1;

View File

@ -447,7 +447,7 @@ int config_parse_lldp_emit(
else { else {
r = parse_boolean(rvalue); r = parse_boolean(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse LLDP emission setting, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse LLDP emission setting, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -479,13 +479,13 @@ int config_parse_lldp_mud(
r = cunescape(rvalue, 0, &unescaped); r = cunescape(rvalue, 0, &unescaped);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to Failed to unescape LLDP MUD URL, ignoring: %s", rvalue); "Failed to Failed to unescape LLDP MUD URL, ignoring: %s", rvalue);
return 0; return 0;
} }
if (!http_url_is_valid(unescaped) || strlen(unescaped) > 255) { if (!http_url_is_valid(unescaped) || strlen(unescaped) > 255) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Failed to parse LLDP MUD URL '%s', ignoring: %m", rvalue); "Failed to parse LLDP MUD URL '%s', ignoring: %m", rvalue);
return 0; return 0;

View File

@ -969,8 +969,10 @@ int config_parse_ndisc_deny_listed_prefix(
union in_addr_union ip; union in_addr_union ip;
r = extract_first_word(&p, &n, NULL, 0); r = extract_first_word(&p, &n, NULL, 0);
if (r == -ENOMEM)
return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse NDISC deny-listed prefix, ignoring assignment: %s", "Failed to parse NDISC deny-listed prefix, ignoring assignment: %s",
rvalue); rvalue);
return 0; return 0;
@ -980,7 +982,7 @@ int config_parse_ndisc_deny_listed_prefix(
r = in_addr_from_string(AF_INET6, n, &ip); r = in_addr_from_string(AF_INET6, n, &ip);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"NDISC deny-listed prefix is invalid, ignoring assignment: %s", n); "NDISC deny-listed prefix is invalid, ignoring assignment: %s", n);
continue; continue;
} }
@ -996,8 +998,6 @@ int config_parse_ndisc_deny_listed_prefix(
if (r < 0) if (r < 0)
return log_oom(); return log_oom();
} }
return 0;
} }
int config_parse_address_generation_type( int config_parse_address_generation_type(
@ -1043,13 +1043,13 @@ int config_parse_address_generation_type(
r = in_addr_from_string(AF_INET6, p, &buffer); r = in_addr_from_string(AF_INET6, p, &buffer);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse IPv6 %s, ignoring: %s", lvalue, rvalue); "Failed to parse IPv6 %s, ignoring: %s", lvalue, rvalue);
return 0; return 0;
} }
if (in_addr_is_null(AF_INET6, &buffer)) { if (in_addr_is_null(AF_INET6, &buffer)) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"IPv6 %s cannot be the ANY address, ignoring: %s", lvalue, rvalue); "IPv6 %s cannot be the ANY address, ignoring: %s", lvalue, rvalue);
return 0; return 0;
} }
@ -1062,7 +1062,7 @@ int config_parse_address_generation_type(
r = ordered_hashmap_put(network->ipv6_tokens, &token->prefix, token); r = ordered_hashmap_put(network->ipv6_tokens, &token->prefix, token);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to store IPv6 token '%s'", rvalue); "Failed to store IPv6 token '%s'", rvalue);
return 0; return 0;
} }

View File

@ -399,11 +399,12 @@ int config_parse_neighbor_address(
r = neighbor_new_static(network, filename, section_line, &n); r = neighbor_new_static(network, filename, section_line, &n);
if (r < 0) if (r < 0)
return r; return log_oom();
r = in_addr_from_string_auto(rvalue, &n->family, &n->in_addr); r = in_addr_from_string_auto(rvalue, &n->family, &n->in_addr);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Neighbor Address is invalid, ignoring assignment: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r,
"Neighbor Address is invalid, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -436,7 +437,7 @@ int config_parse_neighbor_lladdr(
r = neighbor_new_static(network, filename, section_line, &n); r = neighbor_new_static(network, filename, section_line, &n);
if (r < 0) if (r < 0)
return r; return log_oom();
r = ether_addr_from_string(rvalue, &n->lladdr.mac); r = ether_addr_from_string(rvalue, &n->lladdr.mac);
if (r >= 0) if (r >= 0)
@ -444,7 +445,7 @@ int config_parse_neighbor_lladdr(
else { else {
r = in_addr_from_string_auto(rvalue, &family, &n->lladdr.ip); r = in_addr_from_string_auto(rvalue, &family, &n->lladdr.ip);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Neighbor LinkLayerAddress= is invalid, ignoring assignment: %s", "Neighbor LinkLayerAddress= is invalid, ignoring assignment: %s",
rvalue); rvalue);
return 0; return 0;
@ -481,11 +482,11 @@ int config_parse_neighbor_hwaddr(
r = neighbor_new_static(network, filename, section_line, &n); r = neighbor_new_static(network, filename, section_line, &n);
if (r < 0) if (r < 0)
return r; return log_oom();
r = ether_addr_from_string(rvalue, &n->lladdr.mac); r = ether_addr_from_string(rvalue, &n->lladdr.mac);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Neighbor MACAddress= is invalid, ignoring assignment: %s", rvalue); "Neighbor MACAddress= is invalid, ignoring assignment: %s", rvalue);
return 0; return 0;
} }

View File

@ -156,16 +156,16 @@ Route.Scope, config_parse_route_scope,
Route.PreferredSource, config_parse_preferred_src, 0, 0 Route.PreferredSource, config_parse_preferred_src, 0, 0
Route.Table, config_parse_route_table, 0, 0 Route.Table, config_parse_route_table, 0, 0
Route.MTUBytes, config_parse_route_mtu, AF_UNSPEC, 0 Route.MTUBytes, config_parse_route_mtu, AF_UNSPEC, 0
Route.GatewayOnLink, config_parse_gateway_onlink, 0, 0 Route.GatewayOnLink, config_parse_route_boolean, 0, 0
Route.GatewayOnlink, config_parse_gateway_onlink, 0, 0 Route.GatewayOnlink, config_parse_route_boolean, 0, 0
Route.IPv6Preference, config_parse_ipv6_route_preference, 0, 0 Route.IPv6Preference, config_parse_ipv6_route_preference, 0, 0
Route.Protocol, config_parse_route_protocol, 0, 0 Route.Protocol, config_parse_route_protocol, 0, 0
Route.Type, config_parse_route_type, 0, 0 Route.Type, config_parse_route_type, 0, 0
Route.InitialCongestionWindow, config_parse_tcp_window, 0, 0 Route.InitialCongestionWindow, config_parse_tcp_window, 0, 0
Route.InitialAdvertisedReceiveWindow, config_parse_tcp_window, 0, 0 Route.InitialAdvertisedReceiveWindow, config_parse_tcp_window, 0, 0
Route.QuickAck, config_parse_quickack, 0, 0 Route.QuickAck, config_parse_route_boolean, 0, 0
Route.FastOpenNoCookie, config_parse_fast_open_no_cookie, 0, 0 Route.FastOpenNoCookie, config_parse_route_boolean, 0, 0
Route.TTLPropagate, config_parse_route_ttl_propagate, 0, 0 Route.TTLPropagate, config_parse_route_boolean, 0, 0
Route.MultiPathRoute, config_parse_multipath_route, 0, 0 Route.MultiPathRoute, config_parse_multipath_route, 0, 0
NextHop.Id, config_parse_nexthop_id, 0, 0 NextHop.Id, config_parse_nexthop_id, 0, 0
NextHop.Gateway, config_parse_nexthop_gateway, 0, 0 NextHop.Gateway, config_parse_nexthop_gateway, 0, 0

View File

@ -902,7 +902,7 @@ int config_parse_stacked_netdev(const char *unit,
NETDEV_KIND_XFRM)); NETDEV_KIND_XFRM));
if (!ifname_valid(rvalue)) { if (!ifname_valid(rvalue)) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid netdev name in %s=, ignoring assignment: %s", lvalue, rvalue); "Invalid netdev name in %s=, ignoring assignment: %s", lvalue, rvalue);
return 0; return 0;
} }
@ -917,7 +917,7 @@ int config_parse_stacked_netdev(const char *unit,
r = hashmap_put(*h, name, INT_TO_PTR(kind)); r = hashmap_put(*h, name, INT_TO_PTR(kind));
if (r < 0) if (r < 0)
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Cannot add NetDev '%s' to network, ignoring assignment: %m", name); "Cannot add NetDev '%s' to network, ignoring assignment: %m", name);
else if (r == 0) else if (r == 0)
log_syntax(unit, LOG_DEBUG, filename, line, r, log_syntax(unit, LOG_DEBUG, filename, line, r,
@ -940,7 +940,6 @@ int config_parse_domains(
void *data, void *data,
void *userdata) { void *userdata) {
const char *p;
Network *n = data; Network *n = data;
int r; int r;
@ -954,20 +953,21 @@ int config_parse_domains(
return 0; return 0;
} }
p = rvalue; for (const char *p = rvalue;;) {
for (;;) {
_cleanup_free_ char *w = NULL, *normalized = NULL; _cleanup_free_ char *w = NULL, *normalized = NULL;
const char *domain; const char *domain;
bool is_route; bool is_route;
r = extract_first_word(&p, &w, NULL, 0); r = extract_first_word(&p, &w, NULL, 0);
if (r == -ENOMEM)
return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to extract search or route domain, ignoring: %s", rvalue); "Failed to extract search or route domain, ignoring: %s", rvalue);
break; return 0;
} }
if (r == 0) if (r == 0)
break; return 0;
is_route = w[0] == '~'; is_route = w[0] == '~';
domain = is_route ? w + 1 : w; domain = is_route ? w + 1 : w;
@ -981,7 +981,7 @@ int config_parse_domains(
} else { } else {
r = dns_name_normalize(domain, 0, &normalized); r = dns_name_normalize(domain, 0, &normalized);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"'%s' is not a valid domain name, ignoring.", domain); "'%s' is not a valid domain name, ignoring.", domain);
continue; continue;
} }
@ -989,7 +989,7 @@ int config_parse_domains(
domain = normalized; domain = normalized;
if (is_localhost(domain)) { if (is_localhost(domain)) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"'localhost' domain may not be configured as search or route domain, ignoring assignment: %s", "'localhost' domain may not be configured as search or route domain, ignoring assignment: %s",
domain); domain);
continue; continue;
@ -999,14 +999,12 @@ int config_parse_domains(
OrderedSet **set = is_route ? &n->route_domains : &n->search_domains; OrderedSet **set = is_route ? &n->route_domains : &n->search_domains;
r = ordered_set_ensure_allocated(set, &string_hash_ops); r = ordered_set_ensure_allocated(set, &string_hash_ops);
if (r < 0) if (r < 0)
return r; return log_oom();
r = ordered_set_put_strdup(*set, domain); r = ordered_set_put_strdup(*set, domain);
if (r < 0) if (r < 0)
return log_oom(); return log_oom();
} }
return 0;
} }
int config_parse_ipv6token( int config_parse_ipv6token(
@ -1032,19 +1030,19 @@ int config_parse_ipv6token(
r = in_addr_from_string(AF_INET6, rvalue, &buffer); r = in_addr_from_string(AF_INET6, rvalue, &buffer);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse IPv6 token, ignoring: %s", rvalue); "Failed to parse IPv6 token, ignoring: %s", rvalue);
return 0; return 0;
} }
if (in_addr_is_null(AF_INET6, &buffer)) { if (in_addr_is_null(AF_INET6, &buffer)) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"IPv6 token cannot be the ANY address, ignoring: %s", rvalue); "IPv6 token cannot be the ANY address, ignoring: %s", rvalue);
return 0; return 0;
} }
if ((buffer.in6.s6_addr32[0] | buffer.in6.s6_addr32[1]) != 0) { if ((buffer.in6.s6_addr32[0] | buffer.in6.s6_addr32[1]) != 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"IPv6 token cannot be longer than 64 bits, ignoring: %s", rvalue); "IPv6 token cannot be longer than 64 bits, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -1087,7 +1085,7 @@ int config_parse_ipv6_privacy_extensions(
if (streq(rvalue, "kernel")) if (streq(rvalue, "kernel"))
s = _IPV6_PRIVACY_EXTENSIONS_INVALID; s = _IPV6_PRIVACY_EXTENSIONS_INVALID;
else { else {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Failed to parse IPv6 privacy extensions option, ignoring: %s", rvalue); "Failed to parse IPv6 privacy extensions option, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -1123,19 +1121,19 @@ int config_parse_hostname(
return r; return r;
if (!hostname_is_valid(hn, false)) { if (!hostname_is_valid(hn, false)) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Hostname is not valid, ignoring assignment: %s", rvalue); "Hostname is not valid, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
r = dns_name_is_valid(hn); r = dns_name_is_valid(hn);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to check validity of hostname '%s', ignoring assignment: %m", rvalue); "Failed to check validity of hostname '%s', ignoring assignment: %m", rvalue);
return 0; return 0;
} }
if (r == 0) { if (r == 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Hostname is not a valid DNS domain name, ignoring assignment: %s", rvalue); "Hostname is not a valid DNS domain name, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -1167,8 +1165,8 @@ int config_parse_timezone(
if (r < 0) if (r < 0)
return r; return r;
if (!timezone_is_valid(tz, LOG_ERR)) { if (!timezone_is_valid(tz, LOG_WARNING)) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Timezone is not valid, ignoring assignment: %s", rvalue); "Timezone is not valid, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -1195,26 +1193,32 @@ int config_parse_dns(
assert(lvalue); assert(lvalue);
assert(rvalue); assert(rvalue);
for (;;) { if (isempty(rvalue)) {
n->dns = mfree(n->dns);
n->n_dns = 0;
return 0;
}
for (const char *p = rvalue;;) {
_cleanup_free_ char *w = NULL; _cleanup_free_ char *w = NULL;
union in_addr_union a; union in_addr_union a;
struct in_addr_data *m; struct in_addr_data *m;
int family; int family;
r = extract_first_word(&rvalue, &w, NULL, 0); r = extract_first_word(&p, &w, NULL, 0);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid syntax, ignoring: %s", rvalue); "Invalid syntax, ignoring: %s", rvalue);
break; return 0;
} }
if (r == 0) if (r == 0)
break; return 0;
r = in_addr_from_string_auto(w, &family, &a); r = in_addr_from_string_auto(w, &family, &a);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse dns server address, ignoring: %s", w); "Failed to parse dns server address, ignoring: %s", w);
continue; continue;
} }
@ -1230,8 +1234,6 @@ int config_parse_dns(
n->dns = m; n->dns = m;
} }
return 0;
} }
int config_parse_dnssec_negative_trust_anchors( int config_parse_dnssec_negative_trust_anchors(
@ -1246,7 +1248,6 @@ int config_parse_dnssec_negative_trust_anchors(
void *data, void *data,
void *userdata) { void *userdata) {
const char *p = rvalue;
Network *n = data; Network *n = data;
int r; int r;
@ -1259,21 +1260,23 @@ int config_parse_dnssec_negative_trust_anchors(
return 0; return 0;
} }
for (;;) { for (const char *p = rvalue;;) {
_cleanup_free_ char *w = NULL; _cleanup_free_ char *w = NULL;
r = extract_first_word(&p, &w, NULL, 0); r = extract_first_word(&p, &w, NULL, 0);
if (r == -ENOMEM)
return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to extract negative trust anchor domain, ignoring: %s", rvalue); "Failed to extract negative trust anchor domain, ignoring: %s", rvalue);
break; return 0;
} }
if (r == 0) if (r == 0)
break; return 0;
r = dns_name_is_valid(w); r = dns_name_is_valid(w);
if (r <= 0) { if (r <= 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"%s is not a valid domain name, ignoring.", w); "%s is not a valid domain name, ignoring.", w);
continue; continue;
} }
@ -1282,8 +1285,6 @@ int config_parse_dnssec_negative_trust_anchors(
if (r < 0) if (r < 0)
return log_oom(); return log_oom();
} }
return 0;
} }
int config_parse_ntp( int config_parse_ntp(
@ -1310,23 +1311,23 @@ int config_parse_ntp(
return 0; return 0;
} }
for (;;) { for (const char *p = rvalue;;) {
_cleanup_free_ char *w = NULL; _cleanup_free_ char *w = NULL;
r = extract_first_word(&rvalue, &w, NULL, 0); r = extract_first_word(&p, &w, NULL, 0);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to extract NTP server name, ignoring: %s", rvalue); "Failed to extract NTP server name, ignoring: %s", rvalue);
break; return 0;
} }
if (r == 0) if (r == 0)
break; return 0;
r = dns_name_is_valid_or_address(w); r = dns_name_is_valid_or_address(w);
if (r <= 0) { if (r <= 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"%s is not a valid domain name or IP address, ignoring.", w); "%s is not a valid domain name or IP address, ignoring.", w);
continue; continue;
} }
@ -1335,15 +1336,13 @@ int config_parse_ntp(
log_syntax(unit, LOG_WARNING, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"More than %u NTP servers specified, ignoring \"%s\" and any subsequent entries.", "More than %u NTP servers specified, ignoring \"%s\" and any subsequent entries.",
MAX_NTP_SERVERS, w); MAX_NTP_SERVERS, w);
break; return 0;
} }
r = strv_consume(l, TAKE_PTR(w)); r = strv_consume(l, TAKE_PTR(w));
if (r < 0) if (r < 0)
return log_oom(); return log_oom();
} }
return 0;
} }
int config_parse_required_for_online( int config_parse_required_for_online(
@ -1373,7 +1372,7 @@ int config_parse_required_for_online(
if (r < 0) { if (r < 0) {
r = parse_boolean(rvalue); r = parse_boolean(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse %s= setting, ignoring assignment: %s", "Failed to parse %s= setting, ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;

View File

@ -414,11 +414,11 @@ int config_parse_nexthop_id(
r = nexthop_new_static(network, filename, section_line, &n); r = nexthop_new_static(network, filename, section_line, &n);
if (r < 0) if (r < 0)
return r; return log_oom();
r = safe_atou32(rvalue, &n->id); r = safe_atou32(rvalue, &n->id);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Could not parse nexthop id \"%s\", ignoring assignment: %m", rvalue); "Could not parse nexthop id \"%s\", ignoring assignment: %m", rvalue);
return 0; return 0;
} }
@ -451,11 +451,11 @@ int config_parse_nexthop_gateway(
r = nexthop_new_static(network, filename, section_line, &n); r = nexthop_new_static(network, filename, section_line, &n);
if (r < 0) if (r < 0)
return r; return log_oom();
r = in_addr_from_string_auto(rvalue, &n->family, &n->gw); r = in_addr_from_string_auto(rvalue, &n->family, &n->gw);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid %s='%s', ignoring assignment: %m", lvalue, rvalue); "Invalid %s='%s', ignoring assignment: %m", lvalue, rvalue);
return 0; return 0;
} }

View File

@ -211,11 +211,11 @@ int config_parse_prefix(const char *unit,
r = prefix_new_static(network, filename, section_line, &p); r = prefix_new_static(network, filename, section_line, &p);
if (r < 0) if (r < 0)
return r; return log_oom();
r = in_addr_prefix_from_string(rvalue, AF_INET6, &in6addr, &prefixlen); r = in_addr_prefix_from_string(rvalue, AF_INET6, &in6addr, &prefixlen);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Prefix is invalid, ignoring assignment: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Prefix is invalid, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -251,11 +251,11 @@ int config_parse_prefix_flags(const char *unit,
r = prefix_new_static(network, filename, section_line, &p); r = prefix_new_static(network, filename, section_line, &p);
if (r < 0) if (r < 0)
return r; return log_oom();
r = parse_boolean(rvalue); r = parse_boolean(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse address flag, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse address flag, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -296,11 +296,11 @@ int config_parse_prefix_lifetime(const char *unit,
r = prefix_new_static(network, filename, section_line, &p); r = prefix_new_static(network, filename, section_line, &p);
if (r < 0) if (r < 0)
return r; return log_oom();
r = parse_sec(rvalue, &usec); r = parse_sec(rvalue, &usec);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Lifetime is invalid, ignoring assignment: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Lifetime is invalid, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -343,11 +343,11 @@ int config_parse_prefix_assign(
r = prefix_new_static(network, filename, section_line, &p); r = prefix_new_static(network, filename, section_line, &p);
if (r < 0) if (r < 0)
return r; return log_oom();
r = parse_boolean(rvalue); r = parse_boolean(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse %s=, ignoring assignment: %s", "Failed to parse %s=, ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
@ -384,11 +384,11 @@ int config_parse_route_prefix(const char *unit,
r = route_prefix_new_static(network, filename, section_line, &p); r = route_prefix_new_static(network, filename, section_line, &p);
if (r < 0) if (r < 0)
return r; return log_oom();
r = in_addr_prefix_from_string(rvalue, AF_INET6, &in6addr, &prefixlen); r = in_addr_prefix_from_string(rvalue, AF_INET6, &in6addr, &prefixlen);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Route prefix is invalid, ignoring assignment: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Route prefix is invalid, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -425,11 +425,11 @@ int config_parse_route_prefix_lifetime(const char *unit,
r = route_prefix_new_static(network, filename, section_line, &p); r = route_prefix_new_static(network, filename, section_line, &p);
if (r < 0) if (r < 0)
return r; return log_oom();
r = parse_sec(rvalue, &usec); r = parse_sec(rvalue, &usec);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Route lifetime is invalid, ignoring assignment: %s", rvalue); "Route lifetime is invalid, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -716,14 +716,13 @@ int config_parse_radv_dns(
void *userdata) { void *userdata) {
Network *n = data; Network *n = data;
const char *p = rvalue;
int r; int r;
assert(filename); assert(filename);
assert(lvalue); assert(lvalue);
assert(rvalue); assert(rvalue);
for (;;) { for (const char *p = rvalue;;) {
_cleanup_free_ char *w = NULL; _cleanup_free_ char *w = NULL;
union in_addr_union a; union in_addr_union a;
@ -731,25 +730,25 @@ int config_parse_radv_dns(
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to extract word, ignoring: %s", rvalue); "Failed to extract word, ignoring: %s", rvalue);
return 0; return 0;
} }
if (r == 0) if (r == 0)
break; return 0;
if (streq(w, "_link_local")) if (streq(w, "_link_local"))
a = IN_ADDR_NULL; a = IN_ADDR_NULL;
else { else {
r = in_addr_from_string(AF_INET6, w, &a); r = in_addr_from_string(AF_INET6, w, &a);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse DNS server address, ignoring: %s", w); "Failed to parse DNS server address, ignoring: %s", w);
continue; continue;
} }
if (in_addr_is_null(AF_INET6, &a)) { if (in_addr_is_null(AF_INET6, &a)) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"DNS server address is null, ignoring: %s", w); "DNS server address is null, ignoring: %s", w);
continue; continue;
} }
@ -763,8 +762,6 @@ int config_parse_radv_dns(
m[n->n_router_dns++] = a.in6; m[n->n_router_dns++] = a.in6;
n->router_dns = m; n->router_dns = m;
} }
return 0;
} }
int config_parse_radv_search_domains( int config_parse_radv_search_domains(
@ -780,30 +777,29 @@ int config_parse_radv_search_domains(
void *userdata) { void *userdata) {
Network *n = data; Network *n = data;
const char *p = rvalue;
int r; int r;
assert(filename); assert(filename);
assert(lvalue); assert(lvalue);
assert(rvalue); assert(rvalue);
for (;;) { for (const char *p = rvalue;;) {
_cleanup_free_ char *w = NULL, *idna = NULL; _cleanup_free_ char *w = NULL, *idna = NULL;
r = extract_first_word(&p, &w, NULL, 0); r = extract_first_word(&p, &w, NULL, 0);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to extract word, ignoring: %s", rvalue); "Failed to extract word, ignoring: %s", rvalue);
return 0; return 0;
} }
if (r == 0) if (r == 0)
break; return 0;
r = dns_name_apply_idna(w, &idna); r = dns_name_apply_idna(w, &idna);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to apply IDNA to domain name '%s', ignoring: %m", w); "Failed to apply IDNA to domain name '%s', ignoring: %m", w);
continue; continue;
} else if (r == 0) } else if (r == 0)
@ -812,14 +808,12 @@ int config_parse_radv_search_domains(
r = ordered_set_ensure_allocated(&n->router_search_domains, &string_hash_ops); r = ordered_set_ensure_allocated(&n->router_search_domains, &string_hash_ops);
if (r < 0) if (r < 0)
return r; return log_oom();
r = ordered_set_consume(n->router_search_domains, TAKE_PTR(idna)); r = ordered_set_consume(n->router_search_domains, TAKE_PTR(idna));
if (r < 0) if (r < 0)
return r; return log_oom();
} }
return 0;
} }
static const char * const radv_prefix_delegation_table[_RADV_PREFIX_DELEGATION_MAX] = { static const char * const radv_prefix_delegation_table[_RADV_PREFIX_DELEGATION_MAX] = {
@ -857,7 +851,8 @@ int config_parse_router_prefix_delegation(
d = radv_prefix_delegation_from_string(rvalue); d = radv_prefix_delegation_from_string(rvalue);
if (d < 0) { if (d < 0) {
log_syntax(unit, LOG_ERR, filename, line, -EINVAL, "Invalid router prefix delegation '%s', ignoring assignment.", rvalue); log_syntax(unit, LOG_WARNING, filename, line, SYNTHETIC_ERRNO(EINVAL),
"Invalid router prefix delegation '%s', ignoring assignment.", rvalue);
return 0; return 0;
} }
@ -891,7 +886,8 @@ int config_parse_router_preference(const char *unit,
else if (streq(rvalue, "low")) else if (streq(rvalue, "low"))
network->router_preference = SD_NDISC_PREFERENCE_LOW; network->router_preference = SD_NDISC_PREFERENCE_LOW;
else else
log_syntax(unit, LOG_ERR, filename, line, -EINVAL, "Router preference '%s' is invalid, ignoring assignment: %m", rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid router preference, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -922,7 +918,7 @@ int config_parse_router_prefix_subnet_id(const char *unit,
r = safe_atoux64(rvalue, &t); r = safe_atoux64(rvalue, &t);
if (r < 0 || t > INT64_MAX) { if (r < 0 || t > INT64_MAX) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Subnet id '%s' is invalid, ignoring assignment.", "Subnet id '%s' is invalid, ignoring assignment.",
rvalue); rvalue);
return 0; return 0;

View File

@ -15,6 +15,7 @@
#include "socket-netlink.h" #include "socket-netlink.h"
#include "string-table.h" #include "string-table.h"
#include "string-util.h" #include "string-util.h"
#include "strv.h"
#include "strxcpyx.h" #include "strxcpyx.h"
#include "sysctl-util.h" #include "sysctl-util.h"
#include "vrf.h" #include "vrf.h"
@ -991,12 +992,22 @@ int config_parse_gateway(
/* we are not in an Route section, so treat /* we are not in an Route section, so treat
* this as the special '0' section */ * this as the special '0' section */
r = route_new_static(network, NULL, 0, &n); r = route_new_static(network, NULL, 0, &n);
if (r < 0) if (r == -ENOMEM)
return r; return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to allocate route, ignoring assignment: %m");
return 0;
}
} else { } else {
r = route_new_static(network, filename, section_line, &n); r = route_new_static(network, filename, section_line, &n);
if (r < 0) if (r == -ENOMEM)
return r; return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to allocate route, ignoring assignment: %m");
return 0;
}
if (streq(rvalue, "_dhcp")) { if (streq(rvalue, "_dhcp")) {
n->gateway_from_dhcp = true; n->gateway_from_dhcp = true;
@ -1010,7 +1021,7 @@ int config_parse_gateway(
else else
r = in_addr_from_string(n->family, rvalue, &n->gw); r = in_addr_from_string(n->family, rvalue, &n->gw);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid %s='%s', ignoring assignment: %m", lvalue, rvalue); "Invalid %s='%s', ignoring assignment: %m", lvalue, rvalue);
return 0; return 0;
} }
@ -1042,15 +1053,20 @@ int config_parse_preferred_src(
assert(data); assert(data);
r = route_new_static(network, filename, section_line, &n); r = route_new_static(network, filename, section_line, &n);
if (r < 0) if (r == -ENOMEM)
return r; return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to allocate route, ignoring assignment: %m");
return 0;
}
if (n->family == AF_UNSPEC) if (n->family == AF_UNSPEC)
r = in_addr_from_string_auto(rvalue, &n->family, &n->prefsrc); r = in_addr_from_string_auto(rvalue, &n->family, &n->prefsrc);
else else
r = in_addr_from_string(n->family, rvalue, &n->prefsrc); r = in_addr_from_string(n->family, rvalue, &n->prefsrc);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, EINVAL, log_syntax(unit, LOG_WARNING, filename, line, EINVAL,
"Invalid %s='%s', ignoring assignment: %m", lvalue, rvalue); "Invalid %s='%s', ignoring assignment: %m", lvalue, rvalue);
return 0; return 0;
} }
@ -1084,8 +1100,13 @@ int config_parse_destination(
assert(data); assert(data);
r = route_new_static(network, filename, section_line, &n); r = route_new_static(network, filename, section_line, &n);
if (r < 0) if (r == -ENOMEM)
return r; return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to allocate route, ignoring assignment: %m");
return 0;
}
if (streq(lvalue, "Destination")) { if (streq(lvalue, "Destination")) {
buffer = &n->dst; buffer = &n->dst;
@ -1101,7 +1122,7 @@ int config_parse_destination(
else else
r = in_addr_prefix_from_string(rvalue, n->family, buffer, prefixlen); r = in_addr_prefix_from_string(rvalue, n->family, buffer, prefixlen);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, EINVAL, log_syntax(unit, LOG_WARNING, filename, line, EINVAL,
"Invalid %s='%s', ignoring assignment: %m", lvalue, rvalue); "Invalid %s='%s', ignoring assignment: %m", lvalue, rvalue);
return 0; return 0;
} }
@ -1133,12 +1154,17 @@ int config_parse_route_priority(
assert(data); assert(data);
r = route_new_static(network, filename, section_line, &n); r = route_new_static(network, filename, section_line, &n);
if (r < 0) if (r == -ENOMEM)
return r; return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to allocate route, ignoring assignment: %m");
return 0;
}
r = safe_atou32(rvalue, &n->priority); r = safe_atou32(rvalue, &n->priority);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Could not parse route priority \"%s\", ignoring assignment: %m", rvalue); "Could not parse route priority \"%s\", ignoring assignment: %m", rvalue);
return 0; return 0;
} }
@ -1170,12 +1196,17 @@ int config_parse_route_scope(
assert(data); assert(data);
r = route_new_static(network, filename, section_line, &n); r = route_new_static(network, filename, section_line, &n);
if (r < 0) if (r == -ENOMEM)
return r; return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to allocate route, ignoring assignment: %m");
return 0;
}
r = route_scope_from_string(rvalue); r = route_scope_from_string(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Unknown route scope: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "Unknown route scope: %s", rvalue);
return 0; return 0;
} }
@ -1208,8 +1239,13 @@ int config_parse_route_table(
assert(data); assert(data);
r = route_new_static(network, filename, section_line, &n); r = route_new_static(network, filename, section_line, &n);
if (r < 0) if (r == -ENOMEM)
return r; return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to allocate route, ignoring assignment: %m");
return 0;
}
r = route_table_from_string(rvalue); r = route_table_from_string(rvalue);
if (r >= 0) if (r >= 0)
@ -1217,7 +1253,7 @@ int config_parse_route_table(
else { else {
r = safe_atou32(rvalue, &n->table); r = safe_atou32(rvalue, &n->table);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Could not parse route table number \"%s\", ignoring assignment: %m", rvalue); "Could not parse route table number \"%s\", ignoring assignment: %m", rvalue);
return 0; return 0;
} }
@ -1228,7 +1264,7 @@ int config_parse_route_table(
return 0; return 0;
} }
int config_parse_gateway_onlink( int config_parse_route_boolean(
const char *unit, const char *unit,
const char *filename, const char *filename,
unsigned line, unsigned line,
@ -1251,17 +1287,31 @@ int config_parse_gateway_onlink(
assert(data); assert(data);
r = route_new_static(network, filename, section_line, &n); r = route_new_static(network, filename, section_line, &n);
if (r < 0) if (r == -ENOMEM)
return r; return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to allocate route, ignoring assignment: %m");
return 0;
}
r = parse_boolean(rvalue); r = parse_boolean(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Could not parse %s=\"%s\", ignoring assignment: %m", lvalue, rvalue); "Could not parse %s=\"%s\", ignoring assignment: %m", lvalue, rvalue);
return 0; return 0;
} }
if (STR_IN_SET(lvalue, "GatewayOnLink", "GatewayOnlink"))
n->gateway_onlink = r; n->gateway_onlink = r;
else if (streq(lvalue, "QuickAck"))
n->quickack = r;
else if (streq(lvalue, "FastOpenNoCookie"))
n->fast_open_no_cookie = r;
else if (streq(lvalue, "TTLPropagate"))
n->ttl_propagate = r;
else
assert_not_reached("Invalid lvalue");
TAKE_PTR(n); TAKE_PTR(n);
return 0; return 0;
@ -1284,8 +1334,13 @@ int config_parse_ipv6_route_preference(
int r; int r;
r = route_new_static(network, filename, section_line, &n); r = route_new_static(network, filename, section_line, &n);
if (r < 0) if (r == -ENOMEM)
return r; return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to allocate route, ignoring assignment: %m");
return 0;
}
if (streq(rvalue, "low")) if (streq(rvalue, "low"))
n->pref = ICMPV6_ROUTER_PREF_LOW; n->pref = ICMPV6_ROUTER_PREF_LOW;
@ -1294,7 +1349,7 @@ int config_parse_ipv6_route_preference(
else if (streq(rvalue, "high")) else if (streq(rvalue, "high"))
n->pref = ICMPV6_ROUTER_PREF_HIGH; n->pref = ICMPV6_ROUTER_PREF_HIGH;
else { else {
log_syntax(unit, LOG_ERR, filename, line, 0, "Unknown route preference: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "Unknown route preference: %s", rvalue);
return 0; return 0;
} }
@ -1319,8 +1374,13 @@ int config_parse_route_protocol(
int r; int r;
r = route_new_static(network, filename, section_line, &n); r = route_new_static(network, filename, section_line, &n);
if (r < 0) if (r == -ENOMEM)
return r; return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to allocate route, ignoring assignment: %m");
return 0;
}
r = route_protocol_from_string(rvalue); r = route_protocol_from_string(rvalue);
if (r >= 0) if (r >= 0)
@ -1328,7 +1388,7 @@ int config_parse_route_protocol(
else { else {
r = safe_atou8(rvalue , &n->protocol); r = safe_atou8(rvalue , &n->protocol);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Could not parse route protocol \"%s\", ignoring assignment: %m", rvalue); "Could not parse route protocol \"%s\", ignoring assignment: %m", rvalue);
return 0; return 0;
} }
@ -1355,12 +1415,17 @@ int config_parse_route_type(
int t, r; int t, r;
r = route_new_static(network, filename, section_line, &n); r = route_new_static(network, filename, section_line, &n);
if (r < 0) if (r == -ENOMEM)
return r; return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to allocate route, ignoring assignment: %m");
return 0;
}
t = route_type_from_string(rvalue); t = route_type_from_string(rvalue);
if (t < 0) { if (t < 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Could not parse route type \"%s\", ignoring assignment: %m", rvalue); "Could not parse route type \"%s\", ignoring assignment: %m", rvalue);
return 0; return 0;
} }
@ -1395,17 +1460,22 @@ int config_parse_tcp_window(
assert(data); assert(data);
r = route_new_static(network, filename, section_line, &n); r = route_new_static(network, filename, section_line, &n);
if (r < 0) if (r == -ENOMEM)
return r; return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to allocate route, ignoring assignment: %m");
return 0;
}
r = parse_size(rvalue, 1024, &k); r = parse_size(rvalue, 1024, &k);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Could not parse TCP %s \"%s\", ignoring assignment: %m", lvalue, rvalue); "Could not parse TCP %s \"%s\", ignoring assignment: %m", lvalue, rvalue);
return 0; return 0;
} }
if (k > UINT32_MAX) { if (k > UINT32_MAX) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Specified TCP %s \"%s\" is too large, ignoring assignment: %m", lvalue, rvalue); "Specified TCP %s \"%s\" is too large, ignoring assignment: %m", lvalue, rvalue);
return 0; return 0;
} }
@ -1421,82 +1491,6 @@ int config_parse_tcp_window(
return 0; return 0;
} }
int config_parse_quickack(
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_(route_free_or_set_invalidp) Route *n = NULL;
Network *network = userdata;
int k, r;
assert(filename);
assert(section);
assert(lvalue);
assert(rvalue);
assert(data);
r = route_new_static(network, filename, section_line, &n);
if (r < 0)
return r;
k = parse_boolean(rvalue);
if (k < 0) {
log_syntax(unit, LOG_ERR, filename, line, k,
"Failed to parse TCP quickack, ignoring: %s", rvalue);
return 0;
}
n->quickack = !!k;
TAKE_PTR(n);
return 0;
}
int config_parse_fast_open_no_cookie(
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_(route_free_or_set_invalidp) Route *n = NULL;
Network *network = userdata;
int k, r;
assert(filename);
assert(section);
assert(lvalue);
assert(rvalue);
assert(data);
r = route_new_static(network, filename, section_line, &n);
if (r < 0)
return r;
k = parse_boolean(rvalue);
if (k < 0) {
log_syntax(unit, LOG_ERR, filename, line, k,
"Failed to parse TCP fastopen no cookie, ignoring: %s", rvalue);
return 0;
}
n->fast_open_no_cookie = k;
TAKE_PTR(n);
return 0;
}
int config_parse_route_mtu( int config_parse_route_mtu(
const char *unit, const char *unit,
const char *filename, const char *filename,
@ -1520,8 +1514,13 @@ int config_parse_route_mtu(
assert(data); assert(data);
r = route_new_static(network, filename, section_line, &n); r = route_new_static(network, filename, section_line, &n);
if (r < 0) if (r == -ENOMEM)
return r; return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to allocate route, ignoring assignment: %m");
return 0;
}
r = config_parse_mtu(unit, filename, line, section, section_line, lvalue, ltype, rvalue, &n->mtu, userdata); r = config_parse_mtu(unit, filename, line, section, section_line, lvalue, ltype, rvalue, &n->mtu, userdata);
if (r < 0) if (r < 0)
@ -1531,45 +1530,6 @@ int config_parse_route_mtu(
return 0; return 0;
} }
int config_parse_route_ttl_propagate(
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 = userdata;
_cleanup_(route_free_or_set_invalidp) Route *n = NULL;
int r, k;
assert(filename);
assert(section);
assert(lvalue);
assert(rvalue);
assert(data);
r = route_new_static(network, filename, section_line, &n);
if (r < 0)
return r;
k = parse_boolean(rvalue);
if (k < 0) {
log_syntax(unit, LOG_ERR, filename, line, k,
"Failed to parse TTLPropagate= value, ignoring: %s", rvalue);
return 0;
}
n->ttl_propagate = k;
TAKE_PTR(n);
return 0;
}
int config_parse_multipath_route( int config_parse_multipath_route(
const char *unit, const char *unit,
const char *filename, const char *filename,
@ -1597,8 +1557,13 @@ int config_parse_multipath_route(
assert(data); assert(data);
r = route_new_static(network, filename, section_line, &n); r = route_new_static(network, filename, section_line, &n);
if (r < 0) if (r == -ENOMEM)
return r; return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to allocate route, ignoring assignment: %m");
return 0;
}
if (isempty(rvalue)) { if (isempty(rvalue)) {
n->multipath_routes = ordered_set_free_free(n->multipath_routes); n->multipath_routes = ordered_set_free_free(n->multipath_routes);
@ -1614,7 +1579,7 @@ int config_parse_multipath_route(
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r <= 0) { if (r <= 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid multipath route option, ignoring assignment: %s", rvalue); "Invalid multipath route option, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -1631,7 +1596,7 @@ int config_parse_multipath_route(
r = in_addr_from_string_auto(ip, &family, &a); r = in_addr_from_string_auto(ip, &family, &a);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid multipath route gateway '%s', ignoring assignment: %m", rvalue); "Invalid multipath route gateway '%s', ignoring assignment: %m", rvalue);
return 0; return 0;
} }
@ -1641,7 +1606,7 @@ int config_parse_multipath_route(
if (dev) { if (dev) {
r = resolve_interface(NULL, dev); r = resolve_interface(NULL, dev);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid interface name or index, ignoring assignment: %s", dev); "Invalid interface name or index, ignoring assignment: %s", dev);
return 0; return 0;
} }
@ -1651,12 +1616,12 @@ int config_parse_multipath_route(
if (!isempty(p)) { if (!isempty(p)) {
r = safe_atou32(p, &m->weight); r = safe_atou32(p, &m->weight);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid multipath route weight, ignoring assignment: %s", p); "Invalid multipath route weight, ignoring assignment: %s", p);
return 0; return 0;
} }
if (m->weight == 0 || m->weight > 256) { if (m->weight == 0 || m->weight > 256) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid multipath route weight, ignoring assignment: %s", p); "Invalid multipath route weight, ignoring assignment: %s", p);
return 0; return 0;
} }
@ -1668,7 +1633,7 @@ int config_parse_multipath_route(
r = ordered_set_put(n->multipath_routes, m); r = ordered_set_put(n->multipath_routes, m);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to store multipath route, ignoring assignment: %m"); "Failed to store multipath route, ignoring assignment: %m");
return 0; return 0;
} }

View File

@ -100,13 +100,10 @@ CONFIG_PARSER_PROTOTYPE(config_parse_destination);
CONFIG_PARSER_PROTOTYPE(config_parse_route_priority); CONFIG_PARSER_PROTOTYPE(config_parse_route_priority);
CONFIG_PARSER_PROTOTYPE(config_parse_route_scope); CONFIG_PARSER_PROTOTYPE(config_parse_route_scope);
CONFIG_PARSER_PROTOTYPE(config_parse_route_table); CONFIG_PARSER_PROTOTYPE(config_parse_route_table);
CONFIG_PARSER_PROTOTYPE(config_parse_gateway_onlink); CONFIG_PARSER_PROTOTYPE(config_parse_route_boolean);
CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_route_preference); CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_route_preference);
CONFIG_PARSER_PROTOTYPE(config_parse_route_protocol); CONFIG_PARSER_PROTOTYPE(config_parse_route_protocol);
CONFIG_PARSER_PROTOTYPE(config_parse_route_type); CONFIG_PARSER_PROTOTYPE(config_parse_route_type);
CONFIG_PARSER_PROTOTYPE(config_parse_tcp_window); CONFIG_PARSER_PROTOTYPE(config_parse_tcp_window);
CONFIG_PARSER_PROTOTYPE(config_parse_quickack);
CONFIG_PARSER_PROTOTYPE(config_parse_fast_open_no_cookie);
CONFIG_PARSER_PROTOTYPE(config_parse_route_ttl_propagate);
CONFIG_PARSER_PROTOTYPE(config_parse_route_mtu); CONFIG_PARSER_PROTOTYPE(config_parse_route_mtu);
CONFIG_PARSER_PROTOTYPE(config_parse_multipath_route); CONFIG_PARSER_PROTOTYPE(config_parse_multipath_route);

View File

@ -694,11 +694,11 @@ int config_parse_routing_policy_rule_tos(
r = routing_policy_rule_new_static(network, filename, section_line, &n); r = routing_policy_rule_new_static(network, filename, section_line, &n);
if (r < 0) if (r < 0)
return r; return log_oom();
r = safe_atou8(rvalue, &n->tos); r = safe_atou8(rvalue, &n->tos);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse RPDB rule TOS, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse RPDB rule TOS, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -731,11 +731,11 @@ int config_parse_routing_policy_rule_priority(
r = routing_policy_rule_new_static(network, filename, section_line, &n); r = routing_policy_rule_new_static(network, filename, section_line, &n);
if (r < 0) if (r < 0)
return r; return log_oom();
r = safe_atou32(rvalue, &n->priority); r = safe_atou32(rvalue, &n->priority);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse RPDB rule priority, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse RPDB rule priority, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -768,11 +768,11 @@ int config_parse_routing_policy_rule_table(
r = routing_policy_rule_new_static(network, filename, section_line, &n); r = routing_policy_rule_new_static(network, filename, section_line, &n);
if (r < 0) if (r < 0)
return r; return log_oom();
r = safe_atou32(rvalue, &n->table); r = safe_atou32(rvalue, &n->table);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse RPDB rule table, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse RPDB rule table, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -805,11 +805,11 @@ int config_parse_routing_policy_rule_fwmark_mask(
r = routing_policy_rule_new_static(network, filename, section_line, &n); r = routing_policy_rule_new_static(network, filename, section_line, &n);
if (r < 0) if (r < 0)
return r; return log_oom();
r = parse_fwmark_fwmask(rvalue, &n->fwmark, &n->fwmask); r = parse_fwmark_fwmask(rvalue, &n->fwmark, &n->fwmask);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse RPDB rule firewall mark or mask, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse RPDB rule firewall mark or mask, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -844,7 +844,7 @@ int config_parse_routing_policy_rule_prefix(
r = routing_policy_rule_new_static(network, filename, section_line, &n); r = routing_policy_rule_new_static(network, filename, section_line, &n);
if (r < 0) if (r < 0)
return r; return log_oom();
if (streq(lvalue, "To")) { if (streq(lvalue, "To")) {
buffer = &n->to; buffer = &n->to;
@ -859,7 +859,7 @@ int config_parse_routing_policy_rule_prefix(
else else
r = in_addr_prefix_from_string(rvalue, n->family, buffer, prefixlen); r = in_addr_prefix_from_string(rvalue, n->family, buffer, prefixlen);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "RPDB rule prefix is invalid, ignoring assignment: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "RPDB rule prefix is invalid, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -892,10 +892,10 @@ int config_parse_routing_policy_rule_device(
r = routing_policy_rule_new_static(network, filename, section_line, &n); r = routing_policy_rule_new_static(network, filename, section_line, &n);
if (r < 0) if (r < 0)
return r; return log_oom();
if (!ifname_valid(rvalue)) { if (!ifname_valid(rvalue)) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse '%s' interface name, ignoring: %s", lvalue, rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse '%s' interface name, ignoring: %s", lvalue, rvalue);
return 0; return 0;
} }
@ -938,11 +938,11 @@ int config_parse_routing_policy_rule_port_range(
r = routing_policy_rule_new_static(network, filename, section_line, &n); r = routing_policy_rule_new_static(network, filename, section_line, &n);
if (r < 0) if (r < 0)
return r; return log_oom();
r = parse_ip_port_range(rvalue, &low, &high); r = parse_ip_port_range(rvalue, &low, &high);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse routing policy rule port range '%s'", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse routing policy rule port range '%s'", rvalue);
return 0; return 0;
} }
@ -983,11 +983,11 @@ int config_parse_routing_policy_rule_ip_protocol(
r = routing_policy_rule_new_static(network, filename, section_line, &n); r = routing_policy_rule_new_static(network, filename, section_line, &n);
if (r < 0) if (r < 0)
return r; return log_oom();
r = parse_ip_protocol(rvalue); r = parse_ip_protocol(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse IP protocol '%s' for routing policy rule, ignoring: %m", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse IP protocol '%s' for routing policy rule, ignoring: %m", rvalue);
return 0; return 0;
} }
@ -1022,11 +1022,11 @@ int config_parse_routing_policy_rule_invert(
r = routing_policy_rule_new_static(network, filename, section_line, &n); r = routing_policy_rule_new_static(network, filename, section_line, &n);
if (r < 0) if (r < 0)
return r; return log_oom();
r = parse_boolean(rvalue); r = parse_boolean(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse RPDB rule invert, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse RPDB rule invert, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -1062,11 +1062,11 @@ int config_parse_routing_policy_rule_family(
r = routing_policy_rule_new_static(network, filename, section_line, &n); r = routing_policy_rule_new_static(network, filename, section_line, &n);
if (r < 0) if (r < 0)
return r; return log_oom();
a = routing_policy_rule_address_family_from_string(rvalue); a = routing_policy_rule_address_family_from_string(rvalue);
if (a < 0) { if (a < 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid address family '%s', ignoring.", rvalue); "Invalid address family '%s', ignoring.", rvalue);
return 0; return 0;
} }
@ -1102,7 +1102,7 @@ int config_parse_routing_policy_rule_uid_range(
r = routing_policy_rule_new_static(network, filename, section_line, &n); r = routing_policy_rule_new_static(network, filename, section_line, &n);
if (r < 0) if (r < 0)
return r; return log_oom();
r = get_user_creds(&rvalue, &start, NULL, NULL, NULL, 0); r = get_user_creds(&rvalue, &start, NULL, NULL, NULL, 0);
if (r >= 0) if (r >= 0)
@ -1110,7 +1110,7 @@ int config_parse_routing_policy_rule_uid_range(
else { else {
r = parse_uid_range(rvalue, &start, &end); r = parse_uid_range(rvalue, &start, &end);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid uid or uid range '%s', ignoring: %m", rvalue); "Invalid uid or uid range '%s', ignoring: %m", rvalue);
return 0; return 0;
} }
@ -1147,15 +1147,15 @@ int config_parse_routing_policy_rule_suppress_prefixlen(
r = routing_policy_rule_new_static(network, filename, section_line, &n); r = routing_policy_rule_new_static(network, filename, section_line, &n);
if (r < 0) if (r < 0)
return r; return log_oom();
r = parse_ip_prefix_length(rvalue, &n->suppress_prefixlen); r = parse_ip_prefix_length(rvalue, &n->suppress_prefixlen);
if (r == -ERANGE) { if (r == -ERANGE) {
log_syntax(unit, LOG_ERR, filename, line, r, "Prefix length outside of valid range 0-128, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Prefix length outside of valid range 0-128, ignoring: %s", rvalue);
return 0; return 0;
} }
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse RPDB rule suppress_prefixlen, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse RPDB rule suppress_prefixlen, ignoring: %s", rvalue);
return 0; return 0;
} }

View File

@ -283,20 +283,20 @@ int config_parse_sr_iov_uint32(
r = safe_atou32(rvalue, &k); r = safe_atou32(rvalue, &k);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse SR-IOV '%s=', ignoring assignment: %s", lvalue, rvalue); "Failed to parse SR-IOV '%s=', ignoring assignment: %s", lvalue, rvalue);
return 0; return 0;
} }
if (streq(lvalue, "VLANId")) { if (streq(lvalue, "VLANId")) {
if (k == 0 || k > 4095) { if (k == 0 || k > 4095) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid SR-IOV VLANId: %d", k); log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid SR-IOV VLANId: %d", k);
return 0; return 0;
} }
sr_iov->vlan = k; sr_iov->vlan = k;
} else if (streq(lvalue, "VirtualFunction")) { } else if (streq(lvalue, "VirtualFunction")) {
if (k >= INT_MAX) { if (k >= INT_MAX) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid SR-IOV virtual function: %d", k); log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid SR-IOV virtual function: %d", k);
return 0; return 0;
} }
sr_iov->vf = k; sr_iov->vf = k;
@ -339,7 +339,7 @@ int config_parse_sr_iov_vlan_proto(
else if (streq(rvalue, "802.1ad")) else if (streq(rvalue, "802.1ad"))
sr_iov->vlan_proto = ETH_P_8021AD; sr_iov->vlan_proto = ETH_P_8021AD;
else { else {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid SR-IOV '%s=', ignoring assignment: %s", lvalue, rvalue); "Invalid SR-IOV '%s=', ignoring assignment: %s", lvalue, rvalue);
return 0; return 0;
} }
@ -390,7 +390,7 @@ int config_parse_sr_iov_link_state(
r = parse_boolean(rvalue); r = parse_boolean(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse SR-IOV '%s=', ignoring assignment: %s", lvalue, rvalue); "Failed to parse SR-IOV '%s=', ignoring assignment: %s", lvalue, rvalue);
return 0; return 0;
} }
@ -441,7 +441,7 @@ int config_parse_sr_iov_boolean(
r = parse_boolean(rvalue); r = parse_boolean(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse '%s=', ignoring: %s", lvalue, rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse '%s=', ignoring: %s", lvalue, rvalue);
return 0; return 0;
} }
@ -491,7 +491,7 @@ int config_parse_sr_iov_mac(
r = ether_addr_from_string(rvalue, &sr_iov->mac); r = ether_addr_from_string(rvalue, &sr_iov->mac);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse SR-IOV '%s=', ignoring assignment: %s", lvalue, rvalue); "Failed to parse SR-IOV '%s=', ignoring assignment: %s", lvalue, rvalue);
return 0; return 0;
} }

View File

@ -86,7 +86,7 @@ int config_parse_address_family_with_kernel(
if (streq(rvalue, "kernel")) if (streq(rvalue, "kernel"))
s = ADDRESS_FAMILY_NO; s = ADDRESS_FAMILY_NO;
else { else {
log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse IPForward= option, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse IPForward= option, ignoring: %s", rvalue);
return 0; return 0;
} }
} }

View File

@ -68,9 +68,11 @@ int config_parse_cake_bandwidth(
r = qdisc_new_static(QDISC_KIND_CAKE, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_CAKE, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
c = CAKE(qdisc); c = CAKE(qdisc);
@ -83,7 +85,7 @@ int config_parse_cake_bandwidth(
r = parse_size(rvalue, 1000, &k); r = parse_size(rvalue, 1000, &k);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
@ -121,9 +123,11 @@ int config_parse_cake_overhead(
r = qdisc_new_static(QDISC_KIND_CAKE, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_CAKE, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
c = CAKE(qdisc); c = CAKE(qdisc);
@ -135,13 +139,13 @@ int config_parse_cake_overhead(
r = safe_atoi32(rvalue, &v); r = safe_atoi32(rvalue, &v);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
} }
if (v < -64 || v > 256) { if (v < -64 || v > 256) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid '%s=', ignoring assignment: %s", "Invalid '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;

View File

@ -99,9 +99,11 @@ int config_parse_controlled_delay_u32(
r = qdisc_new_static(QDISC_KIND_CODEL, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_CODEL, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
cd = CODEL(qdisc); cd = CODEL(qdisc);
@ -114,7 +116,7 @@ int config_parse_controlled_delay_u32(
r = safe_atou32(rvalue, &cd->packet_limit); r = safe_atou32(rvalue, &cd->packet_limit);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
@ -151,9 +153,11 @@ int config_parse_controlled_delay_usec(
r = qdisc_new_static(QDISC_KIND_CODEL, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_CODEL, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
cd = CODEL(qdisc); cd = CODEL(qdisc);
@ -178,7 +182,7 @@ int config_parse_controlled_delay_usec(
r = parse_sec(rvalue, p); r = parse_sec(rvalue, p);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
@ -214,9 +218,11 @@ int config_parse_controlled_delay_bool(
r = qdisc_new_static(QDISC_KIND_CODEL, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_CODEL, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
cd = CODEL(qdisc); cd = CODEL(qdisc);
@ -229,7 +235,7 @@ int config_parse_controlled_delay_bool(
r = parse_boolean(rvalue); r = parse_boolean(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;

View File

@ -66,9 +66,13 @@ int config_parse_drr_size(
assert(data); assert(data);
r = tclass_new_static(TCLASS_KIND_DRR, network, filename, section_line, &tclass); r = tclass_new_static(TCLASS_KIND_DRR, network, filename, section_line, &tclass);
if (r < 0) if (r == -ENOMEM)
return log_syntax(unit, LOG_ERR, filename, line, r, return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to create traffic control class, ignoring assignment: %m"); "Failed to create traffic control class, ignoring assignment: %m");
return 0;
}
drr = TCLASS_TO_DRR(tclass); drr = TCLASS_TO_DRR(tclass);
@ -81,13 +85,13 @@ int config_parse_drr_size(
r = parse_size(rvalue, 1024, &u); r = parse_size(rvalue, 1024, &u);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
} }
if (u > UINT32_MAX) { if (u > UINT32_MAX) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid '%s=', ignoring assignment: %s", log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
} }

View File

@ -101,9 +101,11 @@ int config_parse_ets_u8(
r = qdisc_new_static(QDISC_KIND_ETS, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_ETS, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
ets = ETS(qdisc); ets = ETS(qdisc);
if (streq(lvalue, "Bands")) if (streq(lvalue, "Bands"))
@ -122,13 +124,13 @@ int config_parse_ets_u8(
r = safe_atou8(rvalue, &v); r = safe_atou8(rvalue, &v);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
} }
if (v > TCQ_ETS_MAX_BANDS) { if (v > TCQ_ETS_MAX_BANDS) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid '%s='. The value must be <= %d, ignoring assignment: %s", "Invalid '%s='. The value must be <= %d, ignoring assignment: %s",
lvalue, TCQ_ETS_MAX_BANDS, rvalue); lvalue, TCQ_ETS_MAX_BANDS, rvalue);
return 0; return 0;
@ -165,9 +167,11 @@ int config_parse_ets_quanta(
r = qdisc_new_static(QDISC_KIND_ETS, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_ETS, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
ets = ETS(qdisc); ets = ETS(qdisc);
@ -187,28 +191,28 @@ int config_parse_ets_quanta(
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to extract next value, ignoring: %m"); "Failed to extract next value, ignoring: %m");
continue; break;
} }
if (r == 0) if (r == 0)
break; break;
r = parse_size(word, 1024, &v); r = parse_size(word, 1024, &v);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, word); lvalue, word);
continue; continue;
} }
if (v == 0 || v > UINT32_MAX) { if (v == 0 || v > UINT32_MAX) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid '%s=', ignoring assignment: %s", "Invalid '%s=', ignoring assignment: %s",
lvalue, word); lvalue, word);
continue; continue;
} }
if (ets->n_quanta >= TCQ_ETS_MAX_BANDS) { if (ets->n_quanta >= TCQ_ETS_MAX_BANDS) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Too many quanta in '%s=', ignoring assignment: %s", "Too many quanta in '%s=', ignoring assignment: %s",
lvalue, word); lvalue, word);
continue; continue;
@ -247,9 +251,11 @@ int config_parse_ets_prio(
r = qdisc_new_static(QDISC_KIND_ETS, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_ETS, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
ets = ETS(qdisc); ets = ETS(qdisc);
@ -269,22 +275,22 @@ int config_parse_ets_prio(
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to extract next value, ignoring: %m"); "Failed to extract next value, ignoring: %m");
continue; break;
} }
if (r == 0) if (r == 0)
break; break;
r = safe_atou8(word, &v); r = safe_atou8(word, &v);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, word); lvalue, word);
continue; continue;
} }
if (ets->n_prio > TC_PRIO_MAX) { if (ets->n_prio > TC_PRIO_MAX) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Too many priomap in '%s=', ignoring assignment: %s", "Too many priomap in '%s=', ignoring assignment: %s",
lvalue, word); lvalue, word);
continue; continue;

View File

@ -67,9 +67,11 @@ int config_parse_pfifo_size(
r = qdisc_new_static(ltype, network, filename, section_line, &qdisc); r = qdisc_new_static(ltype, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
switch(qdisc->kind) { switch(qdisc->kind) {
case QDISC_KIND_PFIFO: case QDISC_KIND_PFIFO:
@ -91,7 +93,7 @@ int config_parse_pfifo_size(
r = safe_atou32(rvalue, &fifo->limit); r = safe_atou32(rvalue, &fifo->limit);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
@ -127,9 +129,11 @@ int config_parse_bfifo_size(
r = qdisc_new_static(QDISC_KIND_BFIFO, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_BFIFO, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
fifo = BFIFO(qdisc); fifo = BFIFO(qdisc);
@ -142,13 +146,13 @@ int config_parse_bfifo_size(
r = parse_size(rvalue, 1024, &u); r = parse_size(rvalue, 1024, &u);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
} }
if (u > UINT32_MAX) { if (u > UINT32_MAX) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid '%s=', ignoring assignment: %s", log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
} }

View File

@ -120,9 +120,11 @@ int config_parse_fair_queueing_controlled_delay_u32(
r = qdisc_new_static(QDISC_KIND_FQ_CODEL, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_FQ_CODEL, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
fqcd = FQ_CODEL(qdisc); fqcd = FQ_CODEL(qdisc);
@ -142,7 +144,7 @@ int config_parse_fair_queueing_controlled_delay_u32(
r = safe_atou32(rvalue, p); r = safe_atou32(rvalue, p);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
@ -179,9 +181,11 @@ int config_parse_fair_queueing_controlled_delay_usec(
r = qdisc_new_static(QDISC_KIND_FQ_CODEL, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_FQ_CODEL, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
fqcd = FQ_CODEL(qdisc); fqcd = FQ_CODEL(qdisc);
@ -206,7 +210,7 @@ int config_parse_fair_queueing_controlled_delay_usec(
r = parse_sec(rvalue, p); r = parse_sec(rvalue, p);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
@ -242,9 +246,11 @@ int config_parse_fair_queueing_controlled_delay_bool(
r = qdisc_new_static(QDISC_KIND_FQ_CODEL, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_FQ_CODEL, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
fqcd = FQ_CODEL(qdisc); fqcd = FQ_CODEL(qdisc);
@ -257,7 +263,7 @@ int config_parse_fair_queueing_controlled_delay_bool(
r = parse_boolean(rvalue); r = parse_boolean(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
@ -296,9 +302,11 @@ int config_parse_fair_queueing_controlled_delay_size(
r = qdisc_new_static(QDISC_KIND_FQ_CODEL, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_FQ_CODEL, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
fqcd = FQ_CODEL(qdisc); fqcd = FQ_CODEL(qdisc);
@ -321,13 +329,13 @@ int config_parse_fair_queueing_controlled_delay_size(
r = parse_size(rvalue, 1024, &sz); r = parse_size(rvalue, 1024, &sz);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
} }
if (sz >= UINT32_MAX) { if (sz >= UINT32_MAX) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Specified '%s=' is too large, ignoring assignment: %s", "Specified '%s=' is too large, ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;

View File

@ -128,9 +128,11 @@ int config_parse_fair_queueing_u32(
r = qdisc_new_static(QDISC_KIND_FQ, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_FQ, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
fq = FQ(qdisc); fq = FQ(qdisc);
@ -154,7 +156,7 @@ int config_parse_fair_queueing_u32(
r = safe_atou32(rvalue, p); r = safe_atou32(rvalue, p);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
@ -192,9 +194,11 @@ int config_parse_fair_queueing_size(
r = qdisc_new_static(QDISC_KIND_FQ, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_FQ, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
fq = FQ(qdisc); fq = FQ(qdisc);
@ -214,13 +218,13 @@ int config_parse_fair_queueing_size(
r = parse_size(rvalue, 1024, &sz); r = parse_size(rvalue, 1024, &sz);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
} }
if (sz > UINT32_MAX) { if (sz > UINT32_MAX) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Specified '%s=' is too large, ignoring assignment: %s", "Specified '%s=' is too large, ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
@ -257,9 +261,11 @@ int config_parse_fair_queueing_bool(
r = qdisc_new_static(QDISC_KIND_FQ, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_FQ, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
fq = FQ(qdisc); fq = FQ(qdisc);
@ -272,7 +278,7 @@ int config_parse_fair_queueing_bool(
r = parse_boolean(rvalue); r = parse_boolean(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
@ -310,9 +316,11 @@ int config_parse_fair_queueing_usec(
r = qdisc_new_static(QDISC_KIND_FQ, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_FQ, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
fq = FQ(qdisc); fq = FQ(qdisc);
@ -325,13 +333,13 @@ int config_parse_fair_queueing_usec(
r = parse_sec(rvalue, &sec); r = parse_sec(rvalue, &sec);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
} }
if (sec > UINT32_MAX) { if (sec > UINT32_MAX) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Specified '%s=' is too large, ignoring assignment: %s", "Specified '%s=' is too large, ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
@ -369,9 +377,11 @@ int config_parse_fair_queueing_max_rate(
r = qdisc_new_static(QDISC_KIND_FQ, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_FQ, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
fq = FQ(qdisc); fq = FQ(qdisc);
@ -384,13 +394,13 @@ int config_parse_fair_queueing_max_rate(
r = parse_size(rvalue, 1000, &sz); r = parse_size(rvalue, 1000, &sz);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
} }
if (sz / 8 > UINT32_MAX) { if (sz / 8 > UINT32_MAX) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Specified '%s=' is too large, ignoring assignment: %s", "Specified '%s=' is too large, ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;

View File

@ -93,9 +93,11 @@ int config_parse_generic_random_early_detection_u32(
r = qdisc_new_static(QDISC_KIND_GRED, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_GRED, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
gred = GRED(qdisc); gred = GRED(qdisc);
@ -115,14 +117,14 @@ int config_parse_generic_random_early_detection_u32(
r = safe_atou32(rvalue, &v); r = safe_atou32(rvalue, &v);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
} }
if (v > MAX_DPs) { if (v > MAX_DPs) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid '%s=', ignoring assignment: %s", "Invalid '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
} }
@ -157,9 +159,11 @@ int config_parse_generic_random_early_detection_bool(
r = qdisc_new_static(QDISC_KIND_GRED, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_GRED, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
gred = GRED(qdisc); gred = GRED(qdisc);
@ -172,7 +176,7 @@ int config_parse_generic_random_early_detection_bool(
r = parse_boolean(rvalue); r = parse_boolean(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;

View File

@ -63,9 +63,11 @@ int config_parse_heavy_hitter_filter_packet_limit(
r = qdisc_new_static(QDISC_KIND_HHF, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_HHF, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
hhf = HHF(qdisc); hhf = HHF(qdisc);
@ -78,7 +80,7 @@ int config_parse_heavy_hitter_filter_packet_limit(
r = safe_atou32(rvalue, &hhf->packet_limit); r = safe_atou32(rvalue, &hhf->packet_limit);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;

View File

@ -69,9 +69,11 @@ int config_parse_hierarchy_token_bucket_default_class(
r = qdisc_new_static(QDISC_KIND_HTB, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_HTB, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
htb = HTB(qdisc); htb = HTB(qdisc);
@ -84,7 +86,7 @@ int config_parse_hierarchy_token_bucket_default_class(
r = safe_atou32_full(rvalue, 16, &htb->default_class); r = safe_atou32_full(rvalue, 16, &htb->default_class);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
@ -120,9 +122,11 @@ int config_parse_hierarchy_token_bucket_u32(
r = qdisc_new_static(QDISC_KIND_HTB, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_HTB, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
htb = HTB(qdisc); htb = HTB(qdisc);
@ -135,7 +139,7 @@ int config_parse_hierarchy_token_bucket_u32(
r = safe_atou32(rvalue, &htb->rate_to_quantum); r = safe_atou32(rvalue, &htb->rate_to_quantum);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
@ -258,9 +262,13 @@ int config_parse_hierarchy_token_bucket_class_u32(
assert(data); assert(data);
r = tclass_new_static(TCLASS_KIND_HTB, network, filename, section_line, &tclass); r = tclass_new_static(TCLASS_KIND_HTB, network, filename, section_line, &tclass);
if (r < 0) if (r == -ENOMEM)
return log_syntax(unit, LOG_ERR, filename, line, r, return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to create traffic control class, ignoring assignment: %m"); "Failed to create traffic control class, ignoring assignment: %m");
return 0;
}
htb = TCLASS_TO_HTB(tclass); htb = TCLASS_TO_HTB(tclass);
@ -272,7 +280,7 @@ int config_parse_hierarchy_token_bucket_class_u32(
r = safe_atou32(rvalue, &v); r = safe_atou32(rvalue, &v);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
@ -308,9 +316,13 @@ int config_parse_hierarchy_token_bucket_class_size(
assert(data); assert(data);
r = tclass_new_static(TCLASS_KIND_HTB, network, filename, section_line, &tclass); r = tclass_new_static(TCLASS_KIND_HTB, network, filename, section_line, &tclass);
if (r < 0) if (r == -ENOMEM)
return log_syntax(unit, LOG_ERR, filename, line, r, return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to create traffic control class, ignoring assignment: %m"); "Failed to create traffic control class, ignoring assignment: %m");
return 0;
}
htb = TCLASS_TO_HTB(tclass); htb = TCLASS_TO_HTB(tclass);
@ -334,13 +346,13 @@ int config_parse_hierarchy_token_bucket_class_size(
r = parse_size(rvalue, 1024, &v); r = parse_size(rvalue, 1024, &v);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
} }
if ((streq(lvalue, "OverheadBytes") && v > UINT16_MAX) || v > UINT32_MAX) { if ((streq(lvalue, "OverheadBytes") && v > UINT16_MAX) || v > UINT32_MAX) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid '%s=', ignoring assignment: %s", "Invalid '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
@ -388,9 +400,13 @@ int config_parse_hierarchy_token_bucket_class_rate(
assert(data); assert(data);
r = tclass_new_static(TCLASS_KIND_HTB, network, filename, section_line, &tclass); r = tclass_new_static(TCLASS_KIND_HTB, network, filename, section_line, &tclass);
if (r < 0) if (r == -ENOMEM)
return log_syntax(unit, LOG_ERR, filename, line, r, return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to create traffic control class, ignoring assignment: %m"); "Failed to create traffic control class, ignoring assignment: %m");
return 0;
}
htb = TCLASS_TO_HTB(tclass); htb = TCLASS_TO_HTB(tclass);
if (streq(lvalue, "Rate")) if (streq(lvalue, "Rate"))
@ -409,7 +425,7 @@ int config_parse_hierarchy_token_bucket_class_rate(
r = parse_size(rvalue, 1000, v); r = parse_size(rvalue, 1000, v);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;

View File

@ -80,9 +80,11 @@ int config_parse_network_emulator_delay(
r = qdisc_new_static(QDISC_KIND_NETEM, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_NETEM, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
ne = NETEM(qdisc); ne = NETEM(qdisc);
@ -98,7 +100,7 @@ int config_parse_network_emulator_delay(
r = parse_sec(rvalue, &u); r = parse_sec(rvalue, &u);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
@ -140,9 +142,11 @@ int config_parse_network_emulator_rate(
r = qdisc_new_static(QDISC_KIND_NETEM, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_NETEM, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
ne = NETEM(qdisc); ne = NETEM(qdisc);
@ -158,7 +162,7 @@ int config_parse_network_emulator_rate(
r = parse_tc_percent(rvalue, &rate); r = parse_tc_percent(rvalue, &rate);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
@ -198,9 +202,11 @@ int config_parse_network_emulator_packet_limit(
r = qdisc_new_static(QDISC_KIND_NETEM, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_NETEM, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
ne = NETEM(qdisc); ne = NETEM(qdisc);
@ -213,7 +219,7 @@ int config_parse_network_emulator_packet_limit(
r = safe_atou(rvalue, &ne->limit); r = safe_atou(rvalue, &ne->limit);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;

View File

@ -62,9 +62,11 @@ int config_parse_pie_packet_limit(
r = qdisc_new_static(QDISC_KIND_PIE, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_PIE, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
pie = PIE(qdisc); pie = PIE(qdisc);
@ -77,7 +79,7 @@ int config_parse_pie_packet_limit(
r = safe_atou32(rvalue, &pie->packet_limit); r = safe_atou32(rvalue, &pie->packet_limit);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;

View File

@ -288,8 +288,13 @@ int config_parse_qdisc_parent(
assert(data); assert(data);
r = qdisc_new_static(ltype, network, filename, section_line, &qdisc); r = qdisc_new_static(ltype, network, filename, section_line, &qdisc);
if (r < 0) if (r == -ENOMEM)
return r; return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
if (streq(rvalue, "root")) { if (streq(rvalue, "root")) {
qdisc->parent = TC_H_ROOT; qdisc->parent = TC_H_ROOT;
@ -304,7 +309,7 @@ int config_parse_qdisc_parent(
} else { } else {
r = parse_handle(rvalue, &qdisc->parent); r = parse_handle(rvalue, &qdisc->parent);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse 'Parent=', ignoring assignment: %s", "Failed to parse 'Parent=', ignoring assignment: %s",
rvalue); rvalue);
return 0; return 0;
@ -346,8 +351,13 @@ int config_parse_qdisc_handle(
assert(data); assert(data);
r = qdisc_new_static(ltype, network, filename, section_line, &qdisc); r = qdisc_new_static(ltype, network, filename, section_line, &qdisc);
if (r < 0) if (r == -ENOMEM)
return r; return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
if (isempty(rvalue)) { if (isempty(rvalue)) {
qdisc->handle = TC_H_UNSPEC; qdisc->handle = TC_H_UNSPEC;
@ -357,7 +367,7 @@ int config_parse_qdisc_handle(
r = safe_atou16_full(rvalue, 16, &n); r = safe_atou16_full(rvalue, 16, &n);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse 'Handle=', ignoring assignment: %s", "Failed to parse 'Handle=', ignoring assignment: %s",
rvalue); rvalue);
return 0; return 0;

View File

@ -73,9 +73,13 @@ int config_parse_quick_fair_queueing_weight(
assert(data); assert(data);
r = tclass_new_static(TCLASS_KIND_QFQ, network, filename, section_line, &tclass); r = tclass_new_static(TCLASS_KIND_QFQ, network, filename, section_line, &tclass);
if (r < 0) if (r == -ENOMEM)
return log_syntax(unit, LOG_ERR, filename, line, r, return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to create traffic control class, ignoring assignment: %m"); "Failed to create traffic control class, ignoring assignment: %m");
return 0;
}
qfq = TCLASS_TO_QFQ(tclass); qfq = TCLASS_TO_QFQ(tclass);
@ -87,14 +91,14 @@ int config_parse_quick_fair_queueing_weight(
r = safe_atou32(rvalue, &v); r = safe_atou32(rvalue, &v);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
} }
if (v == 0 || v > QFQ_MAX_WEIGHT) { if (v == 0 || v > QFQ_MAX_WEIGHT) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid '%s=', ignoring assignment: %s", "Invalid '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
@ -130,9 +134,13 @@ int config_parse_quick_fair_queueing_max_packet(
assert(data); assert(data);
r = tclass_new_static(TCLASS_KIND_QFQ, network, filename, section_line, &tclass); r = tclass_new_static(TCLASS_KIND_QFQ, network, filename, section_line, &tclass);
if (r < 0) if (r == -ENOMEM)
return log_syntax(unit, LOG_ERR, filename, line, r, return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to create traffic control class, ignoring assignment: %m"); "Failed to create traffic control class, ignoring assignment: %m");
return 0;
}
qfq = TCLASS_TO_QFQ(tclass); qfq = TCLASS_TO_QFQ(tclass);
@ -144,14 +152,14 @@ int config_parse_quick_fair_queueing_max_packet(
r = parse_size(rvalue, 1024, &v); r = parse_size(rvalue, 1024, &v);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
} }
if (v < QFQ_MIN_MAX_PACKET || v > QFQ_MAX_MAX_PACKET) { if (v < QFQ_MIN_MAX_PACKET || v > QFQ_MAX_MAX_PACKET) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid '%s=', ignoring assignment: %s", "Invalid '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;

View File

@ -73,9 +73,11 @@ int config_parse_stochastic_fair_blue_u32(
r = qdisc_new_static(QDISC_KIND_SFB, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_SFB, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
sfb = SFB(qdisc); sfb = SFB(qdisc);
@ -88,7 +90,7 @@ int config_parse_stochastic_fair_blue_u32(
r = safe_atou32(rvalue, &sfb->packet_limit); r = safe_atou32(rvalue, &sfb->packet_limit);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;

View File

@ -56,9 +56,11 @@ int config_parse_stochastic_fairness_queueing_perturb_period(
r = qdisc_new_static(QDISC_KIND_SFQ, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_SFQ, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
sfq = SFQ(qdisc); sfq = SFQ(qdisc);
@ -71,7 +73,7 @@ int config_parse_stochastic_fairness_queueing_perturb_period(
r = parse_sec(rvalue, &sfq->perturb_period); r = parse_sec(rvalue, &sfq->perturb_period);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;

View File

@ -136,9 +136,11 @@ int config_parse_token_bucket_filter_size(
r = qdisc_new_static(QDISC_KIND_TBF, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_TBF, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
tbf = TBF(qdisc); tbf = TBF(qdisc);
@ -160,7 +162,7 @@ int config_parse_token_bucket_filter_size(
r = parse_size(rvalue, 1024, &k); r = parse_size(rvalue, 1024, &k);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
@ -208,9 +210,11 @@ int config_parse_token_bucket_filter_rate(
r = qdisc_new_static(QDISC_KIND_TBF, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_TBF, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
tbf = TBF(qdisc); tbf = TBF(qdisc);
if (streq(lvalue, "Rate")) if (streq(lvalue, "Rate"))
@ -229,7 +233,7 @@ int config_parse_token_bucket_filter_rate(
r = parse_size(rvalue, 1000, &k); r = parse_size(rvalue, 1000, &k);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
@ -268,9 +272,11 @@ int config_parse_token_bucket_filter_latency(
r = qdisc_new_static(QDISC_KIND_TBF, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_TBF, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
tbf = TBF(qdisc); tbf = TBF(qdisc);
@ -283,7 +289,7 @@ int config_parse_token_bucket_filter_latency(
r = parse_sec(rvalue, &u); r = parse_sec(rvalue, &u);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;

View File

@ -214,15 +214,20 @@ int config_parse_tclass_parent(
assert(data); assert(data);
r = tclass_new_static(ltype, network, filename, section_line, &tclass); r = tclass_new_static(ltype, network, filename, section_line, &tclass);
if (r < 0) if (r == -ENOMEM)
return r; return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to create traffic control class, ignoring assignment: %m");
return 0;
}
if (streq(rvalue, "root")) if (streq(rvalue, "root"))
tclass->parent = TC_H_ROOT; tclass->parent = TC_H_ROOT;
else { else {
r = parse_handle(rvalue, &tclass->parent); r = parse_handle(rvalue, &tclass->parent);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse 'Parent=', ignoring assignment: %s", "Failed to parse 'Parent=', ignoring assignment: %s",
rvalue); rvalue);
return 0; return 0;
@ -256,8 +261,13 @@ int config_parse_tclass_classid(
assert(data); assert(data);
r = tclass_new_static(ltype, network, filename, section_line, &tclass); r = tclass_new_static(ltype, network, filename, section_line, &tclass);
if (r < 0) if (r == -ENOMEM)
return r; return log_oom();
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to create traffic control class, ignoring assignment: %m");
return 0;
}
if (isempty(rvalue)) { if (isempty(rvalue)) {
tclass->classid = TC_H_UNSPEC; tclass->classid = TC_H_UNSPEC;
@ -267,7 +277,7 @@ int config_parse_tclass_classid(
r = parse_handle(rvalue, &tclass->classid); r = parse_handle(rvalue, &tclass->classid);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse 'ClassId=', ignoring assignment: %s", "Failed to parse 'ClassId=', ignoring assignment: %s",
rvalue); rvalue);
return 0; return 0;

View File

@ -57,9 +57,11 @@ int config_parse_trivial_link_equalizer_id(
r = qdisc_new_static(QDISC_KIND_TEQL, network, filename, section_line, &qdisc); r = qdisc_new_static(QDISC_KIND_TEQL, network, filename, section_line, &qdisc);
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) if (r < 0) {
return log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"More than one kind of queueing discipline, ignoring assignment: %m"); "More than one kind of queueing discipline, ignoring assignment: %m");
return 0;
}
teql = TEQL(qdisc); teql = TEQL(qdisc);
@ -72,13 +74,13 @@ int config_parse_trivial_link_equalizer_id(
r = safe_atou(rvalue, &id); r = safe_atou(rvalue, &id);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse '%s=', ignoring assignment: %s", "Failed to parse '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
} }
if (id > INT_MAX) { if (id > INT_MAX) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"'%s=' is too large, ignoring assignment: %s", "'%s=' is too large, ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
} }

View File

@ -563,10 +563,14 @@ int mount_all(const char *dest,
MOUNT_FATAL|MOUNT_MKDIR }, MOUNT_FATAL|MOUNT_MKDIR },
{ "tmpfs", "/run", "tmpfs", "mode=755" TMPFS_LIMITS_RUN, MS_NOSUID|MS_NODEV|MS_STRICTATIME, { "tmpfs", "/run", "tmpfs", "mode=755" TMPFS_LIMITS_RUN, MS_NOSUID|MS_NODEV|MS_STRICTATIME,
MOUNT_FATAL|MOUNT_MKDIR }, MOUNT_FATAL|MOUNT_MKDIR },
{ "/usr/lib/os-release", "/run/host/usr/lib/os-release", NULL, NULL, MS_BIND|MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV, { "/usr/lib/os-release", "/run/host/usr/lib/os-release", NULL, NULL, MS_BIND,
MOUNT_FATAL|MOUNT_MKDIR|MOUNT_TOUCH }, MOUNT_FATAL|MOUNT_MKDIR|MOUNT_TOUCH }, /* As per kernel interface requirements, bind mount first (creating mount points) and make read-only later */
{ "/etc/os-release", "/run/host/etc/os-release", NULL, NULL, MS_BIND|MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV, { NULL, "/run/host/usr/lib/os-release", NULL, NULL, MS_BIND|MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_REMOUNT,
0 },
{ "/etc/os-release", "/run/host/etc/os-release", NULL, NULL, MS_BIND,
MOUNT_MKDIR|MOUNT_TOUCH }, MOUNT_MKDIR|MOUNT_TOUCH },
{ NULL, "/run/host/etc/os-release", NULL, NULL, MS_BIND|MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_REMOUNT,
0 },
#if HAVE_SELINUX #if HAVE_SELINUX
{ "/sys/fs/selinux", "/sys/fs/selinux", NULL, NULL, MS_BIND, { "/sys/fs/selinux", "/sys/fs/selinux", NULL, NULL, MS_BIND,
@ -587,7 +591,6 @@ int mount_all(const char *dest,
for (k = 0; k < ELEMENTSOF(mount_table); k++) { for (k = 0; k < ELEMENTSOF(mount_table); k++) {
_cleanup_free_ char *where = NULL, *options = NULL; _cleanup_free_ char *where = NULL, *options = NULL;
const char *o; const char *o;
struct stat source_st;
bool fatal = FLAGS_SET(mount_table[k].mount_settings, MOUNT_FATAL); bool fatal = FLAGS_SET(mount_table[k].mount_settings, MOUNT_FATAL);
if (in_userns != FLAGS_SET(mount_table[k].mount_settings, MOUNT_IN_USERNS)) if (in_userns != FLAGS_SET(mount_table[k].mount_settings, MOUNT_IN_USERNS))
@ -617,7 +620,7 @@ int mount_all(const char *dest,
/* Shortcut for optional bind mounts: if the source can't be found skip ahead to avoid creating /* Shortcut for optional bind mounts: if the source can't be found skip ahead to avoid creating
* empty and unused directories. */ * empty and unused directories. */
if (!fatal && FLAGS_SET(mount_table[k].mount_settings, MOUNT_MKDIR) && FLAGS_SET(mount_table[k].flags, MS_BIND)) { if (!fatal && FLAGS_SET(mount_table[k].mount_settings, MOUNT_MKDIR) && FLAGS_SET(mount_table[k].flags, MS_BIND)) {
r = stat(mount_table[k].what, &source_st); r = access(mount_table[k].what, F_OK);
if (r < 0) { if (r < 0) {
if (errno == ENOENT) if (errno == ENOENT)
continue; continue;

View File

@ -548,7 +548,7 @@ int config_parse_iec_size(const char* unit,
if (r >= 0 && (uint64_t) (size_t) v != v) if (r >= 0 && (uint64_t) (size_t) v != v)
r = -ERANGE; r = -ERANGE;
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse size value '%s', ignoring: %m", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse size value '%s', ignoring: %m", rvalue);
return 0; return 0;
} }
@ -577,10 +577,8 @@ int config_parse_si_uint64(
assert(data); assert(data);
r = parse_size(rvalue, 1000, sz); r = parse_size(rvalue, 1000, sz);
if (r < 0) { if (r < 0)
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse size value '%s', ignoring: %m", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse size value '%s', ignoring: %m", rvalue);
return 0;
}
return 0; return 0;
} }
@ -607,7 +605,7 @@ int config_parse_iec_uint64(
r = parse_size(rvalue, 1024, bytes); r = parse_size(rvalue, 1024, bytes);
if (r < 0) if (r < 0)
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse size value, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse size value, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -634,7 +632,7 @@ int config_parse_bool(const char* unit,
k = parse_boolean(rvalue); k = parse_boolean(rvalue);
if (k < 0) { if (k < 0) {
log_syntax(unit, LOG_ERR, filename, line, k, log_syntax(unit, fatal ? LOG_ERR : LOG_WARNING, filename, line, k,
"Failed to parse boolean value%s: %s", "Failed to parse boolean value%s: %s",
fatal ? "" : ", ignoring", rvalue); fatal ? "" : ", ignoring", rvalue);
return fatal ? -ENOEXEC : 0; return fatal ? -ENOEXEC : 0;
@ -664,10 +662,15 @@ int config_parse_id128(
assert(rvalue); assert(rvalue);
r = sd_id128_from_string(rvalue, &t); r = sd_id128_from_string(rvalue, &t);
if (r < 0) if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse 128bit ID/UUID, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse 128bit ID/UUID, ignoring: %s", rvalue);
else if (sd_id128_is_null(t)) return 0;
log_syntax(unit, LOG_ERR, filename, line, 0, "128bit ID/UUID is all 0, ignoring: %s", rvalue); }
if (sd_id128_is_null(t)) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "128bit ID/UUID is all 0, ignoring: %s", rvalue);
return 0;
}
*result = t; *result = t;
return 0; return 0;
@ -698,7 +701,7 @@ int config_parse_tristate(
k = parse_boolean(rvalue); k = parse_boolean(rvalue);
if (k < 0) { if (k < 0) {
log_syntax(unit, LOG_ERR, filename, line, k, "Failed to parse boolean value, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, k, "Failed to parse boolean value, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -793,25 +796,23 @@ int config_parse_strv(
return 0; return 0;
} }
for (;;) { for (const char *p = rvalue;;) {
char *word = NULL; char *word = NULL;
r = extract_first_word(&rvalue, &word, NULL, EXTRACT_UNQUOTE|EXTRACT_RETAIN_ESCAPE); r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE|EXTRACT_RETAIN_ESCAPE);
if (r == 0) if (r == 0)
break; return 0;
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Invalid syntax, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid syntax, ignoring: %s", rvalue);
break; return 0;
} }
r = strv_consume(sv, word); r = strv_consume(sv, word);
if (r < 0) if (r < 0)
return log_oom(); return log_oom();
} }
return 0;
} }
int config_parse_warn_compat( int config_parse_warn_compat(
@ -870,7 +871,7 @@ int config_parse_log_facility(
x = log_facility_unshifted_from_string(rvalue); x = log_facility_unshifted_from_string(rvalue);
if (x < 0) { if (x < 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse log facility, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse log facility, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -900,7 +901,7 @@ int config_parse_log_level(
x = log_level_from_string(rvalue); x = log_level_from_string(rvalue);
if (x < 0) { if (x < 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse log level, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse log level, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -933,7 +934,7 @@ int config_parse_signal(
r = signal_from_string(rvalue); r = signal_from_string(rvalue);
if (r <= 0) { if (r <= 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse signal name, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse signal name, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -965,7 +966,7 @@ int config_parse_personality(
else { else {
p = personality_from_string(rvalue); p = personality_from_string(rvalue);
if (p == PERSONALITY_INVALID) { if (p == PERSONALITY_INVALID) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse personality, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse personality, ignoring: %s", rvalue);
return 0; return 0;
} }
} }
@ -1000,7 +1001,7 @@ int config_parse_ifname(
} }
if (!ifname_valid(rvalue)) { if (!ifname_valid(rvalue)) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Interface name is not valid or too long, ignoring assignment: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, 0, "Interface name is not valid or too long, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -1025,7 +1026,6 @@ int config_parse_ifnames(
_cleanup_strv_free_ char **names = NULL; _cleanup_strv_free_ char **names = NULL;
char ***s = data; char ***s = data;
const char *p;
int r; int r;
assert(filename); assert(filename);
@ -1038,13 +1038,14 @@ int config_parse_ifnames(
return 0; return 0;
} }
p = rvalue; for (const char *p = rvalue;;) {
for (;;) {
_cleanup_free_ char *word = NULL; _cleanup_free_ char *word = NULL;
r = extract_first_word(&p, &word, NULL, 0); r = extract_first_word(&p, &word, NULL, 0);
if (r == -ENOMEM)
return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to extract interface name, ignoring assignment: %s", "Failed to extract interface name, ignoring assignment: %s",
rvalue); rvalue);
return 0; return 0;
@ -1053,7 +1054,7 @@ int config_parse_ifnames(
break; break;
if (!ifname_valid_full(word, ltype)) { if (!ifname_valid_full(word, ltype)) {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Interface name is not valid or too long, ignoring assignment: %s", "Interface name is not valid or too long, ignoring assignment: %s",
word); word);
continue; continue;
@ -1099,7 +1100,7 @@ int config_parse_ip_port(
r = parse_ip_port(rvalue, &port); r = parse_ip_port(rvalue, &port);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse port '%s'.", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse port '%s'.", rvalue);
return 0; return 0;
} }
@ -1128,14 +1129,14 @@ int config_parse_mtu(
r = parse_mtu(ltype, rvalue, mtu); r = parse_mtu(ltype, rvalue, mtu);
if (r == -ERANGE) { if (r == -ERANGE) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Maximum transfer unit (MTU) value out of range. Permitted range is %" PRIu32 "…%" PRIu32 ", ignoring: %s", "Maximum transfer unit (MTU) value out of range. Permitted range is %" PRIu32 "…%" PRIu32 ", ignoring: %s",
(uint32_t) (ltype == AF_INET6 ? IPV6_MIN_MTU : IPV4_MIN_MTU), (uint32_t) UINT32_MAX, (uint32_t) (ltype == AF_INET6 ? IPV6_MIN_MTU : IPV4_MIN_MTU), (uint32_t) UINT32_MAX,
rvalue); rvalue);
return 0; return 0;
} }
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse MTU value '%s', ignoring: %m", rvalue); "Failed to parse MTU value '%s', ignoring: %m", rvalue);
return 0; return 0;
} }
@ -1167,7 +1168,7 @@ int config_parse_rlimit(
return 0; return 0;
} }
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse resource value, ignoring: %s", rvalue); log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse resource value, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -1203,7 +1204,7 @@ int config_parse_permille(const char* unit,
r = parse_permille(rvalue); r = parse_permille(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse permille value, ignoring: %s", rvalue); "Failed to parse permille value, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -1237,7 +1238,7 @@ int config_parse_vlanprotocol(const char* unit,
else if (STR_IN_SET(rvalue, "802.1q", "802.1Q")) else if (STR_IN_SET(rvalue, "802.1q", "802.1Q"))
*vlan_protocol = ETH_P_8021Q; *vlan_protocol = ETH_P_8021Q;
else { else {
log_syntax(unit, LOG_ERR, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Failed to parse VLAN protocol value, ignoring: %s", rvalue); "Failed to parse VLAN protocol value, ignoring: %s", rvalue);
return 0; return 0;
} }

View File

@ -165,7 +165,7 @@ typedef enum Disabled {
\ \
r = parser(rvalue); \ r = parser(rvalue); \
if (r < 0) { \ if (r < 0) { \
log_syntax(unit, LOG_ERR, filename, line, r, \ log_syntax(unit, LOG_WARNING, filename, line, r, \
msg ", ignoring: %s", rvalue); \ msg ", ignoring: %s", rvalue); \
return 0; \ return 0; \
} \ } \
@ -186,7 +186,7 @@ typedef enum Disabled {
\ \
r = parser(rvalue, i); \ r = parser(rvalue, i); \
if (r < 0) \ if (r < 0) \
log_syntax(unit, LOG_ERR, filename, line, r, \ log_syntax(unit, LOG_WARNING, filename, line, r, \
msg ", ignoring: %s", rvalue); \ msg ", ignoring: %s", rvalue); \
\ \
return 0; \ return 0; \
@ -203,7 +203,7 @@ typedef enum Disabled {
\ \
x = name##_from_string(rvalue); \ x = name##_from_string(rvalue); \
if (x < 0) { \ if (x < 0) { \
log_syntax(unit, LOG_ERR, filename, line, 0, \ log_syntax(unit, LOG_WARNING, filename, line, 0, \
msg ", ignoring: %s", rvalue); \ msg ", ignoring: %s", rvalue); \
return 0; \ return 0; \
} \ } \
@ -228,7 +228,7 @@ typedef enum Disabled {
\ \
x = name##_from_string(rvalue); \ x = name##_from_string(rvalue); \
if (x < 0) { \ if (x < 0) { \
log_syntax(unit, LOG_ERR, filename, line, 0, \ log_syntax(unit, LOG_WARNING, filename, line, 0, \
msg ", ignoring: %s", rvalue); \ msg ", ignoring: %s", rvalue); \
return 0; \ return 0; \
} \ } \
@ -261,10 +261,10 @@ typedef enum Disabled {
\ \
en = strndup(word, l); \ en = strndup(word, l); \
if (!en) \ if (!en) \
return -ENOMEM; \ return log_oom(); \
\ \
if ((x = name##_from_string(en)) < 0) { \ if ((x = name##_from_string(en)) < 0) { \
log_syntax(unit, LOG_ERR, filename, line, 0, \ log_syntax(unit, LOG_WARNING, filename, line, 0, \
msg ", ignoring: %s", en); \ msg ", ignoring: %s", en); \
continue; \ continue; \
} \ } \
@ -287,7 +287,7 @@ typedef enum Disabled {
if (new_xs) \ if (new_xs) \
xs = new_xs; \ xs = new_xs; \
else \ else \
return -ENOMEM; \ return log_oom(); \
\ \
*(xs + i) = invalid; \ *(xs + i) = invalid; \
} \ } \

View File

@ -130,7 +130,7 @@ int load_os_release_pairs_with_prefix(const char *root, const char *prefix, char
STRV_FOREACH_PAIR(p, q, os_release_pairs) { STRV_FOREACH_PAIR(p, q, os_release_pairs) {
char *line; char *line;
// We strictly return only the four main ID fields and ignore the rest /* We strictly return only the four main ID fields and ignore the rest */
if (!STR_IN_SET(*p, "ID", "VERSION_ID", "BUILD_ID", "VARIANT_ID")) if (!STR_IN_SET(*p, "ID", "VERSION_ID", "BUILD_ID", "VARIANT_ID"))
continue; continue;

View File

@ -67,6 +67,8 @@ if [ -n "${VERSION_ID:+set}" ] && [ "${VERSION_ID}" != "${container_host_version
if [ -n "${BUILD_ID:+set}" ] && [ "${BUILD_ID}" != "${container_host_build_id}" ]; then exit 1; fi if [ -n "${BUILD_ID:+set}" ] && [ "${BUILD_ID}" != "${container_host_build_id}" ]; then exit 1; fi
if [ -n "${VARIANT_ID:+set}" ] && [ "${VARIANT_ID}" != "${container_host_variant_id}" ]; then exit 1; fi if [ -n "${VARIANT_ID:+set}" ] && [ "${VARIANT_ID}" != "${container_host_variant_id}" ]; then exit 1; fi
cd /tmp; (cd /run/host/usr/lib; md5sum os-release) | md5sum -c cd /tmp; (cd /run/host/usr/lib; md5sum os-release) | md5sum -c
if echo test >> /run/host/usr/lib/os-release; then exit 1; fi
if echo test >> /run/host/etc/os-release; then exit 1; fi
' '
systemd-nspawn --register=no -D /testsuite-13.nc-container --bind=/etc/os-release:/tmp/os-release /bin/sh -x -e -c "$_cmd" systemd-nspawn --register=no -D /testsuite-13.nc-container --bind=/etc/os-release:/tmp/os-release /bin/sh -x -e -c "$_cmd"