diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-08-11 22:44:51 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-08-11 22:46:42 +0200 |
commit | 44e7b9492617408130d11ffa451c2660942974f6 (patch) | |
tree | 3f92bbd49b5c08ba427eb0add72322d0b4f9fe80 /src/network/networkd-netdev-tunnel.c | |
parent | cedc8c44d43c8b6689ae5f5ebe1aabb7ad9755ba (diff) |
networkd: monopolize in_addr utility functions in shared/in-addr-util.h
Primarily, this means we get rid of net_parse_inaddr(), and replace it
everywhere with in_addr_from_string() and in_addr_from_string_auto().
These functions do not clobber the callers arguments on failure, which
is more close to our usual coding style.
Diffstat (limited to 'src/network/networkd-netdev-tunnel.c')
-rw-r--r-- | src/network/networkd-netdev-tunnel.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/network/networkd-netdev-tunnel.c b/src/network/networkd-netdev-tunnel.c index 4561f8d0a9..56eeb99e4b 100644 --- a/src/network/networkd-netdev-tunnel.c +++ b/src/network/networkd-netdev-tunnel.c @@ -266,21 +266,28 @@ int config_parse_tunnel_address(const char *unit, void *data, void *userdata) { Tunnel *t = userdata; - union in_addr_union *addr = data; - int r; + union in_addr_union *addr = data, buffer; + int r, f; assert(filename); assert(lvalue); assert(rvalue); assert(data); - r = net_parse_inaddr(rvalue, &t->family, addr); + r = in_addr_from_string_auto(rvalue, &f, &buffer); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, EINVAL, - "Tunnel address is invalid, ignoring assignment: %s", rvalue); + log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Tunnel address is invalid, ignoring assignment: %s", rvalue); return 0; } + if (t->family != AF_UNSPEC && t->family != f) { + log_syntax(unit, LOG_ERR, filename, line, EINVAL, "Tunnel addresses incompatible, ignoring assignment: %s", rvalue); + return 0; + } + + t->family = f; + *addr = buffer; + return 0; } |