Blob Blame History Raw
From d9106cd887f111eb1f7fe40e8e2129d8e7652521 Mon Sep 17 00:00:00 2001
From: Eric Garver <eric@garver.life>
Date: Mon, 29 Apr 2019 13:19:47 -0400
Subject: [PATCH 37/73] fix: tests/nftables: compatibility with numeric output
 changes

Newer versions (>0.9.0) of nft changed "-n" to mean _all_ numeric
output. Newer versions also default to the older versions equivalent of
"-nn", which is what we use. So key off the newer arguments and use the
appropriate flags depending on nft version.

See nftables commit 505794f75f2a ("src: get rid of
nft_ctx_output_{get,set}_numeric()") and other related commits.

(cherry picked from commit fa740a638e60265957f3ef1b86df6d3f99dd5010)
(cherry picked from commit 612c5d9d281404aa8d0babbd66d115854a1822d1)
---
 src/tests/functions.at | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/tests/functions.at b/src/tests/functions.at
index 102004f678b3..ca9224476a56 100644
--- a/src/tests/functions.at
+++ b/src/tests/functions.at
@@ -249,8 +249,9 @@ m4_define([NFT_LIST_RULES], [
         sed -e 's/meta mark/mark/g'dnl
         | sed -e '/type.*hook.*priority.*policy.*/d'dnl
     ])
+
     m4_ifdef([TESTING_FIREWALL_OFFLINE_CMD], [], [
-        NS_CHECK([nft -nn list chain $1 firewalld $2 | TRIM_WHITESPACE | NFT_LIST_RULES_NORMALIZE], [$3], [m4_strip([$4])], [m4_strip([$5])], [$6], [$7])
+        NS_CHECK([nft NFT_NUMERIC_ARGS list chain $1 firewalld $2 | TRIM_WHITESPACE | NFT_LIST_RULES_NORMALIZE], [$3], [m4_strip([$4])], [m4_strip([$5])], [$6], [$7])
     ])
     m4_undefine([NFT_LIST_RULES_NORMALIZE])
 ])
@@ -266,7 +267,7 @@ m4_define([IPSET_LIST_SET], [
 
 m4_define([NFT_LIST_SET], [
     m4_ifdef([TESTING_FIREWALL_OFFLINE_CMD], [], [
-        NS_CHECK([nft -nn list set inet firewalld $1 | TRIM_WHITESPACE], [$2], [m4_strip([$3])], [m4_strip([$4])], [$5], [$6])
+        NS_CHECK([nft NFT_NUMERIC_ARGS list set inet firewalld $1 | TRIM_WHITESPACE], [$2], [m4_strip([$3])], [m4_strip([$4])], [$5], [$6])
     ])
 ])
 
@@ -370,3 +371,5 @@ m4_ifnblank(
     [m4_define([HOST_SUPPORTS_NFT_FIB], [yes])],
     [m4_define([HOST_SUPPORTS_NFT_FIB], [no])]
 )
+
+m4_define([NFT_NUMERIC_ARGS], m4_esyscmd([nft -h |grep "numeric-protocol" >/dev/null && echo -n "" || { echo -n "-" && echo -n "nn"; } ]))
-- 
2.20.1