Skip to content

Commit

Permalink
qubes-firewall: Move dynamic forward rules to a dedicated chain.
Browse files Browse the repository at this point in the history
Users can jump to this chain to implement their custom configurations.

Closes: QubesOS/qubes-issues#9340
  • Loading branch information
3hhh committed Jul 5, 2024
1 parent 47ae4a3 commit 7447fa2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion qubesagent/firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def create_chain(self, addr, chain, family):
'table {family} {table} {{\n'
' chain {chain} {{\n'
' }}\n'
' chain forward {{\n'
' chain qubes-forward {{\n'
' {family} saddr {ip} jump {chain}\n'
' }}\n'
'}}\n'.format(
Expand Down Expand Up @@ -600,11 +600,14 @@ def apply_rules(self, source, rules):
def init(self):
nft_init = (
'table {family} qubes-firewall {{\n'
' chain qubes-forward {{\n'
' }}\n'
' chain forward {{\n'
' type filter hook forward priority 0;\n'
' policy drop;\n'
' ct state established,related accept\n'
' meta iifname != "vif*" accept\n'
' jump qubes-forward\n'
' }}\n'
' chain prerouting {{\n'
' type filter hook prerouting priority -300;\n'
Expand Down
8 changes: 7 additions & 1 deletion qubesagent/test_firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def expected_create_chain(self, family, addr, chain):
'table {family} qubes-firewall {{\n'
' chain {chain} {{\n'
' }}\n'
' chain forward {{\n'
' chain qubes-forward {{\n'
' {family} saddr {addr} jump {chain}\n'
' }}\n'
'}}\n'.format(family=family, addr=addr, chain=chain))
Expand Down Expand Up @@ -293,11 +293,14 @@ def test_006_init(self):
self.assertEqual(self.obj.loaded_rules,
[
'table ip qubes-firewall {\n'
' chain qubes-forward {\n'
' }\n'
' chain forward {\n'
' type filter hook forward priority 0;\n'
' policy drop;\n'
' ct state established,related accept\n'
' meta iifname != "vif*" accept\n'
' jump qubes-forward\n'
' }\n'
' chain prerouting {\n'
' type filter hook prerouting priority -300;\n'
Expand All @@ -309,11 +312,14 @@ def test_006_init(self):
' }\n'
'}\n'
'table ip6 qubes-firewall {\n'
' chain qubes-forward {\n'
' }\n'
' chain forward {\n'
' type filter hook forward priority 0;\n'
' policy drop;\n'
' ct state established,related accept\n'
' meta iifname != "vif*" accept\n'
' jump qubes-forward\n'
' }\n'
' chain prerouting {\n'
' type filter hook prerouting priority -300;\n'
Expand Down

0 comments on commit 7447fa2

Please sign in to comment.