Blame SOURCES/0067-fix-zone-add-source-with-mac-address.patch

00d018
From 2871abfceceba37c6ba38aa0ef25e23a059294ec Mon Sep 17 00:00:00 2001
00d018
From: Vrinda Punj <vpunj@redhat.com>
00d018
Date: Wed, 18 Nov 2020 13:14:44 -0500
00d018
Subject: [PATCH 67/68] fix(zone): add source with mac address
00d018
00d018
nftables supports matching the destination MAC, but iptables does not.
00d018
As such, lift the restriction from nftables. For iptables, gracefully
00d018
ignore the scenarios in which we attempt to match destination MAC.
00d018
00d018
Fixes: #703
00d018
Fixes: df4aefcbe7b7 ("improvement(ipXtables): add utility function match sources")
00d018
Fixes: 1582c5dd736a ("feat: nftables: convert to libnftables JSON interface")
00d018
00d018
Co-authored-by: Eric Garver <eric@garver.life>
00d018
(cherry picked from commit 20151fbb5c5104e3d4dbc4ea938b9a68bdbcf225)
00d018
(cherry picked from commit 79bb113a2a108ce1c69dc7bc7af60297b8ec2ad0)
00d018
---
00d018
 src/firewall/core/ipXtables.py     |  4 ++++
00d018
 src/firewall/core/nftables.py      |  2 --
00d018
 src/tests/regression/gh703.at      | 23 +++++++++++++++++++++++
00d018
 src/tests/regression/regression.at |  1 +
00d018
 4 files changed, 28 insertions(+), 2 deletions(-)
00d018
 create mode 100644 src/tests/regression/gh703.at
00d018
00d018
diff --git a/src/firewall/core/ipXtables.py b/src/firewall/core/ipXtables.py
00d018
index 450e427c08b5..b28146edd060 100644
00d018
--- a/src/firewall/core/ipXtables.py
00d018
+++ b/src/firewall/core/ipXtables.py
00d018
@@ -814,6 +814,10 @@ class ip4tables(object):
00d018
         else:
00d018
             zone_dispatch_chain = "%s_ZONES" % (chain)
00d018
 
00d018
+        # iptables can not match destination MAC
00d018
+        if check_mac(address) and chain in ["POSTROUTING", "FORWARD_OUT", "OUTPUT"]:
00d018
+            return []
00d018
+
00d018
         target = DEFAULT_ZONE_TARGET.format(chain=SHORTCUTS[chain], zone=zone)
00d018
         action = "-g"
00d018
 
00d018
diff --git a/src/firewall/core/nftables.py b/src/firewall/core/nftables.py
00d018
index 0a73c2c2669d..a0a899dd3eef 100644
00d018
--- a/src/firewall/core/nftables.py
00d018
+++ b/src/firewall/core/nftables.py
00d018
@@ -1067,8 +1067,6 @@ class nftables(object):
00d018
             return self._set_match_fragment(address[len("ipset:"):], True if "daddr" == addr_field else False, invert)
00d018
         else:
00d018
             if check_mac(address):
00d018
-                if addr_field == "daddr":
00d018
-                    raise FirewallError(INVALID_RULE, "%s._rule_addr_fragment()", (self.__class__))
00d018
                 family = "ether"
00d018
             elif check_single_address("ipv4", address):
00d018
                 family = "ip"
00d018
diff --git a/src/tests/regression/gh703.at b/src/tests/regression/gh703.at
00d018
new file mode 100644
00d018
index 000000000000..af724a7713a7
00d018
--- /dev/null
00d018
+++ b/src/tests/regression/gh703.at
00d018
@@ -0,0 +1,23 @@
00d018
+FWD_START_TEST([add source with mac address])
00d018
+AT_KEYWORDS(gh703)
00d018
+
00d018
+FWD_CHECK([--zone=home --add-source=34:7e:5c:3a:4c:32], 0, [ignore])
00d018
+
00d018
+NFT_LIST_RULES([ip], [nat_POSTROUTING_ZONES_SOURCE], 0, [dnl
00d018
+    table ip firewalld {
00d018
+        chain nat_POSTROUTING_ZONES_SOURCE {
00d018
+            ether daddr 34:7e:5c:3a:4c:32 goto nat_POST_home
00d018
+        }          
00d018
+    }          
00d018
+])
00d018
+NFT_LIST_RULES([ip6], [nat_POSTROUTING_ZONES_SOURCE], 0, [dnl
00d018
+    table ip6 firewalld {
00d018
+        chain nat_POSTROUTING_ZONES_SOURCE {
00d018
+            ether daddr 34:7e:5c:3a:4c:32 goto nat_POST_home
00d018
+        }          
00d018
+    }          
00d018
+])
00d018
+
00d018
+dnl NOTE: iptables does _not_ support matching mac destination.
00d018
+
00d018
+FWD_END_TEST
00d018
diff --git a/src/tests/regression/regression.at b/src/tests/regression/regression.at
00d018
index c1e8620ee700..7597a458076c 100644
00d018
--- a/src/tests/regression/regression.at
00d018
+++ b/src/tests/regression/regression.at
00d018
@@ -36,3 +36,4 @@ m4_include([regression/rhbz1541077.at])
00d018
 m4_include([regression/rhbz1855140.at])
00d018
 m4_include([regression/rhbz1871298.at])
00d018
 m4_include([regression/rhbz1596304.at])
00d018
+m4_include([regression/gh703.at])
00d018
-- 
00d018
2.27.0
00d018