diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-11-22 21:03:43 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-12-08 02:47:42 +0100 |
commit | a0460dfed617a73f7dbf36a6eb7e474e887ae780 (patch) | |
tree | aaf1f82c268be8459c499d95273ffd05a4deeb08 /src/basic/parse-util.c | |
parent | network: do not try to update IP sysctl settings for CAN devices (diff) | |
download | systemd-a0460dfed617a73f7dbf36a6eb7e474e887ae780.tar.xz systemd-a0460dfed617a73f7dbf36a6eb7e474e887ae780.zip |
parse-util: accept arbitrary MTU size when AF_UNSPEC
When [Link] MTU= is specified in a .network file, we have no idea about
that what kind of interface will be configured with the .network file.
The maximum and minimum MTU size depend on the kind of interface.
So, we should not filter MTU eagerly in the parser.
Closes #30140.
Diffstat (limited to 'src/basic/parse-util.c')
-rw-r--r-- | src/basic/parse-util.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/basic/parse-util.c b/src/basic/parse-util.c index dc868c9b8e..0430e33e40 100644 --- a/src/basic/parse-util.c +++ b/src/basic/parse-util.c @@ -123,8 +123,7 @@ int parse_ifindex(const char *s) { } int parse_mtu(int family, const char *s, uint32_t *ret) { - uint64_t u; - size_t m; + uint64_t u, m; int r; r = parse_size(s, 1024, &u); @@ -134,10 +133,16 @@ int parse_mtu(int family, const char *s, uint32_t *ret) { if (u > UINT32_MAX) return -ERANGE; - if (family == AF_INET6) + switch (family) { + case AF_INET: + m = IPV4_MIN_MTU; /* This is 68 */ + break; + case AF_INET6: m = IPV6_MIN_MTU; /* This is 1280 */ - else - m = IPV4_MIN_MTU; /* For all other protocols, including 'unspecified' we assume the IPv4 minimal MTU */ + break; + default: + m = 0; + } if (u < m) return -ERANGE; |