]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: move check of nat table existence
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 7 Apr 2021 16:47:52 +0000 (01:47 +0900)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 8 Apr 2021 12:39:53 +0000 (14:39 +0200)
As test_v4() with iptables backend will be called after nftables tests.

Follow-up for afbcd905526111e3a1bd55b0d6d5ee4413734735.

src/test/test-firewall-util.c

index c5a138ee1ecb19ef4ef4701b84cd99a104909de5..d2843cfab73da20a52234a7f98f53e327f9efad8 100644 (file)
@@ -61,6 +61,13 @@ static bool test_v4(FirewallContext *ctx) {
 
         log_info("/* %s(backend=%s) */", __func__, firewall_backend_to_string(ctx->backend));
 
+#if HAVE_LIBIPTC
+        if (ctx->backend == FW_BACKEND_IPTABLES && fw_iptables_init_nat(NULL) < 0) {
+                log_debug("iptables backend is used, but nat table is not enabled, skipping tests");
+                return false;
+        }
+#endif
+
         assert_se(fw_add_masquerade(&ctx, true, AF_INET, NULL, 0) == -EINVAL);
         assert_se(fw_add_masquerade(&ctx, true, AF_INET, parse_addr("10.1.2.0", &u), 0) == -EINVAL);
 
@@ -102,11 +109,6 @@ int main(int argc, char *argv[]) {
         if (ctx->backend == FW_BACKEND_NONE)
                 return EXIT_TEST_SKIP;
 
-#if HAVE_LIBIPTC
-        if (ctx->backend == FW_BACKEND_IPTABLES && fw_iptables_init_nat(NULL) < 0)
-                return EXIT_TEST_SKIP;
-#endif
-
         if (test_v4(ctx) && ctx->backend == FW_BACKEND_NFTABLES)
                 test_v6(ctx);