On a kernel with broken (never upstreamed) patch this fails with: Accepted bad ruleset with jump from filter type to masquerade (3) and Accepted bad ruleset with jump from prerouting to masquerade ... because bogus optimisation suppresses re-validation of 'n2', even though it becomes reachable from an invalid base chain (filter, but n2 has nat-only masquerade expression). Another broken corner-case is validation of the different hook types: When it becomes reachable from nat:prerouting in addition to the allowed nat:postrouting the validation step must fail. Improve test coverage to ensure future optimisations catch this. Signed-off-by: Florian Westphal --- .../testcases/transactions/bad_rule_graphs | 68 +++++++++++++ .../dumps/bad_rule_graphs.json-nft | 98 +++++++++++++++++-- .../transactions/dumps/bad_rule_graphs.nft | 17 +++- 3 files changed, 173 insertions(+), 10 deletions(-) diff --git a/tests/shell/testcases/transactions/bad_rule_graphs b/tests/shell/testcases/transactions/bad_rule_graphs index 53047c3c229f..1f36bad80792 100755 --- a/tests/shell/testcases/transactions/bad_rule_graphs +++ b/tests/shell/testcases/transactions/bad_rule_graphs @@ -259,4 +259,72 @@ $NFT "add rule t c9 tcp dport 80 tproxy to :20000 meta mark set 1 accept" good_ruleset $? "add tproxy expression to c9" check_bad_expr +$NFT -f - <