Blame SOURCES/0059-fix-do-not-allow-zone-drifting.patch

c8bceb
From 74760c43588be65303795397717d4aa5ef5e4236 Mon Sep 17 00:00:00 2001
c8bceb
From: Eric Garver <eric@garver.life>
c8bceb
Date: Wed, 29 May 2019 15:21:34 -0400
c8bceb
Subject: [PATCH 59/73] fix: do not allow zone drifting
c8bceb
c8bceb
Chain zone dispatch together and always use "goto". This guarantees
c8bceb
there is no fall through to other zones. This was especially problematic
c8bceb
in regards to the default zone.
c8bceb
c8bceb
This removes the _ZONES_SOURCE chains, but adds _ZONES_IFACES. At the
c8bceb
end of _ZONES we do a goto to _ZONES_IFACES. This is so sources always
c8bceb
take precedence over interfaces.
c8bceb
c8bceb
Fixes: #258
c8bceb
Fixes: #441
c8bceb
(cherry picked from commit 70993581d79beb40a3d23bd8cbfb776ad5df5dca)
c8bceb
(cherry picked from commit 16c7603b57d5b07389e9c2ba0ca8b4836b2aaf93)
c8bceb
---
c8bceb
 src/firewall/core/fw_zone.py   |  6 +--
c8bceb
 src/firewall/core/ipXtables.py | 70 ++++++++++++++++------------------
c8bceb
 src/firewall/core/nftables.py  | 67 +++++++++++++++-----------------
c8bceb
 src/tests/firewall-cmd.at      |  8 ++--
c8bceb
 4 files changed, 69 insertions(+), 82 deletions(-)
c8bceb
c8bceb
diff --git a/src/firewall/core/fw_zone.py b/src/firewall/core/fw_zone.py
c8bceb
index ee02a161bcfb..90ae1036f124 100644
c8bceb
--- a/src/firewall/core/fw_zone.py
c8bceb
+++ b/src/firewall/core/fw_zone.py
c8bceb
@@ -1514,8 +1514,7 @@ class FirewallZone(object):
c8bceb
                         zone_transaction.add_chain(table, chain)
c8bceb
 
c8bceb
                     rules = backend.build_zone_source_interface_rules(enable,
c8bceb
-                                        zone, self._zones[zone].target,
c8bceb
-                                        interface, table, chain, append)
c8bceb
+                                        zone, interface, table, chain, append)
c8bceb
                     zone_transaction.add_rules(backend, rules)
c8bceb
 
c8bceb
     # IPSETS
c8bceb
@@ -1555,8 +1554,7 @@ class FirewallZone(object):
c8bceb
                         zone_transaction.add_chain(table, chain)
c8bceb
 
c8bceb
                     rules = backend.build_zone_source_address_rules(enable, zone,
c8bceb
-                                    self._zones[zone].target, source, table,
c8bceb
-                                    chain)
c8bceb
+                                                        source, table, chain)
c8bceb
                     zone_transaction.add_rules(backend, rules)
c8bceb
 
c8bceb
     def _rule_prepare(self, enable, zone, rule, mark_id, zone_transaction):
c8bceb
diff --git a/src/firewall/core/ipXtables.py b/src/firewall/core/ipXtables.py
c8bceb
index 4a9c06242f08..c2339e40539a 100644
c8bceb
--- a/src/firewall/core/ipXtables.py
c8bceb
+++ b/src/firewall/core/ipXtables.py
c8bceb
@@ -526,11 +526,11 @@ class ip4tables(object):
c8bceb
                 self.our_chains["raw"].add("%s_direct" % chain)
c8bceb
 
c8bceb
                 if chain == "PREROUTING":
c8bceb
-                    default_rules["raw"].append("-N %s_ZONES_SOURCE" % chain)
c8bceb
                     default_rules["raw"].append("-N %s_ZONES" % chain)
c8bceb
-                    default_rules["raw"].append("-A %s -j %s_ZONES_SOURCE" % (chain, chain))
c8bceb
+                    default_rules["raw"].append("-N %s_ZONES_IFACES" % chain)
c8bceb
                     default_rules["raw"].append("-A %s -j %s_ZONES" % (chain, chain))
