All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 0/9] network: add new features
@ 2018-01-29 11:41 Alexey Kodanev
  2018-01-29 11:41 ` [LTP] [PATCH 1/9] lib: add safe_sendmsg() Alexey Kodanev
                   ` (9 more replies)
  0 siblings, 10 replies; 13+ messages in thread
From: Alexey Kodanev @ 2018-01-29 11:41 UTC (permalink / raw)
  To: ltp

* SO_ZEROCOPY (no auto test-cases yet, can be tried manually with
  netstress 'z' option);

* IP_BIND_ADDRESS_NO_PORT, new bind_noport01 test;

* one more protocol added to netstress - UDPLITE; busy_poll03, dccp01 and
  UDP IPsec tests are updated;

* netstress server now sends data to client using send(), sendto() and
  sendmsg(), if protocol allows.

Alexey Kodanev (9):
  lib: add safe_sendmsg()
  lib: add safe_getsockopt() and tst_getsockport()
  netstress: make socketaddr returned by recvfrom() thread-local
  netstress: server: write to socket with send/sendto/sendmsg
  netstress: support UDPLITE protocol
  netstress: support SO_ZEROCOPY
  netstress: support IP_BIND_ADDRESS_NO_PORT
  network: add new test-cases with UDP LITE protocol
  network: new test-case for IP_BIND_ADDRESS_NO_PORT

 include/lapi/netinet_in.h                     |    8 +
 include/lapi/socket.h                         |   12 ++
 include/lapi/udp.h                            |   30 +++
 include/safe_net_fn.h                         |    8 +
 include/tst_safe_net.h                        |    9 +
 lib/safe_net.c                                |   60 ++++++
 runtest/net.features                          |    3 +
 testcases/network/busy_poll/busy_poll03.sh    |   32 ++--
 testcases/network/dccp/dccp01.sh              |   28 ++-
 testcases/network/netstress/netstress.c       |  239 +++++++++++++++++--------
 testcases/network/sockets/Makefile            |    2 +-
 testcases/network/sockets/bind_noport01.sh    |   50 +++++
 testcases/network/stress/udp/udp_ipsec.sh     |    7 +-
 testcases/network/stress/udp/udp_ipsec_vti.sh |    7 +-
 14 files changed, 394 insertions(+), 101 deletions(-)
 create mode 100644 include/lapi/udp.h
 create mode 100755 testcases/network/sockets/bind_noport01.sh


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [LTP] [PATCH 1/9] lib: add safe_sendmsg()
  2018-01-29 11:41 [LTP] [PATCH 0/9] network: add new features Alexey Kodanev
@ 2018-01-29 11:41 ` Alexey Kodanev
  2018-01-29 11:41 ` [LTP] [PATCH 2/9] lib: add safe_getsockopt() and tst_getsockport() Alexey Kodanev
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Alexey Kodanev @ 2018-01-29 11:41 UTC (permalink / raw)
  To: ltp

Instead of strict flag, it requires to pass the actual msg_len for the
sending buffers. In case of zero, the check is skipped similar to the
strict flag in safe_send() and safe_sendto().

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 include/safe_net_fn.h  |    3 +++
 include/tst_safe_net.h |    3 +++
 lib/safe_net.c         |   22 ++++++++++++++++++++++
 3 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/include/safe_net_fn.h b/include/safe_net_fn.h
index 75acf5e..ed81463 100644
--- a/include/safe_net_fn.h
+++ b/include/safe_net_fn.h
@@ -41,6 +41,9 @@ ssize_t safe_sendto(const char *file, const int lineno, char len_strict,
 		    int sockfd, const void *buf, size_t len, int flags,
 		    const struct sockaddr *dest_addr, socklen_t addrlen);
 
+ssize_t safe_sendmsg(const char *file, const int lineno, size_t msg_len,
+		  int sockfd, const struct msghdr *msg, int flags);
+
 int safe_bind(const char *file, const int lineno, void (cleanup_fn)(void),
 	      int socket, const struct sockaddr *address,
 	      socklen_t address_len);
diff --git a/include/tst_safe_net.h b/include/tst_safe_net.h
index 104184d..6c37143 100644
--- a/include/tst_safe_net.h
+++ b/include/tst_safe_net.h
@@ -45,6 +45,9 @@
 	safe_sendto(__FILE__, __LINE__, strict, fd, buf, len, flags, \
 		    dest_addr, addrlen)
 
+#define SAFE_SENDMSG(msg_len, fd, msg, flags) \
+	safe_sendmsg(__FILE__, __LINE__, msg_len, fd, msg, flags)
+
 #define SAFE_BIND(socket, address, address_len) \
 	safe_bind(__FILE__, __LINE__, NULL, socket, address, \
 		  address_len)
diff --git a/lib/safe_net.c b/lib/safe_net.c
index e48b06d..23f84fc 100644
--- a/lib/safe_net.c
+++ b/lib/safe_net.c
@@ -149,6 +149,28 @@ ssize_t safe_sendto(const char *file, const int lineno, char len_strict,
 	return rval;
 }
 
