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_NF_TABLES_COMPAT_H
14 # include <sys/socket.h>
16 # include <linux/netfilter/nfnetlink.h>
17 # include <linux/netfilter/nf_tables_compat.h>
20 test_nlmsg_type(const int fd)
23 struct nlmsghdr nlh = {
24 .nlmsg_len = sizeof(nlh),
25 .nlmsg_flags = NLM_F_REQUEST,
28 nlh.nlmsg_type = NFNL_SUBSYS_NFT_COMPAT << 8 | NFNL_MSG_COMPAT_GET;
29 rc = sendto(fd, &nlh, nlh.nlmsg_len, MSG_DONTWAIT, NULL, 0);
30 printf("sendto(%d, {len=%u"
31 ", type=NFNL_SUBSYS_NFT_COMPAT<<8|NFNL_MSG_COMPAT_GET"
32 ", flags=NLM_F_REQUEST, seq=0, pid=0}"
33 ", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
34 fd, nlh.nlmsg_len, nlh.nlmsg_len, sprintrc(rc));
36 nlh.nlmsg_type = NFNL_SUBSYS_NFT_COMPAT << 8 | 0xff;
37 rc = sendto(fd, &nlh, nlh.nlmsg_len, MSG_DONTWAIT, NULL, 0);
38 printf("sendto(%d, {len=%u"
39 ", type=NFNL_SUBSYS_NFT_COMPAT<<8|0xff /* NFNL_MSG_COMPAT_??? */"
40 ", flags=NLM_F_REQUEST, seq=0, pid=0}"
41 ", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
42 fd, nlh.nlmsg_len, nlh.nlmsg_len, sprintrc(rc));
46 test_nlmsg_flags(const int fd)
49 struct nlmsghdr nlh = {
50 .nlmsg_len = sizeof(nlh),
53 nlh.nlmsg_type = NFNL_SUBSYS_NFT_COMPAT << 8 | NFNL_MSG_COMPAT_GET;
54 nlh.nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP;
55 rc = sendto(fd, &nlh, nlh.nlmsg_len, MSG_DONTWAIT, NULL, 0);
56 printf("sendto(%d, {len=%u"
57 ", type=NFNL_SUBSYS_NFT_COMPAT<<8|NFNL_MSG_COMPAT_GET"
58 ", flags=NLM_F_REQUEST|NLM_F_DUMP, seq=0, pid=0}"
59 ", %u, MSG_DONTWAIT, NULL, 0) = %s\n",
60 fd, nlh.nlmsg_len, nlh.nlmsg_len, sprintrc(rc));
66 skip_if_unavailable("/proc/self/fd/");
68 int fd = create_nl_socket(NETLINK_NETFILTER);
73 puts("+++ exited with 0 +++");
80 SKIP_MAIN_UNDEFINED("HAVE_LINUX_NETFILTER_NF_TABLES_COMPAT_H")