c8bceb
-                    self.our_chains["raw"].update(set(["%s_ZONES_SOURCE" % chain, "%s_ZONES" % chain]))
c8bceb
+                    default_rules["raw"].append("-A %s_ZONES -g %s_ZONES_IFACES" % (chain, chain))
c8bceb
+                    self.our_chains["raw"].update(set(["%s_ZONES" % chain, "%s_ZONES_IFACES" % chain]))
c8bceb
 
c8bceb
         if self.get_available_tables("mangle"):
c8bceb
             default_rules["mangle"] = [ ]
c8bceb
@@ -541,11 +541,11 @@ class ip4tables(object):
c8bceb
                 self.our_chains["mangle"].add("%s_direct" % chain)
c8bceb
 
c8bceb
                 if chain == "PREROUTING":
c8bceb
-                    default_rules["mangle"].append("-N %s_ZONES_SOURCE" % chain)
c8bceb
                     default_rules["mangle"].append("-N %s_ZONES" % chain)
c8bceb
-                    default_rules["mangle"].append("-A %s -j %s_ZONES_SOURCE" % (chain, chain))
c8bceb
+                    default_rules["mangle"].append("-N %s_ZONES_IFACES" % chain)
c8bceb
                     default_rules["mangle"].append("-A %s -j %s_ZONES" % (chain, chain))
c8bceb
-                    self.our_chains["mangle"].update(set(["%s_ZONES_SOURCE" % chain, "%s_ZONES" % chain]))
c8bceb
+                    default_rules["mangle"].append("-A %s_ZONES -g %s_ZONES_IFACES" % (chain, chain))
c8bceb
+                    self.our_chains["mangle"].update(set(["%s_ZONES" % chain, "%s_ZONES_IFACES" % chain]))
c8bceb
 
c8bceb
         if self.get_available_tables("nat"):
c8bceb
             default_rules["nat"] = [ ]
c8bceb
@@ -556,22 +556,22 @@ class ip4tables(object):
c8bceb
                 self.our_chains["nat"].add("%s_direct" % chain)
c8bceb
 
c8bceb
                 if chain in [ "PREROUTING", "POSTROUTING" ]:
c8bceb
-                    default_rules["nat"].append("-N %s_ZONES_SOURCE" % chain)
c8bceb
                     default_rules["nat"].append("-N %s_ZONES" % chain)
c8bceb
-                    default_rules["nat"].append("-A %s -j %s_ZONES_SOURCE" % (chain, chain))
c8bceb
+                    default_rules["nat"].append("-N %s_ZONES_IFACES" % chain)
c8bceb
                     default_rules["nat"].append("-A %s -j %s_ZONES" % (chain, chain))
c8bceb
-                    self.our_chains["nat"].update(set(["%s_ZONES_SOURCE" % chain, "%s_ZONES" % chain]))
c8bceb
+                    default_rules["nat"].append("-A %s_ZONES -g %s_ZONES_IFACES" % (chain, chain))
c8bceb
+                    self.our_chains["nat"].update(set(["%s_ZONES" % chain, "%s_ZONES_IFACES" % chain]))
c8bceb
 
c8bceb
         default_rules["filter"] = [
c8bceb
             "-N INPUT_direct",
c8bceb
-            "-N INPUT_ZONES_SOURCE",
c8bceb
             "-N INPUT_ZONES",
c8bceb
+            "-N INPUT_ZONES_IFACES",
c8bceb
 
c8bceb
             "-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT",
c8bceb
             "-A INPUT -i lo -j ACCEPT",
c8bceb
             "-A INPUT -j INPUT_direct",
c8bceb
-            "-A INPUT -j INPUT_ZONES_SOURCE",
c8bceb
             "-A INPUT -j INPUT_ZONES",
c8bceb
+            "-A INPUT_ZONES -g INPUT_ZONES_IFACES",
c8bceb
         ]
c8bceb
         if log_denied != "off":
c8bceb
             default_rules["filter"].append("-A INPUT -m conntrack --ctstate INVALID %%LOGTYPE%% -j LOG --log-prefix 'STATE_INVALID_DROP: '")
