Skip to content

Commit

Permalink
python3 flake: fix CsNetfilter.py
Browse files Browse the repository at this point in the history
```
../debian/opt/cloud/bin/cs/CsNetfilter.py:226:13: E117 over-indented
../debian/opt/cloud/bin/cs/CsNetfilter.py:233:180: E501 line too long (197 > 179 characters)
../debian/opt/cloud/bin/cs/CsNetfilter.py:241:14: E201 whitespace after '{'
../debian/opt/cloud/bin/cs/CsNetfilter.py:242:14: E201 whitespace after '{'
../debian/opt/cloud/bin/cs/CsNetfilter.py:247:18: E201 whitespace after '{'
../debian/opt/cloud/bin/cs/CsNetfilter.py:247:74: E202 whitespace before '}'
../debian/opt/cloud/bin/cs/CsNetfilter.py:248:18: E201 whitespace after '{'
```
  • Loading branch information
weizhouapache committed Jan 30, 2024
1 parent f676edc commit 0ff96f3
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions systemvm/debian/opt/cloud/bin/cs/CsNetfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,29 +223,30 @@ def delete(self, rule):
self.rules[:] = [x for x in self.rules if not x == rule]

def add_ip6_chain(self, address_family, table, chain, hook, action):
chain_policy = ""
if hook:
chain_policy = "type filter hook %s priority 0;" % hook
if chain_policy and action:
chain_policy = "%s policy %s;" % (chain_policy, action)
CsHelper.execute("nft add chain %s %s %s '{ %s }'" % (address_family, table, chain, chain_policy))
if hook == "input" or hook == "output":
CsHelper.execute("nft add rule %s %s %s icmpv6 type { echo-request, echo-reply, nd-neighbor-solicit, nd-router-advert, nd-neighbor-advert } accept" % (address_family, table, chain))
chain_policy = ""
if hook:
chain_policy = "type filter hook %s priority 0;" % hook
if chain_policy and action:
chain_policy = "%s policy %s;" % (chain_policy, action)
CsHelper.execute("nft add chain %s %s %s '{ %s }'" % (address_family, table, chain, chain_policy))
if hook == "input" or hook == "output":
CsHelper.execute("nft add rule %s %s %s icmpv6 type { echo-request, echo-reply, \
nd-neighbor-solicit, nd-router-advert, nd-neighbor-advert } accept" % (address_family, table, chain))

def apply_ip6_rules(self, rules, type):
if len(rules) == 0:
return
address_family = 'ip6'
table = 'ip6_firewall'
default_chains = [
{ "chain": "fw_input", "hook": "input", "action": "drop"},
{ "chain": "fw_forward", "hook": "forward", "action": "accept"}
{"chain": "fw_input", "hook": "input", "action": "drop"},
{"chain": "fw_forward", "hook": "forward", "action": "accept"}
]
if type == "acl":
table = 'ip6_acl'
default_chains = [
{ "chain": "acl_input", "hook": "input", "action": "drop" },
{ "chain": "acl_forward", "hook": "forward", "action": "accept"}
{"chain": "acl_input", "hook": "input", "action": "drop"},
{"chain": "acl_forward", "hook": "forward", "action": "accept"}
]
CsHelper.execute("nft add table %s %s" % (address_family, table))
for chain in default_chains:
Expand Down

0 comments on commit 0ff96f3

Please sign in to comment.