diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2020-07-07 14:31:33 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2020-07-08 11:23:19 +0200 |
commit | 8f56db64be3f2c57a196a5eaef0286ec71782950 (patch) | |
tree | 83d0b1af1db2133994ab15f170d17b6394e16c41 /src/statement.c | |
parent | 26d2f70c59f8c66d7cf1a016b74e3007c0e2c118 (diff) |
src: use expression to store the log prefix
Intsead of using an array of char.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/statement.c')
-rw-r--r-- | src/statement.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/statement.c b/src/statement.c index 21a1bc8d..afedbba2 100644 --- a/src/statement.c +++ b/src/statement.c @@ -18,6 +18,7 @@ #include <arpa/inet.h> #include <linux/netfilter.h> +#include <linux/netfilter/nf_log.h> #include <netinet/ip_icmp.h> #include <netinet/icmp6.h> #include <statement.h> @@ -300,8 +301,12 @@ int log_level_parse(const char *level) static void log_stmt_print(const struct stmt *stmt, struct output_ctx *octx) { nft_print(octx, "log"); - if (stmt->log.flags & STMT_LOG_PREFIX) - nft_print(octx, " prefix \"%s\"", stmt->log.prefix); + if (stmt->log.flags & STMT_LOG_PREFIX) { + char prefix[NF_LOG_PREFIXLEN] = {}; + + expr_to_string(stmt->log.prefix, prefix); + nft_print(octx, " prefix \"%s\"", prefix); + } if (stmt->log.flags & STMT_LOG_GROUP) nft_print(octx, " group %u", stmt->log.group); if (stmt->log.flags & STMT_LOG_SNAPLEN) @@ -338,7 +343,7 @@ static void log_stmt_print(const struct stmt *stmt, struct output_ctx *octx) static void log_stmt_destroy(struct stmt *stmt) { - xfree(stmt->log.prefix); + expr_free(stmt->log.prefix); } static const struct stmt_ops log_stmt_ops = { |