Blame SOURCES/0118-fix-tests-convert-nftables-fib-checks-to-runtime.patch

136e2c
From 942c551547e23965f1653776f140297f790a4400 Mon Sep 17 00:00:00 2001
136e2c
From: Eric Garver <eric@garver.life>
136e2c
Date: Wed, 16 Oct 2019 12:56:57 -0400
136e2c
Subject: [PATCH 118/122] fix: tests: convert nftables fib checks to runtime
136e2c
136e2c
Instead of when the testsuite is generated.
136e2c
136e2c
(cherry picked from commit d5d05165222eb7a4933aace8fe2bc9c46bddab36)
136e2c
(cherry picked from commit 4aa4e01315b3404370ecaef661cc7eba604eee3d)
136e2c
---
136e2c
 src/tests/dbus/firewalld.conf.at | 16 +++++++++++++---
136e2c
 src/tests/functions.at           | 26 +++++++++++++-------------
136e2c
 src/tests/regression/gh258.at    | 26 +++++++++++++++++---------
136e2c
 src/tests/regression/gh509.at    |  2 +-
136e2c
 4 files changed, 44 insertions(+), 26 deletions(-)
136e2c
136e2c
diff --git a/src/tests/dbus/firewalld.conf.at b/src/tests/dbus/firewalld.conf.at
136e2c
index 3887d7ee4a7d..05eb3dd5f650 100644
136e2c
--- a/src/tests/dbus/firewalld.conf.at
136e2c
+++ b/src/tests/dbus/firewalld.conf.at
136e2c
@@ -1,17 +1,27 @@
136e2c
 FWD_START_TEST([firewalld.conf])
136e2c
 
136e2c
 dnl Verify defaults over dbus. Should be inline with default firewalld.conf.
136e2c
+IF_HOST_SUPPORTS_NFT_FIB([
136e2c
 DBUS_GETALL([config], [config], 0, [dnl
136e2c
 string "AutomaticHelpers" : variant string "system"
136e2c
 string "CleanupOnExit" : variant string "no"
136e2c
 string "DefaultZone" : variant string "public"
136e2c
-m4_if(no, HOST_SUPPORTS_NFT_FIB, [dnl
136e2c
-string "IPv6_rpfilter" : variant string "no"],[dnl
136e2c
-string "IPv6_rpfilter" : variant string "yes"])
136e2c
+string "IPv6_rpfilter" : variant string "yes"
136e2c
 string "IndividualCalls" : variant string "no"
136e2c
 string "Lockdown" : variant string "no"
136e2c
 string "LogDenied" : variant string "off"
136e2c
 string "MinimalMark" : variant int32 100
136e2c
+])], [
136e2c
+DBUS_GETALL([config], [config], 0, [dnl
136e2c
+string "AutomaticHelpers" : variant string "system"
136e2c
+string "CleanupOnExit" : variant string "no"
136e2c
+string "DefaultZone" : variant string "public"
136e2c
+string "IPv6_rpfilter" : variant string "no"
136e2c
+string "IndividualCalls" : variant string "no"
136e2c
+string "Lockdown" : variant string "no"
136e2c
+string "LogDenied" : variant string "off"
136e2c
+string "MinimalMark" : variant int32 100
136e2c
+])
136e2c
 ])
136e2c
 
