From: Serhey Popovych <serhe.popovych@gmail.com>
To: netdev@vger.kernel.org
Subject: [PATCH iproute2 6/6] ip: Get rid of inet_get_addr()
Date: Thu, 18 Jan 2018 20:13:47 +0200 [thread overview]
Message-ID: <1516299227-26724-7-git-send-email-serhe.popovych@gmail.com> (raw)
In-Reply-To: <1516299227-26724-1-git-send-email-serhe.popovych@gmail.com>
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>
---
include/utils.h | 1 -
ip/iproute_lwtunnel.c | 5 ++++-
ip/ipseg6.c | 8 +++-----
lib/utils.c | 8 --------
4 files changed, 7 insertions(+), 15 deletions(-)
diff --git a/include/utils.h b/include/utils.h
index 6f072f6..f562547 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 740da7c..2ccc783 100644
--- a/ip/iproute_lwtunnel.c
+++ b/ip/iproute_lwtunnel.c
@@ -434,7 +434,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 461a3c1..e3ab31a 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 e66c1ff..e20b60e 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;
--
1.7.10.4
next prev parent reply other threads:[~2018-01-18 18:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-18 18:13 [PATCH iproute2 0/6] utils: Get rid of inet_get_addr() Serhey Popovych
2018-01-18 18:13 ` [PATCH iproute2 1/6] utils: Always specify family for address in get_addr_1() Serhey Popovych
2018-01-18 18:13 ` [PATCH iproute2 2/6] utils: Always specify family and ->bytelen in get_prefix_1() Serhey Popovych
2018-01-18 18:13 ` [PATCH iproute2 3/6] utils: Fast inet address classification after get_addr() Serhey Popovych
2018-01-18 18:13 ` [PATCH iproute2 4/6] iplink_geneve: Get rid of inet_get_addr() Serhey Popovych
2018-01-18 18:13 ` [PATCH iproute2 5/6] iplink_vxlan: " Serhey Popovych
2018-01-18 18:13 ` Serhey Popovych [this message]
2018-01-18 18:35 ` [PATCH iproute2 0/6] utils: " Stephen Hemminger
2018-01-21 18:13 ` David Ahern
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1516299227-26724-7-git-send-email-serhe.popovych@gmail.com \
--to=serhe.popovych@gmail.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox