Skip to content

Commit

Permalink
firewall: T4502: add ofload to firewall table actions
Browse files Browse the repository at this point in the history
  • Loading branch information
GurliGebis authored Dec 15, 2023
1 parent c2bbfc0 commit e2d9b21
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
8 changes: 6 additions & 2 deletions interface-definitions/include/firewall/action.xml.i
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<properties>
<help>Rule action</help>
<completionHelp>
<list>accept continue jump reject return drop queue synproxy</list>
<list>accept continue jump reject return drop queue offload synproxy</list>
</completionHelp>
<valueHelp>
<format>accept</format>
Expand Down Expand Up @@ -33,12 +33,16 @@
<format>queue</format>
<description>Enqueue packet to userspace</description>
</valueHelp>
<valueHelp>
<format>offload</format>
<description>Offload packet via flowtable</description>
</valueHelp>
<valueHelp>
<format>synproxy</format>
<description>Synproxy connections</description>
</valueHelp>
<constraint>
<regex>(accept|continue|jump|reject|return|drop|queue|synproxy)</regex>
<regex>(accept|continue|jump|reject|return|drop|queue|offload|synproxy)</regex>
</constraint>
</properties>
</leafNode>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<children>
#include <include/firewall/common-rule-ipv4.xml.i>
#include <include/firewall/inbound-interface.xml.i>
#include <include/firewall/offload-target.xml.i>
#include <include/firewall/outbound-interface.xml.i>
</children>
</tagNode>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<children>
#include <include/firewall/common-rule-ipv6.xml.i>
#include <include/firewall/inbound-interface.xml.i>
#include <include/firewall/offload-target.xml.i>
#include <include/firewall/outbound-interface.xml.i>
</children>
</tagNode>
Expand Down
36 changes: 36 additions & 0 deletions smoketest/scripts/cli/test_firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,5 +753,41 @@ def test_flow_offload(self):
self.verify_nftables_chain([['accept']], 'ip vyos_conntrack', 'FW_CONNTRACK')
self.verify_nftables_chain([['accept']], 'ip6 vyos_conntrack', 'FW_CONNTRACK')

def test_zone_flow_offload(self):
self.cli_set(['firewall', 'flowtable', 'smoketest', 'interface', 'eth0'])
self.cli_set(['firewall', 'flowtable', 'smoketest', 'offload', 'hardware'])

# QEMU virtual NIC does not support hw-tc-offload
with self.assertRaises(ConfigSessionError):
self.cli_commit()

self.cli_set(['firewall', 'flowtable', 'smoketest', 'offload', 'software'])

self.cli_set(['firewall', 'ipv4', 'name', 'smoketest', 'rule', '1', 'action', 'offload'])
self.cli_set(['firewall', 'ipv4', 'name', 'smoketest', 'rule', '1', 'offload-target', 'smoketest'])

self.cli_set(['firewall', 'ipv6', 'name', 'smoketest', 'rule', '1', 'action', 'offload'])
self.cli_set(['firewall', 'ipv6', 'name', 'smoketest', 'rule', '1', 'offload-target', 'smoketest'])

self.cli_commit()

nftables_search = [
['chain NAME_smoketest'],
['flow add @VYOS_FLOWTABLE_smoketest']
]

self.verify_nftables(nftables_search, 'ip vyos_filter')

nftables_search = [
['chain NAME6_smoketest'],
['flow add @VYOS_FLOWTABLE_smoketest']
]

self.verify_nftables(nftables_search, 'ip6 vyos_filter')

# Check conntrack
self.verify_nftables_chain([['accept']], 'ip vyos_conntrack', 'FW_CONNTRACK')
self.verify_nftables_chain([['accept']], 'ip6 vyos_conntrack', 'FW_CONNTRACK')

if __name__ == '__main__':
unittest.main(verbosity=2)

0 comments on commit e2d9b21

Please sign in to comment.