summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-04-20 16:31:17 +0200
committerLennart Poettering <lennart@poettering.net>2018-04-26 13:51:44 +0200
commit79138a384f0c6a0d47cf97cf5a917f32ec4a9ba9 (patch)
tree83f8cd731a9ee640e20eda89ea203dac5dcd9516 /src
parentf91c6093efba5738436adb41aa4b6d0abc66cdc9 (diff)
downloadsystemd-79138a384f0c6a0d47cf97cf5a917f32ec4a9ba9.tar.gz
conf-parse: add a generic config_parse_mtu() conf file parser function
It's mostly a wrapper around parse_mtu() but with some nicer logging. The address family is initialized from the "ltype" parameter, so that configuration file parser tables can be easily declare it.
Diffstat (limited to 'src')
-rw-r--r--src/shared/conf-parser.c35
-rw-r--r--src/shared/conf-parser.h1
2 files changed, 36 insertions, 0 deletions
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index a5b38604ca..4588561890 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -1158,3 +1158,38 @@ int config_parse_join_controllers(
return 0;
}
+
+int config_parse_mtu(
+ 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) {
+
+ uint32_t *mtu = data;
+ int r;
+
+ assert(rvalue);
+ assert(mtu);
+
+ r = parse_mtu(ltype, rvalue, mtu);
+ if (r == -ERANGE) {
+ log_syntax(unit, LOG_ERR, filename, line, r,
+ "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,
+ rvalue);
+ return 0;
+ }
+ if (r < 0) {
+ log_syntax(unit, LOG_ERR, filename, line, r,
+ "Failed to parse MTU value '%s', ignoring: %m", rvalue);
+ return 0;
+ }
+
+ return 0;
+}
diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h
index 150fa07e7e..094b9cbc44 100644
--- a/src/shared/conf-parser.h
+++ b/src/shared/conf-parser.h
@@ -146,6 +146,7 @@ int config_parse_personality(GENERIC_PARSER_ARGS);
int config_parse_ifname(GENERIC_PARSER_ARGS);
int config_parse_ip_port(GENERIC_PARSER_ARGS);
int config_parse_join_controllers(GENERIC_PARSER_ARGS);
+int config_parse_mtu(GENERIC_PARSER_ARGS);
typedef enum Disabled {
DISABLED_CONFIGURATION,