]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: add new --debug=mnl option to enable libmnl debugging
authorPablo Neira Ayuso <pablo@netfilter.org>
Thu, 16 Jan 2014 16:42:02 +0000 (17:42 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 16 Jan 2014 18:47:50 +0000 (19:47 +0100)
This allows you to dump the netlink message that is send via
libmnl.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/nftables.h
src/main.c
src/mnl.c

index f9891619dae397f4549f50904a54a9895a314c80..b36e10ae96976cdefe4bd499b1f1ec9ef2cbbbe2 100644 (file)
@@ -18,6 +18,7 @@ enum debug_level {
        DEBUG_EVALUATION        = 0x4,
        DEBUG_NETLINK           = 0x8,
        DEBUG_SEGTREE           = 0x10,
+       DEBUG_MNL               = 0x20,
 };
 
 #define INCLUDE_PATHS_MAX      16
index d78eea79ba93a1040de21633b2a2b6d0ebeda79e..3f5dd04e3fe20737f76ef1d5648d902599d54fc0 100644 (file)
@@ -111,7 +111,7 @@ static void show_help(const char *name)
 "  -a/--handle                 Output rule handle.\n"
 "  -I/--includepath <directory>        Add <directory> to the paths searched for include files.\n"
 #ifdef DEBUG
-"  --debug <level [,level...]> Specify debugging level (scanner, parser, eval, netlink, segtree, all)\n"
+"  --debug <level [,level...]> Specify debugging level (scanner, parser, eval, netlink, mnl, segtree, all)\n"
 #endif
 "\n",
        name);
@@ -138,6 +138,10 @@ static const struct {
                .name           = "netlink",
                .level          = DEBUG_NETLINK,
        },
+       {
+               .name           = "mnl",
+               .level          = DEBUG_MNL,
+       },
        {
                .name           = "segtree",
                .level          = DEBUG_SEGTREE,
index a4a4c4afe5a44575662e4efbb7163fcb01bbbd5f..1662500095f592ca4dc5410ae7fd4fc8456e564f 100644 (file)
--- a/src/mnl.c
+++ b/src/mnl.c
@@ -39,7 +39,7 @@ mnl_talk(struct mnl_socket *nf_sock, const void *data, unsigned int len,
        int ret;
 
 #ifdef DEBUG
-       if (debug_level & DEBUG_NETLINK)
+       if (debug_level & DEBUG_MNL)
                mnl_nlmsg_fprintf(stdout, data, len, sizeof(struct nfgenmsg));
 #endif
 
@@ -207,7 +207,7 @@ static ssize_t mnl_nft_socket_sendmsg(const struct mnl_socket *nl)
                iov[i].iov_len = mnl_nlmsg_batch_size(batch_page->batch);
                i++;
 #ifdef DEBUG
-               if (debug_level & DEBUG_NETLINK) {
+               if (debug_level & DEBUG_MNL) {
                        mnl_nlmsg_fprintf(stdout,
                                          mnl_nlmsg_batch_head(batch_page->batch),
                                          mnl_nlmsg_batch_size(batch_page->batch),