Compare commits

..

No commits in common. "d96edb2c6e7014e93e6713c79a698c91463c8929" and "3cd44590032e04cd903db1d6f15afbedc1d47104" have entirely different histories.

65 changed files with 818 additions and 961 deletions

View File

@ -22,7 +22,7 @@
<refnamediv> <refnamediv>
<refname>environment.d</refname> <refname>environment.d</refname>
<refpurpose>Definition of user service environment</refpurpose> <refpurpose>Definition of user session environment</refpurpose>
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
@ -36,8 +36,8 @@
<refsect1> <refsect1>
<title>Description</title> <title>Description</title>
<para>Configuration files in the <filename>environment.d/</filename> directories contain lists of <para>The <filename>environment.d</filename> directories contain a list of environment variable
environment variable assignments for services started by the systemd user instance. 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,6 +58,7 @@
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>,
@ -94,7 +95,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_is_valid(uid) && !gid_is_valid(gid) && flags == 0) { if (uid == UID_INVALID && gid == UID_INVALID && 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_is_valid(uid) && !gid_is_valid(gid) && flags == 0) { if (uid == UID_INVALID && gid == UID_INVALID && 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->var_tmp_dir) else if (runtime->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 (!machine) if (!mn)
return -ESRCH; return -ESRCH;
if (machine->class != MACHINE_CONTAINER) if (machine->class != MACHINE_CONTAINER)

View File

@ -320,15 +320,13 @@ int config_parse_arp_ip_target_address(
return 0; return 0;
} }
for (const char *p = rvalue;;) { for (;;) {
_cleanup_free_ char *n = NULL; _cleanup_free_ char *n = NULL;
union in_addr_union ip; union in_addr_union ip;
r = extract_first_word(&p, &n, NULL, 0); r = extract_first_word(&rvalue, &n, NULL, 0);
if (r == -ENOMEM)
return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
@ -338,7 +336,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
} }
@ -359,7 +357,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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);
} }
} }
@ -386,13 +384,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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;
@ -425,13 +423,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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;
} }
@ -463,13 +461,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, "Failed to parse Geneve VNI '%s'.", rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, "Geneve VNI out is of range '%s'.", rvalue); log_syntax(unit, LOG_ERR, filename, line, r, "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_WARNING, filename, line, r, "geneve '%s' address is invalid, ignoring assignment: %s", lvalue, rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, "geneve invalid multicast '%s' address, ignoring assignment: %s", lvalue, rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, "Failed to parse Geneve flow label '%s'.", rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, filename, line, r,
"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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, filename, line, r,
"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 log_oom(); return r;
r = safe_atou32(rvalue, &k); r = safe_atou32(rvalue, &k);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, filename, line, r,
"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 log_oom(); return r;
spec = l2tp_l2spec_type_from_string(rvalue); spec = l2tp_l2spec_type_from_string(rvalue);
if (spec < 0) { if (spec < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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 log_oom(); return r;
if (!ifname_valid(rvalue)) { if (!ifname_valid(rvalue)) {
log_syntax(unit, LOG_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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 log_oom(); return r;
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 log_oom(); return r;
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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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 log_oom(); return r;
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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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 log_oom(); return r;
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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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 log_oom(); return r;
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_WARNING, filename, line, r, "Failed to parse key. Ignoring assignment: %m"); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, "Invalid key length (%zu). Ignoring assignment", l); log_syntax(unit, LOG_ERR, 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 log_oom(); return r;
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 log_oom(); return r;
r = unhexmem(rvalue, strlen(rvalue), &p, &l); r = unhexmem(rvalue, strlen(rvalue), &p, &l);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse KeyId \"%s\": %m", rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, return log_syntax(unit, LOG_ERR, 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 log_oom(); return r;
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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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,20 +945,18 @@ 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 log_oom(); return r;
if (isempty(rvalue)) { if (isempty(rvalue))
a->sa.use_for_encoding = -1; r = -1;
TAKE_PTR(a); else {
return 0; r = parse_boolean(rvalue);
} if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
r = parse_boolean(rvalue); "Failed to parse %s= setting. Ignoring assignment: %s",
if (r < 0) { lvalue, rvalue);
log_syntax(unit, LOG_WARNING, filename, line, r, return 0;
"Failed to parse %s= setting. Ignoring assignment: %s", }
lvalue, rvalue);
return 0;
} }
a->sa.use_for_encoding = r; a->sa.use_for_encoding = r;

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_WARNING, filename, line, 0, "Failed to parse netdev kind, ignoring assignment: %s", rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, "Failed to parse tunnel key ignoring assignment: %s", rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, "Failed to parse IPv6 flowlabel option, ignoring: %s", rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, "Failed to parse Tunnel Encapsulation Limit option, ignoring: %s", rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, "Invalid Tunnel Encapsulation value, ignoring: %d", k); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, "Failed to parse 6rd prefix \"%s\", ignoring: %m", rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, "6rd prefix length of \"%s\" must be greater than zero, ignoring", rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, "vxlan '%s' address is invalid, ignoring assignment: %s", lvalue, rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, "vxlan %s invalid multicast address, ignoring assignment: %s", lvalue, rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, "vxlan %s cannot be a multicast address, ignoring assignment: %s", lvalue, rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, "Failed to parse VXLAN flow label '%s'.", rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, SYNTHETIC_ERRNO(EINVAL), return log_syntax(unit, LOG_ERR, filename, line, 0,
"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,10 +583,9 @@ 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 log_oom(); return r;
(void) wireguard_decode_key_and_warn(rvalue, peer->preshared_key, unit, filename, line, lvalue); return 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(
@ -612,7 +611,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 log_oom(); return r;
if (isempty(rvalue)) { if (isempty(rvalue)) {
peer->preshared_key_file = mfree(peer->preshared_key_file); peer->preshared_key_file = mfree(peer->preshared_key_file);
@ -654,11 +653,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 log_oom(); return r;
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 0; return r;
TAKE_PTR(peer); TAKE_PTR(peer);
return 0; return 0;
@ -691,25 +690,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 log_oom(); return r;
for (const char *p = rvalue;;) { for (;;) {
_cleanup_free_ char *word = NULL; _cleanup_free_ char *word = NULL;
r = extract_first_word(&p, &word, "," WHITESPACE, 0); r = extract_first_word(&rvalue, &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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, filename, line, r,
"Network address is invalid, ignoring assignment: %s", word); "Network address is invalid, ignoring assignment: %s", word);
continue; continue;
} }
@ -759,7 +758,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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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;
@ -767,7 +766,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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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;
@ -777,7 +776,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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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;
@ -788,7 +787,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 log_oom(); return r;
r = free_and_strndup(&peer->endpoint_host, begin, len); r = free_and_strndup(&peer->endpoint_host, begin, len);
if (r < 0) if (r < 0)
@ -831,14 +830,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 log_oom(); return r;
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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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 log_oom(); return r;
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_WARNING, filename, line, r, "Address label is invalid, ignoring assignment: %s", rvalue); log_syntax(unit, LOG_ERR, 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 log_oom(); return r;
r = safe_atou32(rvalue, &k); r = safe_atou32(rvalue, &k);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse address label, ignoring: %s", rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, "Address label is invalid, ignoring: %s", rvalue); log_syntax(unit, LOG_ERR, filename, line, r, "Address label is invalid, ignoring: %s", rvalue);
return 0; return 0;
} }

View File

@ -790,23 +790,18 @@ 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 == -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;
}
if (n->family == AF_INET6) { if (n->family == AF_INET6) {
log_syntax(unit, LOG_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, filename, line, r,
"Broadcast is invalid, ignoring assignment: %s", rvalue); "Broadcast is invalid, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -846,18 +841,14 @@ 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)
return log_oom(); if (r < 0)
if (r < 0) { return r;
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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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);
@ -865,12 +856,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_WARNING, filename, line, r, "Invalid address '%s', ignoring assignment: %m", rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, "Address is incompatible, ignoring assignment: %s", rvalue); log_syntax(unit, LOG_ERR, filename, line, 0, "Address is incompatible, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -880,7 +871,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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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;
@ -926,16 +917,11 @@ 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 == -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;
}
if (!address_label_valid(rvalue)) { if (!address_label_valid(rvalue)) {
log_syntax(unit, LOG_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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;
} }
@ -970,13 +956,8 @@ 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 == -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;
}
/* 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", ""))
@ -984,7 +965,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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, filename, line, 0,
"Invalid PreferredLifetime= value, ignoring: %s", rvalue); "Invalid PreferredLifetime= value, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -1016,17 +997,12 @@ 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 == -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;
}
r = parse_boolean(rvalue); r = parse_boolean(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, filename, line, r,
"Failed to parse %s=, ignoring: %s", lvalue, rvalue); "Failed to parse %s=, ignoring: %s", lvalue, rvalue);
return 0; return 0;
} }
@ -1069,13 +1045,8 @@ 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 == -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;
}
if (streq(rvalue, "host")) if (streq(rvalue, "host"))
n->scope = RT_SCOPE_HOST; n->scope = RT_SCOPE_HOST;
@ -1086,7 +1057,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
} }
@ -1120,13 +1091,8 @@ 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 == -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;
}
r = parse_boolean(rvalue); r = parse_boolean(rvalue);
if (r >= 0) { if (r >= 0) {
@ -1141,7 +1107,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_WARNING, filename, line, SYNTHETIC_ERRNO(EINVAL), log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, "Failed to parse VLAN, ignoring: %s", rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, "Could not parse VLAN: %s", rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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,29 +144,26 @@ 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 (const char *p = rvalue;;) { for (;;) {
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(&p, &cbyte, ":", 0); r = extract_first_word(&rvalue, &cbyte, ":", 0);
if (r == -ENOMEM)
return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to read DUID, ignoring assignment: %s.", rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, "Max DUID length exceeded, ignoring assignment: %s.", rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, "Invalid length - DUID byte: %s, ignoring assignment: %s.", cbyte, rvalue); log_syntax(unit, LOG_ERR, 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]);
@ -176,7 +173,7 @@ int config_parse_duid_rawdata(
n2 = 0; n2 = 0;
if (n1 < 0 || n2 < 0) { if (n1 < 0 || n2 < 0) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid DUID byte: %s. Ignoring assignment: %s.", cbyte, rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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 (const char *p = rvalue;;) { for (;;) {
_cleanup_free_ char *w = NULL; _cleanup_free_ char *w = NULL;
r = extract_first_word(&p, &w, NULL, EXTRACT_CUNESCAPE|EXTRACT_UNQUOTE); r = extract_first_word(&rvalue, &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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, filename, line, r,
"Failed to split user classes option, ignoring: %s", rvalue); "Failed to split user classes option, ignoring: %s", rvalue);
return 0; break;
} }
if (r == 0) if (r == 0)
return 0; break;
if (ltype == AF_INET) { if (ltype == AF_INET) {
if (strlen(w) > UINT8_MAX) { if (strlen(w) > UINT8_MAX) {
log_syntax(unit, LOG_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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,6 +321,8 @@ int config_parse_dhcp_user_class(
w = NULL; w = NULL;
} }
return 0;
} }
int config_parse_dhcp_vendor_class( int config_parse_dhcp_vendor_class(
@ -346,22 +348,22 @@ int config_parse_dhcp_vendor_class(
return 0; return 0;
} }
for (const char *p = rvalue;;) { for (;;) {
_cleanup_free_ char *w = NULL; _cleanup_free_ char *w = NULL;
r = extract_first_word(&p, &w, NULL, EXTRACT_CUNESCAPE|EXTRACT_UNQUOTE); r = extract_first_word(&rvalue, &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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, filename, line, r,
"Failed to split vendor classes option, ignoring: %s", rvalue); "Failed to split vendor classes option, ignoring: %s", rvalue);
return 0; break;
} }
if (r == 0) if (r == 0)
return 0; break;
if (strlen(w) > UINT8_MAX) { if (strlen(w) > UINT8_MAX) {
log_syntax(unit, LOG_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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;
} }
@ -372,6 +374,8 @@ int config_parse_dhcp_vendor_class(
w = NULL; w = NULL;
} }
return 0;
} }
int config_parse_dhcp_send_option( int config_parse_dhcp_send_option(
@ -416,14 +420,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
} }
@ -434,7 +438,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, filename, line, r,
"Invalid DHCP option, ignoring assignment: %s", rvalue); "Invalid DHCP option, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -442,24 +446,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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;
} }
@ -470,14 +474,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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;
} }
@ -486,7 +490,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
} }
@ -498,7 +502,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
} }
@ -510,7 +514,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
} }
@ -523,7 +527,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
} }
@ -535,7 +539,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
} }
@ -547,7 +551,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_WARNING, filename, line, sz, log_syntax(unit, LOG_ERR, filename, line, sz,
"Failed to decode DHCP option data, ignoring assignment: %s", p); "Failed to decode DHCP option data, ignoring assignment: %s", p);
} }
@ -560,7 +564,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
} }
@ -573,7 +577,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
} }
@ -581,7 +585,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
} }
@ -594,7 +598,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
} }
@ -638,10 +642,8 @@ 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
@ -651,13 +653,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, filename, line, r,
"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;
} }
@ -665,9 +667,11 @@ 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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);
static void dhcp4_release_old_lease(Link *link) { void dhcp4_release_old_lease(Link *link) {
struct in_addr address = {}, address_old = {}; struct in_addr address = {}, address_old = {};
assert(link); assert(link);
@ -52,16 +52,12 @@ static void dhcp4_release_old_lease(Link *link) {
} }
static void dhcp4_check_ready(Link *link) { static void dhcp4_check_ready(Link *link) {
if (link->network->dhcp_send_decline && !link->dhcp4_address_bind) if (link->dhcp4_messages == 0) {
return; link->dhcp4_configured = true;
/* New address and routes are configured now. Let's release old lease. */
if (link->dhcp4_messages > 0) dhcp4_release_old_lease(link);
return; link_check_ready(link);
}
link->dhcp4_configured = true;
/* New address and routes are configured now. Let's release old lease. */
dhcp4_release_old_lease(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) {
@ -90,18 +86,20 @@ static int dhcp4_route_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *li
return 1; return 1;
} }
if (link->dhcp4_messages == 0 && link->dhcp4_route_failed) { if (link->dhcp4_messages == 0) {
link->dhcp4_route_failed = false; if (link->dhcp4_route_failed) {
link->dhcp4_route_retrying = true; link->dhcp4_route_failed = false;
link->dhcp4_route_retrying = true;
r = dhcp4_remove_all(link); r = dhcp4_remove_all(link);
if (r < 0) if (r < 0)
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;
} }
@ -795,9 +793,6 @@ 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;
@ -838,7 +833,6 @@ 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;
@ -847,9 +841,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_warning(link, "DAD conflict. Dropping DHCP4 address %s", strna(pretty)); log_link_warning(link, "DAD conflict. Dropping DHCP4 address %s", strna(pretty));
r = sd_dhcp_client_send_decline(link->dhcp_client); (void) 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);
@ -891,44 +883,6 @@ 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;
@ -958,14 +912,31 @@ static int dhcp4_address_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *
return 1; return 1;
} }
r = dhcp4_start_acd(link); if (link->network->dhcp_send_decline) {
if (r < 0) { union in_addr_union addr;
log_link_error_errno(link, r, "Failed to start IPv4ACD for DHCP4 adddress: %m");
link_enter_failed(link);
return 1;
}
dhcp4_check_ready(link); (void) sd_dhcp_lease_get_address(link->dhcp_lease, &addr.in);
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);
return 1; return 1;
} }
@ -1265,11 +1236,8 @@ 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)
r = sd_dhcp_client_send_release(client); (void) 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) {
@ -1591,6 +1559,7 @@ 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);
} }
@ -1700,13 +1669,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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;
} }
@ -1749,10 +1718,8 @@ 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
@ -1762,16 +1729,18 @@ 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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(
@ -1828,13 +1797,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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;
@ -1871,7 +1840,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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, filename, line, 0,
"Invalid LeaseLifetime= value, ignoring: %s", rvalue); "Invalid LeaseLifetime= value, ignoring: %s", rvalue);
return 0; return 0;
} }

