]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
doc: Improve example in libnftables-json(5)
authorPhil Sutter <phil@nwl.cc>
Wed, 29 Aug 2018 14:23:20 +0000 (16:23 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 30 Aug 2018 10:19:36 +0000 (12:19 +0200)
The introductory example was a bit flawed in that the third command
('list ruleset') wouldn't yield expected results due to all three
commands ending in a single transaction and therefore the changes of the
first two commands were not committed yet at the time ruleset was
listed.

Instead demonstrate adding a chain and a rule to the new table.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
doc/libnftables-json.adoc

index ce1d3af83122cb5c6be83117a01808a5dc7e3c86..af49adf740881e79a75ca4e1d9168d87d13e78cf 100644 (file)
@@ -68,7 +68,8 @@ order of appearance. For instance, the following standard syntax input:
 ----
 flush ruleset
 add table inet mytable
-list ruleset
+add chain inet mytable mychain
+add rule inet mytable mychain tcp dport 22 accept
 ----
 
 translates into JSON as such:
@@ -76,8 +77,30 @@ translates into JSON as such:
 ----
 { "nftables": [
        { "flush": { "ruleset": null }},
-       { "add": { "table": { "family": "inet", "name": "mytable" }}},
-       { "list": { "ruleset": null }}
+       { "add": { "table": {
+                       "family": "inet",
+                       "name": "mytable"
+       }}},
+       { "add": { "chain": {
+                       "family": "inet",
+                       "table": "mytable",
+                       "chain": "mychain"
+       }}}
+       { "add": { "rule": {
+                       "family": "inet",
+                       "table": "mytable",
+                       "chain": "mychain",
+                       "expr": [
+                               { "match": {
+                                       "left": { "payload": {
+                                                       "name": "tcp",
+                                                       "field": "dport"
+                                       }},
+                                       "right": 22
+                               }},
+                               { "accept": null }
+                       ]
+       }}}
 ]}
 ----