Skip to contentSkip to conversation

example: remove nftnl_batch_is_supported() call

PATCH New Pablo Neira Ayuso 1 participant 1 message Nov 14, 2022 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 example: remove nftnl_batch_is_supported() call

Linux kernel <= 3.13 needs for this check, remove it from examples.

Kernel commit:

958bee14d071 ("netfilter: nf_tables: use new transaction infrastructure to handle sets")

added support for set into the batch.

---
 examples/nft-flowtable-add.c | 19 ++++---------------
 examples/nft-flowtable-del.c | 20 +++++---------------
 2 files changed, 9 insertions(+), 30 deletions(-)
examples/nft-flowtable-add.c +4 -15
index 5ca62be01a01..4e0e50b95cbf 100644
@@ -47,7 +47,6 @@ int main(int argc, char *argv[])
 	int ret, family;
 	struct nftnl_flowtable *t;
 	struct mnl_nlmsg_batch *batch;
-	int batching;
 
 	if (argc != 6) {
 		fprintf(stderr, "Usage: %s <family> <table> <name> <hook> <prio>\n",
@@ -74,19 +73,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);
 
 	flowtable_seq = seq;
 	nlh = nftnl_flowtable_nlmsg_build_hdr(mnl_nlmsg_batch_current(batch),
@@ -96,10 +87,8 @@ int main(int argc, char *argv[])
 	nftnl_flowtable_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) {
examples/nft-flowtable-del.c +5 -15
index 91e5d3a74410..ffc83b25f716 100644
@@ -33,7 +33,7 @@ int main(int argc, char *argv[])
 	struct nlmsghdr *nlh;
 	uint32_t portid, seq, flowtable_seq;
 	struct nftnl_flowtable *t;
-	int ret, family, batching;
+	int ret, family;
 
 	if (argc != 4) {
 		fprintf(stderr, "Usage: %s <family> <table> <flowtable>\n",
@@ -60,19 +60,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);
 
 	flowtable_seq = seq;
 	nlh = nftnl_flowtable_nlmsg_build_hdr(mnl_nlmsg_batch_current(batch),
@@ -82,10 +74,8 @@ int main(int argc, char *argv[])
 	nftnl_flowtable_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) {
Signature · 1 line
2.30.2