View File

@ -17,6 +17,7 @@ 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_WARNING, filename, line, r, "Failed to parse PrefixDelegationHint=%s, ignoring assignment", rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, "Invalid prefix length='%d', ignoring assignment", network->dhcp6_pd_length); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, "Not a valid MAC address, ignoring assignment: %s", rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, SYNTHETIC_ERRNO(EINVAL), log_syntax(unit, LOG_ERR, filename, line, 0,
"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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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,18 +113,17 @@ 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 log_oom(); return r;
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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse IPv6 proxy NDP address, ignoring: %s",
"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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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,6 +800,8 @@ 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,7 +108,6 @@ 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_WARNING, filename, line, 0, "Failed to parse LLDP emission setting, ignoring: %s", rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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,10 +969,8 @@ 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
@ -982,7 +980,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
} }
@ -998,6 +996,8 @@ 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, filename, line, r,
"Failed to store IPv6 token '%s'", rvalue); "Failed to store IPv6 token '%s'", rvalue);
return 0; return 0;
} }

View File

@ -399,12 +399,11 @@ 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 log_oom(); return r;
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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, filename, line, r, "Neighbor Address is invalid, ignoring assignment: %s", rvalue);
"Neighbor Address is invalid, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -437,7 +436,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 log_oom(); return r;
r = ether_addr_from_string(rvalue, &n->lladdr.mac); r = ether_addr_from_string(rvalue, &n->lladdr.mac);
if (r >= 0) if (r >= 0)
@ -445,7 +444,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, filename, line, r,
"Neighbor LinkLayerAddress= is invalid, ignoring assignment: %s", "Neighbor LinkLayerAddress= is invalid, ignoring assignment: %s",
rvalue); rvalue);
return 0; return 0;
@ -482,11 +481,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 log_oom(); return r;
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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_route_boolean, 0, 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.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_route_boolean, 0, 0 Route.QuickAck, config_parse_quickack, 0, 0
Route.FastOpenNoCookie, config_parse_route_boolean, 0, 0 Route.FastOpenNoCookie, config_parse_fast_open_no_cookie, 0, 0
Route.TTLPropagate, config_parse_route_boolean, 0, 0 Route.TTLPropagate, config_parse_route_ttl_propagate, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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,6 +940,7 @@ 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;
@ -953,21 +954,20 @@ int config_parse_domains(
return 0; return 0;
} }
for (const char *p = rvalue;;) { 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, filename, line, r,
"Failed to extract search or route domain, ignoring: %s", rvalue); "Failed to extract search or route domain, ignoring: %s", rvalue);
return 0; break;
} }
if (r == 0) if (r == 0)
return 0; break;
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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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,12 +999,14 @@ 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 log_oom(); return r;
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(
@ -1030,19 +1032,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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;
} }
@ -1085,7 +1087,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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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;
} }
@ -1121,19 +1123,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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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;
} }
@ -1165,8 +1167,8 @@ int config_parse_timezone(
if (r < 0) if (r < 0)
return r; return r;
if (!timezone_is_valid(tz, LOG_WARNING)) { if (!timezone_is_valid(tz, LOG_ERR)) {
log_syntax(unit, LOG_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, filename, line, 0,
"Timezone is not valid, ignoring assignment: %s", rvalue); "Timezone is not valid, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -1193,32 +1195,26 @@ int config_parse_dns(
assert(lvalue); assert(lvalue);
assert(rvalue); assert(rvalue);
if (isempty(rvalue)) { for (;;) {
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(&p, &w, NULL, 0); r = extract_first_word(&rvalue, &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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, filename, line, r,
"Invalid syntax, ignoring: %s", rvalue); "Invalid syntax, ignoring: %s", rvalue);
return 0; break;
} }
if (r == 0) if (r == 0)
return 0; break;
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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, filename, line, r,
"Failed to parse dns server address, ignoring: %s", w); "Failed to parse dns server address, ignoring: %s", w);
continue; continue;
} }
@ -1234,6 +1230,8 @@ 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(
@ -1248,6 +1246,7 @@ 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;
@ -1260,23 +1259,21 @@ int config_parse_dnssec_negative_trust_anchors(
return 0; return 0;
} }
for (const char *p = rvalue;;) { for (;;) {
_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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, filename, line, r,
"Failed to extract negative trust anchor domain, ignoring: %s", rvalue); "Failed to extract negative trust anchor domain, ignoring: %s", rvalue);
return 0; break;
} }
if (r == 0) if (r == 0)
return 0; break;
r = dns_name_is_valid(w); r = dns_name_is_valid(w);
if (r <= 0) { if (r <= 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, filename, line, r,
"%s is not a valid domain name, ignoring.", w); "%s is not a valid domain name, ignoring.", w);
continue; continue;
} }
@ -1285,6 +1282,8 @@ 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(
@ -1311,23 +1310,23 @@ int config_parse_ntp(
return 0; return 0;
} }
for (const char *p = rvalue;;) { for (;;) {
_cleanup_free_ char *w = NULL; _cleanup_free_ char *w = NULL;
r = extract_first_word(&p, &w, NULL, 0); r = extract_first_word(&rvalue, &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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, filename, line, r,
"Failed to extract NTP server name, ignoring: %s", rvalue); "Failed to extract NTP server name, ignoring: %s", rvalue);
return 0; break;
} }
if (r == 0) if (r == 0)
return 0; break;
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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
} }
@ -1336,13 +1335,15 @@ 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);
return 0; break;
} }
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(
@ -1372,7 +1373,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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 log_oom(); return r;
r = safe_atou32(rvalue, &n->id); r = safe_atou32(rvalue, &n->id);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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 log_oom(); return r;
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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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 log_oom(); return r;
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_WARNING, filename, line, r, "Prefix is invalid, ignoring assignment: %s", rvalue); log_syntax(unit, LOG_ERR, 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 log_oom(); return r;
r = parse_boolean(rvalue); r = parse_boolean(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse address flag, ignoring: %s", rvalue); log_syntax(unit, LOG_ERR, 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 log_oom(); return r;
r = parse_sec(rvalue, &usec); r = parse_sec(rvalue, &usec);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, "Lifetime is invalid, ignoring assignment: %s", rvalue); log_syntax(unit, LOG_ERR, 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 log_oom(); return r;
r = parse_boolean(rvalue); r = parse_boolean(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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 log_oom(); return r;
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_WARNING, filename, line, r, "Route prefix is invalid, ignoring assignment: %s", rvalue); log_syntax(unit, LOG_ERR, 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 log_oom(); return r;
r = parse_sec(rvalue, &usec); r = parse_sec(rvalue, &usec);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, filename, line, r,
"Route lifetime is invalid, ignoring assignment: %s", rvalue); "Route lifetime is invalid, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -716,13 +716,14 @@ 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 (const char *p = rvalue;;) { for (;;) {
_cleanup_free_ char *w = NULL; _cleanup_free_ char *w = NULL;
union in_addr_union a; union in_addr_union a;
@ -730,25 +731,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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)
return 0; break;
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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, filename, line, 0,
"DNS server address is null, ignoring: %s", w); "DNS server address is null, ignoring: %s", w);
continue; continue;
} }
@ -762,6 +763,8 @@ 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(
@ -777,29 +780,30 @@ 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 (const char *p = rvalue;;) { for (;;) {
_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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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)
return 0; break;
r = dns_name_apply_idna(w, &idna); r = dns_name_apply_idna(w, &idna);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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)
@ -808,12 +812,14 @@ 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 log_oom(); return r;
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 log_oom(); return r;
} }
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] = {
@ -851,8 +857,7 @@ 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_WARNING, filename, line, SYNTHETIC_ERRNO(EINVAL), log_syntax(unit, LOG_ERR, filename, line, -EINVAL, "Invalid router prefix delegation '%s', ignoring assignment.", rvalue);
"Invalid router prefix delegation '%s', ignoring assignment.", rvalue);
return 0; return 0;
} }
@ -886,8 +891,7 @@ 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, filename, line, -EINVAL, "Router preference '%s' is invalid, ignoring assignment: %m", rvalue);
"Invalid router preference, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -918,7 +922,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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,7 +15,6 @@
#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"
@ -992,22 +991,12 @@ 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 == -ENOMEM) if (r < 0)
return log_oom(); return r;
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 == -ENOMEM) if (r < 0)
return log_oom(); return r;
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;
@ -1021,7 +1010,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, filename, line, r,
"Invalid %s='%s', ignoring assignment: %m", lvalue, rvalue); "Invalid %s='%s', ignoring assignment: %m", lvalue, rvalue);
return 0; return 0;
} }
@ -1053,20 +1042,15 @@ 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 == -ENOMEM) if (r < 0)
return log_oom(); return r;
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_WARNING, filename, line, EINVAL, log_syntax(unit, LOG_ERR, filename, line, EINVAL,
"Invalid %s='%s', ignoring assignment: %m", lvalue, rvalue); "Invalid %s='%s', ignoring assignment: %m", lvalue, rvalue);
return 0; return 0;
} }
@ -1100,13 +1084,8 @@ 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 == -ENOMEM) if (r < 0)
return log_oom(); return r;
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;
@ -1122,7 +1101,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_WARNING, filename, line, EINVAL, log_syntax(unit, LOG_ERR, filename, line, EINVAL,
"Invalid %s='%s', ignoring assignment: %m", lvalue, rvalue); "Invalid %s='%s', ignoring assignment: %m", lvalue, rvalue);
return 0; return 0;
} }
@ -1154,17 +1133,12 @@ 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 == -ENOMEM) if (r < 0)
return log_oom(); return r;
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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
} }
@ -1196,17 +1170,12 @@ 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 == -ENOMEM) if (r < 0)
return log_oom(); return r;
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_WARNING, filename, line, 0, "Unknown route scope: %s", rvalue); log_syntax(unit, LOG_ERR, filename, line, 0, "Unknown route scope: %s", rvalue);
return 0; return 0;
} }
@ -1239,13 +1208,8 @@ 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 == -ENOMEM) if (r < 0)
return log_oom(); return r;
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)
@ -1253,7 +1217,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
} }
@ -1264,7 +1228,7 @@ int config_parse_route_table(
return 0; return 0;
} }
int config_parse_route_boolean( int config_parse_gateway_onlink(
const char *unit, const char *unit,
const char *filename, const char *filename,
unsigned line, unsigned line,
@ -1287,31 +1251,17 @@ int config_parse_route_boolean(
assert(data); assert(data);
r = route_new_static(network, filename, section_line, &n); r = route_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 route, ignoring assignment: %m");
return 0;
}
r = parse_boolean(rvalue); r = parse_boolean(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
@ -1334,13 +1284,8 @@ 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 == -ENOMEM) if (r < 0)
return log_oom(); return r;
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;
@ -1349,7 +1294,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_WARNING, filename, line, 0, "Unknown route preference: %s", rvalue); log_syntax(unit, LOG_ERR, filename, line, 0, "Unknown route preference: %s", rvalue);
return 0; return 0;
} }
@ -1374,13 +1319,8 @@ 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 == -ENOMEM) if (r < 0)
return log_oom(); return r;
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)
@ -1388,7 +1328,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
} }
@ -1415,17 +1355,12 @@ 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 == -ENOMEM) if (r < 0)
return log_oom(); return r;
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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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;
} }
@ -1460,22 +1395,17 @@ 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 == -ENOMEM) if (r < 0)
return log_oom(); return r;
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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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;
} }
@ -1491,6 +1421,82 @@ 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,
@ -1514,13 +1520,8 @@ 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 == -ENOMEM) if (r < 0)
return log_oom(); return r;
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)
@ -1530,6 +1531,45 @@ 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,
@ -1557,13 +1597,8 @@ 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 == -ENOMEM) if (r < 0)
return log_oom(); return r;
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);
@ -1579,7 +1614,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, filename, line, r,
"Invalid multipath route option, ignoring assignment: %s", rvalue); "Invalid multipath route option, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -1596,7 +1631,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
} }
@ -1606,7 +1641,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
} }
@ -1616,12 +1651,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, filename, line, 0,
"Invalid multipath route weight, ignoring assignment: %s", p); "Invalid multipath route weight, ignoring assignment: %s", p);
return 0; return 0;
} }
@ -1633,7 +1668,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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,10 +100,13 @@ 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_route_boolean); CONFIG_PARSER_PROTOTYPE(config_parse_gateway_onlink);
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 log_oom(); return r;
r = safe_atou8(rvalue, &n->tos); r = safe_atou8(rvalue, &n->tos);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse RPDB rule TOS, ignoring: %s", rvalue); log_syntax(unit, LOG_ERR, 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 log_oom(); return r;
r = safe_atou32(rvalue, &n->priority); r = safe_atou32(rvalue, &n->priority);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse RPDB rule priority, ignoring: %s", rvalue); log_syntax(unit, LOG_ERR, 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 log_oom(); return r;
r = safe_atou32(rvalue, &n->table); r = safe_atou32(rvalue, &n->table);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse RPDB rule table, ignoring: %s", rvalue); log_syntax(unit, LOG_ERR, 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 log_oom(); return r;
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_WARNING, filename, line, r, "Failed to parse RPDB rule firewall mark or mask, ignoring: %s", rvalue); log_syntax(unit, LOG_ERR, 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 log_oom(); return r;
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_WARNING, filename, line, r, "RPDB rule prefix is invalid, ignoring assignment: %s", rvalue); log_syntax(unit, LOG_ERR, 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 log_oom(); return r;
if (!ifname_valid(rvalue)) { if (!ifname_valid(rvalue)) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse '%s' interface name, ignoring: %s", lvalue, rvalue); log_syntax(unit, LOG_ERR, filename, line, r, "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 log_oom(); return r;
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_WARNING, filename, line, r, "Failed to parse routing policy rule port range '%s'", rvalue); log_syntax(unit, LOG_ERR, 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 log_oom(); return r;
r = parse_ip_protocol(rvalue); r = parse_ip_protocol(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse IP protocol '%s' for routing policy rule, ignoring: %m", rvalue); log_syntax(unit, LOG_ERR, 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 log_oom(); return r;
r = parse_boolean(rvalue); r = parse_boolean(rvalue);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse RPDB rule invert, ignoring: %s", rvalue); log_syntax(unit, LOG_ERR, 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 log_oom(); return r;
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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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 log_oom(); return r;
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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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 log_oom(); return r;
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_WARNING, filename, line, r, "Prefix length outside of valid range 0-128, ignoring: %s", rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, "Failed to parse RPDB rule suppress_prefixlen, ignoring: %s", rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, "Invalid SR-IOV VLANId: %d", k); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, "Invalid SR-IOV virtual function: %d", k); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, "Failed to parse '%s=', ignoring: %s", lvalue, rvalue); log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, filename, line, 0,
"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_WARNING, filename, line, 0, "Failed to parse IPForward= option, ignoring: %s", rvalue); log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse IPForward= option, ignoring: %s", rvalue);
return 0; return 0;
} }
} }

