|
|
00d018 |
From 244d1bfe190f2cc32c10d0fecaf81536761ecc09 Mon Sep 17 00:00:00 2001
|
|
|
00d018 |
From: Eric Garver <eric@garver.life>
|
|
|
00d018 |
Date: Tue, 1 Sep 2020 13:16:23 -0400
|
|
|
00d018 |
Subject: [PATCH 59/62] fix(icmptype): nftables: runtimeToPermanent if
|
|
|
00d018 |
ip6tables not available
|
|
|
00d018 |
|
|
|
00d018 |
We were not filling the runtime ipv6 icmptypes list if the active
|
|
|
00d018 |
backend was nftables and ip6tables wasn't available. This caused "ipv6"
|
|
|
00d018 |
to be dropped from the supported ipvs/destinations for the icmptype.
|
|
|
00d018 |
This also caused runtimeToPermanent to fail because the runtime
|
|
|
00d018 |
icmptypes definition dropped "ipv6" causing runtimeToPermanent to copy
|
|
|
00d018 |
the runtime icmptype to permanent because they were different... this
|
|
|
00d018 |
caused sanity checks on the permanent configuration to fail.
|
|
|
00d018 |
|
|
|
00d018 |
(cherry picked from commit c92d43dcdf5622e82e28454652acd6a981b015f9)
|
|
|
00d018 |
(cherry picked from commit 6f23f727be818f356625e39682fb226a81925647)
|
|
|
00d018 |
---
|
|
|
00d018 |
src/firewall/core/fw.py | 24 ++++++++++++++----------
|
|
|
00d018 |
src/firewall/core/fw_icmptype.py | 8 ++++----
|
|
|
00d018 |
src/firewall/core/ipXtables.py | 2 +-
|
|
|
00d018 |
src/firewall/core/nftables.py | 6 +++---
|
|
|
00d018 |
src/firewall/server/firewalld.py | 4 ++--
|
|
|
00d018 |
5 files changed, 24 insertions(+), 20 deletions(-)
|
|
|
00d018 |
|
|
|
00d018 |
diff --git a/src/firewall/core/fw.py b/src/firewall/core/fw.py
|
|
|
00d018 |
index c767f416f3d2..1df916efb10f 100644
|
|
|
00d018 |
--- a/src/firewall/core/fw.py
|
|
|
00d018 |
+++ b/src/firewall/core/fw.py
|
|
|
00d018 |
@@ -76,10 +76,10 @@ class Firewall(object):
|
|
|
00d018 |
else:
|
|
|
00d018 |
self.ip4tables_backend = ipXtables.ip4tables(self)
|
|
|
00d018 |
self.ip4tables_enabled = True
|
|
|
00d018 |
- self.ip4tables_supported_icmp_types = [ ]
|
|
|
00d018 |
+ self.ipv4_supported_icmp_types = [ ]
|
|
|
00d018 |
self.ip6tables_backend = ipXtables.ip6tables(self)
|
|
|
00d018 |
self.ip6tables_enabled = True
|
|
|
00d018 |
- self.ip6tables_supported_icmp_types = [ ]
|
|
|
00d018 |
+ self.ipv6_supported_icmp_types = [ ]
|
|
|
00d018 |
self.ebtables_backend = ebtables.ebtables()
|
|
|
00d018 |
self.ebtables_enabled = True
|
|
|
00d018 |
self.ipset_backend = ipset.ipset()
|
|
|
00d018 |
@@ -172,11 +172,13 @@ class Firewall(object):
|
|
|
00d018 |
log.warning("iptables-restore and iptables are missing, "
|
|
|
00d018 |
"disabling IPv4 firewall.")
|
|
|
00d018 |
self.ip4tables_enabled = False
|
|
|
00d018 |
- if self.ip4tables_enabled:
|
|
|
00d018 |
- self.ip4tables_supported_icmp_types = \
|
|
|
00d018 |
- self.ip4tables_backend.supported_icmp_types()
|
|
|
00d018 |
+ if self.nftables_enabled:
|
|
|
00d018 |
+ self.ipv4_supported_icmp_types = self.nftables_backend.supported_icmp_types("ipv4")
|
|
|
00d018 |
else:
|
|
|
00d018 |
- self.ip4tables_supported_icmp_types = [ ]
|
|
|
00d018 |
+ if self.ip4tables_enabled:
|
|
|
00d018 |
+ self.ipv4_supported_icmp_types = self.ip4tables_backend.supported_icmp_types()
|
|
|
00d018 |
+ else:
|
|
|
00d018 |
+ self.ipv4_supported_icmp_types = [ ]
|
|
|
00d018 |
self.ip6tables_backend.fill_exists()
|
|
|
00d018 |
if not self.ip6tables_backend.restore_command_exists:
|
|
|
00d018 |
if self.ip6tables_backend.command_exists:
|
|
|
00d018 |
@@ -186,11 +188,13 @@ class Firewall(object):
|
|
|
00d018 |
log.warning("ip6tables-restore and ip6tables are missing, "
|
|
|
00d018 |
"disabling IPv6 firewall.")
|
|
|
00d018 |
self.ip6tables_enabled = False
|
|
|
00d018 |
- if self.ip6tables_enabled:
|
|
|
00d018 |
- self.ip6tables_supported_icmp_types = \
|
|
|
00d018 |
- self.ip6tables_backend.supported_icmp_types()
|
|
|
00d018 |
+ if self.nftables_enabled:
|
|
|
00d018 |
+ self.ipv6_supported_icmp_types = self.nftables_backend.supported_icmp_types("ipv6")
|
|
|
00d018 |
else:
|
|
|
00d018 |
- self.ip6tables_supported_icmp_types = [ ]
|
|
|
00d018 |
+ if self.ip6tables_enabled:
|
|
|
00d018 |
+ self.ipv6_supported_icmp_types = self.ip6tables_backend.supported_icmp_types()
|
|
|
00d018 |
+ else:
|
|
|
00d018 |
+ self.ipv6_supported_icmp_types = [ ]
|
|
|
00d018 |
self.ebtables_backend.fill_exists()
|
|
|
00d018 |
if not self.ebtables_backend.restore_command_exists:
|
|
|
00d018 |
if self.ebtables_backend.command_exists:
|
|
|
00d018 |
diff --git a/src/firewall/core/fw_icmptype.py b/src/firewall/core/fw_icmptype.py
|
|
|
00d018 |
index afe9f91d6bf6..a565bb6d8733 100644
|
|
|
00d018 |
--- a/src/firewall/core/fw_icmptype.py
|
|
|
00d018 |
+++ b/src/firewall/core/fw_icmptype.py
|
|
|
00d018 |
@@ -57,13 +57,13 @@ class FirewallIcmpType(object):
|
|
|
00d018 |
ipvs = orig_ipvs[:]
|
|
|
00d018 |
for ipv in orig_ipvs:
|
|
|
00d018 |
if ipv == "ipv4":
|
|
|
00d018 |
- if not self._fw.ip4tables_enabled:
|
|
|
00d018 |
+ if not self._fw.ip4tables_enabled and not self._fw.nftables_enabled:
|
|
|
00d018 |
continue
|
|
|
00d018 |
- supported_icmps = self._fw.ip4tables_supported_icmp_types
|
|
|
00d018 |
+ supported_icmps = self._fw.ipv4_supported_icmp_types
|
|
|
00d018 |
elif ipv == "ipv6":
|
|
|
00d018 |
- if not self._fw.ip6tables_enabled:
|
|
|
00d018 |
+ if not self._fw.ip6tables_enabled and not self._fw.nftables_enabled:
|
|
|
00d018 |
continue
|
|
|
00d018 |
- supported_icmps = self._fw.ip6tables_supported_icmp_types
|
|
|
00d018 |
+ supported_icmps = self._fw.ipv6_supported_icmp_types
|
|
|
00d018 |
else:
|
|
|
00d018 |
supported_icmps = [ ]
|
|
|
00d018 |
if obj.name.lower() not in supported_icmps:
|
|
|
00d018 |
diff --git a/src/firewall/core/ipXtables.py b/src/firewall/core/ipXtables.py
|
|
|
00d018 |
index c4535f2e5818..450e427c08b5 100644
|
|
|
00d018 |
--- a/src/firewall/core/ipXtables.py
|
|
|
00d018 |
+++ b/src/firewall/core/ipXtables.py
|
|
|
00d018 |
@@ -612,7 +612,7 @@ class ip4tables(object):
|
|
|
00d018 |
rules.append(["-t", table, "-P", chain, _policy])
|
|
|
00d018 |
return rules
|
|
|
00d018 |
|
|
|
00d018 |
- def supported_icmp_types(self):
|
|
|
00d018 |
+ def supported_icmp_types(self, ipv=None):
|
|
|
00d018 |
"""Return ICMP types that are supported by the iptables/ip6tables command and kernel"""
|
|
|
00d018 |
ret = [ ]
|
|
|
00d018 |
output = ""
|
|
|
00d018 |
diff --git a/src/firewall/core/nftables.py b/src/firewall/core/nftables.py
|
|
|
00d018 |
index daa7ace085a2..0a73c2c2669d 100644
|
|
|
00d018 |
--- a/src/firewall/core/nftables.py
|
|
|
00d018 |
+++ b/src/firewall/core/nftables.py
|
|
|
00d018 |
@@ -480,13 +480,13 @@ class nftables(object):
|
|
|
00d018 |
|
|
|
00d018 |
return rules
|
|
|
00d018 |
|
|
|
00d018 |
- def supported_icmp_types(self):
|
|
|
00d018 |
+ def supported_icmp_types(self, ipv=None):
|
|
|
00d018 |
# nftables supports any icmp_type via arbitrary type/code matching.
|
|
|
00d018 |
# We just need a translation for it in ICMP_TYPES_FRAGMENTS.
|
|
|
00d018 |
supported = set()
|
|
|
00d018 |
|
|
|
00d018 |
- for ipv in ICMP_TYPES_FRAGMENTS.keys():
|
|
|
00d018 |
- supported.update(ICMP_TYPES_FRAGMENTS[ipv].keys())
|
|
|
00d018 |
+ for _ipv in [ipv] if ipv else ICMP_TYPES_FRAGMENTS.keys():
|
|
|
00d018 |
+ supported.update(ICMP_TYPES_FRAGMENTS[_ipv].keys())
|
|
|
00d018 |
|
|
|
00d018 |
return list(supported)
|
|
|
00d018 |
|
|
|
00d018 |
diff --git a/src/firewall/server/firewalld.py b/src/firewall/server/firewalld.py
|
|
|
00d018 |
index 10b085d48660..949f577053cc 100644
|
|
|
00d018 |
--- a/src/firewall/server/firewalld.py
|
|
|
00d018 |
+++ b/src/firewall/server/firewalld.py
|
|
|
00d018 |
@@ -162,7 +162,7 @@ class FirewallD(slip.dbus.service.Object):
|
|
|
00d018 |
return dbus.Boolean(self.fw.ip4tables_enabled)
|
|
|
00d018 |
|
|
|
00d018 |
elif prop == "IPv4ICMPTypes":
|
|
|
00d018 |
- return dbus.Array(self.fw.ip4tables_supported_icmp_types, "s")
|
|
|
00d018 |
+ return dbus.Array(self.fw.ipv4_supported_icmp_types, "s")
|
|
|
00d018 |
|
|
|
00d018 |
elif prop == "IPv6":
|
|
|
00d018 |
return dbus.Boolean(self.fw.ip6tables_enabled)
|
|
|
00d018 |
@@ -171,7 +171,7 @@ class FirewallD(slip.dbus.service.Object):
|
|
|
00d018 |
return dbus.Boolean(self.fw.ipv6_rpfilter_enabled)
|
|
|
00d018 |
|
|
|
00d018 |
elif prop == "IPv6ICMPTypes":
|
|
|
00d018 |
- return dbus.Array(self.fw.ip6tables_supported_icmp_types, "s")
|
|
|
00d018 |
+ return dbus.Array(self.fw.ipv6_supported_icmp_types, "s")
|
|
|
00d018 |
|
|
|
00d018 |
elif prop == "BRIDGE":
|
|
|
00d018 |
return dbus.Boolean(self.fw.ebtables_enabled)
|
|
|
00d018 |
--
|
|
|
00d018 |
2.28.0
|
|
|
00d018 |
|