summaryrefslogtreecommitdiffstats
path: root/include/expression.h
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2018-03-06 18:58:29 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2018-03-07 12:48:03 +0100
commita43cc8d53096de069fab5d9bf1a2cc7b655c21c7 (patch)
treee92be32ae5a89481c3861d671796c658104ad127 /include/expression.h
parent783e853198b33576c3de23eeb0c03f9711e1fd4b (diff)
src: support for get element command
You need a Linux kernel >= 4.15 to use this feature. This patch allows us to dump the content of an existing set. # nft list ruleset table ip x { set x { type ipv4_addr flags interval elements = { 1.1.1.1-2.2.2.2, 3.3.3.3, 5.5.5.5-6.6.6.6 } } } You check if a single element exists in the set: # nft get element x x { 1.1.1.5 } table ip x { set x { type ipv4_addr flags interval elements = { 1.1.1.1-2.2.2.2 } } } Output means '1.1.1.5' belongs to the '1.1.1.1-2.2.2.2' interval. You can also check for intervals: # nft get element x x { 1.1.1.1-2.2.2.2 } table ip x { set x { type ipv4_addr flags interval elements = { 1.1.1.1-2.2.2.2 } } } If you try to check for an element that doesn't exist, an error is displayed. # nft get element x x { 1.1.1.0 } Error: Could not receive set elements: No such file or directory get element x x { 1.1.1.0 } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ You can also check for multiple elements in one go: # nft get element x x { 1.1.1.5, 5.5.5.10 } table ip x { set x { type ipv4_addr flags interval elements = { 1.1.1.1-2.2.2.2, 5.5.5.5-6.6.6.6 } } } You can also use this to fetch the existing timeout for specific elements, in case you have a set with timeouts in place: # nft get element w z { 2.2.2.2 } table ip w { set z { type ipv4_addr timeout 30s elements = { 2.2.2.2 expires 17s } } } Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'include/expression.h')
-rw-r--r--include/expression.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/expression.h b/include/expression.h
index 6f4edbf5..29dd0346 100644
--- a/include/expression.h
+++ b/include/expression.h
@@ -433,6 +433,11 @@ extern int set_to_intervals(struct list_head *msgs, struct set *set,
unsigned int debug_mask, bool merge);
extern void interval_map_decompose(struct expr *set);
+extern struct expr *get_set_intervals(const struct set *set,
+ const struct expr *init);
+struct table;
+extern void get_set_decompose(struct table *table, struct set *set);
+
extern struct expr *mapping_expr_alloc(const struct location *loc,
struct expr *from, struct expr *to);
extern struct expr *map_expr_alloc(const struct location *loc,