View File

@ -68,11 +68,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -85,7 +83,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
@ -123,11 +121,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -139,13 +135,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, filename, line, 0,
"Invalid '%s=', ignoring assignment: %s", "Invalid '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;

View File

@ -99,11 +99,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -116,7 +114,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
@ -153,11 +151,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -182,7 +178,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
@ -218,11 +214,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -235,7 +229,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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,13 +66,9 @@ 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 == -ENOMEM) if (r < 0)
return log_oom(); return log_syntax(unit, LOG_ERR, filename, line, r,
if (r < 0) { "Failed to create traffic control class, ignoring assignment: %m");
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to create traffic control class, ignoring assignment: %m");
return 0;
}
drr = TCLASS_TO_DRR(tclass); drr = TCLASS_TO_DRR(tclass);
@ -85,13 +81,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, "Invalid '%s=', ignoring assignment: %s", log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
} }

View File

@ -101,11 +101,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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"))
@ -124,13 +122,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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;
@ -167,11 +165,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -191,28 +187,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, filename, line, r,
"Failed to extract next value, ignoring: %m"); "Failed to extract next value, ignoring: %m");
break; continue;
} }
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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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;
@ -251,11 +247,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -275,22 +269,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, filename, line, r,
"Failed to extract next value, ignoring: %m"); "Failed to extract next value, ignoring: %m");
break; continue;
} }
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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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,11 +67,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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:
@ -93,7 +91,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
@ -129,11 +127,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -146,13 +142,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, "Invalid '%s=', ignoring assignment: %s", log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
} }