c8bceb
@@ -582,18 +582,18 @@ class ip4tables(object):
c8bceb
 
c8bceb
         default_rules["filter"] += [
c8bceb
             "-N FORWARD_direct",
c8bceb
-            "-N FORWARD_IN_ZONES_SOURCE",
c8bceb
             "-N FORWARD_IN_ZONES",
c8bceb
-            "-N FORWARD_OUT_ZONES_SOURCE",
c8bceb
             "-N FORWARD_OUT_ZONES",
c8bceb
+            "-N FORWARD_IN_ZONES_IFACES",
c8bceb
+            "-N FORWARD_OUT_ZONES_IFACES",
c8bceb
 
c8bceb
             "-A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT",
c8bceb
             "-A FORWARD -i lo -j ACCEPT",
c8bceb
             "-A FORWARD -j FORWARD_direct",
c8bceb
-            "-A FORWARD -j FORWARD_IN_ZONES_SOURCE",
c8bceb
             "-A FORWARD -j FORWARD_IN_ZONES",
c8bceb
-            "-A FORWARD -j FORWARD_OUT_ZONES_SOURCE",
c8bceb
             "-A FORWARD -j FORWARD_OUT_ZONES",
c8bceb
+            "-A FORWARD_IN_ZONES -g FORWARD_IN_ZONES_IFACES",
c8bceb
+            "-A FORWARD_OUT_ZONES -g FORWARD_OUT_ZONES_IFACES",
c8bceb
         ]
c8bceb
         if log_denied != "off":
c8bceb
             default_rules["filter"].append("-A FORWARD -m conntrack --ctstate INVALID %%LOGTYPE%% -j LOG --log-prefix 'STATE_INVALID_DROP: '")
c8bceb
@@ -609,10 +609,10 @@ class ip4tables(object):
c8bceb
             "-A OUTPUT -j OUTPUT_direct",
c8bceb
         ]
c8bceb
 
c8bceb
-        self.our_chains["filter"] = set(["INPUT_direct", "INPUT_ZONES_SOURCE", "INPUT_ZONES",
c8bceb
-                                    "FORWARD_direct", "FORWARD_IN_ZONES_SOURCE",
c8bceb
-                                    "FORWARD_IN_ZONES", "FORWARD_OUT_ZONES_SOURCE",
c8bceb
-                                    "FORWARD_OUT_ZONES", "OUTPUT_direct"])
c8bceb
+        self.our_chains["filter"] = set(["INPUT_direct", "INPUT_ZONES", "INPUT_ZONES_IFACES"
c8bceb
+                                         "FORWARD_direct", "FORWARD_IN_ZONES",
c8bceb
+                                         "FORWARD_IN_ZONES_IFACES" "FORWARD_OUT_ZONES",
c8bceb
+                                         "FORWARD_OUT_ZONES_IFACES", "OUTPUT_direct"])
c8bceb
 
c8bceb
         final_default_rules = []
c8bceb
         for table in default_rules:
c8bceb
@@ -639,9 +639,8 @@ class ip4tables(object):
c8bceb
 
c8bceb
         return {}
c8bceb
 
c8bceb
-    def build_zone_source_interface_rules(self, enable, zone, zone_target,
c8bceb
-                                          interface, table, chain,
c8bceb
-                                          append=False):
c8bceb
+    def build_zone_source_interface_rules(self, enable, zone, interface,
c8bceb
+                                          table, chain, append=False):
c8bceb
         # handle all zones in the same way here, now
c8bceb
         # trust and block zone targets are handled now in __chain
c8bceb
         opt = {
c8bceb
@@ -654,22 +653,20 @@ class ip4tables(object):
c8bceb
         }[chain]
c8bceb
 
c8bceb
         target = DEFAULT_ZONE_TARGET.format(chain=SHORTCUTS[chain], zone=zone)
c8bceb
-        if zone_target == DEFAULT_ZONE_TARGET:
c8bceb
-            action = "-g"
c8bceb
-        else:
c8bceb
-            action = "-j"
c8bceb
+        action = "-g"
c8bceb
+
c8bceb
         if enable and not append:
c8bceb
-            rule = [ "-I", "%s_ZONES" % chain, "1" ]
c8bceb
+            rule = [ "-I", "%s_ZONES_IFACES" % chain, "1" ]
c8bceb
         elif enable:
c8bceb
-            rule = [ "-A", "%s_ZONES" % chain ]
c8bceb
+            rule = [ "-A", "%s_ZONES_IFACES" % chain ]
c8bceb
         else:
c8bceb
-            rule = [ "-D", "%s_ZONES" % chain ]
c8bceb
+            rule = [ "-D", "%s_ZONES_IFACES" % chain ]
c8bceb
         rule += [ "-t", table, opt, interface, action, target ]
c8bceb
         return [rule]
c8bceb
 
c8bceb
-    def build_zone_source_address_rules(self, enable, zone, zone_target,
c8bceb
+    def build_zone_source_address_rules(self, enable, zone,
c8bceb
                                         address, table, chain):
c8bceb
-        add_del = { True: "-A", False: "-D" }[enable]
c8bceb
+        add_del = { True: "-I", False: "-D" }[enable]
c8bceb
 
c8bceb
         opt = {
c8bceb
             "PREROUTING": "-s",
c8bceb
@@ -681,10 +678,7 @@ class ip4tables(object):
c8bceb
         }[chain]
c8bceb
 
c8bceb
         target = DEFAULT_ZONE_TARGET.format(chain=SHORTCUTS[chain], zone=zone)
c8bceb
-        if zone_target == DEFAULT_ZONE_TARGET:
c8bceb
-            action = "-g"
c8bceb
-        else:
c8bceb
-            action = "-j"
c8bceb
+        action = "-g"
c8bceb
 
c8bceb
         if address.startswith("ipset:"):
c8bceb
             name = address[6:]
c8bceb
@@ -694,7 +688,7 @@ class ip4tables(object):
c8bceb
                 opt = "src"
c8bceb
             flags = ",".join([opt] * self._fw.ipset.get_dimension(name))
c8bceb
             rule = [ add_del,
c8bceb
-                     "%s_ZONES_SOURCE" % chain, "-t", table,
c8bceb
+                     "%s_ZONES" % chain, "-t", table,
c8bceb
                      "-m", "set", "--match-set", name,
c8bceb
                      flags, action, target ]
c8bceb
         else:
c8bceb
@@ -703,12 +697,12 @@ class ip4tables(object):
c8bceb
                 if opt == "-d":
c8bceb
                     return ""
c8bceb
                 rule = [ add_del,
c8bceb
-                         "%s_ZONES_SOURCE" % chain, "-t", table,
c8bceb
+                         "%s_ZONES" % chain, "-t", table,
c8bceb
                          "-m", "mac", "--mac-source", address.upper(),
c8bceb
                          action, target ]
c8bceb
             else:
c8bceb
                 rule = [ add_del,
c8bceb
-                         "%s_ZONES_SOURCE" % chain, "-t", table,
c8bceb
+                         "%s_ZONES" % chain, "-t", table,
c8bceb
                          opt, address, action, target ]
c8bceb
         return [rule]
c8bceb
 
c8bceb
diff --git a/src/firewall/core/nftables.py b/src/firewall/core/nftables.py
c8bceb
index bf41ed98a542..0fe686a01878 100644
c8bceb
--- a/src/firewall/core/nftables.py
c8bceb
+++ b/src/firewall/core/nftables.py
c8bceb
@@ -358,11 +358,11 @@ class nftables(object):
c8bceb
                                   IPTABLES_TO_NFT_HOOK["raw"][chain][0],
c8bceb
                                   IPTABLES_TO_NFT_HOOK["raw"][chain][1]))
c8bceb
 
c8bceb
-            default_rules.append("add chain inet %s raw_%s_ZONES_SOURCE" % (TABLE_NAME, chain))
c8bceb
             default_rules.append("add chain inet %s raw_%s_ZONES" % (TABLE_NAME, chain))
