diff options
author | Susant Sahani <ssahani@users.noreply.github.com> | 2017-05-06 00:04:07 +0000 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-05-05 20:04:07 -0400 |
commit | f7bf1abef9b4db7ffe18a6cf84db2aaef7d908d3 (patch) | |
tree | 76375c21a042debd6c1fe92de593eadc03f3cc88 /src/network | |
parent | 192fa38bef60ecb7916145a050a683d7fced6915 (diff) | |
download | systemd-f7bf1abef9b4db7ffe18a6cf84db2aaef7d908d3.tar.gz systemd-f7bf1abef9b4db7ffe18a6cf84db2aaef7d908d3.tar.bz2 systemd-f7bf1abef9b4db7ffe18a6cf84db2aaef7d908d3.zip |
socket-util: add parse_ip_prefix (#5867)
networkd: replace parse prefix with generic in_addr_prefix_from_string
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/networkd-address-label.c | 42 | ||||
-rw-r--r-- | src/network/networkd-address-label.h | 1 |
2 files changed, 4 insertions, 39 deletions
diff --git a/src/network/networkd-address-label.c b/src/network/networkd-address-label.c index 1248719cf3..b89995ec44 100644 --- a/src/network/networkd-address-label.c +++ b/src/network/networkd-address-label.c @@ -117,7 +117,7 @@ int address_label_configure( assert(link->manager->rtnl); r = sd_rtnl_message_new_addrlabel(link->manager->rtnl, &req, RTM_NEWADDRLABEL, - link->ifindex, label->family); + link->ifindex, AF_INET6); if (r < 0) return log_error_errno(r, "Could not allocate RTM_NEWADDR message: %m"); @@ -155,9 +155,7 @@ int config_parse_address_label_prefix(const char *unit, _cleanup_address_label_free_ AddressLabel *n = NULL; Network *network = userdata; - const char *prefix, *e; - union in_addr_union buffer; - int r, f; + int r; assert(filename); assert(section); @@ -169,44 +167,12 @@ int config_parse_address_label_prefix(const char *unit, if (r < 0) return r; - /* AddressLabel=prefix/prefixlen */ - - /* prefixlen */ - e = strchr(rvalue, '/'); - if (e) { - unsigned i; - - r = safe_atou(e + 1, &i); - if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Prefix length is invalid, ignoring assignment: %s", e + 1); - return 0; - } - - if (i > 128) { - log_syntax(unit, LOG_ERR, filename, line, r, "Prefix length is out of range, ignoring assignment: %s", e + 1); - return 0; - } - - n->prefixlen = (unsigned char) i; - - prefix = strndupa(rvalue, e - rvalue); - } else - prefix = rvalue; - - r = in_addr_from_string_auto(prefix, &f, &buffer); + r = in_addr_prefix_from_string(rvalue, AF_INET6, &n->in_addr, &n->prefixlen); if (r < 0) { - log_syntax(unit, LOG_ERR, filename, line, r, "Address label is invalid, ignoring assignment: %s", prefix); - return 0; - } - - if (f != AF_INET6) { - log_syntax(unit, LOG_ERR, filename, line, 0, "Address label family is not IPv6, ignoring assignment: %s", prefix); + log_syntax(unit, LOG_ERR, filename, line, r, "Address label is invalid, ignoring assignment: %s", rvalue); return 0; } - n->family = f; - n->in_addr = buffer; - n = NULL; return 0; diff --git a/src/network/networkd-address-label.h b/src/network/networkd-address-label.h index 05bb24924c..8724ea8cb5 100644 --- a/src/network/networkd-address-label.h +++ b/src/network/networkd-address-label.h @@ -38,7 +38,6 @@ struct AddressLabel { Link *link; NetworkConfigSection *section; - int family; unsigned char prefixlen; uint32_t label; |