View File

@ -120,11 +120,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -144,7 +142,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
@ -181,11 +179,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -210,7 +206,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
@ -246,11 +242,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -263,7 +257,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
@ -302,11 +296,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -329,13 +321,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, filename, line, r,
"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,11 +128,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -156,7 +154,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
@ -194,11 +192,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -218,13 +214,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, filename, line, r,
"Specified '%s=' is too large, ignoring assignment: %s", "Specified '%s=' is too large, ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
@ -261,11 +257,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -278,7 +272,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
@ -316,11 +310,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -333,13 +325,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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;
@ -377,11 +369,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -394,13 +384,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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,11 +93,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -117,14 +115,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, filename, line, 0,
"Invalid '%s=', ignoring assignment: %s", "Invalid '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
} }
@ -159,11 +157,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -176,7 +172,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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,11 +63,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -80,7 +78,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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,11 +69,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -86,7 +84,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
@ -122,11 +120,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -139,7 +135,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
@ -262,13 +258,9 @@ 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 == -ENOMEM) if (r < 0)
return log_oom(); return log_syntax(unit, LOG_ERR, filename, line, r,
if (r < 0) { "Failed to create traffic control class, ignoring assignment: %m");
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to create traffic control class, ignoring assignment: %m");
return 0;
}
htb = TCLASS_TO_HTB(tclass); htb = TCLASS_TO_HTB(tclass);
@ -280,7 +272,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
@ -316,13 +308,9 @@ 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 == -ENOMEM) if (r < 0)
return log_oom(); return log_syntax(unit, LOG_ERR, filename, line, r,
if (r < 0) { "Failed to create traffic control class, ignoring assignment: %m");
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to create traffic control class, ignoring assignment: %m");
return 0;
}
htb = TCLASS_TO_HTB(tclass); htb = TCLASS_TO_HTB(tclass);
@ -346,13 +334,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, filename, line, 0,
"Invalid '%s=', ignoring assignment: %s", "Invalid '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
@ -400,13 +388,9 @@ 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 == -ENOMEM) if (r < 0)
return log_oom(); return log_syntax(unit, LOG_ERR, filename, line, r,
if (r < 0) { "Failed to create traffic control class, ignoring assignment: %m");
log_syntax(unit, LOG_WARNING, filename, line, r,
"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"))
@ -425,7 +409,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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,11 +80,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -100,7 +98,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
@ -142,11 +140,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -162,7 +158,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
@ -202,11 +198,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -219,7 +213,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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,11 +62,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -79,7 +77,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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,13 +288,8 @@ 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 == -ENOMEM) if (r < 0)
return log_oom(); return r;
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;
@ -309,7 +304,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, filename, line, r,
"Failed to parse 'Parent=', ignoring assignment: %s", "Failed to parse 'Parent=', ignoring assignment: %s",
rvalue); rvalue);
return 0; return 0;
@ -351,13 +346,8 @@ 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 == -ENOMEM) if (r < 0)
return log_oom(); return r;
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;
@ -367,7 +357,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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,13 +73,9 @@ 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 == -ENOMEM) if (r < 0)
return log_oom(); return log_syntax(unit, LOG_ERR, filename, line, r,
if (r < 0) { "Failed to create traffic control class, ignoring assignment: %m");
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to create traffic control class, ignoring assignment: %m");
return 0;
}
qfq = TCLASS_TO_QFQ(tclass); qfq = TCLASS_TO_QFQ(tclass);
@ -91,14 +87,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, filename, line, 0,
"Invalid '%s=', ignoring assignment: %s", "Invalid '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;
@ -134,13 +130,9 @@ 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 == -ENOMEM) if (r < 0)
return log_oom(); return log_syntax(unit, LOG_ERR, filename, line, r,
if (r < 0) { "Failed to create traffic control class, ignoring assignment: %m");
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to create traffic control class, ignoring assignment: %m");
return 0;
}
qfq = TCLASS_TO_QFQ(tclass); qfq = TCLASS_TO_QFQ(tclass);
@ -152,14 +144,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, filename, line, 0,
"Invalid '%s=', ignoring assignment: %s", "Invalid '%s=', ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
return 0; return 0;

