]> git.ipfire.org Git - thirdparty/libnftnl.git/commitdiff
examples: do not call nftnl_batch_is_supported()
authorPablo Neira Ayuso <pablo@netfilter.org>
Thu, 1 Feb 2018 18:33:52 +0000 (19:33 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 14 Feb 2018 18:51:01 +0000 (19:51 +0100)
This is only required by Linux kernel <= 3.16.x, that's too old and at
that time nft was very limited in term of features, so let's remove this
check from example files.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
14 files changed:
examples/nft-chain-add.c
examples/nft-chain-del.c
examples/nft-chain-parse-add.c
examples/nft-map-add.c
examples/nft-rule-add.c
examples/nft-rule-del.c
examples/nft-rule-parse-add.c
examples/nft-ruleset-parse-file.c
examples/nft-set-add.c
examples/nft-set-parse-add.c
examples/nft-table-add.c
examples/nft-table-del.c
examples/nft-table-parse-add.c
examples/nft-table-upd.c

index e0d889df40eb147754dc49104490d3351ec84424..5796d10f8668c6ca2793e84d55f384f3ea1f1729 100644 (file)
@@ -67,7 +67,6 @@ int main(int argc, char *argv[])
        int ret, family;
        struct nftnl_chain *t;
        struct mnl_nlmsg_batch *batch;
-       int batching;
 
        if (argc != 4 && argc != 6) {
                fprintf(stderr, "Usage: %s <family> <table> <chain> "
@@ -93,19 +92,11 @@ int main(int argc, char *argv[])
        if (t == NULL)
                exit(EXIT_FAILURE);
 
-       batching = nftnl_batch_is_supported();
-       if (batching < 0) {
-               perror("cannot talk to nfnetlink");
-               exit(EXIT_FAILURE);
-       }
-
        seq = time(NULL);
        batch = mnl_nlmsg_batch_start(buf, sizeof(buf));
 
-       if (batching) {
-               nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
 
        chain_seq = seq;
        nlh = nftnl_chain_nlmsg_build_hdr(mnl_nlmsg_batch_current(batch),
@@ -115,10 +106,8 @@ int main(int argc, char *argv[])
        nftnl_chain_free(t);
        mnl_nlmsg_batch_next(batch);
 
-       if (batching) {
-               nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
 
        nl = mnl_socket_open(NETLINK_NETFILTER);
        if (nl == NULL) {
index e99bb8a2474fc4b7ce8d6d50dd83af7785c53043..09a47182fe499b3ee45edcef3cccb206f6ddad0c 100644 (file)
@@ -44,7 +44,7 @@ int main(int argc, char *argv[])
        struct nlmsghdr *nlh;
        uint32_t portid, seq, chain_seq;
        struct nftnl_chain *t;
-       int ret, family, batching;
+       int ret, family;
 
        if (argc != 4) {
                fprintf(stderr, "Usage: %s <family> <table> <chain>\n",
@@ -69,19 +69,11 @@ int main(int argc, char *argv[])
        if (t == NULL)
                exit(EXIT_FAILURE);
 
-       batching = nftnl_batch_is_supported();
-       if (batching < 0) {
-               perror("cannot talk to nfnetlink");
-               exit(EXIT_FAILURE);
-       }
-
        seq = time(NULL);
        batch = mnl_nlmsg_batch_start(buf, sizeof(buf));
 
-       if (batching) {
-               nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
 
        chain_seq = seq;
        nlh = nftnl_chain_nlmsg_build_hdr(mnl_nlmsg_batch_current(batch),
@@ -91,10 +83,8 @@ int main(int argc, char *argv[])
        nftnl_chain_free(t);
        mnl_nlmsg_batch_next(batch);
 
-       if (batching) {
-               nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
 
        nl = mnl_socket_open(NETLINK_NETFILTER);
        if (nl == NULL) {
index a9ee8e9259b2dbdbc28373d1186c303776871a8f..9198615d9a5f6d4993a5c7a6248492444867331e 100644 (file)
@@ -77,8 +77,8 @@ int main(int argc, char *argv[])
        uint32_t portid, seq, chain_seq;
        struct nftnl_chain *c;
        uint16_t family, format, outformat;
-       int ret, batching;
        struct mnl_nlmsg_batch *batch;
+       int ret;
 
        if (argc < 3) {
                printf("Usage: %s {json} <file>\n", argv[0]);
@@ -104,18 +104,11 @@ int main(int argc, char *argv[])
        family = nftnl_chain_get_u32(c, NFTNL_CHAIN_FAMILY);
 
        seq = time(NULL);
-       batching = nftnl_batch_is_supported();
-       if (batching < 0) {
-               perror("cannot talk to nfnetlink");
-               exit(EXIT_FAILURE);
-       }
 
        batch = mnl_nlmsg_batch_start(buf, sizeof(buf));
 
-       if (batching) {
-               nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
 
        chain_seq = seq;
        nlh = nftnl_chain_nlmsg_build_hdr(mnl_nlmsg_batch_current(batch),
@@ -125,10 +118,8 @@ int main(int argc, char *argv[])
        nftnl_chain_free(c);
        mnl_nlmsg_batch_next(batch);
 
-       if (batching) {
-               nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
 
        nl = mnl_socket_open(NETLINK_NETFILTER);
        if (nl == NULL) {
index a906d2dfeba9c4e3a6d42aea67040a668142aaef..d87d84160f7767540930e0aaffa5b2f547bf31d3 100644 (file)
@@ -63,7 +63,7 @@ int main(int argc, char *argv[])
        uint8_t family;
        char buf[MNL_SOCKET_BUFFER_SIZE];
        uint32_t seq = time(NULL);
-       int ret, batching;
+       int ret;
 
        if (argc != 4) {
                fprintf(stderr, "Usage: %s <family> <table> <setname>\n", argv[0]);
@@ -96,18 +96,10 @@ int main(int argc, char *argv[])
                exit(EXIT_FAILURE);
        }
 
-       batching = nftnl_batch_is_supported();
-       if (batching < 0) {
-               perror("cannot talk to nfnetlink");
-               exit(EXIT_FAILURE);
-       }
-
        batch = mnl_nlmsg_batch_start(buf, sizeof(buf));
 
-       if (batching) {
-               nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
 
        nlh = nftnl_set_nlmsg_build_hdr(mnl_nlmsg_batch_current(batch),
                                      NFT_MSG_NEWSET, family,
@@ -117,10 +109,8 @@ int main(int argc, char *argv[])
        nftnl_set_free(s);
        mnl_nlmsg_batch_next(batch);
 
-       if (batching) {
-               nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
 
        ret = mnl_socket_sendto(nl, mnl_nlmsg_batch_head(batch),
                                mnl_nlmsg_batch_size(batch));
index 3aeb2e06ee425dd37d6c6b9c9a32aeac6d1d9cc1..6aaf5a0650f8a99a19b27e444389a056fead954c 100644 (file)
@@ -126,7 +126,7 @@ int main(int argc, char *argv[])
        uint8_t family;
        char buf[MNL_SOCKET_BUFFER_SIZE];
        uint32_t seq = time(NULL);
-       int ret, batching;
+       int ret;
 
        if (argc < 4 || argc > 5) {
                fprintf(stderr, "Usage: %s <family> <table> <chain>\n", argv[0]);
@@ -158,18 +158,10 @@ int main(int argc, char *argv[])
                exit(EXIT_FAILURE);
        }
 
-       batching = nftnl_batch_is_supported();
-       if (batching < 0) {
-               perror("cannot talk to nfnetlink");
-               exit(EXIT_FAILURE);
-       }
-
        batch = mnl_nlmsg_batch_start(buf, sizeof(buf));
 
-       if (batching) {
-               nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
 
        nlh = nftnl_rule_nlmsg_build_hdr(mnl_nlmsg_batch_current(batch),
                        NFT_MSG_NEWRULE,
@@ -180,10 +172,8 @@ int main(int argc, char *argv[])
        nftnl_rule_free(r);
        mnl_nlmsg_batch_next(batch);
 
-       if (batching) {
-               nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
 
        ret = mnl_socket_sendto(nl, mnl_nlmsg_batch_head(batch),
                                mnl_nlmsg_batch_size(batch));
index 5c68363e7a749165c278b61a1035f4a89ce13495..bfd37abf1621db701290ac37bbbdff5fb9fae266 100644 (file)
@@ -30,7 +30,7 @@ int main(int argc, char *argv[])
        struct mnl_nlmsg_batch *batch;
        uint32_t portid, seq;
        struct nftnl_rule *r = NULL;
-       int ret, batching, family;
+       int ret, family;
 
        if (argc < 4 || argc > 5) {
                fprintf(stderr, "Usage: %s <family> <table> <chain> [<handle>]\n",
@@ -65,18 +65,10 @@ int main(int argc, char *argv[])
        if (argc == 5)
                nftnl_rule_set_u64(r, NFTNL_RULE_HANDLE, atoi(argv[4]));
 
-       batching = nftnl_batch_is_supported();
-       if (batching < 0) {
-               perror("cannot talk to nfnetlink");
-               exit(EXIT_FAILURE);
-       }
-
        batch = mnl_nlmsg_batch_start(buf, sizeof(buf));
 
-       if (batching) {
-               nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
 
        nlh = nftnl_rule_nlmsg_build_hdr(mnl_nlmsg_batch_current(batch),
                                NFT_MSG_DELRULE,
@@ -87,10 +79,8 @@ int main(int argc, char *argv[])
        nftnl_rule_free(r);
        mnl_nlmsg_batch_next(batch);
 
-       if (batching) {
-               nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
 
        nl = mnl_socket_open(NETLINK_NETFILTER);
        if (nl == NULL) {
index e6946c87866fe2e3ecc661420428711063203d73..3fcf2691295b82d6629e79cca6d5da0c2c9d1c91 100644 (file)
@@ -80,7 +80,7 @@ int main(int argc, char *argv[])
        struct nlmsghdr *nlh;
        uint32_t portid, seq, rule_seq;
        struct nftnl_rule *r;
-       int ret, batching;
+       int ret;
        uint16_t family, format, outformat;
 
        if (argc < 3) {
@@ -103,19 +103,11 @@ int main(int argc, char *argv[])
        nftnl_rule_fprintf(stdout, r, outformat, 0);
        fprintf(stdout, "\n");
 
-       batching = nftnl_batch_is_supported();
-       if (batching < 0) {
-               perror("Cannot talk to nfnetlink");
-               exit(EXIT_FAILURE);
-       }
-
        seq = time(NULL);
        batch = mnl_nlmsg_batch_start(buf, sizeof(buf));
 
-       if (batching) {
-               nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
 
        rule_seq = seq;
        family = nftnl_rule_get_u32(r, NFTNL_RULE_FAMILY);
@@ -127,10 +119,8 @@ int main(int argc, char *argv[])
        nftnl_rule_free(r);
        mnl_nlmsg_batch_next(batch);
 
-       if (batching) {
-               nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
 
        nl = mnl_socket_open(NETLINK_NETFILTER);
        if (nl == NULL) {
index 505c43c78da8498569afcbc95279314a2606ecb6..be0994fd84f55c1ebf634438eef6646887201c01 100644 (file)
@@ -379,7 +379,7 @@ int main(int argc, char *argv[])
        struct nftnl_parse_err *err;
        const char *filename;
        FILE *fp;
-       int ret = -1, len, batching, portid;
+       int ret = -1, len, portid;
        uint32_t ruleset_seq;
        char buf[MNL_SOCKET_BUFFER_SIZE];
        struct mnl_socket *nl;
@@ -402,19 +402,11 @@ int main(int argc, char *argv[])
                exit(EXIT_FAILURE);
        }
 
-       batching = nftnl_batch_is_supported();
-       if (batching < 0) {
-               perror("Cannot talk to nfnetlink");
-               exit(EXIT_FAILURE);
-       }
-
        seq = time(NULL);
        batch = mnl_nlmsg_batch_start(buf, sizeof(buf));
 
-       if (batching) {
-               nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
        ruleset_seq = seq;
 
        filename = argv[1];
@@ -435,10 +427,8 @@ int main(int argc, char *argv[])
 
        fclose(fp);
 
-       if (batching) {
-               nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
 
        nl = mnl_socket_open(NETLINK_NETFILTER);
        if (nl == NULL) {
index bdb93737a9e03d9f10e98dcdb13534048a7c67a5..d8e3e4e848b6c7e3b6e6a43c6d66f192e4731793 100644 (file)
@@ -59,7 +59,7 @@ int main(int argc, char *argv[])
        uint8_t family;
        char buf[MNL_SOCKET_BUFFER_SIZE];
        uint32_t seq = time(NULL);
-       int ret, batching;
+       int ret;
 
        if (argc != 4) {
                fprintf(stderr, "Usage: %s <family> <table> <setname>\n", argv[0]);
@@ -92,18 +92,10 @@ int main(int argc, char *argv[])
                exit(EXIT_FAILURE);
        }
 
-       batching = nftnl_batch_is_supported();
-       if (batching < 0) {
-               perror("cannot talk to nfnetlink");
-               exit(EXIT_FAILURE);
-       }
-
        batch = mnl_nlmsg_batch_start(buf, sizeof(buf));
 
-       if (batching) {
-               nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
 
        nlh = nftnl_set_nlmsg_build_hdr(mnl_nlmsg_batch_current(batch),
                                      NFT_MSG_NEWSET, family,
@@ -113,10 +105,8 @@ int main(int argc, char *argv[])
        nftnl_set_free(s);
        mnl_nlmsg_batch_next(batch);
 
-       if (batching) {
-               nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
 
        ret = mnl_socket_sendto(nl, mnl_nlmsg_batch_head(batch),
                                mnl_nlmsg_batch_size(batch));
index 2882f141551c6cf439ef261b4b40d25f3d84efd4..5197dc30aafe8dc4c9e153d2132c4828155e025a 100644 (file)
@@ -80,9 +80,9 @@ int main(int argc, char *argv[])
        struct nlmsghdr *nlh;
        uint32_t portid, seq, set_seq;
        struct nftnl_set *s;
-       int ret, batching;
        uint16_t family, format, outformat;
        struct mnl_nlmsg_batch *batch;
+       int ret;
 
        if (argc < 2) {
                printf("Usage: %s {json} <file>\n", argv[0]);
@@ -105,18 +105,11 @@ int main(int argc, char *argv[])
        fprintf(stdout, "\n");
 
        seq = time(NULL);
-       batching = nftnl_batch_is_supported();
-       if (batching < 0) {
-               perror("cannot talk to nfnetlink");
-               exit(EXIT_FAILURE);
-       }
 
        batch = mnl_nlmsg_batch_start(buf, sizeof(buf));
 
-       if (batching) {
-               nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
 
        family = nftnl_set_get_u32(s, NFTNL_SET_FAMILY);
 
@@ -128,10 +121,8 @@ int main(int argc, char *argv[])
        nftnl_set_free(s);
        mnl_nlmsg_batch_next(batch);
 
-       if (batching) {
-               nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
 
        nl = mnl_socket_open(NETLINK_NETFILTER);
        if (nl == NULL) {
index aa6e2688fb6e33b1dc73b8c1d00dc0649573e478..4418a51fb010cb3214d0affcab5ffd65c95c7ccd 100644 (file)
@@ -58,7 +58,7 @@ int main(int argc, char *argv[])
        uint32_t portid, seq, table_seq, family;
        struct nftnl_table *t;
        struct mnl_nlmsg_batch *batch;
-       int ret, batching;
+       int ret;
 
        if (argc != 3) {
                fprintf(stderr, "%s <family> <name>\n", argv[0]);
@@ -69,19 +69,11 @@ int main(int argc, char *argv[])
        if (t == NULL)
                exit(EXIT_FAILURE);
 
-       batching = nftnl_batch_is_supported();
-       if (batching < 0) {
-               perror("cannot talk to nfnetlink");
-               exit(EXIT_FAILURE);
-       }
-
        seq = time(NULL);
        batch = mnl_nlmsg_batch_start(buf, sizeof(buf));
 
-       if (batching) {
-               nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
 
        table_seq = seq;
        family = nftnl_table_get_u32(t, NFTNL_TABLE_FAMILY);
@@ -92,10 +84,8 @@ int main(int argc, char *argv[])
        nftnl_table_free(t);
        mnl_nlmsg_batch_next(batch);
 
-       if (batching) {
-               nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
 
        nl = mnl_socket_open(NETLINK_NETFILTER);
        if (nl == NULL) {
index 9d1f3be97bf03755d18f45bb5876f54c07d51efd..aa1827d7168cd18b5439a365c39199160cb4ecb1 100644 (file)
@@ -58,7 +58,7 @@ int main(int argc, char *argv[])
        uint32_t portid, seq, table_seq, family;
        struct nftnl_table *t;
        struct mnl_nlmsg_batch *batch;
-       int ret, batching;
+       int ret;
 
        if (argc != 3) {
                fprintf(stderr, "%s <family> <name>\n", argv[0]);
@@ -69,19 +69,11 @@ int main(int argc, char *argv[])
        if (t == NULL)
                exit(EXIT_FAILURE);
 
-       batching = nftnl_batch_is_supported();
-       if (batching < 0) {
-               perror("cannot talk to nfnetlink");
-               exit(EXIT_FAILURE);
-       }
-
        seq = time(NULL);
        batch = mnl_nlmsg_batch_start(buf, sizeof(buf));
 
-       if (batching) {
-               nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
 
        table_seq = seq;
        family = nftnl_table_get_u32(t, NFTNL_TABLE_FAMILY);
@@ -92,10 +84,8 @@ int main(int argc, char *argv[])
        mnl_nlmsg_batch_next(batch);
        nftnl_table_free(t);
 
-       if (batching) {
-               nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
 
        nl = mnl_socket_open(NETLINK_NETFILTER);
        if (nl == NULL) {
index cb4bcc67dced2ba7e70381249d64d9ab54fbb9ca..55dbc132ecead92cdcbf5556ea61a5cda75a25ae 100644 (file)
@@ -75,9 +75,9 @@ int main(int argc, char *argv[])
        struct nlmsghdr *nlh;
        uint32_t portid, seq, table_seq;
        struct nftnl_table *t = NULL;
-       int ret, batching;
        uint16_t family, format, outformat;
        struct mnl_nlmsg_batch *batch;
+       int ret;
 
        if (argc < 3) {
                printf("Usage: %s {json} <file>\n", argv[0]);
@@ -100,18 +100,11 @@ int main(int argc, char *argv[])
        fprintf(stdout, "\n");
 
        seq = time(NULL);
-       batching = nftnl_batch_is_supported();
-       if (batching < 0) {
-               perror("cannot talk to nfnetlink");
-               exit(EXIT_FAILURE);
-       }
 
        batch = mnl_nlmsg_batch_start(buf, sizeof(buf));
 
-       if (batching) {
-               nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
 
        family = nftnl_table_get_u32(t, NFTNL_TABLE_FAMILY);
 
@@ -123,10 +116,8 @@ int main(int argc, char *argv[])
        nftnl_table_free(t);
        mnl_nlmsg_batch_next(batch);
 
-       if (batching) {
-               nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
 
        nl = mnl_socket_open(NETLINK_NETFILTER);
        if (nl == NULL) {
index 9b960bbfdf24351d2c8eddf02e67ed131000f51c..586d84ca48a6f2a4aad3d9bff1fbe7263c68761d 100644 (file)
@@ -28,7 +28,7 @@ int main(int argc, char *argv[])
        uint32_t portid, seq, table_seq, family, flags;
        struct nftnl_table *t = NULL;
        struct mnl_nlmsg_batch *batch;
-       int ret, batching;
+       int ret;
 
        if (argc != 4) {
                fprintf(stderr, "%s <family> <name> <state>\n", argv[0]);
@@ -41,19 +41,11 @@ int main(int argc, char *argv[])
                exit(EXIT_FAILURE);
        }
 
-       batching = nftnl_batch_is_supported();
-       if (batching < 0) {
-               perror("cannot talk to nfnetlink");
-               exit(EXIT_FAILURE);
-       }
-
        seq = time(NULL);
        batch = mnl_nlmsg_batch_start(buf, sizeof(buf));
 
-       if (batching) {
-               nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_begin(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
 
        if (strcmp(argv[1], "ip") == 0)
                family = NFPROTO_IPV4;
@@ -91,10 +83,8 @@ int main(int argc, char *argv[])
        nftnl_table_free(t);
        mnl_nlmsg_batch_next(batch);
 
-       if (batching) {
-               nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
-               mnl_nlmsg_batch_next(batch);
-       }
+       nftnl_batch_end(mnl_nlmsg_batch_current(batch), seq++);
+       mnl_nlmsg_batch_next(batch);
 
        nl = mnl_socket_open(NETLINK_NETFILTER);
        if (nl == NULL) {