]> granicus.if.org Git - strace/commitdiff
tests: add check for decoding of netfilter subsystem
authorChen Jingpiao <chenjingpiao@gmail.com>
Sun, 11 Mar 2018 12:14:57 +0000 (20:14 +0800)
committerDmitry V. Levin <ldv@altlinux.org>
Sun, 11 Mar 2018 15:35:19 +0000 (15:35 +0000)
* tests/netlink_netfilter.c(test_nfgenmsg): Add check for decoding
of netfilter subsystem.

tests/netlink_netfilter.c

index 2826017d156dabb58b9ee4e9995b761b92d2df35..57532f5295a9781a205f3b0a970120d6d42b0eae 100644 (file)
@@ -164,6 +164,27 @@ test_nfgenmsg(const int fd)
                     printf(", res_id=htons(%d)"
                            ", \"\\x31\\x32\\x33\\x34\"", 0xabcd));
 # endif /* NFNL_MSG_BATCH_BEGIN */
+
+       static const struct nlattr nla = {
+               .nla_len = sizeof(nla),
+               .nla_type = 0x0bcd
+       };
+       char nla_buf[NLMSG_ALIGN(sizeof(msg)) + sizeof(nla)];
+
+       msg.res_id = htons(NFNL_SUBSYS_NFTABLES);
+       memcpy(nla_buf, &msg, sizeof(msg));
+       memcpy(nla_buf + NLMSG_ALIGN(sizeof(msg)), &nla, sizeof(nla));
+
+       TEST_NETLINK_(fd, nlh0,
+                     NFNL_SUBSYS_NFTABLES << 8 | 0xff,
+                     "NFNL_SUBSYS_NFTABLES<<8|0xff /* NFT_MSG_??? */",
+                     NLM_F_REQUEST, "NLM_F_REQUEST",
+                     sizeof(nla_buf), nla_buf, sizeof(nla_buf),
+                     printf("{nfgen_family=AF_UNIX");
+                     printf(", version=NFNETLINK_V0");
+                     printf(", res_id=htons(NFNL_SUBSYS_NFTABLES)"
+                            ", {nla_len=%d, nla_type=%#x}",
+                            nla.nla_len, nla.nla_type));
 }
 
 int main(void)