View File

@ -73,11 +73,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -90,7 +88,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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,11 +56,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -73,7 +71,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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,11 +136,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -162,7 +160,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
@ -210,11 +208,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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"))
@ -233,7 +229,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
@ -272,11 +268,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -289,7 +283,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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,20 +214,15 @@ 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 == -ENOMEM) if (r < 0)
return log_oom(); return r;
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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, filename, line, r,
"Failed to parse 'Parent=', ignoring assignment: %s", "Failed to parse 'Parent=', ignoring assignment: %s",
rvalue); rvalue);
return 0; return 0;
@ -261,13 +256,8 @@ 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 == -ENOMEM) if (r < 0)
return log_oom(); return r;
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;
@ -277,7 +267,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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,11 +57,9 @@ 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)
log_syntax(unit, LOG_WARNING, filename, line, r, return log_syntax(unit, LOG_ERR, 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);
@ -74,13 +72,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, filename, line, 0,
"'%s=' is too large, ignoring assignment: %s", "'%s=' is too large, ignoring assignment: %s",
lvalue, rvalue); lvalue, rvalue);
} }

View File

@ -563,14 +563,10 @@ 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, { "/usr/lib/os-release", "/run/host/usr/lib/os-release", NULL, NULL, MS_BIND|MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV,
MOUNT_FATAL|MOUNT_MKDIR|MOUNT_TOUCH }, /* As per kernel interface requirements, bind mount first (creating mount points) and make read-only later */ MOUNT_FATAL|MOUNT_MKDIR|MOUNT_TOUCH },
{ NULL, "/run/host/usr/lib/os-release", NULL, NULL, MS_BIND|MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_REMOUNT, { "/etc/os-release", "/run/host/etc/os-release", NULL, NULL, MS_BIND|MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV,
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,
@ -591,6 +587,7 @@ 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))
@ -620,7 +617,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 = access(mount_table[k].what, F_OK); r = stat(mount_table[k].what, &source_st);
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_WARNING, filename, line, r, "Failed to parse size value '%s', ignoring: %m", rvalue); log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse size value '%s', ignoring: %m", rvalue);
return 0; return 0;
} }
@ -577,8 +577,10 @@ 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_WARNING, filename, line, r, "Failed to parse size value '%s', ignoring: %m", rvalue); log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse size value '%s', ignoring: %m", rvalue);
return 0;
}
return 0; return 0;
} }
@ -605,7 +607,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_WARNING, filename, line, r, "Failed to parse size value, ignoring: %s", rvalue); log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse size value, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -632,7 +634,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, fatal ? LOG_ERR : LOG_WARNING, filename, line, k, log_syntax(unit, LOG_ERR, 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;
@ -662,15 +664,10 @@ 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_WARNING, filename, line, r, "Failed to parse 128bit ID/UUID, ignoring: %s", rvalue); log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse 128bit ID/UUID, ignoring: %s", rvalue);
return 0; else if (sd_id128_is_null(t))
} 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;
@ -701,7 +698,7 @@ int config_parse_tristate(
k = parse_boolean(rvalue); k = parse_boolean(rvalue);
if (k < 0) { if (k < 0) {
log_syntax(unit, LOG_WARNING, filename, line, k, "Failed to parse boolean value, ignoring: %s", rvalue); log_syntax(unit, LOG_ERR, filename, line, k, "Failed to parse boolean value, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -796,23 +793,25 @@ int config_parse_strv(
return 0; return 0;
} }
for (const char *p = rvalue;;) { for (;;) {
char *word = NULL; char *word = NULL;
r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE|EXTRACT_RETAIN_ESCAPE); r = extract_first_word(&rvalue, &word, NULL, EXTRACT_UNQUOTE|EXTRACT_RETAIN_ESCAPE);
if (r == 0) if (r == 0)
return 0; break;
if (r == -ENOMEM) if (r == -ENOMEM)
return log_oom(); return log_oom();
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid syntax, ignoring: %s", rvalue); log_syntax(unit, LOG_ERR, filename, line, r, "Invalid syntax, ignoring: %s", rvalue);
return 0; break;
} }
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(
@ -871,7 +870,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_WARNING, filename, line, 0, "Failed to parse log facility, ignoring: %s", rvalue); log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse log facility, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -901,7 +900,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_WARNING, filename, line, 0, "Failed to parse log level, ignoring: %s", rvalue); log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse log level, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -934,7 +933,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_WARNING, filename, line, 0, "Failed to parse signal name, ignoring: %s", rvalue); log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse signal name, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -966,7 +965,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_WARNING, filename, line, 0, "Failed to parse personality, ignoring: %s", rvalue); log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse personality, ignoring: %s", rvalue);
return 0; return 0;
} }
} }
@ -1001,7 +1000,7 @@ int config_parse_ifname(
} }
if (!ifname_valid(rvalue)) { if (!ifname_valid(rvalue)) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Interface name is not valid or too long, ignoring assignment: %s", rvalue); log_syntax(unit, LOG_ERR, filename, line, 0, "Interface name is not valid or too long, ignoring assignment: %s", rvalue);
return 0; return 0;
} }
@ -1026,6 +1025,7 @@ 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,14 +1038,13 @@ int config_parse_ifnames(
return 0; return 0;
} }
for (const char *p = rvalue;;) { 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
@ -1054,7 +1053,7 @@ int config_parse_ifnames(
break; break;
if (!ifname_valid_full(word, ltype)) { if (!ifname_valid_full(word, ltype)) {
log_syntax(unit, LOG_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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;
@ -1100,7 +1099,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_WARNING, filename, line, r, "Failed to parse port '%s'.", rvalue); log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse port '%s'.", rvalue);
return 0; return 0;
} }
@ -1129,14 +1128,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, 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;
} }
@ -1168,7 +1167,7 @@ int config_parse_rlimit(
return 0; return 0;
} }
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse resource value, ignoring: %s", rvalue); log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse resource value, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -1204,7 +1203,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_WARNING, filename, line, r, log_syntax(unit, LOG_ERR, filename, line, r,
"Failed to parse permille value, ignoring: %s", rvalue); "Failed to parse permille value, ignoring: %s", rvalue);
return 0; return 0;
} }
@ -1238,7 +1237,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_WARNING, filename, line, 0, log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, \ log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, r, \ log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, \ log_syntax(unit, LOG_ERR, 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_WARNING, filename, line, 0, \ log_syntax(unit, LOG_ERR, 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 log_oom(); \ return -ENOMEM; \
\ \
if ((x = name##_from_string(en)) < 0) { \ if ((x = name##_from_string(en)) < 0) { \
log_syntax(unit, LOG_WARNING, filename, line, 0, \ log_syntax(unit, LOG_ERR, 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 log_oom(); \ return -ENOMEM; \
\ \
*(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,8 +67,6 @@ 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"