c8bceb
-            default_rules.append("add rule inet %s raw_%s jump raw_%s_ZONES_SOURCE" % (TABLE_NAME, chain, chain))
c8bceb
+            default_rules.append("add chain inet %s raw_%s_ZONES_IFACES" % (TABLE_NAME, chain))
c8bceb
             default_rules.append("add rule inet %s raw_%s jump raw_%s_ZONES" % (TABLE_NAME, chain, chain))
c8bceb
-            OUR_CHAINS["inet"]["raw"].update(set(["%s_ZONES_SOURCE" % chain, "%s_ZONES" % chain]))
c8bceb
+            default_rules.append("add rule inet %s raw_%s_ZONES goto raw_%s_ZONES_IFACES" % (TABLE_NAME, chain, chain))
c8bceb
+            OUR_CHAINS["inet"]["raw"].update(set(["%s_ZONES_IFACES" % chain, "%s_ZONES" % chain]))
c8bceb
 
c8bceb
         OUR_CHAINS["inet"]["mangle"] = set()
c8bceb
         for chain in IPTABLES_TO_NFT_HOOK["mangle"].keys():
c8bceb
@@ -371,11 +371,11 @@ class nftables(object):
c8bceb
                                   IPTABLES_TO_NFT_HOOK["mangle"][chain][0],
c8bceb
                                   IPTABLES_TO_NFT_HOOK["mangle"][chain][1]))
c8bceb
 
c8bceb
-            default_rules.append("add chain inet %s mangle_%s_ZONES_SOURCE" % (TABLE_NAME, chain))
c8bceb
             default_rules.append("add chain inet %s mangle_%s_ZONES" % (TABLE_NAME, chain))
c8bceb
-            default_rules.append("add rule inet %s mangle_%s jump mangle_%s_ZONES_SOURCE" % (TABLE_NAME, chain, chain))
c8bceb
+            default_rules.append("add chain inet %s mangle_%s_ZONES_IFACES" % (TABLE_NAME, chain))
c8bceb
             default_rules.append("add rule inet %s mangle_%s jump mangle_%s_ZONES" % (TABLE_NAME, chain, chain))
c8bceb
-            OUR_CHAINS["inet"]["mangle"].update(set(["%s_ZONES_SOURCE" % chain, "%s_ZONES" % chain]))
c8bceb
+            default_rules.append("add rule inet %s mangle_%s_ZONES goto mangle_%s_ZONES_IFACES" % (TABLE_NAME, chain, chain))
c8bceb
+            OUR_CHAINS["inet"]["mangle"].update(set(["%s_ZONES_IFACES" % chain, "%s_ZONES" % chain]))
c8bceb
 
c8bceb
         OUR_CHAINS["ip"]["nat"] = set()
c8bceb
         OUR_CHAINS["ip6"]["nat"] = set()
c8bceb
@@ -386,11 +386,11 @@ class nftables(object):
c8bceb
                                       IPTABLES_TO_NFT_HOOK["nat"][chain][0],
c8bceb
                                       IPTABLES_TO_NFT_HOOK["nat"][chain][1]))
c8bceb
 
c8bceb
-                default_rules.append("add chain %s %s nat_%s_ZONES_SOURCE" % (family, TABLE_NAME, chain))
c8bceb
                 default_rules.append("add chain %s %s nat_%s_ZONES" % (family, TABLE_NAME, chain))
c8bceb
-                default_rules.append("add rule %s %s nat_%s jump nat_%s_ZONES_SOURCE" % (family, TABLE_NAME, chain, chain))
c8bceb
+                default_rules.append("add chain %s %s nat_%s_ZONES_IFACES" % (family, TABLE_NAME, chain))
c8bceb
                 default_rules.append("add rule %s %s nat_%s jump nat_%s_ZONES" % (family, TABLE_NAME, chain, chain))
c8bceb
-                OUR_CHAINS[family]["nat"].update(set(["%s_ZONES_SOURCE" % chain, "%s_ZONES" % chain]))
c8bceb
+                default_rules.append("add rule %s %s nat_%s_ZONES goto nat_%s_ZONES_IFACES" % (family, TABLE_NAME, chain, chain))
c8bceb
+                OUR_CHAINS[family]["nat"].update(set(["%s_ZONES_IFACES" % chain, "%s_ZONES" % chain]))
c8bceb
 