+ssize_t safe_sendmsg(const char *file, const int lineno, size_t len,
+		     int sockfd, const struct msghdr *msg, int flags)
+{
+	ssize_t rval;
+
+	rval = sendmsg(sockfd, msg, flags);
+
+	if (rval == -1) {
+		tst_brkm(TBROK | TERRNO, NULL,
+			 "%s:%d: sendmsg(%d, %p, %d) failed",
+			 file, lineno, sockfd, msg, flags);
+	}
+
+	if (!len && (size_t)rval != len) {
+		tst_brkm(TBROK, NULL,
+			 "%s:%d: sendmsg(%d, %p, %d) ret(%zd) != len(%zu)",
+			 file, lineno, sockfd, msg, flags, rval, len);
+	}
+
+	return rval;
+}
+
 int safe_bind(const char *file, const int lineno, void (cleanup_fn)(void),
 	      int socket, const struct sockaddr *address,
 	      socklen_t address_len)
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [LTP] [PATCH 2/9] lib: add safe_getsockopt() and tst_getsockport()
  2018-01-29 11:41 [LTP] [PATCH 0/9] network: add new features Alexey Kodanev
  2018-01-29 11:41 ` [LTP] [PATCH 1/9] lib: add safe_sendmsg() Alexey Kodanev
@ 2018-01-29 11:41 ` Alexey Kodanev
  2018-01-29 11:41 ` [LTP] [PATCH 3/9] netstress: make socketaddr returned by recvfrom() thread-local Alexey Kodanev
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Alexey Kodanev @ 2018-01-29 11:41 UTC (permalink / raw)
  To: ltp

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 include/safe_net_fn.h  |    5 +++++
 include/tst_safe_net.h |    6 ++++++
 lib/safe_net.c         |   38 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/include/safe_net_fn.h b/include/safe_net_fn.h
index ed81463..2a19be8 100644
--- a/include/safe_net_fn.h
+++ b/include/safe_net_fn.h
@@ -28,9 +28,14 @@
 char *tst_sock_addr(const struct sockaddr *sa, socklen_t salen, char *res,
 		    size_t len);
 
+int tst_getsockport(const char *file, const int lineno, int sockfd);
+
 int safe_socket(const char *file, const int lineno, void (cleanup_fn)(void),
 		int domain, int type, int protocol);
 
+int safe_getsockopt(const char *file, const int lineno, int sockfd, int level,
+		    int optname, void *optval, socklen_t *optlen);
+
 int safe_setsockopt(const char *file, const int lineno, int sockfd, int level,
 		    int optname, const void *optval, socklen_t optlen);
 
diff --git a/include/tst_safe_net.h b/include/tst_safe_net.h
index 6c37143..68e9f5c 100644
--- a/include/tst_safe_net.h
+++ b/include/tst_safe_net.h
@@ -26,9 +26,15 @@
 
 #include "safe_net_fn.h"
 
+#define TST_GETSOCKPORT(sockfd) \
+	tst_getsockport(__FILE__, __LINE__, sockfd)
+
 #define SAFE_SOCKET(domain, type, protocol) \
 	safe_socket(__FILE__, __LINE__, NULL, domain, type, protocol)
 
+#define SAFE_GETSOCKOPT(fd, level, optname, optval, optlen) \
+	safe_getsockopt(__FILE__, __LINE__, fd, level, optname, optval, optlen)
+
 #define SAFE_SETSOCKOPT(fd, level, optname, optval, optlen) \
 	safe_setsockopt(__FILE__, __LINE__, fd, level, optname, optval, optlen)
 
diff --git a/lib/safe_net.c b/lib/safe_net.c
index 23f84fc..9ea9d2b 100644
--- a/lib/safe_net.c
+++ b/lib/safe_net.c
@@ -81,6 +81,29 @@ char *tst_sock_addr(const struct sockaddr *sa, socklen_t salen, char *res,
 	}
 }
 
+int tst_getsockport(const char *file, const int lineno, int sockfd)
+{
+	struct sockaddr_storage ss;
+	socklen_t addrlen = sizeof(ss);
+	struct sockaddr *sa = (struct sockaddr *)&ss;
+
+	safe_getsockname(file, lineno, NULL, sockfd, sa, &addrlen);
+
+	switch (sa->sa_family) {
+	case AF_INET: {
+		struct sockaddr_in *sin = (struct sockaddr_in *)sa;
+
+		return ntohs(sin->sin_port);
+	}
+	case AF_INET6: {
+		struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa;
+
+		return ntohs(sin6->sin6_port);
+	} }
+
+	return -1;
+}
+
 int safe_socket(const char *file, const int lineno, void (cleanup_fn)(void),
 		int domain, int type, int protocol)
 {
@@ -97,6 +120,21 @@ int safe_socket(const char *file, const int lineno, void (cleanup_fn)(void),
 	return rval;
 }
 
+int safe_getsockopt(const char *file, const int lineno, int sockfd, int level,
+		    int optname, void *optval, socklen_t *optlen)
+{
+	int rval = getsockopt(sockfd, level, optname, optval, optlen);
+
+	if (!rval)
+		return 0;
+
+	tst_brkm(TBROK | TERRNO, NULL,
+		 "%s:%d: getsockopt(%d, %d, %d, %p, %p) failed",
+		 file, lineno, sockfd, level, optname, optval, optlen);
+
+	return rval;
+}
+
 int safe_setsockopt(const char *file, const int lineno, int sockfd, int level,
 		    int optname, const void *optval, socklen_t optlen)
 {
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [LTP] [PATCH 3/9] netstress: make socketaddr returned by recvfrom() thread-local
  2018-01-29 11:41 [LTP] [PATCH 0/9] network: add new features Alexey Kodanev
  2018-01-29 11:41 ` [LTP] [PATCH 1/9] lib: add safe_sendmsg() Alexey Kodanev
  2018-01-29 11:41 ` [LTP] [PATCH 2/9] lib: add safe_getsockopt() and tst_getsockport() Alexey Kodanev
@ 2018-01-29 11:41 ` Alexey Kodanev
  2018-01-29 11:41 ` [LTP] [PATCH 4/9] netstress: server: write to socket with send/sendto/sendmsg Alexey Kodanev
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Alexey Kodanev @ 2018-01-29 11:41 UTC (permalink / raw)
  To: ltp

Group other socket parameters into struct as well.

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 testcases/network/netstress/netstress.c |  100 +++++++++++++++++--------------
 1 files changed, 54 insertions(+), 46 deletions(-)

diff --git a/testcases/network/netstress/netstress.c b/testcases/network/netstress/netstress.c
index eec60b8..ccab403 100644
--- a/testcases/network/netstress/netstress.c
+++ b/testcases/network/netstress/netstress.c
@@ -128,8 +128,14 @@ static pthread_t *thread_ids;
 
 static struct addrinfo *remote_addrinfo;
 static struct addrinfo *local_addrinfo;
-static struct sockaddr_storage remote_addr;
-static socklen_t remote_addr_len;
+
+struct sock_info {
+	int fd;
+	struct sockaddr_storage raddr;
+	socklen_t raddr_len;
+	int etime_cnt;
+	int timeout;
+};
 
 static void init_socket_opts(int sd)
 {
@@ -163,17 +169,16 @@ static void do_cleanup(void)
 }
 TST_DECLARE_ONCE_FN(cleanup, do_cleanup)
 
-static int sock_recv_poll(int fd, char *buf, int buf_size, int offset,
-			  int *timeout)
+static int sock_recv_poll(char *buf, int size, struct sock_info *i)
 {
 	struct pollfd pfd;
-	pfd.fd = fd;
+	pfd.fd = i->fd;
 	pfd.events = POLLIN;
 	int len = -1;
 
 	while (1) {
 		errno = 0;
-		int ret = poll(&pfd, 1, *timeout);
+		int ret = poll(&pfd, 1, i->timeout);
 		if (ret == -1) {
 			if (errno == EINTR)
 				continue;
@@ -189,9 +194,9 @@ static int sock_recv_poll(int fd, char *buf, int buf_size, int offset,
 			break;
 
 		errno = 0;
-		len = recvfrom(fd, buf + offset, buf_size - offset,
-			       MSG_DONTWAIT, (struct sockaddr *)&remote_addr,
-			       &remote_addr_len);
+		len = recvfrom(i->fd, buf, size, MSG_DONTWAIT,
+			       (struct sockaddr *)&i->raddr,
+			       &i->raddr_len);
 
 		if (len == -1 && errno == EINTR)
 			continue;
@@ -205,14 +210,13 @@ static int sock_recv_poll(int fd, char *buf, int buf_size, int offset,
 	return len;
 }
 
-static int client_recv(int *fd, char *buf, int srv_msg_len, int *etime_cnt,
-		       int *timeout)
+static int client_recv(char *buf, int srv_msg_len, struct sock_info *i)
 {
 	int len, offset = 0;
 
 	while (1) {
 		errno = 0;
-		len = sock_recv_poll(*fd, buf, srv_msg_len, offset, timeout);
+		len = sock_recv_poll(buf + offset, srv_msg_len - offset, i);
 
 		/* socket closed or msg is not valid */
 		if (len < 1 || (offset + len) > srv_msg_len ||
@@ -232,15 +236,15 @@ static int client_recv(int *fd, char *buf, int srv_msg_len, int *etime_cnt,
 	}
 
 	if (errno == ETIME && sock_type != SOCK_STREAM) {
-		if (++(*etime_cnt) > max_etime_cnt)
-			tst_brk(TFAIL, "protocol timeout: %dms", *timeout);
+		if (++(i->etime_cnt) > max_etime_cnt)
+			tst_brk(TFAIL, "protocol timeout: %dms", i->timeout);
 		/* Increase timeout in poll up to 3.2 sec */
-		if (*timeout < 3000)
-			*timeout <<= 1;
+		if (i->timeout < 3000)
+			i->timeout <<= 1;
 		return 0;
 	}
 
-	SAFE_CLOSE(*fd);
+	SAFE_CLOSE(i->fd);
 	return (errno) ? -1 : 0;
 }
 
@@ -294,22 +298,26 @@ void *client_fn(LTP_ATTRIBUTE_UNUSED void *arg)
 {
 	int cln_len = init_cln_msg_len,
 	    srv_len = init_srv_msg_len;
+	struct sock_info inf;
 	char buf[max_msg_len];
 	char client_msg[max_msg_len];
-	int cfd, i = 0, etime_cnt = 0;
+	int i = 0;
 	intptr_t err = 0;
-	int timeout = wait_timeout;
+
+	inf.raddr_len = sizeof(inf.raddr);
+	inf.etime_cnt = 0;
+	inf.timeout = wait_timeout;
 
 	make_client_request(client_msg, &cln_len, &srv_len);
 
 	/* connect & send requests */
-	cfd = client_connect_send(client_msg, cln_len);
-	if (cfd == -1) {
+	inf.fd = client_connect_send(client_msg, cln_len);
+	if (inf.fd == -1) {
 		err = errno;
 		goto out;
 	}
 
-	if (client_recv(&cfd, buf, srv_len, &etime_cnt, &timeout)) {
+	if (client_recv(buf, srv_len, &inf)) {
 		err = errno;
 		goto out;
 	}
@@ -318,15 +326,14 @@ void *client_fn(LTP_ATTRIBUTE_UNUSED void *arg)
 		if (proto_type == TYPE_UDP)
 			goto send;
 
-		if (cfd == -1) {
-			cfd = client_connect_send(client_msg, cln_len);
-			if (cfd == -1) {
+		if (inf.fd == -1) {
+			inf.fd = client_connect_send(client_msg, cln_len);
+			if (inf.fd == -1) {
 				err = errno;
 				goto out;
 			}
 
-			if (client_recv(&cfd, buf, srv_len, &etime_cnt,
-			    &timeout)) {
+			if (client_recv(buf, srv_len, &inf)) {
 				err = errno;
 				break;
 			}
@@ -337,16 +344,16 @@ send:
 		if (max_rand_msg_len)
 			make_client_request(client_msg, &cln_len, &srv_len);
 
-		SAFE_SEND(1, cfd, client_msg, cln_len, MSG_NOSIGNAL);
+		SAFE_SEND(1, inf.fd, client_msg, cln_len, MSG_NOSIGNAL);
 
-		if (client_recv(&cfd, buf, srv_len, &etime_cnt, &timeout)) {
+		if (client_recv(buf, srv_len, &inf)) {
 			err = errno;
 			break;
 		}
 	}
 
-	if (cfd != -1)
-		SAFE_CLOSE(cfd);
+	if (inf.fd != -1)
+		SAFE_CLOSE(inf.fd);
 
 out:
 	if (i != client_max_requests)
@@ -468,22 +475,25 @@ static void make_server_reply(char *send_msg, int size)
 
 void *server_fn(void *cfd)
 {
-	int client_fd = (intptr_t) cfd;
 	int num_requests = 0, offset = 0;
-	int timeout = wait_timeout;
 	/* Reply will be constructed from first client request */
 	char send_msg[max_msg_len];
 	int send_msg_len = 0;
 	char recv_msg[max_msg_len];
+	struct sock_info inf;
 	ssize_t recv_len;
 
+	inf.fd = (intptr_t) cfd;
+	inf.raddr_len = sizeof(inf.raddr);
+	inf.timeout = wait_timeout;
+
 	send_msg[0] = '\0';
 
-	init_socket_opts(client_fd);
+	init_socket_opts(inf.fd);
 
 	while (1) {
-		recv_len = sock_recv_poll(client_fd, recv_msg,
-			max_msg_len, offset, &timeout);
+		recv_len = sock_recv_poll(recv_msg + offset,
+					  max_msg_len - offset, &inf);
 
 		if (recv_len == 0)
 			break;
@@ -491,7 +501,7 @@ void *server_fn(void *cfd)
 		if (recv_len < 0 || (offset + recv_len) > max_msg_len ||
 		   (recv_msg[0] != start_byte &&
 		    recv_msg[0] != start_fin_byte)) {
-			tst_res(TFAIL, "recv failed, sock '%d'", client_fd);
+			tst_res(TFAIL, "recv failed, sock '%d'", inf.fd);
 			goto out;
 		}
 
@@ -526,28 +536,28 @@ void *server_fn(void *cfd)
 
 		switch (proto_type) {
 		case TYPE_SCTP:
-			SAFE_SEND(1, client_fd, send_msg, send_msg_len,
+			SAFE_SEND(1, inf.fd, send_msg, send_msg_len,
 				MSG_NOSIGNAL);
 		break;
 		default:
-			SAFE_SENDTO(1, client_fd, send_msg, send_msg_len,
-				MSG_NOSIGNAL, (struct sockaddr *)&remote_addr,
-				remote_addr_len);
+			SAFE_SENDTO(1, inf.fd, send_msg, send_msg_len,
+				MSG_NOSIGNAL, (struct sockaddr *)&inf.raddr,
+				inf.raddr_len);
 		}
 
 		if (sock_type == SOCK_STREAM &&
 		    num_requests >= server_max_requests) {
 			/* max reqs, close socket */
-			shutdown(client_fd, SHUT_WR);
+			shutdown(inf.fd, SHUT_WR);
 			break;
 		}
 	}
 
-	SAFE_CLOSE(client_fd);
+	SAFE_CLOSE(inf.fd);
 	return NULL;
 
 out:
-	SAFE_CLOSE(client_fd);
+	SAFE_CLOSE(inf.fd);
 	tst_brk(TBROK, "Server closed");
 	return NULL;
 }
@@ -790,8 +800,6 @@ static void setup(void)
 		}
 	}
 
-	remote_addr_len = sizeof(struct sockaddr_storage);
-
 	switch (proto_type) {
 	case TYPE_TCP:
 		tst_res(TINFO, "TCP %s is using %s TCP API.",
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [LTP] [PATCH 4/9] netstress: server: write to socket with send/sendto/sendmsg
  2018-01-29 11:41 [LTP] [PATCH 0/9] network: add new features Alexey Kodanev
                   ` (2 preceding siblings ...)
  2018-01-29 11:41 ` [LTP] [PATCH 3/9] netstress: make socketaddr returned by recvfrom() thread-local Alexey Kodanev
@ 2018-01-29 11:41 ` Alexey Kodanev
  2018-01-29 11:41 ` [LTP] [PATCH 5/9] netstress: support UDPLITE protocol Alexey Kodanev
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Alexey Kodanev @ 2018-01-29 11:41 UTC (permalink / raw)
  To: ltp

server sends with send/sendto/sendmsg in round-robin way.
UDP & DCCP skip send(). SCTP 1-1 uses only send().

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 testcases/network/netstress/netstress.c |   40 ++++++++++++++++++++++--------
 1 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/testcases/network/netstress/netstress.c b/testcases/network/netstress/netstress.c
index ccab403..f795f2d 100644
--- a/testcases/network/netstress/netstress.c
+++ b/testcases/network/netstress/netstress.c
@@ -476,18 +476,26 @@ static void make_server_reply(char *send_msg, int size)
 void *server_fn(void *cfd)
 {
 	int num_requests = 0, offset = 0;
-	/* Reply will be constructed from first client request */
-	char send_msg[max_msg_len];
-	int send_msg_len = 0;
+	char send_msg[max_msg_len], end[] = { end_byte };
+	int start_send_type = (sock_type == SOCK_DGRAM) ? 1 : 0;
+	int send_msg_len, send_type = start_send_type;
 	char recv_msg[max_msg_len];
 	struct sock_info inf;
 	ssize_t recv_len;
+	struct iovec iov[2];
+	struct msghdr msg;
 
 	inf.fd = (intptr_t) cfd;
 	inf.raddr_len = sizeof(inf.raddr);
 	inf.timeout = wait_timeout;
 
-	send_msg[0] = '\0';
+	iov[0].iov_base = send_msg;
+	iov[1].iov_base = end;
+	iov[1].iov_len = 1;
+	memset(&msg, 0, sizeof(msg));
+	msg.msg_name = &inf.raddr;
+	msg.msg_iov = iov;
+	msg.msg_iovlen = 2;
 
 	init_socket_opts(inf.fd);
 
@@ -534,15 +542,25 @@ void *server_fn(void *cfd)
 		    ++num_requests >= server_max_requests)
 			send_msg[0] = start_fin_byte;
 
-		switch (proto_type) {
-		case TYPE_SCTP:
+		switch (send_type) {
+		case 0:
 			SAFE_SEND(1, inf.fd, send_msg, send_msg_len,
-				MSG_NOSIGNAL);
-		break;
-		default:
+				  MSG_NOSIGNAL);
+			if (proto_type != TYPE_SCTP)
+				++send_type;
+			break;
+		case 1:
 			SAFE_SENDTO(1, inf.fd, send_msg, send_msg_len,
-				MSG_NOSIGNAL, (struct sockaddr *)&inf.raddr,
-				inf.raddr_len);
+				    MSG_NOSIGNAL, (struct sockaddr *)&inf.raddr,
+				    inf.raddr_len);
+			++send_type;
+			break;
+		default:
+			iov[0].iov_len = send_msg_len - 1;
+			msg.msg_namelen = inf.raddr_len;
+			SAFE_SENDMSG(send_msg_len, inf.fd, &msg, MSG_NOSIGNAL);
+			send_type = start_send_type;
+			break;
 		}
 
 		if (sock_type == SOCK_STREAM &&
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [LTP] [PATCH 5/9] netstress: support UDPLITE protocol
  2018-01-29 11:41 [LTP] [PATCH 0/9] network: add new features Alexey Kodanev
                   ` (3 preceding siblings ...)
  2018-01-29 11:41 ` [LTP] [PATCH 4/9] netstress: server: write to socket with send/sendto/sendmsg Alexey Kodanev
@ 2018-01-29 11:41 ` Alexey Kodanev
  2018-01-29 11:41 ` [LTP] [PATCH 6/9] netstress: support SO_ZEROCOPY Alexey Kodanev
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Alexey Kodanev @ 2018-01-29 11:41 UTC (permalink / raw)
  To: ltp

Use initial server message length to set partial checksum.

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 include/lapi/netinet_in.h               |    4 +++
 include/lapi/socket.h                   |    4 +++
 include/lapi/udp.h                      |   30 +++++++++++++++++++++++
 testcases/network/netstress/netstress.c |   40 +++++++++++++++++++++++++-----
 4 files changed, 71 insertions(+), 7 deletions(-)
 create mode 100644 include/lapi/udp.h

diff --git a/include/lapi/netinet_in.h b/include/lapi/netinet_in.h
index 84aca4d..7da7b32 100644
--- a/include/lapi/netinet_in.h
+++ b/include/lapi/netinet_in.h
@@ -24,4 +24,8 @@
 #define IPPROTO_DCCP		33
 #endif
 
+#ifndef IPPROTO_UDPLITE
+# define IPPROTO_UDPLITE	136 /* UDP-Lite (RFC 3828) */
+#endif
+
 #endif	/* LAPI_IN_H__ */
diff --git a/include/lapi/socket.h b/include/lapi/socket.h
index 95337ce..a0217e1 100644
--- a/include/lapi/socket.h
+++ b/include/lapi/socket.h
@@ -37,6 +37,10 @@
 # define SOCK_CLOEXEC 02000000
 #endif
 
+#ifndef SOL_UDPLITE
+# define SOL_UDPLITE		136 /* UDP-Lite (RFC 3828) */
+#endif
+
 #ifndef SOL_DCCP
 # define SOL_DCCP		269
 #endif
diff --git a/include/lapi/udp.h b/include/lapi/udp.h
new file mode 100644
index 0000000..b6f50f8
--- /dev/null
+++ b/include/lapi/udp.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2018 Oracle and/or its affiliates.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LAPI_UDP_H__
+#define LAPI_UDP_H__
+
+#include <netinet/udp.h>
+
+#ifndef UDPLITE_SEND_CSCOV
+# define UDPLITE_SEND_CSCOV   10 /* sender partial coverage (as sent) */
+#endif
+#ifndef UDPLITE_RECV_CSCOV
+# define UDPLITE_RECV_CSCOV   11 /* receiver partial coverage (threshold ) */
+#endif
+
+#endif	/* LAPI_UDP_H__ */
diff --git a/testcases/network/netstress/netstress.c b/testcases/network/netstress/netstress.c
index f795f2d..97de35c 100644
--- a/testcases/network/netstress/netstress.c
+++ b/testcases/network/netstress/netstress.c
@@ -34,6 +34,7 @@
 #include <unistd.h>
 #include <errno.h>
 
+#include "lapi/udp.h"
 #include "lapi/dccp.h"
 #include "lapi/netinet_in.h"
 #include "lapi/posix_clocks.h"
@@ -91,6 +92,7 @@ static int max_etime_cnt = 12; /* ~30 sec max timeout if no connection */
 enum {
 	TYPE_TCP = 0,
 	TYPE_UDP,
+	TYPE_UDP_LITE,
 	TYPE_DCCP,
 	TYPE_SCTP
 };
@@ -142,13 +144,25 @@ static void init_socket_opts(int sd)
 	if (busy_poll >= 0)
 		SAFE_SETSOCKOPT_INT(sd, SOL_SOCKET, SO_BUSY_POLL, busy_poll);
 
-	if (proto_type == TYPE_DCCP) {
+	switch (proto_type) {
+	case TYPE_TCP:
+		if (client_mode && fastopen_sapi) {
+			SAFE_SETSOCKOPT_INT(sd, IPPROTO_TCP,
+					    TCP_FASTOPEN_CONNECT, 1);
+		}
+	break;
+	case TYPE_DCCP:
 		SAFE_SETSOCKOPT_INT(sd, SOL_DCCP, DCCP_SOCKOPT_SERVICE,
-			service_code);
+				    service_code);
+	break;
+	case TYPE_UDP_LITE:
+		/* set checksum for header and partially for payload */
+		SAFE_SETSOCKOPT_INT(sd, SOL_UDPLITE, UDPLITE_SEND_CSCOV,
+				    init_srv_msg_len >> 1);
+		SAFE_SETSOCKOPT_INT(sd, SOL_UDPLITE, UDPLITE_RECV_CSCOV,
+				    init_srv_msg_len >> 2);
+	break;
 	}
-
-	if (client_mode && fastopen_sapi)
-		SAFE_SETSOCKOPT_INT(sd, IPPROTO_TCP, TCP_FASTOPEN_CONNECT, 1);
 }
 
 static void do_cleanup(void)
@@ -612,7 +626,7 @@ static void server_init(void)
 
 	freeaddrinfo(local_addrinfo);
 
-	if (proto_type == TYPE_UDP)
+	if (sock_type == SOCK_DGRAM)
 		return;
 
 	init_socket_opts(sfd);
@@ -730,6 +744,8 @@ static void set_protocol_type(void)
 		proto_type = TYPE_TCP;
 	else if (!strcmp(type, "udp"))
 		proto_type = TYPE_UDP;
+	else if (!strcmp(type, "udp_lite"))
+		proto_type = TYPE_UDP_LITE;
 	else if (!strcmp(type, "dccp"))
 		proto_type = TYPE_DCCP;
 	else if (!strcmp(type, "sctp"))
@@ -795,7 +811,10 @@ static void setup(void)
 		net.run		= client_run;
 		net.cleanup	= client_cleanup;
 
-		if (proto_type == TYPE_DCCP || proto_type == TYPE_UDP) {
+		switch (proto_type) {
+		case TYPE_DCCP:
+		case TYPE_UDP:
+		case TYPE_UDP_LITE:
 			tst_res(TINFO, "max timeout errors %d", max_etime_cnt);
 			wait_timeout = 100;
 		}
@@ -812,6 +831,7 @@ static void setup(void)
 			net.cleanup	= server_cleanup;
 		break;
 		case TYPE_UDP:
+		case TYPE_UDP_LITE:
 			net.run		= server_run_udp;
 			net.cleanup	= NULL;
 		break;
@@ -830,6 +850,12 @@ static void setup(void)
 		fastopen_api = fastopen_sapi = NULL;
 		sock_type = SOCK_DGRAM;
 	break;
+	case TYPE_UDP_LITE:
+		tst_res(TINFO, "using UDP Lite");
+		fastopen_api = fastopen_sapi = NULL;
+		sock_type = SOCK_DGRAM;
+		protocol = IPPROTO_UDPLITE;
+	break;
 	case TYPE_DCCP:
 		tst_res(TINFO, "DCCP %s", (client_mode) ? "client" : "server");
 		fastopen_api = fastopen_sapi = NULL;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [LTP] [PATCH 6/9] netstress: support SO_ZEROCOPY
  2018-01-29 11:41 [LTP] [PATCH 0/9] network: add new features Alexey Kodanev
                   ` (4 preceding siblings ...)
  2018-01-29 11:41 ` [LTP] [PATCH 5/9] netstress: support UDPLITE protocol Alexey Kodanev
@ 2018-01-29 11:41 ` Alexey Kodanev
  2018-01-29 11:41 ` [LTP] [PATCH 7/9] netstress: support IP_BIND_ADDRESS_NO_PORT Alexey Kodanev
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Alexey Kodanev @ 2018-01-29 11:41 UTC (permalink / raw)
  To: ltp

SO_ZEROCOPY is available since Linux 4.14:
commit 76851d1212c1 ("sock: add SOCK_ZEROCOPY sockopt").

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 include/lapi/socket.h                   |    8 +++++
 testcases/network/netstress/netstress.c |   46 +++++++++++++++++++++++-------
 2 files changed, 43 insertions(+), 11 deletions(-)

diff --git a/include/lapi/socket.h b/include/lapi/socket.h
index a0217e1..426906f 100644
--- a/include/lapi/socket.h
+++ b/include/lapi/socket.h
@@ -21,6 +21,10 @@
 
 #include <sys/socket.h>
 
+#ifndef MSG_ZEROCOPY
+# define MSG_ZEROCOPY	0x4000000 /* Use user data in kernel path */
+#endif
+
 #ifndef MSG_FASTOPEN
 # define MSG_FASTOPEN	0x20000000 /* Send data in TCP SYN */
 #endif
@@ -29,6 +33,10 @@
 # define SO_BUSY_POLL	46
 #endif
 
+#ifndef SO_ZEROCOPY
+# define SO_ZEROCOPY	60
+#endif
+
 #ifndef SOCK_DCCP
 # define SOCK_DCCP		6
 #endif
diff --git a/testcases/network/netstress/netstress.c b/testcases/network/netstress/netstress.c
index 97de35c..d06cdae 100644
--- a/testcases/network/netstress/netstress.c
+++ b/testcases/network/netstress/netstress.c
@@ -139,6 +139,9 @@ struct sock_info {
 	int timeout;
 };
 
+static char *zcopy;
+static int send_flags = MSG_NOSIGNAL;
+
 static void init_socket_opts(int sd)
 {
 	if (busy_poll >= 0)
@@ -150,6 +153,8 @@ static void init_socket_opts(int sd)
 			SAFE_SETSOCKOPT_INT(sd, IPPROTO_TCP,
 					    TCP_FASTOPEN_CONNECT, 1);
 		}
+		if (client_mode && zcopy)
+			SAFE_SETSOCKOPT_INT(sd, SOL_SOCKET, SO_ZEROCOPY, 1);
 	break;
 	case TYPE_DCCP:
 		SAFE_SETSOCKOPT_INT(sd, SOL_DCCP, DCCP_SOCKOPT_SERVICE,
@@ -199,13 +204,25 @@ static int sock_recv_poll(char *buf, int size, struct sock_info *i)
 			break;
 		}
 
-		if (ret == 0) {
-			errno = ETIME;
+		if (ret != 1) {
+			if (!errno)
+				errno = ETIME;
 			break;
 		}
 
-		if (ret != 1 || !(pfd.revents & POLLIN))
+		if (!(pfd.revents & POLLIN)) {
+			if (pfd.revents & POLLERR) {
+				int err = 0;
+				socklen_t err_len = sizeof(err);
+
+				getsockopt(i->fd, SOL_SOCKET, SO_ERROR,
+					   &err, &err_len);
+				if (!err)
+					continue;
+				errno = err;
+			}
 			break;
+		}
 
 		errno = 0;
 		len = recvfrom(i->fd, buf, size, MSG_DONTWAIT,
@@ -270,7 +287,7 @@ static int client_connect_send(const char *msg, int size)
 
 	if (fastopen_api) {
 		/* Replaces connect() + send()/write() */
-		SAFE_SENDTO(1, cfd, msg, size, MSG_FASTOPEN | MSG_NOSIGNAL,
+		SAFE_SENDTO(1, cfd, msg, size, send_flags | MSG_FASTOPEN,
 			remote_addrinfo->ai_addr, remote_addrinfo->ai_addrlen);
 	} else {
 		if (local_addrinfo)
@@ -279,9 +296,8 @@ static int client_connect_send(const char *msg, int size)
 		/* old TCP API */
 		SAFE_CONNECT(cfd, remote_addrinfo->ai_addr,
 			     remote_addrinfo->ai_addrlen);
-		SAFE_SEND(1, cfd, msg, size, MSG_NOSIGNAL);
+		SAFE_SEND(1, cfd, msg, size, send_flags);
 	}
-
 	return cfd;
 }
 
@@ -358,7 +374,7 @@ send:
 		if (max_rand_msg_len)
 			make_client_request(client_msg, &cln_len, &srv_len);
 
-		SAFE_SEND(1, inf.fd, client_msg, cln_len, MSG_NOSIGNAL);
+		SAFE_SEND(1, inf.fd, client_msg, cln_len, send_flags);
 
 		if (client_recv(buf, srv_len, &inf)) {
 			err = errno;
@@ -559,20 +575,20 @@ void *server_fn(void *cfd)
 		switch (send_type) {
 		case 0:
 			SAFE_SEND(1, inf.fd, send_msg, send_msg_len,
-				  MSG_NOSIGNAL);
+				  send_flags);
 			if (proto_type != TYPE_SCTP)
 				++send_type;
 			break;
 		case 1:
 			SAFE_SENDTO(1, inf.fd, send_msg, send_msg_len,
-				    MSG_NOSIGNAL, (struct sockaddr *)&inf.raddr,
+				    send_flags, (struct sockaddr *)&inf.raddr,
 				    inf.raddr_len);
 			++send_type;
 			break;
 		default:
 			iov[0].iov_len = send_msg_len - 1;
 			msg.msg_namelen = inf.raddr_len;
-			SAFE_SENDMSG(send_msg_len, inf.fd, &msg, MSG_NOSIGNAL);
+			SAFE_SENDMSG(send_msg_len, inf.fd, &msg, send_flags);
 			send_type = start_send_type;
 			break;
 		}
@@ -636,8 +652,13 @@ static void server_init(void)
 			tfo_queue_size);
 	}
 
+	if (zcopy)
+		SAFE_SETSOCKOPT_INT(sfd, SOL_SOCKET, SO_ZEROCOPY, 1);
+
 	SAFE_LISTEN(sfd, max_queue_len);
+
 	tst_res(TINFO, "Listen on the socket '%d', port '%s'", sfd, tcp_port);
+
 }
 
 static void server_cleanup(void)
@@ -843,6 +864,8 @@ static void setup(void)
 		tst_res(TINFO, "TCP %s is using %s TCP API.",
 			(client_mode) ? "client" : "server",
 			(fastopen_api) ? "Fastopen" : "old");
+		if (zcopy)
+			send_flags |= MSG_ZEROCOPY;
 		check_tfo_value();
 	break;
 	case TYPE_UDP:
@@ -887,7 +910,8 @@ static struct tst_option options[] = {
 	{"S:", &source_addr, "-S x     Source address to bind"},
 	{"g:", &tcp_port, "-g x     x - server port"},
 	{"b:", &barg, "-b x     x - low latency busy poll timeout"},
-	{"T:", &type, "-T x     tcp (default), udp, dccp, sctp\n"},
+	{"T:", &type, "-T x     tcp (default), udp, dccp, sctp"},
+	{"z", &zcopy, "-z       enable SO_ZEROCOPY\n"},
 
 	{"H:", &server_addr, "Client:\n-H x     Server name or IP address"},
 	{"l", &client_mode, "-l       Become client, default is server"},
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [LTP] [PATCH 7/9] netstress: support IP_BIND_ADDRESS_NO_PORT
  2018-01-29 11:41 [LTP] [PATCH 0/9] network: add new features Alexey Kodanev
                   ` (5 preceding siblings ...)
  2018-01-29 11:41 ` [LTP] [PATCH 6/9] netstress: support SO_ZEROCOPY Alexey Kodanev
@ 2018-01-29 11:41 ` Alexey Kodanev
  2018-01-29 11:41 ` [LTP] [PATCH 8/9] network: add new test-cases with UDP LITE protocol Alexey Kodanev
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Alexey Kodanev @ 2018-01-29 11:41 UTC (permalink / raw)
  To: ltp

Added in Linux 4.2 commit 90c337da1524 ("inet: add
IP_BIND_ADDRESS_NO_PORT to overcome bind(0) limitations")

It will be enabled by default in netstress for v4.2+ kernels
if '-S' option is used.

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 include/lapi/netinet_in.h               |    4 ++++
 testcases/network/netstress/netstress.c |   27 ++++++++++++++++++++++++---
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/include/lapi/netinet_in.h b/include/lapi/netinet_in.h
index 7da7b32..427f283 100644
--- a/include/lapi/netinet_in.h
+++ b/include/lapi/netinet_in.h
@@ -28,4 +28,8 @@
 # define IPPROTO_UDPLITE	136 /* UDP-Lite (RFC 3828) */
 #endif
 
+#ifndef IP_BIND_ADDRESS_NO_PORT
+# define IP_BIND_ADDRESS_NO_PORT	24
+#endif
+
 #endif	/* LAPI_IN_H__ */
diff --git a/testcases/network/netstress/netstress.c b/testcases/network/netstress/netstress.c
index d06cdae..64fdc91 100644
--- a/testcases/network/netstress/netstress.c
+++ b/testcases/network/netstress/netstress.c
@@ -279,6 +279,25 @@ static int client_recv(char *buf, int srv_msg_len, struct sock_info *i)
 	return (errno) ? -1 : 0;
 }
 
+static int bind_no_port;
+static void bind_before_connect(int sd)
+{
+	if (!local_addrinfo)
+		return;
+
+	if (bind_no_port)
+		SAFE_SETSOCKOPT_INT(sd, SOL_IP, IP_BIND_ADDRESS_NO_PORT, 1);
+
+	SAFE_BIND(sd, local_addrinfo->ai_addr, local_addrinfo->ai_addrlen);
+
+	if (bind_no_port && proto_type != TYPE_SCTP) {
+		int port = TST_GETSOCKPORT(sd);
+
+		if (port)
+			tst_brk(TFAIL, "port not zero after bind(): %d", port);
+	}
+}
+
 static int client_connect_send(const char *msg, int size)
 {
 	int cfd = SAFE_SOCKET(family, sock_type, protocol);
@@ -290,9 +309,7 @@ static int client_connect_send(const char *msg, int size)
 		SAFE_SENDTO(1, cfd, msg, size, send_flags | MSG_FASTOPEN,
 			remote_addrinfo->ai_addr, remote_addrinfo->ai_addrlen);
 	} else {
-		if (local_addrinfo)
-			SAFE_BIND(cfd, local_addrinfo->ai_addr,
-				  local_addrinfo->ai_addrlen);
+		bind_before_connect(cfd);
 		/* old TCP API */
 		SAFE_CONNECT(cfd, remote_addrinfo->ai_addr,
 			     remote_addrinfo->ai_addrlen);
@@ -817,6 +834,10 @@ static void setup(void)
 	set_protocol_type();
 
 	if (client_mode) {
+		if (source_addr && tst_kvercmp(4, 2, 0) >= 0) {
+			bind_no_port = 1;
+			tst_res(TINFO, "IP_BIND_ADDRESS_NO_PORT is used");
+		}
 		tst_res(TINFO, "connection: addr '%s', port '%s'",
 			server_addr, tcp_port);
 		tst_res(TINFO, "client max req: %d", client_max_requests);
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [LTP] [PATCH 8/9] network: add new test-cases with UDP LITE protocol
  2018-01-29 11:41 [LTP] [PATCH 0/9] network: add new features Alexey Kodanev
                   ` (6 preceding siblings ...)
  2018-01-29 11:41 ` [LTP] [PATCH 7/9] netstress: support IP_BIND_ADDRESS_NO_PORT Alexey Kodanev
@ 2018-01-29 11:41 ` Alexey Kodanev
  2018-01-30 10:03   ` Petr Vorel
  2018-01-29 11:41 ` [LTP] [PATCH 9/9] network: new test-case for IP_BIND_ADDRESS_NO_PORT Alexey Kodanev
  2018-01-30  9:59 ` [LTP] [PATCH 0/9] network: add new features Petr Vorel
  9 siblings, 1 reply; 13+ messages in thread
From: Alexey Kodanev @ 2018-01-29 11:41 UTC (permalink / raw)
  To: ltp

Updated tests: busy_poll03, dccp01 and udp_ipsec.

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 testcases/network/busy_poll/busy_poll03.sh    |   32 ++++++++++++++----------
 testcases/network/dccp/dccp01.sh              |   28 ++++++++++++++-------
 testcases/network/stress/udp/udp_ipsec.sh     |    7 +++--
 testcases/network/stress/udp/udp_ipsec_vti.sh |    7 +++--
 4 files changed, 45 insertions(+), 29 deletions(-)

diff --git a/testcases/network/busy_poll/busy_poll03.sh b/testcases/network/busy_poll/busy_poll03.sh
index 80e0de3..6ccbbd9 100755
--- a/testcases/network/busy_poll/busy_poll03.sh
+++ b/testcases/network/busy_poll/busy_poll03.sh
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright (c) 2016 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2016-2018 Oracle and/or its affiliates.
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License as
@@ -17,7 +17,7 @@
 # Author: Alexey Kodanev <alexey.kodanev@oracle.com>
 #
 
-TST_TOTAL=1
+TST_TOTAL=2
 TCID="busy_poll03"
 TST_NEEDS_TMPDIR=1
 
@@ -45,18 +45,24 @@ rbusy_poll_old=$(tst_rhost_run -c 'cat /proc/sys/net/core/busy_poll')
 TST_CLEANUP="cleanup"
 trap "tst_brkm TBROK 'test interrupted'" INT
 
-for x in 50 0; do
-	tst_resm TINFO "set low latency busy poll to $x per socket"
-	set_busy_poll $x
-	tst_netload -H $(tst_ipaddr rhost) -d res_$x -b $x -T udp
-done
+do_test()
+{
+	for x in 50 0; do
+		tst_resm TINFO "set low latency busy poll to $x per $1 socket"
+		set_busy_poll $x
+		tst_netload -H $(tst_ipaddr rhost) -d res_$x -b $x -T $1
+	done
+
+	poll_cmp=$(( 100 - ($(cat res_50) * 100) / $(cat res_0) ))
 
-poll_cmp=$(( 100 - ($(cat res_50) * 100) / $(cat res_0) ))
+	if [ "$poll_cmp" -lt 1 ]; then
+		tst_resm TFAIL "busy poll result is '$poll_cmp' %"
+	else
+		tst_resm TPASS "busy poll increased performance by '$poll_cmp' %"
+	fi
+}
 
-if [ "$poll_cmp" -lt 1 ]; then
-	tst_resm TFAIL "busy poll result is '$poll_cmp' %"
-else
-	tst_resm TPASS "busy poll increased performance by '$poll_cmp' %"
-fi
+do_test udp
+do_test udp_lite
 
 tst_exit
diff --git a/testcases/network/dccp/dccp01.sh b/testcases/network/dccp/dccp01.sh
index 0475588..9de7f92 100755
--- a/testcases/network/dccp/dccp01.sh
+++ b/testcases/network/dccp/dccp01.sh
@@ -33,23 +33,31 @@ setup()
 	tst_require_root
 }
 
+compare()
+{
+	local per=$(( $res0 * 100 / $res1 - 100 ))
+
+	if [ "$per" -gt "100" -o "$per" -lt "-100" ]; then
+		tst_resm TFAIL "$1 performance $per %"
+	else
+		tst_resm TPASS "$1 performance $per % in range -100 ... 100 %"
+	fi
+}
+
 test_run()
 {
-	tst_resm TINFO "compare UDP/DCCP performance"
+	tst_resm TINFO "compare UDP/DCCP/UDPLITE performance"
 
 	tst_netload -H $(tst_ipaddr rhost) -T udp
-	local res0="$(cat tst_netload.res)"
+	res0="$(cat tst_netload.res)"
 
 	tst_netload -H $(tst_ipaddr rhost) -T dccp
-	local res1="$(cat tst_netload.res)"
-
-	local per=$(( $res0 * 100 / $res1 - 100 ))
+	res1="$(cat tst_netload.res)"
+	compare dccp
 
-	if [ "$per" -gt "100" -o "$per" -lt "-100" ]; then
-		tst_resm TFAIL "dccp performance $per %"
-	else
-		tst_resm TPASS "dccp performance $per % in range -100 ... 100 %"
-	fi
+	tst_netload -H $(tst_ipaddr rhost) -T udp_lite
+	res1="$(cat tst_netload.res)"
+	compare udplite
 }
 
 setup
diff --git a/testcases/network/stress/udp/udp_ipsec.sh b/testcases/network/stress/udp/udp_ipsec.sh
index ef9c31e..4ebf087 100755
--- a/testcases/network/stress/udp/udp_ipsec.sh
+++ b/testcases/network/stress/udp/udp_ipsec.sh
@@ -17,7 +17,7 @@
 # Author: Alexey Kodanev <alexey.kodanev@oracle.com>
 
 TCID=udp_ipsec
-TST_TOTAL=3
+TST_TOTAL=6
 TST_NEEDS_TMPDIR=1
 TST_CLEANUP="tst_ipsec_cleanup"
 
@@ -35,13 +35,14 @@ do_setup()
 do_test()
 {
 	for p in $IPSEC_SIZE_ARRAY; do
-		tst_netload -H $(tst_ipaddr rhost) -T udp -n $p -N $p \
+		tst_netload -H $(tst_ipaddr rhost) -T $1 -n $p -N $p \
 			-r $IPSEC_REQUESTS
 	done
 }
 
 do_setup
 
-do_test
+do_test udp
+do_test udp_lite
 
 tst_exit
diff --git a/testcases/network/stress/udp/udp_ipsec_vti.sh b/testcases/network/stress/udp/udp_ipsec_vti.sh
index c6d76c1..36a50bb 100755
--- a/testcases/network/stress/udp/udp_ipsec_vti.sh
+++ b/testcases/network/stress/udp/udp_ipsec_vti.sh
@@ -17,7 +17,7 @@
 # Author: Alexey Kodanev <alexey.kodanev@oracle.com>
 
 TCID=udp_ipsec_vti
-TST_TOTAL=3
+TST_TOTAL=6
 TST_NEEDS_TMPDIR=1
 TST_CLEANUP="tst_ipsec_cleanup"
 
@@ -26,13 +26,14 @@ TST_CLEANUP="tst_ipsec_cleanup"
 do_test()
 {
 	for p in $IPSEC_SIZE_ARRAY; do
-		tst_netload -H $ip_rmt_tun -T udp -n $p -N $p \
+		tst_netload -H $ip_rmt_tun -T $1 -n $p -N $p \
 			-r $IPSEC_REQUESTS
 	done
 }
 
 tst_ipsec_setup_vti
 
-do_test
+do_test udp
+do_test udp_lite
 
 tst_exit
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [LTP] [PATCH 9/9] network: new test-case for IP_BIND_ADDRESS_NO_PORT
  2018-01-29 11:41 [LTP] [PATCH 0/9] network: add new features Alexey Kodanev
                   ` (7 preceding siblings ...)
  2018-01-29 11:41 ` [LTP] [PATCH 8/9] network: add new test-cases with UDP LITE protocol Alexey Kodanev
@ 2018-01-29 11:41 ` Alexey Kodanev
  2018-01-30  9:59 ` [LTP] [PATCH 0/9] network: add new features Petr Vorel
  9 siblings, 0 replies; 13+ messages in thread
From: Alexey Kodanev @ 2018-01-29 11:41 UTC (permalink / raw)
  To: ltp

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 runtest/net.features                       |    3 ++
 testcases/network/sockets/Makefile         |    2 +-
 testcases/network/sockets/bind_noport01.sh |   50 ++++++++++++++++++++++++++++
 3 files changed, 54 insertions(+), 1 deletions(-)
 create mode 100755 testcases/network/sockets/bind_noport01.sh

diff --git a/runtest/net.features b/runtest/net.features
index 46c58f0..df78c04 100644
--- a/runtest/net.features
+++ b/runtest/net.features
@@ -2,6 +2,9 @@
 # Stress tests for various network features
 #
 
+bind_noport01 bind_noport01.sh
+bind_noport01_ipv6 bind_noport01.sh -6
+
 busy_poll01 busy_poll01.sh
 busy_poll01_ipv6 busy_poll01.sh -6
 
diff --git a/testcases/network/sockets/Makefile b/testcases/network/sockets/Makefile
index 057b353..a7c263a 100644
--- a/testcases/network/sockets/Makefile
+++ b/testcases/network/sockets/Makefile
@@ -24,7 +24,7 @@ top_srcdir		?= ../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
-INSTALL_TARGETS		:= ltpSockets.sh
+INSTALL_TARGETS		:= *.sh
 
 LDLIBS			+= -lpthread
 
diff --git a/testcases/network/sockets/bind_noport01.sh b/testcases/network/sockets/bind_noport01.sh
new file mode 100755
index 0000000..951712d
--- /dev/null
+++ b/testcases/network/sockets/bind_noport01.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+# Copyright (c) 2018 Oracle and/or its affiliates.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+TST_TOTAL=1
+TCID="bind_noport"
+TST_NEEDS_TMPDIR=1
+
+. test_net.sh
+
+cleanup()
+{
+	tst_rmdir
+}
+
+if tst_kvcmp -lt "4.2"; then
+	tst_brkm TCONF "test must be run with kernel 4.2+"
+fi
+
+trap "tst_brkm TBROK 'test interrupted'" INT
+TST_CLEANUP="cleanup"
+
+do_test()
+{
+	local types="tcp udp udp_lite dccp"
+	TST_NETLOAD_CLN_NUMBER=10
+	TST_NETLOAD_CLN_REQUESTS=1000
+
+	tst_resm TINFO "test IP_BIND_ADDRESS_NO_PORT with $types sockets"
+
+	for t in $types; do
+		tst_netload -T $t -S $(tst_ipaddr) -H $(tst_ipaddr rhost)
+	done
+}
+
+do_test
+
+tst_exit
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [LTP] [PATCH 0/9] network: add new features
  2018-01-29 11:41 [LTP] [PATCH 0/9] network: add new features Alexey Kodanev
                   ` (8 preceding siblings ...)
  2018-01-29 11:41 ` [LTP] [PATCH 9/9] network: new test-case for IP_BIND_ADDRESS_NO_PORT Alexey Kodanev
@ 2018-01-30  9:59 ` Petr Vorel
  9 siblings, 0 replies; 13+ messages in thread
From: Petr Vorel @ 2018-01-30  9:59 UTC (permalink / raw)
  To: ltp

> * SO_ZEROCOPY (no auto test-cases yet, can be tried manually with
>   netstress 'z' option);

> * IP_BIND_ADDRESS_NO_PORT, new bind_noport01 test;

> * one more protocol added to netstress - UDPLITE; busy_poll03, dccp01 and
>   UDP IPsec tests are updated;

> * netstress server now sends data to client using send(), sendto() and
>   sendmsg(), if protocol allows.

> Alexey Kodanev (9):
>   lib: add safe_sendmsg()
>   lib: add safe_getsockopt() and tst_getsockport()
>   netstress: make socketaddr returned by recvfrom() thread-local
>   netstress: server: write to socket with send/sendto/sendmsg
>   netstress: support UDPLITE protocol
>   netstress: support SO_ZEROCOPY
>   netstress: support IP_BIND_ADDRESS_NO_PORT
>   network: add new test-cases with UDP LITE protocol
>   network: new test-case for IP_BIND_ADDRESS_NO_PORT

>  include/lapi/netinet_in.h                     |    8 +
>  include/lapi/socket.h                         |   12 ++
>  include/lapi/udp.h                            |   30 +++
>  include/safe_net_fn.h                         |    8 +
>  include/tst_safe_net.h                        |    9 +
>  lib/safe_net.c                                |   60 ++++++
>  runtest/net.features                          |    3 +
>  testcases/network/busy_poll/busy_poll03.sh    |   32 ++--
>  testcases/network/dccp/dccp01.sh              |   28 ++-
>  testcases/network/netstress/netstress.c       |  239 +++++++++++++++++--------
>  testcases/network/sockets/Makefile            |    2 +-
>  testcases/network/sockets/bind_noport01.sh    |   50 +++++
>  testcases/network/stress/udp/udp_ipsec.sh     |    7 +-
>  testcases/network/stress/udp/udp_ipsec_vti.sh |    7 +-
>  14 files changed, 394 insertions(+), 101 deletions(-)
>  create mode 100644 include/lapi/udp.h
>  create mode 100755 testcases/network/sockets/bind_noport01.sh

LGTM, great work.
Acked-by: Petr Vorel <pvorel@suse.cz>

I'll just post a minor nit about UDPLITE vs. UDP_LITE.


Kind regards,
Petr

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [LTP] [PATCH 8/9] network: add new test-cases with UDP LITE protocol
  2018-01-29 11:41 ` [LTP] [PATCH 8/9] network: add new test-cases with UDP LITE protocol Alexey Kodanev
@ 2018-01-30 10:03   ` Petr Vorel
  2018-02-07 13:39     ` Alexey Kodanev
  0 siblings, 1 reply; 13+ messages in thread
From: Petr Vorel @ 2018-01-30 10:03 UTC (permalink / raw)
  To: ltp

Hi Alexey,

> Updated tests: busy_poll03, dccp01 and udp_ipsec.

> Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
> ---
<snip>
> +do_test udp
> +do_test udp_lite

<snip>
>  test_run()
>  {
> -	tst_resm TINFO "compare UDP/DCCP performance"
> +	tst_resm TINFO "compare UDP/DCCP/UDPLITE performance"
<snip>

> -	if [ "$per" -gt "100" -o "$per" -lt "-100" ]; then
> -		tst_resm TFAIL "dccp performance $per %"
> -	else
> -		tst_resm TPASS "dccp performance $per % in range -100 ... 100 %"
> -	fi
> +	tst_netload -H $(tst_ipaddr rhost) -T udp_lite
> +	res1="$(cat tst_netload.res)"
> +	compare udplite
This is just a minor nit.
You use udplite and udp_lite. I guess there is just one UDP-Lite protocol.
I guess using just one variant for parameters would prevent typo errors in future.

<snip>
> -do_test
> +do_test udp
> +do_test udp_lite
<snip>
> -do_test
> +do_test udp
> +do_test udp_lite


Kind regards,
Petr

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [LTP] [PATCH 8/9] network: add new test-cases with UDP LITE protocol
  2018-01-30 10:03   ` Petr Vorel
