diff options
author | Serhey Popovych <serhe.popovych@gmail.com> | 2018-01-18 20:13:47 +0200 |
---|---|---|
committer | David Ahern <dsahern@gmail.com> | 2018-01-21 09:38:26 -0800 |
commit | 6caad8f505805eb26ddf2e87912d4cb785c6b7e0 (patch) | |
tree | d031782ae955380255eb60e18534463ff4c7002b | |
parent | 1e9b8072de2c7c5ceec33532b5c074a14bf6a007 (diff) |
ip: Get rid of inet_get_addr()
Both geneve and vxlan modules are converted to
use get_addr() we can replace inet_get_addr()
in less problematic places and finally get
rid of inet_get_addr().
Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
-rw-r--r-- | include/utils.h | 1 | ||||
-rw-r--r-- | ip/iproute_lwtunnel.c | 5 | ||||
-rw-r--r-- | ip/ipseg6.c | 8 | ||||
-rw-r--r-- | lib/utils.c | 8 |
4 files changed, 7 insertions, 15 deletions
diff --git a/include/utils.h b/include/utils.h index 6f072f62..f562547d 100644 --- a/include/utils.h +++ b/include/utils.h @@ -269,7 +269,6 @@ void print_nlmsg_timestamp(FILE *fp, const struct nlmsghdr *n); extern int cmdlineno; ssize_t getcmdline(char **line, size_t *len, FILE *in); int makeargs(char *line, char *argv[], int maxargs); -int inet_get_addr(const char *src, __u32 *dst, struct in6_addr *dst6); struct iplink_req { struct nlmsghdr n; diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c index a1d36ba2..7542addb 100644 --- a/ip/iproute_lwtunnel.c +++ b/ip/iproute_lwtunnel.c @@ -431,7 +431,10 @@ static struct ipv6_sr_hdr *parse_srh(char *segbuf, int hmac, bool encap) i = srh->first_segment; for (s = strtok(segbuf, ","); s; s = strtok(NULL, ",")) { - inet_get_addr(s, NULL, &srh->segments[i]); + inet_prefix addr; + + get_addr(&addr, s, AF_INET6); + memcpy(&srh->segments[i], addr.data, sizeof(struct in6_addr)); i--; } diff --git a/ip/ipseg6.c b/ip/ipseg6.c index 461a3c1c..e3ab31a5 100644 --- a/ip/ipseg6.c +++ b/ip/ipseg6.c @@ -49,7 +49,7 @@ static int genl_family = -1; static struct { unsigned int cmd; - struct in6_addr addr; + inet_prefix addr; __u32 keyid; const char *pass; __u8 alg_id; @@ -152,7 +152,7 @@ static int seg6_do_cmd(void) break; } case SEG6_CMD_SET_TUNSRC: - addattr_l(&req.n, sizeof(req), SEG6_ATTR_DST, &opts.addr, + addattr_l(&req.n, sizeof(req), SEG6_ATTR_DST, opts.addr.data, sizeof(struct in6_addr)); break; case SEG6_CMD_DUMPHMAC: @@ -226,9 +226,7 @@ int do_seg6(int argc, char **argv) } else if (matches(*argv, "set") == 0) { NEXT_ARG(); opts.cmd = SEG6_CMD_SET_TUNSRC; - if (!inet_get_addr(*argv, NULL, &opts.addr)) - invarg("tunsrc ADDRESS value is invalid", - *argv); + get_addr(&opts.addr, *argv, AF_INET6); } else { invarg("unknown", *argv); } diff --git a/lib/utils.c b/lib/utils.c index e66c1ff7..e20b60e4 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -1280,14 +1280,6 @@ int makeargs(char *line, char *argv[], int maxargs) return argc; } -int inet_get_addr(const char *src, __u32 *dst, struct in6_addr *dst6) -{ - if (strchr(src, ':')) - return inet_pton(AF_INET6, src, dst6); - else - return inet_pton(AF_INET, src, dst); -} - void print_nlmsg_timestamp(FILE *fp, const struct nlmsghdr *n) { char *tstr; |