c8bceb
         OUR_CHAINS["inet"]["filter"] = set()
c8bceb
         for chain in IPTABLES_TO_NFT_HOOK["filter"].keys():
c8bceb
@@ -400,12 +400,12 @@ class nftables(object):
c8bceb
                                   IPTABLES_TO_NFT_HOOK["filter"][chain][1]))
c8bceb
 
c8bceb
         # filter, INPUT
c8bceb
-        default_rules.append("add chain inet %s filter_%s_ZONES_SOURCE" % (TABLE_NAME, "INPUT"))
c8bceb
         default_rules.append("add chain inet %s filter_%s_ZONES" % (TABLE_NAME, "INPUT"))
c8bceb
+        default_rules.append("add chain inet %s filter_%s_ZONES_IFACES" % (TABLE_NAME, "INPUT"))
c8bceb
         default_rules.append("add rule inet %s filter_%s ct state established,related accept" % (TABLE_NAME, "INPUT"))
c8bceb
         default_rules.append("add rule inet %s filter_%s iifname lo accept" % (TABLE_NAME, "INPUT"))
c8bceb
-        default_rules.append("add rule inet %s filter_%s jump filter_%s_ZONES_SOURCE" % (TABLE_NAME, "INPUT", "INPUT"))
c8bceb
         default_rules.append("add rule inet %s filter_%s jump filter_%s_ZONES" % (TABLE_NAME, "INPUT", "INPUT"))
c8bceb
+        default_rules.append("add rule inet %s filter_%s_ZONES goto filter_%s_ZONES_IFACES" % (TABLE_NAME, "INPUT", "INPUT"))
c8bceb
         if log_denied != "off":
c8bceb
             default_rules.append("add rule inet %s filter_%s ct state invalid %%%%LOGTYPE%%%% log prefix '\"STATE_INVALID_DROP: \"'" % (TABLE_NAME, "INPUT"))
c8bceb
         default_rules.append("add rule inet %s filter_%s ct state invalid drop" % (TABLE_NAME, "INPUT"))
c8bceb
@@ -414,16 +414,16 @@ class nftables(object):
c8bceb
         default_rules.append("add rule inet %s filter_%s reject with icmpx type admin-prohibited" % (TABLE_NAME, "INPUT"))
c8bceb
 
c8bceb
         # filter, FORWARD
c8bceb
-        default_rules.append("add chain inet %s filter_%s_IN_ZONES_SOURCE" % (TABLE_NAME, "FORWARD"))
c8bceb
         default_rules.append("add chain inet %s filter_%s_IN_ZONES" % (TABLE_NAME, "FORWARD"))
c8bceb
-        default_rules.append("add chain inet %s filter_%s_OUT_ZONES_SOURCE" % (TABLE_NAME, "FORWARD"))
c8bceb
+        default_rules.append("add chain inet %s filter_%s_IN_ZONES_IFACES" % (TABLE_NAME, "FORWARD"))
c8bceb
         default_rules.append("add chain inet %s filter_%s_OUT_ZONES" % (TABLE_NAME, "FORWARD"))
c8bceb
+        default_rules.append("add chain inet %s filter_%s_OUT_ZONES_IFACES" % (TABLE_NAME, "FORWARD"))
c8bceb
         default_rules.append("add rule inet %s filter_%s ct state established,related accept" % (TABLE_NAME, "FORWARD"))
c8bceb
         default_rules.append("add rule inet %s filter_%s iifname lo accept" % (TABLE_NAME, "FORWARD"))
c8bceb
-        default_rules.append("add rule inet %s filter_%s jump filter_%s_IN_ZONES_SOURCE" % (TABLE_NAME, "FORWARD", "FORWARD"))
c8bceb
         default_rules.append("add rule inet %s filter_%s jump filter_%s_IN_ZONES" % (TABLE_NAME, "FORWARD", "FORWARD"))