@ 2018-02-07 13:39     ` Alexey Kodanev
  0 siblings, 0 replies; 13+ messages in thread
From: Alexey Kodanev @ 2018-02-07 13:39 UTC (permalink / raw)
  To: ltp

On 30.01.2018 13:03, Petr Vorel wrote:
> Hi Alexey,
> 
>> Updated tests: busy_poll03, dccp01 and udp_ipsec.
> 
>> Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
>> ---
> <snip>
>> +do_test udp
>> +do_test udp_lite
> 
> <snip>
>>  test_run()
>>  {
>> -	tst_resm TINFO "compare UDP/DCCP performance"
>> +	tst_resm TINFO "compare UDP/DCCP/UDPLITE performance"
> <snip>
> 
>> -	if [ "$per" -gt "100" -o "$per" -lt "-100" ]; then
>> -		tst_resm TFAIL "dccp performance $per %"
>> -	else
>> -		tst_resm TPASS "dccp performance $per % in range -100 ... 100 %"
>> -	fi
>> +	tst_netload -H $(tst_ipaddr rhost) -T udp_lite
>> +	res1="$(cat tst_netload.res)"
>> +	compare udplite
> This is just a minor nit.
> You use udplite and udp_lite. I guess there is just one UDP-Lite protocol.
> I guess using just one variant for parameters would prevent typo errors in future.

Hi Petr,

Since compare() uses a protocol name for just showing it in the log,
changed it to UDP-Lite.

Thank you for review! Applied the patches.

Best regards,
Alexey

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2018-02-07 13:39 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-29 11:41 [LTP] [PATCH 0/9] network: add new features Alexey Kodanev
2018-01-29 11:41 ` [LTP] [PATCH 1/9] lib: add safe_sendmsg() Alexey Kodanev
2018-01-29 11:41 ` [LTP] [PATCH 2/9] lib: add safe_getsockopt() and tst_getsockport() Alexey Kodanev
2018-01-29 11:41 ` [LTP] [PATCH 3/9] netstress: make socketaddr returned by recvfrom() thread-local Alexey Kodanev
2018-01-29 11:41 ` [LTP] [PATCH 4/9] netstress: server: write to socket with send/sendto/sendmsg Alexey Kodanev
2018-01-29 11:41 ` [LTP] [PATCH 5/9] netstress: support UDPLITE protocol Alexey Kodanev
2018-01-29 11:41 ` [LTP] [PATCH 6/9] netstress: support SO_ZEROCOPY Alexey Kodanev
2018-01-29 11:41 ` [LTP] [PATCH 7/9] netstress: support IP_BIND_ADDRESS_NO_PORT Alexey Kodanev
2018-01-29 11:41 ` [LTP] [PATCH 8/9] network: add new test-cases with UDP LITE protocol Alexey Kodanev
2018-01-30 10:03   ` Petr Vorel
2018-02-07 13:39     ` Alexey Kodanev
2018-01-29 11:41 ` [LTP] [PATCH 9/9] network: new test-case for IP_BIND_ADDRESS_NO_PORT Alexey Kodanev
2018-01-30  9:59 ` [LTP] [PATCH 0/9] network: add new features Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.