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.
This commit is contained in:
parent
f91c6093ef
commit
79138a384f
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue