From: Zbigniew Jędrzejewski-Szmek Date: Sat, 16 Sep 2023 21:54:18 +0000 (+0200) Subject: network/netdev: fix resetting of 'inherit' field X-Git-Tag: v255-rc1~458^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6fded8dced402eafc5069201f6f4c0fd0e27adf7;p=thirdparty%2Fsystemd.git network/netdev: fix resetting of 'inherit' field We have two fields: inherit and ttl, and ttl is ignored if inherit is true. Setting TTL=inherit and later TTL=n would not work because we didn't unset inherit. --- diff --git a/src/network/netdev/geneve.c b/src/network/netdev/geneve.c index f5f325711cd..c60fe6974d5 100644 --- a/src/network/netdev/geneve.c +++ b/src/network/netdev/geneve.c @@ -224,16 +224,22 @@ int config_parse_geneve_ttl( assert(data); Geneve *v = ASSERT_PTR(userdata); + int r; if (streq(rvalue, "inherit")) { v->inherit = true; + v->ttl = 0; /* unset the unused ttl field for clarity */ return 0; } - return config_parse_uint8_bounded( + r = config_parse_uint8_bounded( unit, filename, line, section, section_line, lvalue, rvalue, 0, UINT8_MAX, true, &v->ttl); + if (r <= 0) + return r; + v->inherit = false; + return 0; } static int netdev_geneve_verify(NetDev *netdev, const char *filename) { diff --git a/src/network/netdev/vxlan.c b/src/network/netdev/vxlan.c index c91ed24cda1..b7d3ee50859 100644 --- a/src/network/netdev/vxlan.c +++ b/src/network/netdev/vxlan.c @@ -351,34 +351,27 @@ int config_parse_vxlan_ttl( void *data, void *userdata) { - VxLan *v = userdata; - unsigned f; - int r; - assert(filename); assert(lvalue); assert(rvalue); assert(data); - if (streq(rvalue, "inherit")) - v->inherit = true; - else { - r = safe_atou(rvalue, &f); - if (r < 0) { - 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_WARNING, filename, line, 0, - "Invalid VXLAN TTL '%s'. TTL must be <= 255. Ignoring assignment.", rvalue); - return 0; - } + VxLan *v = ASSERT_PTR(userdata); + int r; - v->ttl = f; + if (streq(rvalue, "inherit")) { + v->inherit = true; + v->ttl = 0; /* unset the unused ttl field for clarity */ + return 0; } + r = config_parse_unsigned_bounded( + unit, filename, line, section, section_line, lvalue, rvalue, + 0, UINT8_MAX, true, + &v->ttl); + if (r <= 0) + return r; + v->inherit = false; return 0; }