network: downgrade log level in conf parsers

This commit is contained in:
Yu Watanabe
2020-07-17 00:40:09 +09:00
parent 4d939d2c84
commit d96edb2c6e
55 changed files with 864 additions and 754 deletions
+13 -11
View File
@@ -320,13 +320,15 @@ int config_parse_arp_ip_target_address(
return 0;
}
for (;;) {
for (const char *p = rvalue;;) {
_cleanup_free_ char *n = NULL;
union in_addr_union ip;
r = extract_first_word(&rvalue, &n, NULL, 0);
r = extract_first_word(&p, &n, NULL, 0);
if (r == -ENOMEM)
return log_oom();
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse Bond ARP IP target address, ignoring assignment: %s",
rvalue);
return 0;
@@ -336,7 +338,7 @@ int config_parse_arp_ip_target_address(
r = in_addr_from_string(AF_INET, n, &ip);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, r,
"Bond ARP IP target address is invalid, ignoring assignment: %s", n);
continue;
}
@@ -357,7 +359,7 @@ int config_parse_arp_ip_target_address(
log_syntax(unit, LOG_WARNING, filename, line, r,
"Bond ARP IP target address is duplicated, ignoring assignment: %s", n);
if (r < 0)
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to store bond ARP IP target address '%s', ignoring assignment: %m", n);
}
}
@@ -384,13 +386,13 @@ int config_parse_ad_actor_sys_prio(
r = safe_atou16(rvalue, &v);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse actor system priority '%s', ignoring: %m", rvalue);
return 0;
}
if (v == 0) {
log_syntax(unit, LOG_ERR, filename, line, 0,
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Failed to parse actor system priority '%s'. Range is [1,65535], ignoring.",
rvalue);
return 0;
@@ -423,13 +425,13 @@ int config_parse_ad_user_port_key(
r = safe_atou16(rvalue, &v);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse user port key '%s', ignoring: %m", rvalue);
return 0;
}
if (v > 1023) {
log_syntax(unit, LOG_ERR, filename, line, 0,
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Failed to parse user port key '%s'. Range is [0…1023], ignoring.", rvalue);
return 0;
}
@@ -461,13 +463,13 @@ int config_parse_ad_actor_system(
r = ether_addr_from_string(rvalue, &n);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, r,
"Not a valid MAC address %s. Ignoring assignment: %m",
rvalue);
return 0;
}
if (ether_addr_is_null(&n) || (n.ether_addr_octet[0] & 0x01)) {
log_syntax(unit, LOG_ERR, filename, line, 0,
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Not a valid MAC address %s, can not be null or multicast. Ignoring assignment.",
rvalue);
return 0;
+2 -2
View File
@@ -326,13 +326,13 @@ int config_parse_bridge_igmp_version(
r = safe_atou8(rvalue, &u);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse bridge's multicast IGMP version number '%s', ignoring assignment: %m",
rvalue);
return 0;
}
if (!IN_SET(u, 2, 3)) {
log_syntax(unit, LOG_ERR, filename, line, 0,
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid bridge's multicast IGMP version number '%s', ignoring assignment.", rvalue);
return 0;
}
+3 -3
View File
@@ -167,14 +167,14 @@ int config_parse_ip_protocol(
else {
r = safe_atou(rvalue, &protocol);
if (r < 0)
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse IP protocol '%s' for FooOverUDP tunnel, "
"ignoring assignment: %m", rvalue);
return 0;
}
if (protocol > UINT8_MAX) {
log_syntax(unit, LOG_ERR, filename, line, 0,
log_syntax(unit, LOG_WARNING, filename, line, 0,
"IP protocol '%s' for FooOverUDP tunnel out of range, "
"ignoring assignment: %m", rvalue);
return 0;
@@ -212,7 +212,7 @@ int config_parse_fou_tunnel_address(
r = in_addr_from_string_auto(rvalue, f, addr);
if (r < 0)
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, r,
"FooOverUDP tunnel '%s' address is invalid, ignoring assignment: %s",
lvalue, rvalue);
+8 -8
View File
@@ -185,12 +185,12 @@ int config_parse_geneve_vni(const char *unit,
r = safe_atou32(rvalue, &f);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse Geneve VNI '%s'.", rvalue);
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse Geneve VNI '%s'.", rvalue);
return 0;
}
if (f > GENEVE_VID_MAX){
log_syntax(unit, LOG_ERR, filename, line, r, "Geneve VNI out is of range '%s'.", rvalue);
log_syntax(unit, LOG_WARNING, filename, line, 0, "Geneve VNI out is of range '%s'.", rvalue);
return 0;
}
@@ -220,13 +220,13 @@ int config_parse_geneve_address(const char *unit,
r = in_addr_from_string_auto(rvalue, &f, &buffer);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "geneve '%s' address is invalid, ignoring assignment: %s", lvalue, rvalue);
log_syntax(unit, LOG_WARNING, filename, line, r, "geneve '%s' address is invalid, ignoring assignment: %s", lvalue, rvalue);
return 0;
}
r = in_addr_is_multicast(f, &buffer);
if (r > 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, "geneve invalid multicast '%s' address, ignoring assignment: %s", lvalue, rvalue);
log_syntax(unit, LOG_WARNING, filename, line, 0, "geneve invalid multicast '%s' address, ignoring assignment: %s", lvalue, rvalue);
return 0;
}
@@ -257,12 +257,12 @@ int config_parse_geneve_flow_label(const char *unit,
r = safe_atou32(rvalue, &f);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse Geneve flow label '%s'.", rvalue);
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse Geneve flow label '%s'.", rvalue);
return 0;
}
if (f & ~GENEVE_FLOW_LABEL_MAX_MASK) {
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Geneve flow label '%s' not valid. Flow label range should be [0-1048575].", rvalue);
return 0;
}
@@ -296,13 +296,13 @@ int config_parse_geneve_ttl(const char *unit,
else {
r = safe_atou(rvalue, &f);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse Geneve TTL '%s', ignoring assignment: %m", rvalue);
return 0;
}
if (f > 255) {
log_syntax(unit, LOG_ERR, filename, line, 0,
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid Geneve TTL '%s'. TTL must be <= 255. Ignoring assignment.", rvalue);
return 0;
}
+10 -10
View File
@@ -459,7 +459,7 @@ int config_parse_l2tp_tunnel_address(
else
r = in_addr_from_string(t->family, rvalue, addr);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid L2TP Tunnel address specified in %s='%s', ignoring assignment: %m", lvalue, rvalue);
return 0;
}
@@ -489,13 +489,13 @@ int config_parse_l2tp_tunnel_id(
r = safe_atou32(rvalue, &k);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse L2TP tunnel id. Ignoring assignment: %s", rvalue);
return 0;
}
if (k == 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid L2TP tunnel id. Ignoring assignment: %s", rvalue);
return 0;
}
@@ -530,17 +530,17 @@ int config_parse_l2tp_session_id(
r = l2tp_session_new_static(t, filename, section_line, &session);
if (r < 0)
return r;
return log_oom();
r = safe_atou32(rvalue, &k);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse L2TP session id. Ignoring assignment: %s", rvalue);
return 0;
}
if (k == 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid L2TP session id. Ignoring assignment: %s", rvalue);
return 0;
}
@@ -579,11 +579,11 @@ int config_parse_l2tp_session_l2spec(
r = l2tp_session_new_static(t, filename, section_line, &session);
if (r < 0)
return r;
return log_oom();
spec = l2tp_l2spec_type_from_string(rvalue);
if (spec < 0) {
log_syntax(unit, LOG_ERR, filename, line, 0,
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Failed to parse layer2 specific header type. Ignoring assignment: %s", rvalue);
return 0;
}
@@ -618,10 +618,10 @@ int config_parse_l2tp_session_name(
r = l2tp_session_new_static(t, filename, section_line, &session);
if (r < 0)
return r;
return log_oom();
if (!ifname_valid(rvalue)) {
log_syntax(unit, LOG_ERR, filename, line, 0,
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Failed to parse L2TP tunnel session name. Ignoring assignment: %s", rvalue);
return 0;
}
+30 -28
View File
@@ -577,7 +577,7 @@ int config_parse_macsec_port(
else if (streq(section, "MACsecReceiveChannel")) {
r = macsec_receive_channel_new_static(s, filename, section_line, &c);
if (r < 0)
return r;
return log_oom();
dest = &c->sci.port;
} else {
@@ -585,14 +585,14 @@ int config_parse_macsec_port(
r = macsec_receive_association_new_static(s, filename, section_line, &b);
if (r < 0)
return r;
return log_oom();
dest = &b->sci.port;
}
r = parse_ip_port(rvalue, &port);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse port '%s' for secure channel identifier. Ignoring assignment: %m",
rvalue);
return 0;
@@ -634,11 +634,11 @@ int config_parse_macsec_hw_address(
else
r = macsec_receive_association_new_static(s, filename, section_line, &b);
if (r < 0)
return r;
return log_oom();
r = ether_addr_from_string(rvalue, b ? &b->sci.mac : &c->sci.mac);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse MAC address for secure channel identifier. "
"Ignoring assignment: %s", rvalue);
return 0;
@@ -679,18 +679,18 @@ int config_parse_macsec_packet_number(
else
r = macsec_receive_association_new_static(s, filename, section_line, &b);
if (r < 0)
return r;
return log_oom();
dest = a ? &a->sa.packet_number : &b->sa.packet_number;
r = safe_atou32(rvalue, &val);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse packet number. Ignoring assignment: %s", rvalue);
return 0;
}
if (streq(section, "MACsecTransmitAssociation") && val == 0) {
log_syntax(unit, LOG_ERR, filename, line, 0,
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid packet number. Ignoring assignment: %s", rvalue);
return 0;
}
@@ -735,19 +735,19 @@ int config_parse_macsec_key(
else
r = macsec_receive_association_new_static(s, filename, section_line, &b);
if (r < 0)
return r;
return log_oom();
dest = a ? &a->sa : &b->sa;
r = unhexmem_full(rvalue, strlen(rvalue), true, &p, &l);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse key. Ignoring assignment: %m");
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse key. Ignoring assignment: %m");
return 0;
}
if (l != 16) {
/* See DEFAULT_SAK_LEN in drivers/net/macsec.c */
log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid key length (%zu). Ignoring assignment", l);
log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid key length (%zu). Ignoring assignment", l);
return 0;
}
@@ -791,7 +791,7 @@ int config_parse_macsec_key_file(
else
r = macsec_receive_association_new_static(s, filename, section_line, &b);
if (r < 0)
return r;
return log_oom();
dest = a ? &a->sa.key_file : &b->sa.key_file;
@@ -845,15 +845,15 @@ int config_parse_macsec_key_id(
else
r = macsec_receive_association_new_static(s, filename, section_line, &b);
if (r < 0)
return r;
return log_oom();
r = unhexmem(rvalue, strlen(rvalue), &p, &l);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse KeyId \"%s\": %m", rvalue);
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse KeyId \"%s\": %m", rvalue);
return 0;
}
if (l > MACSEC_KEYID_LEN)
return log_syntax(unit, LOG_ERR, filename, line, 0,
return log_syntax(unit, LOG_WARNING, filename, line, 0,
"Specified KeyId is larger then the allowed maximum (%zu > %u), ignoring: %s",
l, MACSEC_KEYID_LEN, rvalue);
@@ -896,7 +896,7 @@ int config_parse_macsec_sa_activate(
else
r = macsec_receive_association_new_static(s, filename, section_line, &b);
if (r < 0)
return r;
return log_oom();
dest = a ? &a->sa.activate : &b->sa.activate;
@@ -905,7 +905,7 @@ int config_parse_macsec_sa_activate(
else {
r = parse_boolean(rvalue);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse activation mode of %s security association. "
"Ignoring assignment: %s",
streq(section, "MACsecTransmitAssociation") ? "transmit" : "receive",
@@ -945,18 +945,20 @@ int config_parse_macsec_use_for_encoding(
r = macsec_transmit_association_new_static(s, filename, section_line, &a);
if (r < 0)
return r;
return log_oom();
if (isempty(rvalue))
r = -1;
else {
r = parse_boolean(rvalue);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
"Failed to parse %s= setting. Ignoring assignment: %s",
lvalue, rvalue);
return 0;
}
if (isempty(rvalue)) {
a->sa.use_for_encoding = -1;
TAKE_PTR(a);
return 0;
}
r = parse_boolean(rvalue);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse %s= setting. Ignoring assignment: %s",
lvalue, rvalue);
return 0;
}
a->sa.use_for_encoding = r;
+2 -2
View File
@@ -137,12 +137,12 @@ int config_parse_netdev_kind(
k = netdev_kind_from_string(rvalue);
if (k < 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse netdev kind, ignoring assignment: %s", rvalue);
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse netdev kind, ignoring assignment: %s", rvalue);
return 0;
}
if (*kind != _NETDEV_KIND_INVALID && *kind != k) {
log_syntax(unit, LOG_ERR, filename, line, 0,
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Specified netdev kind is different from the previous value '%s', ignoring assignment: %s",
netdev_kind_to_string(*kind), rvalue);
return 0;
+8 -8
View File
@@ -541,13 +541,13 @@ int config_parse_tunnel_address(const char *unit,
r = in_addr_from_string_auto(rvalue, &f, &buffer);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, r,
"Tunnel address \"%s\" invalid, ignoring assignment: %m", rvalue);
return 0;
}
if (t->family != AF_UNSPEC && t->family != f) {
log_syntax(unit, LOG_ERR, filename, line, 0,
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Tunnel addresses incompatible, ignoring assignment: %s", rvalue);
return 0;
}
@@ -581,7 +581,7 @@ int config_parse_tunnel_key(const char *unit,
if (r < 0) {
r = safe_atou32(rvalue, &k);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse tunnel key ignoring assignment: %s", rvalue);
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse tunnel key ignoring assignment: %s", rvalue);
return 0;
}
} else
@@ -626,7 +626,7 @@ int config_parse_ipv6_flowlabel(const char* unit,
return r;
if (k > 0xFFFFF)
log_syntax(unit, LOG_ERR, filename, line, 0, "Failed to parse IPv6 flowlabel option, ignoring: %s", rvalue);
log_syntax(unit, LOG_WARNING, filename, line, 0, "Failed to parse IPv6 flowlabel option, ignoring: %s", rvalue);
else {
*ipv6_flowlabel = htobe32(k) & IP6_FLOWINFO_FLOWLABEL;
t->flags &= ~IP6_TNL_F_USE_ORIG_FLOWLABEL;
@@ -659,12 +659,12 @@ int config_parse_encap_limit(const char* unit,
else {
r = safe_atoi(rvalue, &k);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse Tunnel Encapsulation Limit option, ignoring: %s", rvalue);
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse Tunnel Encapsulation Limit option, ignoring: %s", rvalue);
return 0;
}
if (k > 255 || k < 0)
log_syntax(unit, LOG_ERR, filename, line, 0, "Invalid Tunnel Encapsulation value, ignoring: %d", k);
log_syntax(unit, LOG_WARNING, filename, line, 0, "Invalid Tunnel Encapsulation value, ignoring: %d", k);
else {
t->encap_limit = k;
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);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse 6rd prefix \"%s\", ignoring: %m", rvalue);
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse 6rd prefix \"%s\", ignoring: %m", rvalue);
return 0;
}
if (l == 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, "6rd prefix length of \"%s\" must be greater than zero, ignoring", rvalue);
log_syntax(unit, LOG_WARNING, filename, line, 0, "6rd prefix length of \"%s\" must be greater than zero, ignoring", rvalue);
return 0;
}
+8 -8
View File
@@ -196,7 +196,7 @@ int config_parse_vxlan_address(const char *unit,
r = in_addr_from_string_auto(rvalue, &f, &buffer);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "vxlan '%s' address is invalid, ignoring assignment: %s", lvalue, rvalue);
log_syntax(unit, LOG_WARNING, filename, line, r, "vxlan '%s' address is invalid, ignoring assignment: %s", lvalue, rvalue);
return 0;
}
@@ -204,14 +204,14 @@ int config_parse_vxlan_address(const char *unit,
if (streq(lvalue, "Group")) {
if (r <= 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, "vxlan %s invalid multicast address, ignoring assignment: %s", lvalue, rvalue);
log_syntax(unit, LOG_WARNING, filename, line, 0, "vxlan %s invalid multicast address, ignoring assignment: %s", lvalue, rvalue);
return 0;
}
v->group_family = f;
} else {
if (r > 0) {
log_syntax(unit, LOG_ERR, filename, line, 0, "vxlan %s cannot be a multicast address, ignoring assignment: %s", lvalue, rvalue);
log_syntax(unit, LOG_WARNING, filename, line, 0, "vxlan %s cannot be a multicast address, ignoring assignment: %s", lvalue, rvalue);
return 0;
}
@@ -247,7 +247,7 @@ int config_parse_port_range(const char *unit,
r = parse_ip_port_range(rvalue, &low, &high);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse VXLAN port range '%s'. Port should be greater than 0 and less than 65535.", rvalue);
return 0;
}
@@ -279,12 +279,12 @@ int config_parse_flow_label(const char *unit,
r = safe_atou(rvalue, &f);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse VXLAN flow label '%s'.", rvalue);
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse VXLAN flow label '%s'.", rvalue);
return 0;
}
if (f & ~VXLAN_FLOW_LABEL_MAX_MASK) {
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, r,
"VXLAN flow label '%s' not valid. Flow label range should be [0-1048575].", rvalue);
return 0;
}
@@ -318,13 +318,13 @@ int config_parse_vxlan_ttl(const char *unit,
else {
r = safe_atou(rvalue, &f);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse VXLAN TTL '%s', ignoring assignment: %m", rvalue);
return 0;
}
if (f > 255) {
log_syntax(unit, LOG_ERR, filename, line, 0,
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Invalid VXLAN TTL '%s'. TTL must be <= 255. Ignoring assignment.", rvalue);
return 0;
}
+20 -19
View File
@@ -459,7 +459,7 @@ int config_parse_wireguard_listen_port(
r = parse_ip_port(rvalue, s);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, r,
"Invalid port specification, ignoring assignment: %s", rvalue);
return 0;
}
@@ -494,10 +494,10 @@ static int wireguard_decode_key_and_warn(
r = unbase64mem_full(rvalue, strlen(rvalue), true, &key, &len);
if (r < 0)
return log_syntax(unit, LOG_ERR, filename, line, r,
return log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to decode wireguard key provided by %s=, ignoring assignment: %m", lvalue);
if (len != WG_KEY_LEN)
return log_syntax(unit, LOG_ERR, filename, line, 0,
return log_syntax(unit, LOG_WARNING, filename, line, SYNTHETIC_ERRNO(EINVAL),
"Wireguard key provided by %s= has invalid length (%zu bytes), ignoring assignment.",
lvalue, len);
@@ -583,9 +583,10 @@ int config_parse_wireguard_preshared_key(
r = wireguard_peer_new_static(w, filename, section_line, &peer);
if (r < 0)
return r;
return log_oom();
return wireguard_decode_key_and_warn(rvalue, peer->preshared_key, unit, filename, line, lvalue);
(void) wireguard_decode_key_and_warn(rvalue, peer->preshared_key, unit, filename, line, lvalue);
return 0;
}
int config_parse_wireguard_preshared_key_file(
@@ -611,7 +612,7 @@ int config_parse_wireguard_preshared_key_file(
r = wireguard_peer_new_static(w, filename, section_line, &peer);
if (r < 0)
return r;
return log_oom();
if (isempty(rvalue)) {
peer->preshared_key_file = mfree(peer->preshared_key_file);
@@ -653,11 +654,11 @@ int config_parse_wireguard_public_key(
r = wireguard_peer_new_static(w, filename, section_line, &peer);
if (r < 0)
return r;
return log_oom();
r = wireguard_decode_key_and_warn(rvalue, peer->public_key, unit, filename, line, lvalue);
if (r < 0)
return r;
return 0;
TAKE_PTR(peer);
return 0;
@@ -690,25 +691,25 @@ int config_parse_wireguard_allowed_ips(
r = wireguard_peer_new_static(w, filename, section_line, &peer);
if (r < 0)
return r;
return log_oom();
for (;;) {
for (const char *p = rvalue;;) {
_cleanup_free_ char *word = NULL;
r = extract_first_word(&rvalue, &word, "," WHITESPACE, 0);
r = extract_first_word(&p, &word, "," WHITESPACE, 0);
if (r == 0)
break;
if (r == -ENOMEM)
return log_oom();
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to split allowed ips \"%s\" option: %m", rvalue);
break;
}
r = in_addr_prefix_from_string_auto(word, &family, &addr, &prefixlen);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, r,
"Network address is invalid, ignoring assignment: %s", word);
continue;
}
@@ -758,7 +759,7 @@ int config_parse_wireguard_endpoint(
begin = &rvalue[1];
end = strchr(rvalue, ']');
if (!end) {
log_syntax(unit, LOG_ERR, filename, line, 0,
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Unable to find matching brace of endpoint, ignoring assignment: %s",
rvalue);
return 0;
@@ -766,7 +767,7 @@ int config_parse_wireguard_endpoint(
len = end - begin;
++end;
if (*end != ':' || !*(end + 1)) {
log_syntax(unit, LOG_ERR, filename, line, 0,
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Unable to find port of endpoint, ignoring assignment: %s",
rvalue);
return 0;
@@ -776,7 +777,7 @@ int config_parse_wireguard_endpoint(
begin = rvalue;
end = strrchr(rvalue, ':');
if (!end || !*(end + 1)) {
log_syntax(unit, LOG_ERR, filename, line, 0,
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Unable to find port of endpoint, ignoring assignment: %s",
rvalue);
return 0;
@@ -787,7 +788,7 @@ int config_parse_wireguard_endpoint(
r = wireguard_peer_new_static(w, filename, section_line, &peer);
if (r < 0)
return r;
return log_oom();
r = free_and_strndup(&peer->endpoint_host, begin, len);
if (r < 0)
@@ -830,14 +831,14 @@ int config_parse_wireguard_keepalive(
r = wireguard_peer_new_static(w, filename, section_line, &peer);
if (r < 0)
return r;
return log_oom();
if (streq(rvalue, "off"))
keepalive = 0;
else {
r = safe_atou16(rvalue, &keepalive);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r,
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse \"%s\" as keepalive interval (range 0–65535), ignoring assignment: %m",
rvalue);
return 0;