Skip to content

Commit

Permalink
qubes/firewall: allow listing only IPv4/IPv6 rules
Browse files Browse the repository at this point in the history
This will allow setting only IPv4-related rules to IPv4 address, and the
same for IPv6

QubesOS/qubes-issues#1815
  • Loading branch information
marmarek committed Sep 19, 2016
1 parent e01f7b9 commit 5123f46
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion qubes/firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,16 @@ def save(self):
"qubes-reload-firewall@%s.timer" % self.vm.name])


def qdb_entries(self):
def qdb_entries(self, addr_family=None):
entries = {
'policy': str(self.policy)
}
exclude_dsttype = None
if addr_family is not None:
exclude_dsttype = 'dst4' if addr_family == 6 else 'dst6'
for ruleno, rule in zip(itertools.count(), self.rules):
# exclude rules for another address family
if rule.dsthost and rule.dsthost.type == exclude_dsttype:
continue
entries['{:04}'.format(ruleno)] = rule.rule
return entries

0 comments on commit 5123f46

Please sign in to comment.