2 * Copyright (c) 2017 JingPiao Chen <chenjingpiao@gmail.com>
3 * Copyright (c) 2017-2018 The strace developers.
6 * SPDX-License-Identifier: GPL-2.0-or-later
11 #ifdef HAVE_LINUX_NETFILTER_NFNETLINK_CTTIMEOUT_H
14 # include <sys/socket.h>
16 # include <linux/netfilter/nfnetlink.h>
17 # include <linux/netfilter/nfnetlink_cttimeout.h>
20 test_nlmsg_type(const int fd)
23 struct nlmsghdr nlh = {
24 .nlmsg_len = sizeof(nlh),
25 .nlmsg_flags = NLM_F_REQUEST,
29 NFNL_SUBSYS_CTNETLINK_TIMEOUT << 8 | IPCTNL_MSG_TIMEOUT_NEW;
30 rc = sendto(fd, &nlh, nlh.nlmsg_len, MSG_DONTWAIT, NULL, 0);
31 printf("sendto(%d, {len=%u"
32 ", type=NFNL_SUBSYS_CTNETLINK_TIMEOUT<<8|IPCTNL_MSG_TIMEOUT_NEW"
33 ", flags=NLM_F_REQUEST, seq=0, pid=0}"
34 ", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
35 fd, nlh.nlmsg_len, nlh.nlmsg_len, sprintrc(rc));
37 nlh.nlmsg_type = NFNL_SUBSYS_CTNETLINK_TIMEOUT << 8 | 0xff;
38 rc = sendto(fd, &nlh, nlh.nlmsg_len, MSG_DONTWAIT, NULL, 0);
39 printf("sendto(%d, {len=%u"
40 ", type=NFNL_SUBSYS_CTNETLINK_TIMEOUT<<8|0xff /* IPCTNL_MSG_TIMEOUT_??? */"
41 ", flags=NLM_F_REQUEST, seq=0, pid=0}"
42 ", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
43 fd, nlh.nlmsg_len, nlh.nlmsg_len, sprintrc(rc));
47 test_nlmsg_flags(const int fd)
50 struct nlmsghdr nlh = {
51 .nlmsg_len = sizeof(nlh),
55 NFNL_SUBSYS_CTNETLINK_TIMEOUT << 8 | IPCTNL_MSG_TIMEOUT_NEW;
56 nlh.nlmsg_flags = NLM_F_REQUEST | NLM_F_APPEND;
57 rc = sendto(fd, &nlh, nlh.nlmsg_len, MSG_DONTWAIT, NULL, 0);
58 printf("sendto(%d, {len=%u"
59 ", type=NFNL_SUBSYS_CTNETLINK_TIMEOUT<<8|IPCTNL_MSG_TIMEOUT_NEW"
60 ", flags=NLM_F_REQUEST|NLM_F_APPEND, seq=0, pid=0}"
61 ", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
62 fd, nlh.nlmsg_len, nlh.nlmsg_len, sprintrc(rc));
65 NFNL_SUBSYS_CTNETLINK_TIMEOUT << 8 | IPCTNL_MSG_TIMEOUT_GET;
66 nlh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ATOMIC;
67 rc = sendto(fd, &nlh, nlh.nlmsg_len, MSG_DONTWAIT, NULL, 0);
68 printf("sendto(%d, {len=%u"
69 ", type=NFNL_SUBSYS_CTNETLINK_TIMEOUT<<8|IPCTNL_MSG_TIMEOUT_GET"
70 ", flags=NLM_F_REQUEST|NLM_F_ATOMIC, seq=0, pid=0}"
71 ", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
72 fd, nlh.nlmsg_len, nlh.nlmsg_len, sprintrc(rc));
75 NFNL_SUBSYS_CTNETLINK_TIMEOUT << 8 | IPCTNL_MSG_TIMEOUT_DELETE;
76 nlh.nlmsg_flags = NLM_F_REQUEST | NLM_F_NONREC;
77 rc = sendto(fd, &nlh, nlh.nlmsg_len, MSG_DONTWAIT, NULL, 0);
78 printf("sendto(%d, {len=%u"
79 ", type=NFNL_SUBSYS_CTNETLINK_TIMEOUT<<8|IPCTNL_MSG_TIMEOUT_DELETE"
80 ", flags=NLM_F_REQUEST|NLM_F_NONREC, seq=0, pid=0}"
81 ", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
82 fd, nlh.nlmsg_len, nlh.nlmsg_len, sprintrc(rc));
88 skip_if_unavailable("/proc/self/fd/");
90 int fd = create_nl_socket(NETLINK_NETFILTER);
95 puts("+++ exited with 0 +++");
102 SKIP_MAIN_UNDEFINED("HAVE_LINUX_NETFILTER_NFNETLINK_CTTIMEOUT_H")