Blame SOURCES/0004-rich-rules-fix-mark-action.patch

c8bceb
From da851982df4020460fe4fa005dd99be4357ff9bd Mon Sep 17 00:00:00 2001
c8bceb
From: Eric Garver <e@erig.me>
c8bceb
Date: Fri, 2 Nov 2018 14:10:38 -0400
c8bceb
Subject: [PATCH 4/5] rich rules: fix mark action
c8bceb
c8bceb
They were being placed in the wrong (and nonexistent) chain. Also add
c8bceb
test coverage for the "mark" action.
c8bceb
c8bceb
Fixes: 7c5f5f4d12ee ("fw_zone: push rich rule generation to backend")
c8bceb
Tested-by: Felix Kaechele <heffer@fedoraproject.org>
c8bceb
(cherry picked from commit 5d36e0f55887c6204e07bd8095ead1ce2d535ddb)
c8bceb
---
c8bceb
 src/firewall/core/ipXtables.py | 4 ++--
c8bceb
 src/firewall/core/nftables.py  | 4 ++--
c8bceb
 src/tests/firewall-cmd.at      | 1 +
c8bceb
 3 files changed, 5 insertions(+), 4 deletions(-)
c8bceb
c8bceb
diff --git a/src/firewall/core/ipXtables.py b/src/firewall/core/ipXtables.py
c8bceb
index 11aebec6e05a..b98ba5228e68 100644
c8bceb
--- a/src/firewall/core/ipXtables.py
c8bceb
+++ b/src/firewall/core/ipXtables.py
c8bceb
@@ -807,10 +807,10 @@ class ip4tables(object):
c8bceb
             chain = "%s_deny" % target
c8bceb
             rule_action = [ "-j", "DROP" ]
c8bceb
         elif type(rich_rule.action) == Rich_Mark:
c8bceb
-            chain = "%s_allow" % target
c8bceb
-            table = "mangle"
c8bceb
             target = DEFAULT_ZONE_TARGET.format(chain=SHORTCUTS["PREROUTING"],
c8bceb
                                                 zone=zone)
c8bceb
+            table = "mangle"
c8bceb
+            chain = "%s_allow" % target
c8bceb
             rule_action = [ "-j", "MARK", "--set-xmark", rich_rule.action.set ]
c8bceb
         else:
c8bceb
             raise FirewallError(INVALID_RULE,
c8bceb
diff --git a/src/firewall/core/nftables.py b/src/firewall/core/nftables.py
c8bceb
index cd05b2c3137e..69236a9600c2 100644
c8bceb
--- a/src/firewall/core/nftables.py
c8bceb
+++ b/src/firewall/core/nftables.py
c8bceb
@@ -723,10 +723,10 @@ class nftables(object):
c8bceb
             chain = "%s_%s_deny" % (table, target)
c8bceb
             rule_action = ["drop"]
c8bceb
         elif type(rich_rule.action) == Rich_Mark:
c8bceb
-            table = "mangle"
c8bceb
-            chain = "%s_%s_allow" % (table, target)
c8bceb
             target = DEFAULT_ZONE_TARGET.format(chain=SHORTCUTS["PREROUTING"],
c8bceb
                                                 zone=zone)
c8bceb
+            table = "mangle"
c8bceb
+            chain = "%s_%s_allow" % (table, target)
c8bceb
             rule_action = ["meta", "mark", "set", rich_rule.action.set]
c8bceb
         else:
c8bceb
             raise FirewallError(INVALID_RULE,
c8bceb
diff --git a/src/tests/firewall-cmd.at b/src/tests/firewall-cmd.at
c8bceb
index f496b67e4a35..82ffa9f52b47 100644
c8bceb
--- a/src/tests/firewall-cmd.at
c8bceb
+++ b/src/tests/firewall-cmd.at
c8bceb
@@ -863,6 +863,7 @@ FWD_START_TEST([rich rules good])
c8bceb
     rich_rule_test([rule forward-port port="66" to-port="666" to-addr="192.168.100.2" protocol="sctp" family="ipv4" source address="192.168.2.100"])
c8bceb
     rich_rule_test([rule forward-port port="99" to-port="999" to-addr="1::2:3:4:7" protocol="dccp" family="ipv6" source address="1:2:3:4:6::"])
c8bceb
     rich_rule_test([rule forward-port port="99" to-port="10999" to-addr="1::2:3:4:7" protocol="dccp" family="ipv6" source address="1:2:3:4:6::"])
c8bceb
+    rich_rule_test([rule family="ipv4" port port="222" protocol="tcp" mark set="0xff"])
c8bceb
 FWD_END_TEST
c8bceb
 FWD_START_TEST([rich rules audit])
c8bceb
 	CHECK_LOG_AUDIT
c8bceb
-- 
c8bceb
2.18.0
c8bceb