c8bceb
-        default_rules.append("add rule inet %s filter_%s jump filter_%s_OUT_ZONES_SOURCE" % (TABLE_NAME, "FORWARD", "FORWARD"))
c8bceb
         default_rules.append("add rule inet %s filter_%s jump filter_%s_OUT_ZONES" % (TABLE_NAME, "FORWARD", "FORWARD"))
c8bceb
+        default_rules.append("add rule inet %s filter_%s_IN_ZONES goto filter_%s_IN_ZONES_IFACES" % (TABLE_NAME, "FORWARD", "FORWARD"))
c8bceb
+        default_rules.append("add rule inet %s filter_%s_OUT_ZONES goto filter_%s_OUT_ZONES_IFACES" % (TABLE_NAME, "FORWARD", "FORWARD"))
c8bceb
         if log_denied != "off":
c8bceb
             default_rules.append("add rule inet %s filter_%s ct state invalid %%%%LOGTYPE%%%% log prefix '\"STATE_INVALID_DROP: \"'" % (TABLE_NAME, "FORWARD"))
c8bceb
         default_rules.append("add rule inet %s filter_%s ct state invalid drop" % (TABLE_NAME, "FORWARD"))
c8bceb
@@ -452,16 +452,16 @@ class nftables(object):
c8bceb
 
c8bceb
         return {}
c8bceb
 
c8bceb
-    def build_zone_source_interface_rules(self, enable, zone, zone_target,
c8bceb
-                                          interface, table, chain,
c8bceb
-                                          append=False, family="inet"):
c8bceb
+    def build_zone_source_interface_rules(self, enable, zone, interface,
c8bceb
+                                          table, chain, append=False,
c8bceb
+                                          family="inet"):
c8bceb
         # nat tables needs to use ip/ip6 family
c8bceb
         if table == "nat" and family == "inet":
c8bceb
             rules = []
c8bceb
             rules.extend(self.build_zone_source_interface_rules(enable, zone,
c8bceb
-                            zone_target, interface, table, chain, append, "ip"))
c8bceb
+                            interface, table, chain, append, "ip"))
c8bceb
             rules.extend(self.build_zone_source_interface_rules(enable, zone,
c8bceb
-                            zone_target, interface, table, chain, append, "ip6"))
c8bceb
+                            interface, table, chain, append, "ip6"))
c8bceb
             return rules
c8bceb
 
c8bceb
         # handle all zones in the same way here, now
c8bceb
@@ -479,36 +479,34 @@ class nftables(object):
c8bceb
             interface = interface[:len(interface)-1] + "*"
c8bceb
 
c8bceb
         target = DEFAULT_ZONE_TARGET.format(chain=SHORTCUTS[chain], zone=zone)
c8bceb
-        if zone_target == DEFAULT_ZONE_TARGET:
c8bceb
-            action = "goto"
c8bceb
-        else:
c8bceb
-            action = "jump"
c8bceb
+        action = "goto"
c8bceb
+
c8bceb
         if enable and not append:
c8bceb
-            rule = ["insert", "rule", family, "%s" % TABLE_NAME, "%s_%s_ZONES" % (table, chain)]
c8bceb
+            rule = ["insert", "rule", family, "%s" % TABLE_NAME, "%s_%s_ZONES_IFACES" % (table, chain)]
c8bceb
         elif enable:
c8bceb
-            rule = ["add", "rule", family, "%s" % TABLE_NAME, "%s_%s_ZONES" % (table, chain)]
c8bceb
+            rule = ["add", "rule", family, "%s" % TABLE_NAME, "%s_%s_ZONES_IFACES" % (table, chain)]
c8bceb
         else:
c8bceb
-            rule = ["delete", "rule", family, "%s" % TABLE_NAME, "%s_%s_ZONES" % (table, chain)]
c8bceb
+            rule = ["delete", "rule", family, "%s" % TABLE_NAME, "%s_%s_ZONES_IFACES" % (table, chain)]
c8bceb
         if interface == "*":
c8bceb
             rule += [action, "%s_%s" % (table, target)]
c8bceb
         else:
c8bceb
             rule += [opt, "\"" + interface + "\"", action, "%s_%s" % (table, target)]
c8bceb
         return [rule]
