1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-10-30 06:25:25 +03:00

networkd: replace geneve parsers with generic config_parse_uint8

This commit is contained in:
Susant Sahani 2017-04-25 18:42:56 +05:30
parent 134e24e136
commit 3ded5bbfda
3 changed files with 18 additions and 89 deletions

View File

@ -201,71 +201,6 @@ int config_parse_geneve_vni(const char *unit,
return 0;
}
int config_parse_geneve_tos(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) {
Geneve *v = userdata;
uint8_t f;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
r = safe_atou8(rvalue, &f);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse Geneve TOS '%s'.", rvalue);
return 0;
}
v->tos = f;
return 0;
}
int config_parse_geneve_ttl(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) {
Geneve *v = userdata;
uint8_t f;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
r = safe_atou8(rvalue, &f);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse Geneve TTL '%s'.", rvalue);
return 0;
}
if (f == 0) {
log_syntax(unit, LOG_ERR, filename, line, r, "Invalid Geneve TTL '%s'.", rvalue);
return 0;
}
v->ttl = f;
return 0;
}
int config_parse_geneve_address(const char *unit,
const char *filename,
unsigned line,
@ -369,6 +304,21 @@ int config_parse_geneve_flow_label(const char *unit,
return 0;
}
static int netdev_geneve_verify(NetDev *netdev, const char *filename) {
Geneve *v = GENEVE(netdev);
assert(netdev);
assert(v);
assert(filename);
if (v->ttl == 0) {
log_warning("Invalid Geneve TTL value '0' configured in '%s'. Ignoring", filename);
return -EINVAL;
}
return 0;
}
static void geneve_init(NetDev *netdev) {
Geneve *v;
@ -391,4 +341,5 @@ const NetDevVTable geneve_vtable = {
.sections = "Match\0NetDev\0GENEVE\0",
.create = netdev_geneve_create,
.create_type = NETDEV_CREATE_INDEPENDENT,
.config_verify = netdev_geneve_verify,
};

View File

@ -63,28 +63,6 @@ int config_parse_geneve_vni(const char *unit,
void *data,
void *userdata);
int config_parse_geneve_tos(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);
int config_parse_geneve_ttl(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);
int config_parse_geneve_address(const char *unit,
const char *filename,
unsigned line,

View File

@ -83,8 +83,8 @@ VXLAN.DestinationPort, config_parse_destination_port, 0,
VXLAN.FlowLabel, config_parse_flow_label, 0, 0
GENEVE.Id, config_parse_geneve_vni, 0, offsetof(Geneve, id)
GENEVE.Remote, config_parse_geneve_address, 0, offsetof(Geneve, remote)
GENEVE.TOS, config_parse_geneve_tos, 0, offsetof(Geneve, tos)
GENEVE.TTL, config_parse_geneve_ttl, 0, offsetof(Geneve, ttl)
GENEVE.TOS, config_parse_uint8, 0, offsetof(Geneve, tos)
GENEVE.TTL, config_parse_uint8, 0, offsetof(Geneve, ttl)
GENEVE.UDPChecksum, config_parse_bool, 0, offsetof(Geneve, udpcsum)
GENEVE.UDP6ZeroCheckSumRx, config_parse_bool, 0, offsetof(Geneve, udp6zerocsumrx)
GENEVE.UDP6ZeroCheckSumTx, config_parse_bool, 0, offsetof(Geneve, udp6zerocsumtx)