-
Notifications
You must be signed in to change notification settings - Fork 335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
T4072: add firewall bridge filtering. #2222
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{% macro bridge(bridge) %} | ||
{% set ns = namespace(sets=[]) %} | ||
{% if bridge.forward is vyos_defined %} | ||
{% for prior, conf in bridge.forward.items() %} | ||
{% set def_action = conf.default_action %} | ||
chain VYOS_FORWARD_{{ prior }} { | ||
type filter hook forward priority {{ prior }}; policy {{ def_action }}; | ||
{% if conf.rule is vyos_defined %} | ||
{% for rule_id, rule_conf in conf.rule.items() if rule_conf.disable is not vyos_defined %} | ||
{{ rule_conf | nft_rule('FWD', prior, rule_id, 'bri') }} | ||
{% if rule_conf.recent is vyos_defined %} | ||
{% set ns.sets = ns.sets + ['FWD_' + prior + '_' + rule_id] %} | ||
{% endif %} | ||
{% endfor %} | ||
{% endif %} | ||
} | ||
{% endfor %} | ||
{% endif %} | ||
|
||
{% if bridge.name is vyos_defined %} | ||
{% for name_text, conf in bridge.name.items() %} | ||
chain NAME_{{ name_text }} { | ||
{% if conf.rule is vyos_defined %} | ||
{% for rule_id, rule_conf in conf.rule.items() if rule_conf.disable is not vyos_defined %} | ||
{{ rule_conf | nft_rule('NAM', name_text, rule_id, 'bri') }} | ||
{% if rule_conf.recent is vyos_defined %} | ||
{% set ns.sets = ns.sets + ['NAM_' + name_text + '_' + rule_id] %} | ||
{% endif %} | ||
{% endfor %} | ||
{% endif %} | ||
{{ conf | nft_default_rule(name_text) }} | ||
} | ||
{% endfor %} | ||
{% endif %} | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!-- include start from firewall/action.xml.i --> | ||
<leafNode name="action"> | ||
<properties> | ||
<help>Rule action</help> | ||
<completionHelp> | ||
<list>accept continue jump return drop queue</list> | ||
</completionHelp> | ||
<valueHelp> | ||
<format>accept</format> | ||
<description>Accept matching entries</description> | ||
</valueHelp> | ||
<valueHelp> | ||
<format>continue</format> | ||
<description>Continue parsing next rule</description> | ||
</valueHelp> | ||
<valueHelp> | ||
<format>jump</format> | ||
<description>Jump to another chain</description> | ||
</valueHelp> | ||
<valueHelp> | ||
<format>return</format> | ||
<description>Return from the current chain and continue at the next rule of the last chain</description> | ||
</valueHelp> | ||
<valueHelp> | ||
<format>drop</format> | ||
<description>Drop matching entries</description> | ||
</valueHelp> | ||
<valueHelp> | ||
<format>queue</format> | ||
<description>Enqueue packet to userspace</description> | ||
</valueHelp> | ||
<constraint> | ||
<regex>(accept|continue|jump|return|drop|queue)</regex> | ||
</constraint> | ||
</properties> | ||
</leafNode> | ||
<!-- include end --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
interface-definitions/include/firewall/bridge-custom-name.xml.i
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!-- include start from firewall/bridge-custom-name.xml.i --> | ||
<tagNode name="name"> | ||
<properties> | ||
<help>Bridge custom firewall</help> | ||
<constraint> | ||
<regex>[a-zA-Z0-9][\w\-\.]*</regex> | ||
</constraint> | ||
</properties> | ||
<children> | ||
#include <include/firewall/default-action.xml.i> | ||
#include <include/firewall/enable-default-log.xml.i> | ||
#include <include/generic-description.xml.i> | ||
<leafNode name="default-jump-target"> | ||
<properties> | ||
<help>Set jump target. Action jump must be defined in default-action to use this setting</help> | ||
<completionHelp> | ||
<path>firewall bridge name</path> | ||
</completionHelp> | ||
</properties> | ||
</leafNode> | ||
<tagNode name="rule"> | ||
<properties> | ||
<help>Bridge Firewall forward filter rule number</help> | ||
<valueHelp> | ||
<format>u32:1-999999</format> | ||
<description>Number for this firewall rule</description> | ||
</valueHelp> | ||
<constraint> | ||
<validator name="numeric" argument="--range 1-999999"/> | ||
</constraint> | ||
<constraintErrorMessage>Firewall rule number must be between 1 and 999999</constraintErrorMessage> | ||
</properties> | ||
<children> | ||
#include <include/firewall/common-rule-bridge.xml.i> | ||
</children> | ||
</tagNode> | ||
</children> | ||
</tagNode> | ||
<!-- include end --> |
34 changes: 34 additions & 0 deletions
34
interface-definitions/include/firewall/bridge-hook-forward.xml.i
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!-- include start from firewall/bridge-hook-forward.xml.i --> | ||
<node name="forward"> | ||
<properties> | ||
<help>Bridge forward firewall</help> | ||
</properties> | ||
<children> | ||
<node name="filter"> | ||
<properties> | ||
<help>Bridge firewall forward filter</help> | ||
</properties> | ||
<children> | ||
#include <include/firewall/default-action-base-chains.xml.i> | ||
#include <include/generic-description.xml.i> | ||
<tagNode name="rule"> | ||
<properties> | ||
<help>Bridge Firewall forward filter rule number</help> | ||
<valueHelp> | ||
<format>u32:1-999999</format> | ||
<description>Number for this firewall rule</description> | ||
</valueHelp> | ||
<constraint> | ||
<validator name="numeric" argument="--range 1-999999"/> | ||
</constraint> | ||
<constraintErrorMessage>Firewall rule number must be between 1 and 999999</constraintErrorMessage> | ||
</properties> | ||
<children> | ||
#include <include/firewall/common-rule-bridge.xml.i> | ||
</children> | ||
</tagNode> | ||
</children> | ||
</node> | ||
</children> | ||
</node> | ||
<!-- include end --> |
57 changes: 57 additions & 0 deletions
57
interface-definitions/include/firewall/common-rule-bridge.xml.i
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<!-- include start from firewall/common-rule-bridge.xml.i --> | ||
#include <include/firewall/action-l2.xml.i> | ||
#include <include/firewall/nft-queue.xml.i> | ||
<node name="destination"> | ||
<properties> | ||
<help>Destination parameters</help> | ||
</properties> | ||
<children> | ||
#include <include/firewall/mac-address.xml.i> | ||
</children> | ||
</node> | ||
<leafNode name="disable"> | ||
<properties> | ||
<help>Option to disable firewall rule</help> | ||
<valueless/> | ||
</properties> | ||
</leafNode> | ||
<leafNode name="jump-target"> | ||
<properties> | ||
<help>Set jump target. Action jump must be defined to use this setting</help> | ||
<completionHelp> | ||
<path>firewall bridge name</path> | ||
</completionHelp> | ||
</properties> | ||
</leafNode> | ||
<leafNode name="log"> | ||
<properties> | ||
<help>Option to log packets matching rule</help> | ||
<completionHelp> | ||
<list>enable disable</list> | ||
</completionHelp> | ||
<valueHelp> | ||
<format>enable</format> | ||
<description>Enable log</description> | ||
</valueHelp> | ||
<valueHelp> | ||
<format>disable</format> | ||
<description>Disable log</description> | ||
</valueHelp> | ||
<constraint> | ||
<regex>(enable|disable)</regex> | ||
</constraint> | ||
</properties> | ||
</leafNode> | ||
#include <include/firewall/rule-log-options.xml.i> | ||
<node name="source"> | ||
<properties> | ||
<help>Source parameters</help> | ||
</properties> | ||
<children> | ||
#include <include/firewall/mac-address.xml.i> | ||
</children> | ||
</node> | ||
#include <include/firewall/inbound-interface.xml.i> | ||
#include <include/firewall/outbound-interface.xml.i> | ||
#include <include/firewall/match-vlan.xml.i> | ||
<!-- include end --> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be defaulted to True with
is_l3=True
so it only needs setting to False on the bridge template.