src: Honor obligatory stateless printing of flow tables
PATCH 1/1 src: Honor obligatory stateless printing of flow tables
Signed-off-by Elise Lennion <[email protected]>
--- include/nftables.h | 2 +- src/main.c | 4 ++-- src/statement.c | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-)
include/nftables.h +1 -1
@@ -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 {
src/main.c +2 -2
@@ -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++;
src/statement.c +4 -0
@@ -109,6 +109,8 @@ struct stmt *verdict_stmt_alloc(const struct location *loc, struct expr *expr)static void flow_stmt_print (const struct stmt *stmt) { + stateless_output++; +printf ("flow " );if (stmt->flow.set) {expr_print (stmt->flow.set,NULL );
@@ -119,6 +121,8 @@ static void flow_stmt_print(const struct stmt *stmt)printf (" " );stmt_print (stmt->flow.stmt);printf ("} " ); + + stateless_output--; }static void flow_stmt_destroy (struct stmt *stmt)
Signature · 1 line
2.7.4
Pablo Neira Ayuso
maintainerOn Wed, Jan 18, 2017 at 09:06:47PM -0200, Elise Lennion wrote:
Please, next time always add a description here, even is small one, this is good to help other follow track of what we're doing.
I have applied this, but one more comment below.
Quoted 64 lines
Signed-off-by Elise Lennion <[email protected]>--- include/nftables.h | 2 +- src/main.c | 4 ++-- src/statement.c | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-)include/nftables.h +1
-1@@ -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 {src/main.c +2
-2@@ -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++;src/statement.c +2
-0@@ -109,6 +109,8 @@ struct stmt *verdict_stmt_alloc(const struct location *loc, struct expr *expr)static void flow_stmt_print (const struct stmt *stmt) { + stateless_output++; +printf ("flow " );if (stmt->flow.set) {expr_print (stmt->flow.set,NULL );
src/statement.c static void flow_stmt_print(const struct stmt *stmt) · line 121
Quoted 1 line
src/statement.c +0
-0@@ -119,6 +121,8 @@ static void flow_stmt_print(const struct stmt *stmt)printf (" " );
I have mangled this patch, so:
stateless_output++;
happens here, just before this call below:
src/statement.c static void flow_stmt_print(const struct stmt *stmt) · line 122
Quoted 1 line
src/statement.c +0
-0stmt_print (stmt->flow.stmt);
So we restrict it to the statement that defines the flow table entries.
Thanks!
Quoted 9 lines
src/statement.c +2
-0printf ("} " ); + + stateless_output--; }static void flow_stmt_destroy (struct stmt *stmt)Signature · 1 line
2.7.4