From 1967b4f67cfbb64d12fc4953db35e3d7aa5f773e Mon Sep 17 00:00:00 2001 From: Elise Lennion Date: Wed, 18 Jan 2017 21:06:47 -0200 Subject: src: Honor obligatory stateless printing of flow tables Always print flow statement as stateless expressions, given that this just defines the flow table statement instance that is allocated per entry. Signed-off-by: Elise Lennion --- include/nftables.h | 2 +- src/main.c | 4 ++-- src/statement.c | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/include/nftables.h b/include/nftables.h index 760bbff5..6f541557 100644 --- a/include/nftables.h +++ b/include/nftables.h @@ -26,10 +26,10 @@ enum debug_level { extern unsigned int max_errors; extern unsigned int numeric_output; +extern unsigned int stateless_output; extern unsigned int ip2name_output; extern unsigned int handle_output; extern unsigned int debug_level; -extern bool stateless_output; extern const char *include_paths[INCLUDE_PATHS_MAX]; enum nftables_exit_codes { diff --git a/src/main.c b/src/main.c index 6d073d5c..6ba752b1 100644 --- a/src/main.c +++ b/src/main.c @@ -30,12 +30,12 @@ unsigned int max_errors = 10; unsigned int numeric_output; +unsigned int stateless_output; unsigned int ip2name_output; unsigned int handle_output; #ifdef DEBUG unsigned int debug_level; #endif -bool stateless_output; const char *include_paths[INCLUDE_PATHS_MAX] = { DEFAULT_INCLUDE_PATH }; static unsigned int num_include_paths = 1; @@ -291,7 +291,7 @@ int main(int argc, char * const *argv) numeric_output++; break; case OPT_STATELESS: - stateless_output = true; + stateless_output++; break; case OPT_IP2NAME: ip2name_output++; diff --git a/src/statement.c b/src/statement.c index 25bed65f..9cdabbb9 100644 --- a/src/statement.c +++ b/src/statement.c @@ -117,8 +117,13 @@ static void flow_stmt_print(const struct stmt *stmt) printf("{ "); expr_print(stmt->flow.key); printf(" "); + + stateless_output++; stmt_print(stmt->flow.stmt); + stateless_output--; + printf("} "); + } static void flow_stmt_destroy(struct stmt *stmt) -- cgit v1.2.3