summaryrefslogtreecommitdiffstats
path: root/examples/nft-rule-xml-add.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2013-07-10 18:34:57 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2013-07-10 18:51:11 +0200
commit013227cb6f13cbab2fbccbeb750199a051fd7a43 (patch)
treedb99a745cdbe3eaa21b0689852591be5098fb358 /examples/nft-rule-xml-add.c
parenta73f84d41b93c7945acdbdc92199e1c257887191 (diff)
examples: nft-{table,chain,rule}-xml-add: fix missing NLM_F_CREATE
Thus, automodule loading was not working. While at it, apply not so relevant comestic cleanups and fix some inconsistencies between examples. * Fix copyright header, this is code heavily based on existing nft-*-add examples. * Remove unrequired extern struct nft_table definition. * Make sure we close file descriptor once we don't need it anymore. * Remove unrequired casting. * Remove comment that provides nothing interesting. I considered a patch to address each on those was too much burden. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'examples/nft-rule-xml-add.c')
-rw-r--r--examples/nft-rule-xml-add.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/examples/nft-rule-xml-add.c b/examples/nft-rule-xml-add.c
index 7bd44ff..4de7a69 100644
--- a/examples/nft-rule-xml-add.c
+++ b/examples/nft-rule-xml-add.c
@@ -1,10 +1,13 @@
/*
- * 2013 by Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
+ * (C) 2013 by Pablo Neira Ayuso <pablo@netfilter.org>
+ * (C) 2013 by Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
+ *
+ * This code has been sponsored by Sophos Astaro <http://www.sophos.com>
*/
#include <stdlib.h>
@@ -52,6 +55,7 @@ int main(int argc, char *argv[])
close(fd);
exit(EXIT_FAILURE);
}
+ close(fd);
r = nft_rule_alloc();
if (r == NULL) {
@@ -72,7 +76,8 @@ int main(int argc, char *argv[])
seq = time(NULL);
nlh = nft_rule_nlmsg_build_hdr(buf, NFT_MSG_NEWRULE, family,
- NLM_F_APPEND|NLM_F_ACK, seq);
+ NLM_F_CREATE|NLM_F_APPEND|NLM_F_ACK,
+ seq);
nft_rule_nlmsg_build_payload(nlh, r);
nft_rule_free(r);