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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191002233655.24323-43-mathew.j.martineau@linux.intel.com>
Date:   Wed,  2 Oct 2019 16:36:52 -0700
From:   Mat Martineau <mathew.j.martineau@...ux.intel.com>
To:     netdev@...r.kernel.org, edumazet@...gle.com
Cc:     Florian Westphal <fw@...len.de>, cpaasch@...le.com,
        pabeni@...hat.com, peter.krystad@...ux.intel.com,
        dcaratti@...hat.com, matthieu.baerts@...sares.net
Subject: [RFC PATCH v2 42/45] selftests: mptcp: extend mptcp_connect tool for ipv6 family

From: Florian Westphal <fw@...len.de>

At this time socket() will fail when requesting an ipv6 mptcp socket.
This is ok for now, as the test script won't request ipv6 tests yet.

Tested with a tcp <-> tcp connection.

Signed-off-by: Florian Westphal <fw@...len.de>
---
 .../testing/selftests/net/mptcp/mptcp_connect.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/testing/selftests/net/mptcp/mptcp_connect.c
index cac71f0ac8f8..32a1630b7fa3 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c
@@ -32,11 +32,11 @@ static int  poll_timeout;
 static const char *cfg_host;
 static const char *cfg_port	= "12000";
 static int cfg_sock_proto	= IPPROTO_MPTCP;
-
+static int pf = AF_INET;
 
 static void die_usage(void)
 {
-	fprintf(stderr, "Usage: mptcp_connect [-s MPTCP|TCP] [-p port] "
+	fprintf(stderr, "Usage: mptcp_connect [ -6 ] [-s MPTCP|TCP] [-p port] "
 		"[ -l ] [ -t timeout ] connect_address\n");
 	exit(1);
 }
@@ -74,12 +74,13 @@ static int sock_listen_mptcp(const char * const listenaddr,
 		.ai_flags = AI_PASSIVE | AI_NUMERICHOST
 	};
 
-	hints.ai_family = AF_INET;
+	hints.ai_family = pf;
 
 	struct addrinfo *a, *addr;
 	int one = 1;
 
 	xgetaddrinfo(listenaddr, port, &hints, &addr);
+	hints.ai_family = pf;
 
 	for (a = addr; a; a = a->ai_next) {
 		sock = socket(a->ai_family, a->ai_socktype, cfg_sock_proto);
@@ -124,7 +125,7 @@ static int sock_connect_mptcp(const char * const remoteaddr,
 	struct addrinfo *a, *addr;
 	int sock = -1;
 
-	hints.ai_family = AF_INET;
+	hints.ai_family = pf;
 
 	xgetaddrinfo(remoteaddr, port, &hints, &addr);
 	for (a = addr; a; a = a->ai_next) {
@@ -362,7 +363,7 @@ static void parse_opts(int argc, char **argv)
 {
 	int c;
 
-	while ((c = getopt(argc, argv, "lp:s:ht:")) != -1) {
+	while ((c = getopt(argc, argv, "6lp:s:ht:")) != -1) {
 		switch (c) {
 		case 'l':
 			listen_mode = true;
@@ -376,6 +377,9 @@ static void parse_opts(int argc, char **argv)
 		case 'h':
 			die_usage();
 			break;
+		case '6':
+			pf = AF_INET6;
+			break;
 		case 't':
 			poll_timeout = atoi(optarg) * 1000;
 			if (poll_timeout <= 0)
@@ -387,6 +391,9 @@ static void parse_opts(int argc, char **argv)
 	if (optind + 1 != argc)
 		die_usage();
 	cfg_host = argv[optind];
+
+	if (strchr(cfg_host, ':'))
+		pf = AF_INET6;
 }
 
 int main(int argc, char *argv[])
-- 
2.23.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