c8bceb
 
c8bceb
-    def build_zone_source_address_rules(self, enable, zone, zone_target,
c8bceb
+    def build_zone_source_address_rules(self, enable, zone,
c8bceb
                                         address, table, chain, family="inet"):
c8bceb
         # nat tables needs to use ip/ip6 family
c8bceb
         if table == "nat" and family == "inet":
c8bceb
             rules = []
c8bceb
             if check_address("ipv4", address) or check_mac(address):
c8bceb
                 rules.extend(self.build_zone_source_address_rules(enable, zone,
c8bceb
-                                    zone_target, address, table, chain, "ip"))
c8bceb
+                                    address, table, chain, "ip"))
c8bceb
             if check_address("ipv6", address) or check_mac(address):
c8bceb
                 rules.extend(self.build_zone_source_address_rules(enable, zone,
c8bceb
-                                    zone_target, address, table, chain, "ip6"))
c8bceb
+                                    address, table, chain, "ip6"))
c8bceb
             return rules
c8bceb
 
c8bceb
-        add_del = { True: "add", False: "delete" }[enable]
c8bceb
+        add_del = { True: "insert", False: "delete" }[enable]
c8bceb
 
c8bceb
         opt = {
c8bceb
             "PREROUTING": "saddr",
c8bceb
@@ -520,10 +518,7 @@ class nftables(object):
c8bceb
         }[chain]
c8bceb
 
c8bceb
         target = DEFAULT_ZONE_TARGET.format(chain=SHORTCUTS[chain], zone=zone)
c8bceb
-        if zone_target == DEFAULT_ZONE_TARGET:
c8bceb
-            action = "goto"
c8bceb
-        else:
c8bceb
-            action = "jump"
c8bceb
+        action = "goto"
c8bceb
 
c8bceb
         if address.startswith("ipset:"):
c8bceb
             ipset = address[len("ipset:"):]
c8bceb
@@ -541,7 +536,7 @@ class nftables(object):
c8bceb
                 rule_family = "ip6"
c8bceb
 
c8bceb
         rule = [add_del, "rule", family, "%s" % TABLE_NAME,
c8bceb
-                "%s_%s_ZONES_SOURCE" % (table, chain),
c8bceb
+                "%s_%s_ZONES" % (table, chain),
c8bceb
                 rule_family, opt, address, action, "%s_%s" % (table, target)]
c8bceb
         return [rule]
c8bceb
 
c8bceb
diff --git a/src/tests/firewall-cmd.at b/src/tests/firewall-cmd.at
c8bceb
index a3844151aeb3..0f9cac204ccd 100644
c8bceb
--- a/src/tests/firewall-cmd.at
c8bceb
+++ b/src/tests/firewall-cmd.at
c8bceb
@@ -138,14 +138,14 @@ FWD_START_TEST([zone interfaces])
c8bceb
     FWD_CHECK([--add-interface=foobar+++], 0, ignore)
c8bceb
     FWD_CHECK([--add-interface=foobar+], 0, ignore)
c8bceb
     m4_if(nftables, FIREWALL_BACKEND, [
c8bceb
-    NFT_LIST_RULES([inet], [filter_INPUT_ZONES], 0, [dnl
c8bceb
+    NFT_LIST_RULES([inet], [filter_INPUT_ZONES_IFACES], 0, [dnl
c8bceb
         table inet firewalld {
c8bceb
-        chain filter_INPUT_ZONES {
c8bceb
+        chain filter_INPUT_ZONES_IFACES {
c8bceb
             iifname "foobar*" goto filter_IN_public
c8bceb
             iifname "foobar++*" goto filter_IN_public
c8bceb
-            jump filter_IN_trusted
c8bceb
+            goto filter_IN_trusted
c8bceb
             iifname "perm_dummy" goto filter_IN_work
c8bceb
-            iifname "perm_dummy2" jump filter_IN_trusted
c8bceb
+            iifname "perm_dummy2" goto filter_IN_trusted
c8bceb
             goto filter_IN_public
c8bceb
         }
c8bceb
         }
c8bceb
-- 
c8bceb
2.20.1
c8bceb