From e76bb379401816bbea773e73b524cd747324760a Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Tue, 7 Jul 2020 17:42:37 +0200 Subject: src: allow for variables in the log prefix string For example: define test = "state" define foo = "match" table x { chain y { ct state invalid log prefix "invalid $test $foo:" } } This patch scans for variables in the log prefix string. The log prefix expression is a list of constant and variable expression that are converted into a constant expression from the evaluation phase. Signed-off-by: Pablo Neira Ayuso --- tests/shell/testcases/optionals/dumps/log_prefix_0.nft | 5 +++++ tests/shell/testcases/optionals/log_prefix_0 | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/shell/testcases/optionals/dumps/log_prefix_0.nft create mode 100755 tests/shell/testcases/optionals/log_prefix_0 (limited to 'tests/shell') diff --git a/tests/shell/testcases/optionals/dumps/log_prefix_0.nft b/tests/shell/testcases/optionals/dumps/log_prefix_0.nft new file mode 100644 index 00000000..8c11d697 --- /dev/null +++ b/tests/shell/testcases/optionals/dumps/log_prefix_0.nft @@ -0,0 +1,5 @@ +table ip x { + chain y { + ct state invalid log prefix "invalid state match, logging:" + } +} diff --git a/tests/shell/testcases/optionals/log_prefix_0 b/tests/shell/testcases/optionals/log_prefix_0 new file mode 100755 index 00000000..513a9e74 --- /dev/null +++ b/tests/shell/testcases/optionals/log_prefix_0 @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +TMP=$(mktemp) + +RULESET='define test = "state" +define foo = "match, logging" + +table x { + chain y { + ct state invalid log prefix "invalid $test $foo:" + } +}' + +$NFT -f - <<< "$RULESET" -- cgit v1.2.3