Skip to content

Commit

Permalink
T4072: change same helpers in xml definitions; add notrack action for…
Browse files Browse the repository at this point in the history
… prerouting chain; re introduce <set vrf> in policy; change global options for passing traffic to IPvX firewall; update smoketest
  • Loading branch information
nicolas-fort committed Jul 31, 2024
1 parent ddef041 commit b71702f
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 17 deletions.
6 changes: 3 additions & 3 deletions data/templates/firewall/sysctl-firewall.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ net.ipv4.conf.*.send_redirects = {{ 1 if global_options.send_redirects == 'enabl
net.ipv4.tcp_syncookies = {{ 1 if global_options.syn_cookies == 'enable' else 0 }}
net.ipv4.tcp_rfc1337 = {{ 1 if global_options.twa_hazards_protection == 'enable' else 0 }}

{% if global_options.apply_for_bridge is vyos_defined %}
net.bridge.bridge-nf-call-iptables = {{ 1 if global_options.apply_for_bridge.ipv4 is vyos_defined else 0 }}
net.bridge.bridge-nf-call-ip6tables = {{ 1 if global_options.apply_for_bridge.ipv6 is vyos_defined else 0 }}
{% if global_options.apply_to_bridged_traffic is vyos_defined %}
net.bridge.bridge-nf-call-iptables = {{ 1 if global_options.apply_to_bridged_traffic.ipv4 is vyos_defined else 0 }}
net.bridge.bridge-nf-call-ip6tables = {{ 1 if global_options.apply_to_bridged_traffic.ipv6 is vyos_defined else 0 }}
{% else %}
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-ip6tables = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
</properties>
<children>
#include <include/firewall/common-rule-bridge.xml.i>
#include <include/firewall/action-l2.xml.i>
#include <include/firewall/connection-mark.xml.i>
#include <include/firewall/connection-status.xml.i>
#include <include/firewall/state.xml.i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
</properties>
<children>
#include <include/firewall/common-rule-bridge.xml.i>
#include <include/firewall/action-l2.xml.i>
#include <include/firewall/connection-mark.xml.i>
#include <include/firewall/connection-status.xml.i>
#include <include/firewall/state.xml.i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
</properties>
<children>
#include <include/firewall/common-rule-bridge.xml.i>
#include <include/firewall/action-l2.xml.i>
#include <include/firewall/connection-mark.xml.i>
#include <include/firewall/connection-status.xml.i>
#include <include/firewall/state.xml.i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
</properties>
<children>
#include <include/firewall/common-rule-bridge.xml.i>
#include <include/firewall/action-l2.xml.i>
#include <include/firewall/connection-mark.xml.i>
#include <include/firewall/connection-status.xml.i>
#include <include/firewall/state.xml.i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <include/generic-description.xml.i>
<tagNode name="rule">
<properties>
<help>Bridge Firewall prerouting filter rule number</help>
<help>Bridge firewall prerouting filter rule number</help>
<valueHelp>
<format>u32:1-999999</format>
<description>Number for this firewall rule</description>
Expand All @@ -26,6 +26,7 @@
</properties>
<children>
#include <include/firewall/common-rule-bridge.xml.i>
#include <include/firewall/action-and-notrack.xml.i>
#include <include/firewall/set-packet-modifications.xml.i>
#include <include/firewall/inbound-interface.xml.i>
</children>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<!-- include start from firewall/common-rule-bridge.xml.i -->
#include <include/generic-description.xml.i>
#include <include/generic-disable-node.xml.i>
#include <include/firewall/action-l2.xml.i>
#include <include/firewall/dscp.xml.i>
#include <include/firewall/firewall-mark.xml.i>
#include <include/firewall/fragment.xml.i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</properties>
<defaultValue>disable</defaultValue>
</leafNode>
<node name="apply-for-bridge">
<node name="apply-to-bridged-traffic">
<properties>
<help>Apply configured firewall rules to traffic switched by bridges</help>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<children>
<leafNode name="connection-mark">
<properties>
<help>Connection marking</help>
<help>Set connection mark</help>
<valueHelp>
<format>u32:0-2147483647</format>
<description>Connection marking</description>
<description>Connection mark</description>
</valueHelp>
<constraint>
<validator name="numeric" argument="--range 0-2147483647"/>
Expand All @@ -18,7 +18,7 @@
</leafNode>
<leafNode name="dscp">
<properties>
<help>Packet Differentiated Services Codepoint (DSCP)</help>
<help>Set DSCP (Packet Differentiated Services Codepoint) bits</help>
<valueHelp>
<format>u32:0-63</format>
<description>DSCP number</description>
Expand All @@ -30,10 +30,10 @@
</leafNode>
<leafNode name="mark">
<properties>
<help>Packet marking</help>
<help>Set packet mark</help>
<valueHelp>
<format>u32:1-2147483647</format>
<description>Packet marking</description>
<description>Packet mark</description>
</valueHelp>
<constraint>
<validator name="numeric" argument="--range 1-2147483647"/>
Expand All @@ -42,7 +42,7 @@
</leafNode>
<leafNode name="table">
<properties>
<help>Routing table to forward packet with</help>
<help>Set the routing table for matched packets</help>
<valueHelp>
<format>u32:1-200</format>
<description>Table number</description>
Expand All @@ -61,9 +61,27 @@
</completionHelp>
</properties>
</leafNode>
<leafNode name="vrf">
<properties>
<help>VRF to forward packet with</help>
<valueHelp>
<format>txt</format>
<description>VRF instance name</description>
</valueHelp>
<valueHelp>
<format>default</format>
<description>Forward into default global VRF</description>
</valueHelp>
<completionHelp>
<list>default</list>
<path>vrf name</path>
</completionHelp>
#include <include/constraint/vrf.xml.i>
</properties>
</leafNode>
<leafNode name="tcp-mss">
<properties>
<help>TCP Maximum Segment Size</help>
<help>Set TCP Maximum Segment Size</help>
<valueHelp>
<format>u32:500-1460</format>
<description>Explicitly set TCP MSS value</description>
Expand Down
7 changes: 3 additions & 4 deletions smoketest/scripts/cli/test_firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ def test_bridge_firewall(self):

self.cli_set(['firewall', 'group', 'ipv6-address-group', 'AGV6', 'address', '2001:db1::1'])
self.cli_set(['firewall', 'global-options', 'state-policy', 'established', 'action', 'accept'])
self.cli_set(['firewall', 'global-options', 'apply-for-bridge', 'ipv4'])
self.cli_set(['firewall', 'global-options', 'apply-to-bridged-traffic', 'ipv4'])

self.cli_set(['firewall', 'bridge', 'name', name, 'default-action', 'accept'])
self.cli_set(['firewall', 'bridge', 'name', name, 'default-log'])
Expand All @@ -731,10 +731,9 @@ def test_bridge_firewall(self):
self.cli_set(['firewall', 'bridge', 'input', 'filter', 'rule', '1', 'source', 'address', '192.0.2.2'])
self.cli_set(['firewall', 'bridge', 'input', 'filter', 'rule', '1', 'state', 'new'])

self.cli_set(['firewall', 'bridge', 'prerouting', 'filter', 'rule', '1', 'action', 'drop'])
self.cli_set(['firewall', 'bridge', 'prerouting', 'filter', 'rule', '1', 'action', 'notrack'])
self.cli_set(['firewall', 'bridge', 'prerouting', 'filter', 'rule', '1', 'destination', 'group', 'ipv6-address-group', 'AGV6'])


self.cli_commit()

nftables_search = [
Expand All @@ -755,7 +754,7 @@ def test_bridge_firewall(self):
['ct state new', 'ip saddr 192.0.2.2', f'iifname "{interface_in}"', 'accept'],
['chain VYOS_PREROUTING_filter'],
['type filter hook prerouting priority filter; policy accept;'],
['ip6 daddr @A6_AGV6', 'drop']
['ip6 daddr @A6_AGV6', 'notrack']
]

self.verify_nftables(nftables_search, 'bridge vyos_filter')
Expand Down

0 comments on commit b71702f

Please sign in to comment.