From: Serhey Popovych Date: Thu, 18 Jan 2018 18:13:47 +0000 (+0200) Subject: ip: Get rid of inet_get_addr() X-Git-Tag: v4.16.0~83^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6caad8f505805eb26ddf2e87912d4cb785c6b7e0;p=thirdparty%2Fiproute2.git 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 Signed-off-by: David Ahern --- diff --git a/include/utils.h b/include/utils.h index 6f072f620..f562547d6 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 a1d36ba24..7542addb2 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 461a3c1c1..e3ab31a51 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 e66c1ff7b..e20b60e4b 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;