lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 18 Jan 2018 20:13:47 +0200
From:   Serhey Popovych <serhe.popovych@...il.com>
To:     netdev@...r.kernel.org
Subject: [PATCH iproute2 6/6] 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@...il.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