136e2c
 m4_define([_helper], [
136e2c
diff --git a/src/tests/functions.at b/src/tests/functions.at
136e2c
index debabba8b8eb..fb68388776c9 100644
136e2c
--- a/src/tests/functions.at
136e2c
+++ b/src/tests/functions.at
136e2c
@@ -74,7 +74,7 @@ m4_define([FWD_START_TEST], [
136e2c
         dnl fib matching is pretty new in nftables. Don't use rpfilter on older
136e2c
         dnl kernels.
136e2c
         m4_if(nftables, FIREWALL_BACKEND, [
136e2c
-            m4_if(no, HOST_SUPPORTS_NFT_FIB, [
136e2c
+            IF_HOST_SUPPORTS_NFT_FIB([], [
136e2c
                 sed -i 's/^IPv6_rpfilter.*/IPv6_rpfilter=no/' ./firewalld.conf
136e2c
             ])
136e2c
         ])
136e2c
@@ -406,22 +406,22 @@ m4_define([CHECK_NFT_CT_HELPER], [
136e2c
     ])
136e2c
 ])
136e2c
 
136e2c
-m4_ifnblank(
136e2c
-    m4_esyscmd([
136e2c
-        KERNEL_MAJOR=`uname -r | cut -d. -f1`
136e2c
-        KERNEL_MINOR=`uname -r | cut -d. -f2`
136e2c
-        if test ${KERNEL_MAJOR} -eq 4 && test ${KERNEL_MINOR} -ge 10 || test ${KERNEL_MAJOR} -gt 4; then
136e2c
-            echo -n "yes"
136e2c
-        fi
136e2c
-    ]),
136e2c
-    [m4_define([HOST_SUPPORTS_NFT_FIB], [yes])],
136e2c
-    [m4_define([HOST_SUPPORTS_NFT_FIB], [no])]
136e2c
-)
136e2c
-
136e2c
 m4_define([CHECK_MODULE_PROTO_GRE], [
136e2c
     AT_SKIP_IF([! NS_CMD([modinfo nf_conntrack_proto_gre])])
136e2c
 ])
136e2c
 
136e2c
+m4_define([IF_HOST_SUPPORTS_NFT_FIB], [
136e2c
+    KERNEL_MAJOR=`uname -r | cut -d. -f1`
136e2c
+    KERNEL_MINOR=`uname -r | cut -d. -f2`
136e2c
+    if test ${KERNEL_MAJOR} -eq 4 && test ${KERNEL_MINOR} -ge 10 || test ${KERNEL_MAJOR} -gt 4; then
136e2c
+        :
136e2c
+        $1
136e2c
+    else
136e2c
+        :
136e2c
+        $2
136e2c
+    fi
136e2c
+])
136e2c
+
136e2c
 m4_define([NFT_NUMERIC_ARGS], m4_esyscmd([nft -h |grep "numeric-protocol" >/dev/null && echo -n "" || { echo -n "-" && echo -n "nn"; } ]))
136e2c
 
136e2c
 m4_define([HOST_SUPPORTS_IP6TABLES], m4_esyscmd(
136e2c
diff --git a/src/tests/regression/gh258.at b/src/tests/regression/gh258.at
136e2c
index fb863c35528e..a4b86e8a006f 100644
136e2c
--- a/src/tests/regression/gh258.at
136e2c
+++ b/src/tests/regression/gh258.at
136e2c
@@ -66,16 +66,24 @@ NFT_LIST_RULES([inet], [filter_FORWARD_OUT_ZONES], 0, [dnl
136e2c
         }
136e2c
     }
136e2c
 ])
136e2c
-NFT_LIST_RULES([inet], [raw_PREROUTING], 0, [dnl
136e2c
-    table inet firewalld {
136e2c
-        chain raw_PREROUTING {
136e2c
-            m4_if(yes, HOST_SUPPORTS_NFT_FIB, [dnl
136e2c
-            icmpv6 type { nd-router-advert, nd-neighbor-solicit } accept
136e2c
-            meta nfproto ipv6 fib saddr . iif oif missing drop
136e2c
-            ])dnl
136e2c
-            jump raw_PREROUTING_ZONES
136e2c
+IF_HOST_SUPPORTS_NFT_FIB([
136e2c
+    NFT_LIST_RULES([inet], [raw_PREROUTING], 0, [dnl
136e2c
+        table inet firewalld {
136e2c
+            chain raw_PREROUTING {
136e2c
+                icmpv6 type { nd-router-advert, nd-neighbor-solicit } accept
136e2c
+                meta nfproto ipv6 fib saddr . iif oif missing drop
136e2c
+                jump raw_PREROUTING_ZONES
136e2c
+            }
136e2c
         }
136e2c
-    }
136e2c
+    ])
136e2c
+], [
136e2c
+    NFT_LIST_RULES([inet], [raw_PREROUTING], 0, [dnl
136e2c
+        table inet firewalld {
136e2c
+            chain raw_PREROUTING {
136e2c
+                jump raw_PREROUTING_ZONES
136e2c
+            }
136e2c
+        }
136e2c
+    ])
136e2c
 ])
136e2c
 NFT_LIST_RULES([inet], [raw_PREROUTING_ZONES], 0, [dnl
136e2c
     table inet firewalld {
136e2c
diff --git a/src/tests/regression/gh509.at b/src/tests/regression/gh509.at
136e2c
index 44074fda3550..00cc51c9c51f 100644
136e2c
--- a/src/tests/regression/gh509.at
136e2c
+++ b/src/tests/regression/gh509.at
136e2c
@@ -4,7 +4,7 @@ AT_KEYWORDS(gh509)
136e2c
 dnl We're going to wipe the config below and therefore use the defaults. As
136e2c
 dnl such, if our test host doesn't support defaults then we must skip this test
136e2c
 dnl group.
136e2c
-m4_if(no, HOST_SUPPORTS_NFT_FIB, [AT_SKIP_IF([:])])
136e2c
+IF_HOST_SUPPORTS_NFT_FIB([], [AT_SKIP_IF([:])])
136e2c
 
136e2c
 AT_CHECK([if ! rm ./firewalld.conf; then exit 77; fi])
136e2c
 FWD_RESTART
136e2c
-- 
136e2c
2.23.0
136e2c