[2/2] test: inet, raw -- Storm the test with all protos

Submitted by Cyrill Gorcunov on Nov. 15, 2018, 3:14 p.m.

Details

Message ID 20181115151428.719-3-gorcunov@gmail.com
State Accepted
Series "ip-raw: A fix and test enhancement"
Headers show

Commit Message

Cyrill Gorcunov Nov. 15, 2018, 3:14 p.m.
Raw sockets may carry any protocol they want so
lets try them out.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 test/zdtm/static/socket-raw.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

Patch hide | download patch | download mbox

diff --git a/test/zdtm/static/socket-raw.c b/test/zdtm/static/socket-raw.c
index 355addb1c6a5..9a359485d73a 100644
--- a/test/zdtm/static/socket-raw.c
+++ b/test/zdtm/static/socket-raw.c
@@ -154,6 +154,30 @@  static unsigned short csum(unsigned short *ptr, int nbytes)
 	return answer;
 }
 
+/*
+ * Just create IPv6/IPv6 sockets with any protos
+ * to make sure criu won't BUG on unknown proto.
+ */
+static void raw_socks_storm(void)
+{
+	int sk4[IPPROTO_MAX];
+	int sk6[IPPROTO_MAX];
+	size_t i;
+
+
+	for (i = 1; i < ARRAY_SIZE(sk4); i++) {
+		sk4[i] = socket(PF_INET, SOCK_RAW | SOCK_NONBLOCK, i);
+		if (sk4[i] >= 0)
+			test_msg("Created IPv4 proto %zd: %d\n", i, sk4[i]);
+	}
+
+	for (i = 1; i < ARRAY_SIZE(sk6); i++) {
+		sk6[i] = socket(PF_INET6, SOCK_RAW | SOCK_NONBLOCK, i);
+		if (sk6[i] >= 0)
+			test_msg("Created IPv6 proto %zd: %d\n", i, sk6[i]);
+	}
+}
+
 int main(int argc, char *argv[])
 {
 	const char string_data[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
@@ -340,6 +364,8 @@  int main(int argc, char *argv[])
 		exit(1);
 	}
 
+	raw_socks_storm();
+
 	test_daemon();
 	test_waitsig();