[PATCH 4/4] tests: add check for decoding of NETLINK_CRYPTO nlmsg_flags

JingPiao Chen chenjingpiao at gmail.com
Sun Jul 9 14:48:30 UTC 2017


* tests/netlink_crypto.c (test_nlmsg_flags): New function.
(main): Use it.
---
 tests/netlink_crypto.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/tests/netlink_crypto.c b/tests/netlink_crypto.c
index c43b8e9..376baa8 100644
--- a/tests/netlink_crypto.c
+++ b/tests/netlink_crypto.c
@@ -53,6 +53,40 @@ test_nlmsg_type(const int fd)
 	       fd, nlh.nlmsg_len, (unsigned) sizeof(nlh), sprintrc(rc));
 }
 
+static void
+test_nlmsg_flags(const int fd)
+{
+	long rc;
+	struct nlmsghdr nlh = {
+		.nlmsg_len = sizeof(nlh),
+	};
+
+	nlh.nlmsg_type = CRYPTO_MSG_GETALG;
+	nlh.nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP;
+	rc = sendto(fd, &nlh, sizeof(nlh), MSG_DONTWAIT, NULL, 0);
+	printf("sendto(%d, {len=%u, type=CRYPTO_MSG_GETALG"
+	       ", flags=NLM_F_REQUEST|NLM_F_DUMP, seq=0, pid=0}"
+	       ", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
+	       fd, nlh.nlmsg_len, (unsigned) sizeof(nlh), sprintrc(rc));
+
+	nlh.nlmsg_type = CRYPTO_MSG_NEWALG;
+	nlh.nlmsg_flags = NLM_F_ECHO | NLM_F_REPLACE;
+	rc = sendto(fd, &nlh, sizeof(nlh), MSG_DONTWAIT, NULL, 0);
+	printf("sendto(%d, {len=%u, type=CRYPTO_MSG_NEWALG"
+	       ", flags=NLM_F_ECHO|NLM_F_REPLACE, seq=0, pid=0}"
+	       ", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
+	       fd, nlh.nlmsg_len, (unsigned) sizeof(nlh), sprintrc(rc));
+
+	nlh.nlmsg_type = CRYPTO_MSG_DELALG;
+	nlh.nlmsg_flags = NLM_F_REPLACE;
+	rc = sendto(fd, &nlh, sizeof(nlh), MSG_DONTWAIT, NULL, 0);
+	printf("sendto(%d, {len=%u, type=CRYPTO_MSG_DELALG"
+	       ", flags=%#x /* NLM_F_??? */, seq=0, pid=0}"
+	       ", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
+	       fd, nlh.nlmsg_len, NLM_F_REPLACE,
+	       (unsigned) sizeof(nlh), sprintrc(rc));
+}
+
 int
 main(void)
 {
@@ -61,6 +95,7 @@ main(void)
 	int fd = create_nl_socket(NETLINK_CRYPTO);
 
 	test_nlmsg_type(fd);
+	test_nlmsg_flags(fd);
 
 	printf("+++ exited with 0 +++\n");
 
-- 
2.7.4





More information about the Strace-devel mailing list