summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-04-25 20:28:38 -0400
committerGitHub <noreply@github.com>2017-04-25 20:28:38 -0400
commitd482e676a6a5cc4cbc4099038a42656465887b33 (patch)
tree6f0151aa6bc0f306d4288bda3facfeef254e72fa
parent4ffab21849e6f5ff31545776101661b1157635ce (diff)
parent4c7bd9cf6becd97101cd25c87853fdd18bdcbb45 (diff)
Merge pull request #5803 from ssahani/util
config_parser: add util function config_parse_uint8
-rw-r--r--src/network/netdev/geneve.c81
-rw-r--r--src/network/netdev/geneve.h22
-rw-r--r--src/network/netdev/netdev-gperf.gperf4
-rw-r--r--src/network/networkd-route.c4
-rw-r--r--src/shared/conf-parser.c1
-rw-r--r--src/shared/conf-parser.h1
6 files changed, 24 insertions, 89 deletions
diff --git a/src/network/netdev/geneve.c b/src/network/netdev/geneve.c
index bb9807b556..07c69f4711 100644
--- a/src/network/netdev/geneve.c
+++ b/src/network/netdev/geneve.c
@@ -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,
};
diff --git a/src/network/netdev/geneve.h b/src/network/netdev/geneve.h
index 3ba599aae6..d97dac892c 100644
--- a/src/network/netdev/geneve.h
+++ b/src/network/netdev/geneve.h
@@ -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,
diff --git a/src/network/netdev/netdev-gperf.gperf b/src/network/netdev/netdev-gperf.gperf
index a27a3d5562..6016b99b54 100644
--- a/src/network/netdev/netdev-gperf.gperf
+++ b/src/network/netdev/netdev-gperf.gperf
@@ -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)
diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c
index 56f831628c..94204bddd0 100644
--- a/src/network/networkd-route.c
+++ b/src/network/networkd-route.c
@@ -996,6 +996,10 @@ int config_parse_ipv6_route_preference(const char *unit,
_cleanup_route_free_ Route *n = NULL;
int r;
+ r = route_new_static(network, filename, section_line, &n);
+ if (r < 0)
+ return r;
+
if (streq(rvalue, "low"))
n->pref = ICMPV6_ROUTER_PREF_LOW;
else if (streq(rvalue, "medium"))
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index 265ac83dc0..d8393cbc8d 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -506,6 +506,7 @@ int config_parse_many(
DEFINE_PARSER(int, int, safe_atoi);
DEFINE_PARSER(long, long, safe_atoli);
+DEFINE_PARSER(uint8, uint8_t, safe_atou8);
DEFINE_PARSER(uint16, uint16_t, safe_atou16);
DEFINE_PARSER(uint32, uint32_t, safe_atou32);
DEFINE_PARSER(uint64, uint64_t, safe_atou64);
diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h
index 26ff3df16f..82ea5c1288 100644
--- a/src/shared/conf-parser.h
+++ b/src/shared/conf-parser.h
@@ -119,6 +119,7 @@ int config_parse_many(
int config_parse_int(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_unsigned(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_long(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_uint8(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_uint16(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_uint32(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_uint64(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);